From 0544db450d036fd5685ed877bc7374d80df6f60e Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Fri, 23 Jan 2015 07:07:30 -0200 Subject: [PATCH 0001/1167] Add Virtual LAN support This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows multiple VLANs in a bridged network to share the same physical network link but maintain isolation: http://en.wikipedia.org/wiki/IEEE_802.1Q * grub-core/net/ethernet.c: Add check, get, and set vlan tag id. * grub-core/net/drivers/ieee1275/ofnet.c: Get vlan tag id from bootargs. * grub-core/net/arp.c: Add check. * grub-core/net/ip.c: Likewise. * include/grub/net/arp.h: Add vlantag attribute. * include/grub/net/ip.h: Likewise. --- ChangeLog | 19 ++++++++++ grub-core/net/arp.c | 10 ++++-- grub-core/net/drivers/ieee1275/ofnet.c | 20 ++++++++++- grub-core/net/ethernet.c | 49 +++++++++++++++++++++++--- grub-core/net/ip.c | 31 +++++++++++----- include/grub/net.h | 9 +++++ include/grub/net/arp.h | 5 +-- include/grub/net/ip.h | 3 +- 8 files changed, 126 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 024a876dd..2239f72d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -168,6 +168,25 @@ 2015-01-19 Kris Moore * grub-core/disk/geli.c: Support GELI v6 and v7. +======= +2015-01-23 Paulo Flabiano Smorigo + + Add Virtual LAN support. + + This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging + allows multiple VLANs in a bridged network to share the same physical + network link but maintain isolation: + + http://en.wikipedia.org/wiki/IEEE_802.1Q + + * grub-core/net/ethernet.c: Add check, get, and set vlan tag id. + * grub-core/net/drivers/ieee1275/ofnet.c: Get vlan tag id from + bootargs. + * grub-core/net/arp.c: Add check. + * grub-core/net/ip.c: Likewise. + * include/grub/net/arp.h: Add vlantag attribute. + * include/grub/net/ip.h: Likewise. +>>>>>>> Add Virtual LAN support 2014-12-09 Andrei Borzenkov diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 8cc390b0e..00d37b6c3 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -122,8 +122,8 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, } grub_err_t -grub_net_arp_receive (struct grub_net_buff *nb, - struct grub_net_card *card) +grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, + grub_uint16_t vlantag_vid) { struct arphdr *arp_header = (struct arphdr *) nb->data; grub_uint8_t *sender_hardware_address; @@ -158,6 +158,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { + /* Check vlantag id */ + if (inf->card == card && + ((inf->vlantag.set && vlantag_vid != inf->vlantag.vid) || + (!inf->vlantag.set && vlantag_vid != 0))) + continue; + /* Am I the protocol address target? */ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 && grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index eea8e71d3..7eefb9aed 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -147,11 +147,11 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, char *comma_char = 0; char *equal_char = 0; grub_size_t field_counter = 0; - grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; grub_net_link_level_address_t hw_addr; grub_net_interface_flags_t flags = 0; struct grub_net_network_level_interface *inter; + grub_uint32_t vlantag = 0; hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -169,6 +169,18 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, *equal_char = 0; grub_env_set_net_property ((*card)->name, args, equal_char + 1, grub_strlen(equal_char + 1)); + + if ((grub_strcmp (args, "vtag") == 0) && + (grub_strlen (equal_char + 1) > 4)) + { + vlantag = grub_strtoul (equal_char + 1, 0, 16) & 0xffff; + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + vlantag = 0; + grub_errno = GRUB_ERR_NONE; + } + } + *equal_char = '='; } else @@ -207,6 +219,12 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, hw_addr.mac, sizeof(hw_addr.mac), 0); inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, flags); + if (vlantag > 0) + { + inter->vlantag.set = 1; + inter->vlantag.vid = vlantag & 0xfff; + } + grub_net_add_ipv4_local (inter, __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); } diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c index c397b1b34..3a526b3bf 100644 --- a/grub-core/net/ethernet.c +++ b/grub-core/net/ethernet.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -56,10 +57,16 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, { struct etherhdr *eth; grub_err_t err; + grub_uint8_t etherhdr_size; - COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE); + etherhdr_size = sizeof (*eth); + COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE); - err = grub_netbuff_push (nb, sizeof (*eth)); + /* Increase ethernet header in case of vlantag */ + if (inf->vlantag.set) + etherhdr_size += 4; + + err = grub_netbuff_push (nb, etherhdr_size); if (err) return err; eth = (struct etherhdr *) nb->data; @@ -76,6 +83,21 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, return err; inf->card->opened = 1; } + + /* Check and add a vlan-tag if needed. */ + if (inf->vlantag.set) + { + grub_uint32_t vlantag; + vlantag = grub_cpu_to_be32 ((VLANTAG_IDENTIFIER << 16) | inf->vlantag.vid); + + /* Move eth type to the right */ + grub_memcpy ((char *) nb->data + etherhdr_size - 2, + (char *) nb->data + etherhdr_size - 6, 2); + + /* Add the tag in the middle */ + grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag, 4); + } + return inf->card->driver->send (inf->card, nb); } @@ -90,10 +112,26 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, grub_net_link_level_address_t hwaddress; grub_net_link_level_address_t src_hwaddress; grub_err_t err; + grub_uint8_t etherhdr_size = sizeof (*eth); + grub_uint16_t vlantag_vid = 0; + + /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */ + /* longer than the original one. The vlantag id is extracted and the header */ + /* is reseted to the original size. */ + if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == + grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER)) + { + vlantag_vid = grub_be_to_cpu16 (grub_get_unaligned16 (nb->data + + etherhdr_size)) & 0x1fff; + etherhdr_size += 4; + /* Move eth type to the original position */ + grub_memcpy((char *) nb->data + etherhdr_size - 6, + (char *) nb->data + etherhdr_size - 2, 2); + } eth = (struct etherhdr *) nb->data; type = grub_be_to_cpu16 (eth->type); - err = grub_netbuff_pull (nb, sizeof (*eth)); + err = grub_netbuff_pull (nb, etherhdr_size); if (err) return err; @@ -121,13 +159,14 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, { /* ARP packet. */ case GRUB_NET_ETHERTYPE_ARP: - grub_net_arp_receive (nb, card); + grub_net_arp_receive (nb, card, vlantag_vid); grub_netbuff_free (nb); return GRUB_ERR_NONE; /* IP packet. */ case GRUB_NET_ETHERTYPE_IP: case GRUB_NET_ETHERTYPE_IP6: - return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress); + return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress, + vlantag_vid); } grub_netbuff_free (nb); return GRUB_ERR_NONE; diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index 5a6095444..a2addb3f6 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -225,12 +225,13 @@ handle_dgram (struct grub_net_buff *nb, grub_net_ip_protocol_t proto, const grub_net_network_level_address_t *source, const grub_net_network_level_address_t *dest, + grub_uint16_t vlantag_vid, grub_uint8_t ttl) { struct grub_net_network_level_interface *inf = NULL; grub_err_t err; int multicast = 0; - + /* DHCP needs special treatment since we don't know IP yet. */ { struct udphdr *udph; @@ -290,6 +291,13 @@ handle_dgram (struct grub_net_buff *nb, && grub_net_addr_cmp (&inf->address, dest) == 0 && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0) break; + + /* Check vlantag id */ + if (inf->card == card && + ((inf->vlantag.set && vlantag_vid != inf->vlantag.vid) || + (!inf->vlantag.set && vlantag_vid != 0))) + continue; + /* Solicited node multicast. */ if (inf->card == card && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 @@ -378,7 +386,8 @@ static grub_err_t grub_net_recv_ip4_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t vlantag_vid) { struct iphdr *iph = (struct iphdr *) nb->data; grub_err_t err; @@ -453,7 +462,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, dest.ipv4 = iph->dest; return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, - &source, &dest, iph->ttl); + &source, &dest, vlantag_vid, iph->ttl); } for (prev = &reassembles, rsm = *prev; rsm; prev = &rsm->next, rsm = *prev) @@ -589,7 +598,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, dest.ipv4 = dst; return handle_dgram (ret, card, src_hwaddress, - hwaddress, proto, &source, &dest, + hwaddress, proto, &source, &dest, vlantag_vid, ttl); } } @@ -644,7 +653,8 @@ static grub_err_t grub_net_recv_ip6_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t vlantag_vid) { struct ip6hdr *iph = (struct ip6hdr *) nb->data; grub_err_t err; @@ -695,21 +705,24 @@ grub_net_recv_ip6_packets (struct grub_net_buff *nb, grub_memcpy (dest.ipv6, &iph->dest, sizeof (dest.ipv6)); return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, - &source, &dest, iph->ttl); + &source, &dest, vlantag_vid, iph->ttl); } grub_err_t grub_net_recv_ip_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t vlantag_vid) { struct iphdr *iph = (struct iphdr *) nb->data; if ((iph->verhdrlen >> 4) == 4) - return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress); + return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress, + vlantag_vid); if ((iph->verhdrlen >> 4) == 6) - return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress); + return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress, + vlantag_vid); grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4)); grub_netbuff_free (nb); return GRUB_ERR_NONE; diff --git a/include/grub/net.h b/include/grub/net.h index 538baa33e..66923e68c 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -268,6 +268,12 @@ typedef struct grub_net extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name); +struct grub_net_vlantag +{ + grub_uint8_t set; + grub_uint16_t vid; +}; + struct grub_net_network_level_interface { struct grub_net_network_level_interface *next; @@ -279,6 +285,7 @@ struct grub_net_network_level_interface grub_net_interface_flags_t flags; struct grub_net_bootp_packet *dhcp_ack; grub_size_t dhcp_acklen; + struct grub_net_vlantag vlantag; void *data; }; @@ -538,4 +545,6 @@ extern char *grub_net_default_server; #define GRUB_NET_INTERVAL 400 #define GRUB_NET_INTERVAL_ADDITION 20 +#define VLANTAG_IDENTIFIER 0x8100 + #endif /* ! GRUB_NET_HEADER */ diff --git a/include/grub/net/arp.h b/include/grub/net/arp.h index bb1703622..56336b356 100644 --- a/include/grub/net/arp.h +++ b/include/grub/net/arp.h @@ -22,10 +22,11 @@ #include extern grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, - struct grub_net_card *card); + struct grub_net_card *card, + grub_uint16_t vlantag_vid); grub_err_t grub_net_arp_send_request (struct grub_net_network_level_interface *inf, - const grub_net_network_level_address_t *proto_addr); + const grub_net_network_level_address_t *proto_addr); #endif diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h index dcceaa568..8cd0bfdc0 100644 --- a/include/grub/net/ip.h +++ b/include/grub/net/ip.h @@ -48,7 +48,8 @@ grub_err_t grub_net_recv_ip_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress); + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t vlantag_vid); grub_err_t grub_net_send_ip_packet (struct grub_net_network_level_interface *inf, From 2f73d2733ce8f1e60561a4f7c3a7caa3717fb174 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Fri, 23 Jan 2015 19:52:45 +0300 Subject: [PATCH 0002/1167] accept also hdX as alias to native Xen disk name To be compatible with legacy pv-grub, sort disks by increasing order of handle value. This allows reusing legacy pv-grub menu.lst which is using hdX names. Suggested-By: Michael Chang Closes: 44026 --- ChangeLog | 5 ++++ grub-core/disk/xen/xendisk.c | 45 ++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 024a876dd..3f01f9829 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-23 Andrei Borzenkov + + * grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to + allow legacy menu.lst processing. + 2015-01-22 Felix Janda Remove direct _llseek code and require long filesystem libc. diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c index 2b11c2a2e..b18a9238d 100644 --- a/grub-core/disk/xen/xendisk.c +++ b/grub-core/disk/xen/xendisk.c @@ -40,6 +40,7 @@ struct virtdisk grub_xen_evtchn_t evtchn; void *dma_page; grub_xen_grant_t dma_grant; + struct virtdisk *compat_next; }; #define xen_wmb() mb() @@ -47,6 +48,7 @@ struct virtdisk static struct virtdisk *virtdisks; static grub_size_t vdiskcnt; +struct virtdisk *compat_head; static int grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, @@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, static grub_err_t grub_virtdisk_open (const char *name, grub_disk_t disk) { - grub_size_t i; + int i; grub_uint32_t secsize; char fdir[200]; char *buf; + int num = -1; + struct virtdisk *vd; - for (i = 0; i < vdiskcnt; i++) - if (grub_strcmp (name, virtdisks[i].fullname) == 0) + /* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */ + if (name[0] == 'h' && name[1] == 'd' && name[2]) + { + num = grub_strtoul (name + 2, 0, 10); + if (grub_errno) + { + grub_errno = 0; + num = -1; + } + } + for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++) + if (i == num || grub_strcmp (name, vd->fullname) == 0) break; - if (i == vdiskcnt) + if (!vd) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk"); - disk->data = &virtdisks[i]; - disk->id = i; + disk->data = vd; + disk->id = vd - virtdisks; - grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir); + grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir); buf = grub_xenstore_get_file (fdir, NULL); if (!buf) return grub_errno; @@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t disk) if (grub_errno) return grub_errno; - grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", - virtdisks[i].backend_dir); + grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir); buf = grub_xenstore_get_file (fdir, NULL); if (!buf) return grub_errno; @@ -264,6 +277,7 @@ fill (const char *dir, void *data) grub_err_t err; void *buf; struct evtchn_alloc_unbound alloc_unbound; + struct virtdisk **prev = &compat_head, *vd = compat_head; /* Shouldn't happen unles some hotplug happened. */ if (vdiskcnt >= *ctr) @@ -374,6 +388,19 @@ fill (const char *dir, void *data) virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir); + /* For compatibility with pv-grub maintain linked list sorted by handle + value in increasing order. This allows mapping of (hdX) disk names + from legacy menu.lst */ + while (vd) + { + if (vd->handle > virtdisks[vdiskcnt].handle) + break; + prev = &vd->compat_next; + vd = vd->compat_next; + } + virtdisks[vdiskcnt].compat_next = vd; + *prev = &virtdisks[vdiskcnt]; + vdiskcnt++; return 0; From edf2db97e72916786ee87b5a7630659369e1ee97 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 23 Jan 2015 21:06:16 +0300 Subject: [PATCH 0003/1167] Mention platform "none" in NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index a61df942a..55f09d6d7 100644 --- a/NEWS +++ b/NEWS @@ -85,6 +85,8 @@ New in 2.02: * Support for USB debug dongles. * Support for *-emu on all platforms (previously only i386/x86_64 worked). * Support *-emu on Windows. + * New platform "none" which builds only user level utilities. This is now + default if target CPU is not supported. * Security: * Add optional facility to enforce that all files read by the core image From 8acb9dc697627e4189972f15fc219581557365b6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 23 Jan 2015 19:46:02 +0100 Subject: [PATCH 0004/1167] * tests/file_filter/file: Really add missing file. --- ChangeLog | 4 ++++ tests/file_filter/file | 1 + 2 files changed, 5 insertions(+) create mode 100644 tests/file_filter/file diff --git a/ChangeLog b/ChangeLog index 3f01f9829..869f6bfb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-23 Vladimir Serbinenko + + * tests/file_filter/file: Really add missing file. + 2015-01-23 Andrei Borzenkov * grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to diff --git a/tests/file_filter/file b/tests/file_filter/file new file mode 100644 index 000000000..64650ac58 --- /dev/null +++ b/tests/file_filter/file @@ -0,0 +1 @@ +Hello, user! From 3bd0868364f693b17b36d592bd390ad974885ee1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:29:50 +0100 Subject: [PATCH 0005/1167] Autogenerate ChangeLog from git changelog. Old ChangeLog is moved to ChangeLog-2015. For all changes starting from this one ChangeLog will be generated from gitlog only on explicit make invocation and make dist. --- ChangeLog => ChangeLog-2015 | 0 Makefile.am | 13 +- build-aux/gitlog-to-changelog | 432 ++++++++++++++++++++++++++++++++++ 3 files changed, 444 insertions(+), 1 deletion(-) rename ChangeLog => ChangeLog-2015 (100%) create mode 100755 build-aux/gitlog-to-changelog diff --git a/ChangeLog b/ChangeLog-2015 similarity index 100% rename from ChangeLog rename to ChangeLog-2015 diff --git a/Makefile.am b/Makefile.am index cc537a2c8..df0a7283c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -392,7 +392,7 @@ endif .PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \ bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \ bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \ - bootcheck-linux-mips + bootcheck-linux-mips FORCE # Randomly generated SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d @@ -439,3 +439,14 @@ windowszip: windowsdir rm -rf $(windowsdir) EXTRA_DIST += linguas.sh + +changelog_start_date = 2015-01-24 +gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog + +ChangeLog: FORCE + if test -d $(top_srcdir)/.git; then \ + $(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \ + rm -f '$@'; mv '$@.tmp' '$@'; \ + fi + +EXTRA_DIST += ChangeLog ChangeLog-2015 diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog new file mode 100755 index 000000000..78afff4e8 --- /dev/null +++ b/build-aux/gitlog-to-changelog @@ -0,0 +1,432 @@ +eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' + & eval 'exec perl -wS "$0" $argv:q' + if 0; +# Convert git log output to ChangeLog format. + +my $VERSION = '2012-07-29 06:11'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2008-2014 Free Software Foundation, Inc. + +# This program 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. + +# 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Jim Meyering + +use strict; +use warnings; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # http://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM < ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo + +SPECIAL SYNTAX: + +The following types of strings are interpreted specially when they appear +at the beginning of a log message line. They are not copied to the output. + + Copyright-paperwork-exempt: Yes + Append the "(tiny change)" notation to the usual "date name email" + ChangeLog header to mark a change that does not require a copyright + assignment. + Co-authored-by: Joe User + List the specified name and email address on a second + ChangeLog header, denoting a co-author. + Signed-off-by: Joe User + These lines are simply elided. + +In a FILE specified via --amend, comment lines (starting with "#") are ignored. +FILE must consist of pairs where SHA is a 40-byte SHA1 (alone on +a line) referring to a commit in the current project, and CODE refers to one +or more consecutive lines of Perl code. Pairs must be separated by one or +more blank line. + +Here is sample input for use with --amend=FILE, from coreutils: + +3a169f4c5d9159283548178668d2fae6fced3030 +# fix typo in title: +s/all tile types/all file types/ + +1379ed974f1fa39b12e2ffab18b3f7a607082202 +# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. +# Change the author to be Paul. Note the escaped "@": +s,Jim .*>,Paul Eggert , + +EOF + } + exit $exit_code; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +sub quoted_cmd(@) +{ + return join (' ', map {shell_quote $_} @_); +} + +# Parse file F. +# Comment lines (starting with "#") are ignored. +# F must consist of pairs where SHA is a 40-byte SHA1 +# (alone on a line) referring to a commit in the current project, and +# CODE refers to one or more consecutive lines of Perl code. +# Pairs must be separated by one or more blank line. +sub parse_amend_file($) +{ + my ($f) = @_; + + open F, '<', $f + or die "$ME: $f: failed to open for reading: $!\n"; + + my $fail; + my $h = {}; + my $in_code = 0; + my $sha; + while (defined (my $line = )) + { + $line =~ /^\#/ + and next; + chomp $line; + $line eq '' + and $in_code = 0, next; + + if (!$in_code) + { + $line =~ /^([0-9a-fA-F]{40})$/ + or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), + $fail = 1, next; + $sha = lc $1; + $in_code = 1; + exists $h->{$sha} + and (warn "$ME: $f:$.: duplicate SHA1\n"), + $fail = 1, next; + } + else + { + $h->{$sha} ||= ''; + $h->{$sha} .= "$line\n"; + } + } + close F; + + $fail + and exit 1; + + return $h; +} + +# git_dir_option $SRCDIR +# +# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR +# is undef). Return as a list (0 or 1 element). +sub git_dir_option($) +{ + my ($srcdir) = @_; + my @res = (); + if (defined $srcdir) + { + my $qdir = shell_quote $srcdir; + my $cmd = "cd $qdir && git rev-parse --show-toplevel"; + my $qcmd = shell_quote $cmd; + my $git_dir = qx($cmd); + defined $git_dir + or die "$ME: cannot run $qcmd: $!\n"; + $? == 0 + or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; + chomp $git_dir; + push @res, "--git-dir=$git_dir/.git"; + } + @res; +} + +{ + my $since_date; + my $format_string = '%s%n%b%n'; + my $amend_file; + my $append_dot = 0; + my $cluster = 1; + my $strip_tab = 0; + my $strip_cherry_pick = 0; + my $srcdir; + GetOptions + ( + help => sub { usage 0 }, + version => sub { print "$ME version $VERSION\n"; exit }, + 'since=s' => \$since_date, + 'format=s' => \$format_string, + 'amend=s' => \$amend_file, + 'append-dot' => \$append_dot, + 'cluster!' => \$cluster, + 'strip-tab' => \$strip_tab, + 'strip-cherry-pick' => \$strip_cherry_pick, + 'srcdir=s' => \$srcdir, + ) or usage 1; + + defined $since_date + and unshift @ARGV, "--since=$since_date"; + + # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) + # that makes a correction in the log or attribution of that commit. + my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; + + my @cmd = ('git', + git_dir_option $srcdir, + qw(log --log-size), + '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); + open PIPE, '-|', @cmd + or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" + . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); + + my $prev_multi_paragraph; + my $prev_date_line = ''; + my @prev_coauthors = (); + while (1) + { + defined (my $in = ) + or last; + $in =~ /^log size (\d+)$/ + or die "$ME:$.: Invalid line (expected log size):\n$in"; + my $log_nbytes = $1; + + my $log; + my $n_read = read PIPE, $log, $log_nbytes; + $n_read == $log_nbytes + or die "$ME:$.: unexpected EOF\n"; + + # Extract leading hash. + my ($sha, $rest) = split ':', $log, 2; + defined $sha + or die "$ME:$.: malformed log entry\n"; + $sha =~ /^[0-9a-fA-F]{40}$/ + or die "$ME:$.: invalid SHA1: $sha\n"; + + # If this commit's log requires any transformation, do it now. + my $code = $amend_code->{$sha}; + if (defined $code) + { + eval 'use Safe'; + my $s = new Safe; + # Put the unpreprocessed entry into "$_". + $_ = $rest; + + # Let $code operate on it, safely. + my $r = $s->reval("$code") + or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; + + # Note that we've used this entry. + delete $amend_code->{$sha}; + + # Update $rest upon success. + $rest = $_; + } + + # Remove lines inserted by "git cherry-pick". + if ($strip_cherry_pick) + { + $rest =~ s/^\s*Conflicts:\n.*//sm; + $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; + } + + my @line = split "\n", $rest; + my $author_line = shift @line; + defined $author_line + or die "$ME:$.: unexpected EOF\n"; + $author_line =~ /^(\d+) (.*>)$/ + or die "$ME:$.: Invalid line " + . "(expected date/author/email):\n$author_line\n"; + + # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog + # `(tiny change)' annotation. + my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line) + ? ' (tiny change)' : ''); + + my $date_line = sprintf "%s %s$tiny\n", + strftime ("%F", localtime ($1)), $2; + + my @coauthors = grep /^Co-authored-by:.*$/, @line; + # Omit meta-data lines we've already interpreted. + @line = grep !/^(?:Signed-off-by:[ ].*>$ + |Co-authored-by:[ ] + |Copyright-paperwork-exempt:[ ] + )/x, @line; + + # Remove leading and trailing blank lines. + if (@line) + { + while ($line[0] =~ /^\s*$/) { shift @line; } + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Record whether there are two or more paragraphs. + my $multi_paragraph = grep /^\s*$/, @line; + + # Format 'Co-authored-by: A U Thor ' lines in + # standard multi-author ChangeLog format. + for (@coauthors) + { + s/^Co-authored-by:\s*/\t /; + s/\s*/ + or warn "$ME: warning: missing email address for " + . substr ($_, 5) . "\n"; + } + + # If clustering of commit messages has been disabled, if this header + # would be different from the previous date/name/email/coauthors header, + # or if this or the previous entry consists of two or more paragraphs, + # then print the header. + if ( ! $cluster + || $date_line ne $prev_date_line + || "@coauthors" ne "@prev_coauthors" + || $multi_paragraph + || $prev_multi_paragraph) + { + $prev_date_line eq '' + or print "\n"; + print $date_line; + @coauthors + and print join ("\n", @coauthors), "\n"; + } + $prev_date_line = $date_line; + @prev_coauthors = @coauthors; + $prev_multi_paragraph = $multi_paragraph; + + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n $date_line\n"; + } + else + { + if ($append_dot) + { + # If the first line of the message has enough room, then + if (length $line[0] < 72) + { + # append a dot if there is no other punctuation or blank + # at the end. + $line[0] =~ /[[:punct:]\s]$/ + or $line[0] .= '.'; + } + } + + # Remove one additional leading TAB from each line. + $strip_tab + and map { s/^\t// } @line; + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } + + defined ($in = ) + or last; + $in ne "\n" + and die "$ME:$.: unexpected line:\n$in"; + } + + close PIPE + or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; + # FIXME-someday: include $PROCESS_STATUS in the diagnostic + + # Complain about any unused entry in the --amend=F specified file. + my $fail = 0; + foreach my $sha (keys %$amend_code) + { + warn "$ME:$amend_file: unused entry: $sha\n"; + $fail = 1; + } + + exit $fail; +} + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d %02H:%02M" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "'; # UTC" +# End: From 11504d523cca9206e0df1e4f128d6d7d59ac1d9a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:44:19 +0100 Subject: [PATCH 0006/1167] conf/Makefile.common: Remove unused {LD,C}FLAGS_CPU. --- conf/Makefile.common | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 51fbaf99d..8c4d1483d 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -41,19 +41,19 @@ BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) LDADD_KERNEL = $(TARGET_LIBGCC) -CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding +LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding +LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin -LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S +CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin +LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) From eeea31b2208d862a3ff50f2739e103b22dc0061b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:45:16 +0100 Subject: [PATCH 0007/1167] util/grub-mkrescue.c: Always include part_msdos and part_gpt on EFI. When booted from stick, EFI would use GPT partition and our root device detection algortihm depends on GRUB's ability to see the same partitions. Hence include msdos and gpt partmap modules on EFI even when they're not needed to access root filesystem. --- util/grub-mkrescue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index e71983982..e02340f06 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -653,6 +653,9 @@ main (int argc, char *argv[]) char *efiimgfat; grub_install_mkdir_p (efidir_efi_boot); + grub_install_push_module ("part_gpt"); + grub_install_push_module ("part_msdos"); + imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, "ia64-efi", imgname); free (imgname); @@ -713,6 +716,8 @@ main (int argc, char *argv[]) free (efiimgfat); free (efidir_efi); free (efidir); + grub_install_pop_module (); + grub_install_pop_module (); } grub_install_push_module ("part_apple"); From 7d027b4d3e632b0a3a81dd1f31012a80f7746b74 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 19:53:13 +0100 Subject: [PATCH 0008/1167] efidisk: Return the determined root disk even if partition is unknown. --- grub-core/disk/efi/efidisk.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b12c3499..60a6d3c50 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -803,7 +803,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) && (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)) { - int is_cdrom = 0; struct grub_efidisk_get_device_name_ctx ctx; char *dev_name; grub_efi_device_path_t *dup_dp; @@ -824,9 +823,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) break; - if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE) - is_cdrom = 1; - dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; dup_ldp->length = sizeof (*dup_ldp); @@ -861,10 +857,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) if (! ctx.partition_name) { + /* No partition found. In most cases partition is embed in + the root path anyway, so this is not critical. + This happens only if partition is on partmap that GRUB + doesn't need to access root. + */ grub_disk_close (parent); - if (is_cdrom) - return grub_strdup (device_name); - return 0; + return grub_strdup (device_name); } dev_name = grub_xasprintf ("%s,%s", parent->name, From 14c9a720397e6674c8c46e2e0697c2bf2a7132ae Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:12:51 +0100 Subject: [PATCH 0009/1167] Makefile.am: Fix Changelog cutoff address. gitlog-to-changelog Doesn't generate entries for cutoff day, only for days after the cutoff date, adjust by one to compensate. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index df0a7283c..a232eb1e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -440,7 +440,7 @@ windowszip: windowsdir EXTRA_DIST += linguas.sh -changelog_start_date = 2015-01-24 +changelog_start_date = 2015-01-23 gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog ChangeLog: FORCE From b8f537199a64c7aef68ed39e037f52e9bb629cfc Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:14:59 +0100 Subject: [PATCH 0010/1167] Generate empty ChangeLog if no .git is available. When making dist from a git snapshot without repo available make dist would fail to find ChangeLog. Generate empty ChangeLog if no ChangeLog is already present and repo is not available. Reported by: Andrei Borzenkov --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index a232eb1e2..f702951af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -447,6 +447,8 @@ ChangeLog: FORCE if test -d $(top_srcdir)/.git; then \ $(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \ rm -f '$@'; mv '$@.tmp' '$@'; \ + else \ + touch $@; \ fi EXTRA_DIST += ChangeLog ChangeLog-2015 From 3661261fe17a8fe19681073889b5b36ec1ee823d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:37:08 +0100 Subject: [PATCH 0011/1167] Always add -msoft-float to avoid compiler generating float arithmetics. --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index fdddbaddc..b734dd0ba 100644 --- a/configure.ac +++ b/configure.ac @@ -671,6 +671,12 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" fi +# GRUB doesn't use float or doubles at all. Yet some toolchains may decide +# that floats are a good fit to run instead of what's written in the code. +# Given that floating point unit is disabled (if present to begin with) +# when GRUB is running which may result in various hard crashes. +TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler From 9ff9d5a54ead6fba080a08fcb1ff8462b8cf2497 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:38:12 +0100 Subject: [PATCH 0012/1167] uhci: Fix null pointer dereference. Found by: Coverity scan. --- grub-core/bus/usb/uhci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c index a95fdfe07..7c5811fd6 100644 --- a/grub-core/bus/usb/uhci.c +++ b/grub-core/bus/usb/uhci.c @@ -625,9 +625,7 @@ grub_uhci_check_transfer (grub_usb_controller_t dev, return GRUB_USB_ERR_NONE; } - grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status); - - if (!(errtd->ctrl_status & (1 << 23))) + if (errtd && !(errtd->ctrl_status & (1 << 23))) { grub_usb_err_t err = GRUB_USB_ERR_NONE; From e902163e484523698f1cc4f06b64830f30909153 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:41:43 +0100 Subject: [PATCH 0013/1167] commands/acpi: Use ALIGN_UP rather than manual expression. Improves readability and hopefully automatic scanning. Found by: Coverity Scan. --- grub-core/commands/acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 97c2cf282..f66fa2db3 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -227,7 +227,7 @@ grub_acpi_create_ebda (void) grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target); v2inebda = target; target += v2->length; - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v2 = 0; break; } @@ -246,7 +246,7 @@ grub_acpi_create_ebda (void) grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target); v1inebda = target; target += sizeof (struct grub_acpi_rsdp_v10); - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v1 = 0; break; } From b04c6d32ce816c5d8943c767bb4cc7e56aa3c1c5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:45:25 +0100 Subject: [PATCH 0014/1167] commands/file: Change the confusing loop stop condition. Old condition was used to zero-out header variable on exit of the loop. This is correct but confusing. Replace with in-loop logic. Found by: Coverity Scan. --- grub-core/commands/file.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 42d62d479..12fba99e0 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) be at least 12 bytes and aligned on a 4-byte boundary. */ for (header = buffer; ((char *) header <= - (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12)) - || (header = 0); header += step) + (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12)); + header += step) { if (header[0] == magic && !(grub_le_to_cpu32 (header[0]) @@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) + grub_le_to_cpu32 (header[2]) + (type == IS_MULTIBOOT2 ? grub_le_to_cpu32 (header[3]) : 0))) - break; + { + ret = 1; + break; + } } - if (header != 0) - ret = 1; grub_free (buffer); break; } From 95a8c9182bc8ab25cbd62424f28a32432f823698 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:50:35 +0100 Subject: [PATCH 0015/1167] commands/fileXX: Fix memory leak. Found by: Coverity Scan. --- grub-core/commands/fileXX.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c index 58e1094c6..7743f3e93 100644 --- a/grub-core/commands/fileXX.c +++ b/grub-core/commands/fileXX.c @@ -40,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf) return 0; if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1) - return 0; + goto fail; if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize) - return 0; + goto fail; s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize); stroff = s->sh_offset; @@ -59,13 +59,16 @@ grub_file_check_netbsdXX (grub_elf_t elf) if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) { if (grub_errno) - return grub_errno; + goto fail; continue; } if (grub_memcmp (name, ".note.netbsd.ident", sizeof(".note.netbsd.ident")) != 0) continue; + grub_free (s0); return 1; } + fail: + grub_free (s0); return 0; } From 9d999852a223b9b00b5f417cb49d3334773408d8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:52:02 +0100 Subject: [PATCH 0016/1167] gptsync: Add missing device_close. Found by: Coverity scan --- grub-core/commands/gptsync.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c index 16592e9bb..444e24874 100644 --- a/grub-core/commands/gptsync.c +++ b/grub-core/commands/gptsync.c @@ -235,6 +235,8 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } + grub_device_close (dev); + grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]); return GRUB_ERR_NONE; From 68cf24376c531ee468615a84aa361e2a6e0406a9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:55:06 +0100 Subject: [PATCH 0017/1167] commands/hdparm: Add missing grub_disk_close. Found by: Coverity scan. --- grub-core/commands/hdparm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c index 3fb08912d..f6b178eae 100644 --- a/grub-core/commands/hdparm.c +++ b/grub-core/commands/hdparm.c @@ -329,6 +329,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) break; } default: + grub_disk_close (disk); return grub_error (GRUB_ERR_IO, "not an ATA device"); } From 12a9c52e516b94888db0a4502946242e3b14709f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:57:26 +0100 Subject: [PATCH 0018/1167] zfs: Fix disk-matching logic. Reported by: Tim Chase --- grub-core/fs/zfs/zfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c943b5299..c8c7b97a2 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -252,7 +252,6 @@ struct grub_zfs_data uberblock_t current_uberblock; - int mounted; grub_uint64_t guid; }; @@ -957,7 +956,7 @@ nvpair_value (const char *nvp,char **val, static grub_err_t check_pool_label (struct grub_zfs_data *data, struct grub_zfs_device_desc *diskdesc, - int *inserted) + int *inserted, int original) { grub_uint64_t pool_state, txg = 0; char *nvlist,*features; @@ -1081,11 +1080,12 @@ check_pool_label (struct grub_zfs_data *data, grub_dprintf ("zfs", "check 11 passed\n"); - if (data->mounted && data->guid != poolguid) - return grub_error (GRUB_ERR_BAD_FS, "another zpool"); - else + if (original) data->guid = poolguid; + if (data->guid != poolguid) + return grub_error (GRUB_ERR_BAD_FS, "another zpool"); + { char *nv; nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); @@ -1186,7 +1186,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data, } grub_dprintf ("zfs", "label ok %d\n", label); - err = check_pool_label (data, &desc, inserted); + err = check_pool_label (data, &desc, inserted, original); if (err || !*inserted) { grub_errno = GRUB_ERR_NONE; @@ -3612,8 +3612,6 @@ zfs_mount (grub_device_t dev) ub_endian) >> 63) & 1; grub_free (osp); - data->mounted = 1; - return data; } From f579f097bbf37d0ec23acb1434f2f1a38f266594 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:06:23 +0100 Subject: [PATCH 0019/1167] commands/legacycfg: Fix resource leaks. --- grub-core/commands/legacycfg.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 2c09fb7dd..d42d7779e 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -57,14 +57,20 @@ legacy_file (const char *filename) file = grub_file_open (filename); if (! file) - return grub_errno; + { + grub_free (suffix); + return grub_errno; + } menu = grub_env_get_menu (); if (! menu) { menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (suffix); + return grub_errno; + } grub_env_set_menu (menu); } @@ -77,6 +83,7 @@ legacy_file (const char *filename) if (!buf && grub_errno) { grub_file_close (file); + grub_free (suffix); return grub_errno; } @@ -173,6 +180,8 @@ legacy_file (const char *filename) if (!args) { grub_file_close (file); + grub_free (suffix); + grub_free (entrysrc); return grub_errno; } args[0] = entryname; @@ -376,6 +385,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (part && grub_strcmp (part->partmap->name, "msdos") == 0) bsd_slice = part->number; } + if (dev) + grub_device_close (dev); } /* k*BSD didn't really work well with grub-legacy. */ From 09e84f188b6e18acf7ae2d3d82d798d92c35d7a5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:08:50 +0100 Subject: [PATCH 0020/1167] commands/macbless: Remove incorrect grub_free. Found by: Coverity Scan --- grub-core/commands/macbless.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index 4724edd77..cf90eea20 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -203,7 +203,6 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) grub_device_close (dev); grub_free (device_name); - grub_free (path); return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); } From e3b3e53f72647fa189ae245d73dc560166bb57d3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:12:02 +0100 Subject: [PATCH 0021/1167] commands/macbless: Fix potential overflow. Is a minor concern as no such FS would be created under normal circumstances and failure was benign. Found by: Coverity scan. --- grub-core/commands/macbless.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index cf90eea20..f9e01b6f9 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir, ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz); ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block); embedded_offset = (ablk_start - + extent_start + + ((grub_uint64_t) extent_start) * (ablk_size >> GRUB_DISK_SECTOR_BITS)); err = From 72bbd8046a55f4a7995535696f375e465ccb0237 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:15:14 +0100 Subject: [PATCH 0022/1167] commands/macbless: Handle device opening errors correctly. Wrong variable was checked for errors. Found by: Coverity scan. --- grub-core/commands/macbless.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index f9e01b6f9..18efa1a84 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) { char *device_name; char *path = 0; - grub_device_t dev; + grub_device_t dev = 0; grub_err_t err; if (argc != 1) @@ -197,7 +197,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) else path = path + 1; - if (!path || *path == 0 || !device_name) + if (!path || *path == 0 || !dev) { if (dev) grub_device_close (dev); From bd50aa323d30d064563c213ab7ee8b8846981609 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:18:36 +0100 Subject: [PATCH 0023/1167] commands/nativedisk: Add missing device_close. Found by: Coverity scan. --- grub-core/commands/nativedisk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index 33b6b99ea..b3bc4639c 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -57,6 +57,7 @@ get_uuid (const char *name, char **uuid, int getnative) if (!dev->disk) { grub_dprintf ("nativedisk", "Skipping non-disk\n"); + grub_device_close (dev); return 0; } @@ -90,6 +91,7 @@ get_uuid (const char *name, char **uuid, int getnative) case GRUB_DISK_DEVICE_MEMDISK_ID: grub_dprintf ("nativedisk", "Skipping native disk %s\n", dev->disk->name); + grub_device_close (dev); return 0; /* FIXME: those probably need special handling. */ From 4947f11b09184806cbfda7ebb2ae25df25be6693 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:22:02 +0100 Subject: [PATCH 0024/1167] commands/parttool: Add missing device close. Found by: Coverity scan. --- grub-core/commands/parttool.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index a47ff0776..d907694dd 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -243,11 +243,19 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } if (argc == 1) - return show_help (dev); + { + err = show_help (dev); + grub_device_close (dev); + return err; + } for (i = 1; i < argc; i++) if (grub_strcmp (args[i], "help") == 0) - return show_help (dev); + { + err = show_help (dev); + grub_device_close (dev); + return err; + } parsed = (int *) grub_zalloc (argc * sizeof (int)); From fbae51dcea91bf5b8d1f11a436867f933d370346 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:23:25 +0100 Subject: [PATCH 0025/1167] commands/syslinux: Add missing free. Found by: Coverity scan. --- grub-core/commands/syslinuxcfg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/syslinuxcfg.c b/grub-core/commands/syslinuxcfg.c index 00ae113c5..7be28fada 100644 --- a/grub-core/commands/syslinuxcfg.c +++ b/grub-core/commands/syslinuxcfg.c @@ -119,7 +119,10 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename) { menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (result); + return grub_errno; + } grub_env_set_menu (menu); } From 6079e67926079d4b3ca35aa570eee2c0f4459f04 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:25:42 +0100 Subject: [PATCH 0026/1167] commands/tr: Simplify and fix missing parameter test. Found by: Coverity scan --- grub-core/commands/tr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/tr.c b/grub-core/commands/tr.c index 84ad6ff8f..ef72841a2 100644 --- a/grub-core/commands/tr.c +++ b/grub-core/commands/tr.c @@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args) } else if (argc > 3) return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters"); - if (argc <= 0 && (!s1 || !s2 || !input)) + if (!s1 || !s2 || !input) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters"); if (grub_strlen (s1) != grub_strlen (s2)) From 37ba761b1cba6e210fa451a7f3dbd6e3dab58a65 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:27:10 +0100 Subject: [PATCH 0027/1167] commands/verify: Fix sha1 context zeroing-out. Current code doesn't zero-out context completely. It's a minor issue really as sha1 init already takes care of initing the context. --- grub-core/commands/verify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index d5995766b..656939189 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -308,7 +308,7 @@ grub_load_public_key (grub_file_t f) if (!sk) goto fail; - grub_memset (fingerprint_context, 0, sizeof (fingerprint_context)); + grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize); GRUB_MD_SHA1->init (fingerprint_context); GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1); len_be = grub_cpu_to_be16 (len); From 3b1b39c08234ba856ec89748f379bac7c710e11a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:29:19 +0100 Subject: [PATCH 0028/1167] commands/wildcard: Add missing free. Found by: Coverity scan. --- grub-core/commands/wildcard.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index 2807f806b..d207acfed 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -245,7 +245,10 @@ match_devices_iter (const char *name, void *data) t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2)); if (! t) - return 1; + { + grub_free (buffer); + return 1; + } ctx->devs = t; ctx->devs[ctx->ndev++] = buffer; From 7d973359427394a00d1d8778b352b67c9ff486d6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:33:30 +0100 Subject: [PATCH 0029/1167] disk/AFsplitter: check argument validity before doing any allocs. This avoids possible memory leaks. Found by: Coverity scan. --- grub-core/disk/AFSplitter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c index 7e1bd5748..f5a8ddc61 100644 --- a/grub-core/disk/AFSplitter.c +++ b/grub-core/disk/AFSplitter.c @@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst, grub_size_t i; grub_uint8_t *bufblock; + if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0) + return GPG_ERR_INV_ARG; + bufblock = grub_zalloc (blocksize); if (bufblock == NULL) return GPG_ERR_OUT_OF_MEMORY; - if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0) - return GPG_ERR_INV_ARG; - grub_memset (bufblock, 0, blocksize); for (i = 0; i < blocknumbers - 1; i++) { From 2a8200bba8d6372fdb2ffb38240542795084f7d8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:37:28 +0100 Subject: [PATCH 0030/1167] disk/ahci: Fix device_map_range argument. Argument is not used on x86, hence it's gone unnoticed. Found by: Coverity scan. --- grub-core/disk/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 89365cd09..d6bdbddf6 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -198,7 +198,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, | GRUB_PCI_COMMAND_MEM_ENABLED); hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, - sizeof (hba)); + sizeof (*hba)); grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function); grub_dprintf ("ahci", "tfd[0]: %x\n", From 4c7337bfe9082c2a005a10ce6dd98293e707943c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:38:22 +0100 Subject: [PATCH 0031/1167] disk/cryptodisk: Add missing error check. Found by: Coverity scan. --- grub-core/disk/cryptodisk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index f0e3a900a..376ab8326 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -372,11 +372,13 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev, break; case GRUB_CRYPTODISK_MODE_ECB: if (do_encrypt) - grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i, - (1U << dev->log_sector_size)); + err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i, + (1U << dev->log_sector_size)); else - grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i, - (1U << dev->log_sector_size)); + err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i, + (1U << dev->log_sector_size)); + if (err) + return err; break; default: return GPG_ERR_NOT_IMPLEMENTED; From f2baeb194be2f08e9281115df514cd3ceeba6110 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:44:27 +0100 Subject: [PATCH 0032/1167] disk/diskfilter: Add missing lv presence check. Found by: Coverity scan. --- grub-core/disk/diskfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 97ca54666..612484607 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1065,7 +1065,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, array->lvs->segments->extent_count = totsize; } - if (array->lvs->segments + if (array->lvs && array->lvs->segments && array->lvs->segments->raid_member_size > disk_size) array->lvs->segments->raid_member_size = disk_size; From 6f43e350ed1d122a35c6b1880f6e1756455f0a6c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:46:23 +0100 Subject: [PATCH 0033/1167] disk/geli: Add missing seek success check. Found by: Coverity scan. --- grub-core/disk/geli.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index 4ed07bb91..bf73fbde8 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -212,7 +212,8 @@ grub_util_get_geli_uuid (const char *dev) s = grub_util_get_fd_size (fd, dev, &log_secsize); s >>= log_secsize; - grub_util_fd_seek (fd, (s << log_secsize) - 512); + if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0) + grub_util_error ("%s", _("couldn't read ELI metadata")); uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) From 7656b72b17c3bf12a3e2173fc04aebf67b286983 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:47:51 +0100 Subject: [PATCH 0034/1167] disk/geli: Add missing free. Found by: Coverity scan. --- grub-core/disk/geli.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index bf73fbde8..e9d23299a 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -232,7 +232,10 @@ grub_util_get_geli_uuid (const char *dev) err = make_uuid ((void *) &hdr, uuid); if (err) - return NULL; + { + grub_free (uuid); + return NULL; + } return uuid; } From d1130afa5f22e4fee75ab55f11e16e0fbd98597d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:50:30 +0100 Subject: [PATCH 0035/1167] biosdisk: Add missing cast. Found by: Coverity scan. --- grub-core/disk/i386/pc/biosdisk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 26a4973ad..f0aadd111 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -382,7 +382,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) /* Some buggy BIOSes doesn't return the total sectors correctly but returns zero. So if it is zero, compute it by C/H/S returned by the LBA BIOS call. */ - total_sectors = drp->cylinders * drp->heads * drp->sectors; + total_sectors = ((grub_uint64_t) drp->cylinders) + * drp->heads * drp->sectors; if (drp->bytes_per_sector && !(drp->bytes_per_sector & (drp->bytes_per_sector - 1)) && drp->bytes_per_sector >= 512 @@ -425,7 +426,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) data->heads = 255; if (! total_sectors) - total_sectors = data->cylinders * data->heads * data->sectors; + total_sectors = ((grub_uint64_t) data->cylinders) + * data->heads * data->sectors; } disk->total_sectors = total_sectors; From dd430afbf874f6212742c079d72b4b9e959e0542 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:55:18 +0100 Subject: [PATCH 0036/1167] font: Add missing free. Found by: Coverity Scan. --- grub-core/font/font.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 14b93e172..607964b90 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -777,6 +777,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code) if (grub_file_read (font->file, glyph->bitmap, len) != len) { remove_font (font); + grub_free (glyph); return 0; } } From b6f21bcb98f03d61087b4423261bda5d6a58fb1f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 00:00:49 +0100 Subject: [PATCH 0037/1167] fs/cbfs: Add missing free. Found by: Coverity scan. --- grub-core/fs/cbfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 35750a0e4..4ddd6832f 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -144,7 +144,7 @@ static struct grub_archelp_data * grub_cbfs_mount (grub_disk_t disk) { struct cbfs_file hd; - struct grub_archelp_data *data; + struct grub_archelp_data *data = NULL; grub_uint32_t ptr; grub_off_t header_off; struct cbfs_header head; @@ -196,6 +196,7 @@ grub_cbfs_mount (grub_disk_t disk) return data; fail: + grub_free (data); grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem"); return 0; } From faad548ce3b906535acaeff95777b46836b817e6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 00:11:59 +0100 Subject: [PATCH 0038/1167] fs/cpio_common: Add a sanity check on namesize. Found by: Coverity scan. --- grub-core/fs/cpio_common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index b0ae9f445..20230a741 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -61,6 +61,14 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode)); namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize)); + /* Don't allow negative numbers. */ + if (namesize >= 0x80000000) + { + /* Probably a corruption, don't attempt to recover. */ + *mode = GRUB_ARCHELP_ATTR_END; + return GRUB_ERR_NONE; + } + if (mode) *mode = modeval; From 83543f937a3525ef577c5a6333cb6791aadcee3d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 01:27:44 +0100 Subject: [PATCH 0039/1167] fs/fat: Fix codepath to properly free on error. Found by: Coverity scan. --- grub-core/fs/fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 79fe864d7..71537ff44 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -1136,7 +1136,7 @@ grub_fat_label (grub_device_t device, char **label) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) { grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - return 0; + goto fail; } err = grub_fat_iterate_init (&ctxt); From 4387ca78f0aada6ce04e4132e50f6b73fa60671f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 01:28:17 +0100 Subject: [PATCH 0040/1167] fs/hfs/hfs_open: Check that mount succeeded. Found by: Coverity scan. --- grub-core/fs/hfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index f46f77a94..ab472f4b0 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1306,6 +1306,12 @@ grub_hfs_open (struct grub_file *file, const char *name) data = grub_hfs_mount (file->device->disk); + if (!data) + { + grub_dl_unref (my_mod); + return grub_errno; + } + if (grub_hfs_find_dir (data, name, &frec, 0)) { grub_free (data); From d0af2156c3b3e900956651523da17afff4969815 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 11:32:29 +0100 Subject: [PATCH 0041/1167] fs/hfs: Add pointer sanity checks. Found by: Coverity scan. --- grub-core/fs/hfs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index ab472f4b0..06cf0c7ab 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -692,6 +692,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, int i; struct grub_hfs_extent *dat; int blk; + grub_uint16_t reccnt; dat = (struct grub_hfs_extent *) (type == 0 ? (&data->sblock.catalog_recs) @@ -710,8 +711,12 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, return grub_errno; } + reccnt = grub_be_to_cpu16 (node->node.reccnt); + if (reccnt > (nodesize >> 1)) + reccnt = (nodesize >> 1); + /* Iterate over all records in this node. */ - for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++) + for (i = 0; i < reccnt; i++) { int pos = (nodesize >> 1) - 1 - i; struct pointer @@ -719,16 +724,19 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, grub_uint8_t keylen; grub_uint8_t key; } GRUB_PACKED *pnt; - pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos]) - + node->rawnode); + grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]); + if (off > nodesize - sizeof(*pnt)) + continue; + pnt = (struct pointer *) (off + node->rawnode); + if (nodesize < (grub_size_t) off + pnt->keylen + 1) + continue; struct grub_hfs_record rec = { &pnt->key, pnt->keylen, &pnt->key + pnt->keylen +(pnt->keylen + 1) % 2, - nodesize - grub_be_to_cpu16 (node->offsets[pos]) - - pnt->keylen - 1 + nodesize - off - pnt->keylen - 1 }; if (node_hook (&node->node, &rec, hook_arg)) From fb66b512fa241c98b44ce6032e1d285d9d9f9aa3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 25 Jan 2015 16:36:30 +0300 Subject: [PATCH 0042/1167] commands/fileXX: Fix remaining memory leak. Found by: Coverity Scan. --- grub-core/commands/fileXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c index 7743f3e93..c17d26ce6 100644 --- a/grub-core/commands/fileXX.c +++ b/grub-core/commands/fileXX.c @@ -54,7 +54,7 @@ grub_file_check_netbsdXX (grub_elf_t elf) char name[sizeof(".note.netbsd.ident")]; grub_memset (name, 0, sizeof (name)); if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1) - return grub_errno; + goto fail; if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) { From ac602ce7005090a34e021f736a9ad3ac033a4cc8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:19:58 +0100 Subject: [PATCH 0043/1167] grub_iso9660_read: Explicitly check read_node return value. Not really needed as grub_errno is already checked but is nicer. Found by: Coverity scan. --- grub-core/fs/iso9660.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 6a6677337..67a67cf40 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -959,14 +959,15 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len) { struct grub_iso9660_data *data = (struct grub_iso9660_data *) file->data; + grub_err_t err; /* XXX: The file is stored in as a single extent. */ data->disk->read_hook = file->read_hook; data->disk->read_hook_data = file->read_hook_data; - read_node (data->node, file->offset, len, buf); + err = read_node (data->node, file->offset, len, buf); data->disk->read_hook = NULL; - if (grub_errno) + if (err || grub_errno) return -1; return len; From ca793e9c058dd1d08780e176ce5bcdeefa47a6be Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:21:32 +0100 Subject: [PATCH 0044/1167] fs/minix: Fix sector promotion to 64-bit. While on it make GRUB_MINIX_ZONE2SECT into function. Found by: Coverity scan --- grub-core/fs/minix.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 90ddd34f1..d451b3426 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -82,17 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t; #define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \ (data->inode.double_indir_zone)) -#ifndef MODE_MINIX3 -#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \ - + grub_minix_to_cpu16 (data->sblock.log2_zone_size)) -#endif - -#ifdef MODE_MINIX3 -#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size) -#else -#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ) -#endif - #ifdef MODE_MINIX3 struct grub_minix_sblock @@ -182,15 +171,32 @@ static grub_dl_t my_mod; static grub_err_t grub_minix_find_file (struct grub_minix_data *data, const char *path); +#ifdef MODE_MINIX3 +static inline grub_disk_addr_t +grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone) +{ + return ((grub_disk_addr_t) zone) * data->block_size; +} +#else +static inline grub_disk_addr_t +grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone) +{ + int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE + + grub_minix_to_cpu16 (data->sblock.log2_zone_size)); + return (((grub_disk_addr_t) zone) << log2_zonesz); +} +#endif + + /* Read the block pointer in ZONE, on the offset NUM. */ static grub_minix_uintn_t -grub_get_indir (struct grub_minix_data *data, +grub_get_indir (struct grub_minix_data *data, grub_minix_uintn_t zone, grub_minix_uintn_t num) { grub_minix_uintn_t indirn; grub_disk_read (data->disk, - GRUB_MINIX_ZONE2SECT(zone), + grub_minix_zone2sect(data, zone), sizeof (grub_minix_uintn_t) * num, sizeof (grub_minix_uintn_t), (char *) &indirn); return grub_minix_to_cpu_n (indirn); @@ -281,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data, for (i = posblock; i < blockcnt; i++) { - grub_disk_addr_t blknr; + grub_minix_uintn_t blknr; grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS; grub_off_t skipfirst = 0; @@ -310,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data, data->disk->read_hook = read_hook; data->disk->read_hook_data = read_hook_data; grub_disk_read (data->disk, - GRUB_MINIX_ZONE2SECT(blknr), + grub_minix_zone2sect(data, blknr), skipfirst, blockend, buf); data->disk->read_hook = 0; if (grub_errno) @@ -336,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino) /* The first inode in minix is inode 1. */ ino--; - block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size) + block = grub_minix_zone2sect (data, + 2 + grub_minix_to_cpu16 (sblock->inode_bmap_size) + grub_minix_to_cpu16 (sblock->zone_bmap_size)); block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode)); int offs = (ino % (GRUB_DISK_SECTOR_SIZE From bc0ecd7104b3420964364b7a01b7dd7141081b9b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:22:24 +0100 Subject: [PATCH 0045/1167] fs/ntfs: Add missing free. Found by: Coverity scan. --- grub-core/fs/ntfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index d3a91f5d7..2cbcb0b78 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -618,7 +618,10 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, ustr = get_utf8 (np, ns); if (ustr == NULL) - return 0; + { + grub_free (fdiro); + return 0; + } if (namespace) type |= GRUB_FSHELP_CASE_INSENSITIVE; From 157f9a9cca0990bf213e5041daaf4641c1764e09 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:28:50 +0100 Subject: [PATCH 0046/1167] fs/ntfs: Add sizes sanity checks. Found by: Coverity scan. --- grub-core/fs/ntfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 2cbcb0b78..6f8468862 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -920,12 +920,16 @@ grub_ntfs_mount (grub_disk_t disk) if (bpb.clusters_per_mft > 0) data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc; + else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31) + goto fail; else data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR); if (bpb.clusters_per_index > 0) data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index) << data->log_spc); + else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31) + goto fail; else data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR); From 8c1d08668974cc59f00e0cbc1c37c2f03e1a132e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:29:26 +0100 Subject: [PATCH 0047/1167] fs/reiserfs: Fix sector count overflow. Found by: Coverity scan. --- grub-core/fs/reiserfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index de3d4fa3c..b78166554 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -1090,7 +1090,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node, switch (found.type) { case GRUB_REISERFS_DIRECT: - block = found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS); + block = ((grub_disk_addr_t) found.block_number) * (block_size >> GRUB_DISK_SECTOR_BITS); grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block); if (initial_position < current_position + item_size) { From 66baeffc0f6373be4745a8f1941c46fc5e104392 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:33:03 +0100 Subject: [PATCH 0048/1167] fs/sfs: Fix error check and add sanity check. Found by: Coverity scan. --- grub-core/fs/sfs.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c index 6c8215048..57b8d8da6 100644 --- a/grub-core/fs/sfs.c +++ b/grub-core/fs/sfs.c @@ -173,10 +173,11 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block, struct grub_sfs_btree *tree; int i; grub_uint32_t next; + grub_size_t blocksize = GRUB_DISK_SECTOR_SIZE << data->log_blocksize; - treeblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize); - if (!block) - return 0; + treeblock = grub_malloc (blocksize); + if (!treeblock) + return grub_errno; next = grub_be_to_cpu32 (data->rblock.btree); tree = (struct grub_sfs_btree *) treeblock; @@ -184,17 +185,21 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block, /* Handle this level in the btree. */ do { + grub_uint16_t nnodes; grub_disk_read (data->disk, ((grub_disk_addr_t) next) << data->log_blocksize, - 0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize, - treeblock); + 0, blocksize, treeblock); if (grub_errno) { grub_free (treeblock); return grub_errno; } - for (i = grub_be_to_cpu16 (tree->nodes) - 1; i >= 0; i--) + nnodes = grub_be_to_cpu16 (tree->nodes); + if (nnodes * (grub_uint32_t) (tree)->nodesize > blocksize) + break; + + for (i = (int) nnodes - 1; i >= 0; i--) { #define EXTNODE(tree, index) \ From fc7a64bc5aa2ab9b0a9475692c6f392681525b93 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:35:44 +0100 Subject: [PATCH 0049/1167] configure.ac: Always add -D_FILE_OFFSET_BITS=64. --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b734dd0ba..a3bca06ca 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,9 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then HOST_CFLAGS="$HOST_CFLAGS -m64" fi +CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" +HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64" + AC_C_BIGENDIAN AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long) @@ -1477,7 +1480,7 @@ fi if test x"$grub_mount_excuse" = x ; then # Check for fuse headers. SAVED_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26" AC_CHECK_HEADERS([fuse/fuse.h], [], [grub_mount_excuse=["need FUSE headers"]]) CPPFLAGS="$SAVED_CPPFLAGS" From a4e33a8b180a289ee48ab22c63e0f836adb2ade7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:36:19 +0100 Subject: [PATCH 0050/1167] fs/ufs: Add missing error check. Found by: Coverity scan. --- grub-core/fs/ufs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index f560ad380..0619d6e32 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -465,7 +465,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) && INODE_SIZE (data) <= sizeof (data->inode.symlink)) grub_strcpy (symlink, (char *) data->inode.symlink); else - grub_ufs_read_file (data, 0, 0, 0, sz, symlink); + { + if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0) + { + grub_free(symlink); + return grub_errno; + } + } symlink[sz] = '\0'; /* The symlink is an absolute path, go back to the root inode. */ From bd74a925e5026cd0368b3455df8ffcf0b1b4150b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:37:01 +0100 Subject: [PATCH 0051/1167] gfxmenu/icon_manager: Fix null pointer dereference. Found by: Coverity scan. --- grub-core/gfxmenu/icon_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c index ff49ab0e0..1894682ef 100644 --- a/grub-core/gfxmenu/icon_manager.c +++ b/grub-core/gfxmenu/icon_manager.c @@ -106,8 +106,10 @@ grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr, const char *path) { /* Clear the cache if the theme path has changed. */ - if (((mgr->theme_path == 0) != (path == 0)) - || (grub_strcmp (mgr->theme_path, path) != 0)) + if (mgr->theme_path == 0 && path == 0) + return; + if (mgr->theme_path == 0 || path == 0 + || grub_strcmp (mgr->theme_path, path) != 0) grub_gfxmenu_icon_manager_clear_cache (mgr); grub_free (mgr->theme_path); From af0be976bf5bb45c0d5d5290ca0f2a83fb380785 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:37:39 +0100 Subject: [PATCH 0052/1167] gfxmenu/theme_loader: Add missing allos error check. Found by: Coverity scan. --- grub-core/gfxmenu/theme_loader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c index 8a7945816..1a6ed1d25 100644 --- a/grub-core/gfxmenu/theme_loader.c +++ b/grub-core/gfxmenu/theme_loader.c @@ -774,6 +774,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path) view->canvas->component.ops->destroy (view->canvas); view->canvas = grub_gui_canvas_new (); + if (!view->canvas) + goto fail; ((grub_gui_component_t) view->canvas) ->ops->set_bounds ((grub_gui_component_t) view->canvas, &view->screen); From 21f22c71077a4d460049107a946ceca8b514ffb3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:38:11 +0100 Subject: [PATCH 0053/1167] i386/pc/mmap: Fix memset size. Found by: Coverity scan. --- grub-core/kern/i386/pc/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c index f1375f3e1..c0c3c3585 100644 --- a/grub-core/kern/i386/pc/mmap.c +++ b/grub-core/kern/i386/pc/mmap.c @@ -148,7 +148,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) while (1) { - grub_memset (entry, 0, sizeof (entry)); + grub_memset (entry, 0, sizeof (*entry)); cont = grub_get_mmap_entry (entry, cont); From aa64393144f0a805b191bc2c45b84606b03706a0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:40:42 +0100 Subject: [PATCH 0054/1167] lib/syslinux_parse: Add missing alloc check. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 241cefe69..2f1f1a5a2 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -649,6 +649,8 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu) grub_size_t helplen, alloclen = 0; help = grub_strdup (line); + if (!help) + return grub_errno; helplen = grub_strlen (line); while ((grub_free (buf), buf = grub_file_getline (file))) { From ca7c1fd6f377bebf300d0bfcb61253c34fefc861 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:41:24 +0100 Subject: [PATCH 0055/1167] lib/syslinux_parse: Fix memory leak. Found by: Coveriy scan. --- grub-core/lib/syslinux_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 2f1f1a5a2..1927c4fda 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -684,6 +684,7 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu) } grub_free (buf); + grub_free (help); return grub_errno; } From 49978c5c4f5a88a8065042133e5d4b7e3c472eaa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:42:04 +0100 Subject: [PATCH 0056/1167] lib/syslinux_parse: Add missing error check. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 1927c4fda..f6053267f 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -846,7 +846,12 @@ write_entry (struct output_buffer *outbuf, { grub_err_t err; if (curentry->comments) - print (outbuf, curentry->comments, grub_strlen (curentry->comments)); + { + err = print (outbuf, curentry->comments, + grub_strlen (curentry->comments)); + if (err) + return err; + } { struct syslinux_say *say; for (say = curentry->say; say && say->next; say = say->next); From 1e0d71837124add3adb810ebbb13607dac037635 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:42:42 +0100 Subject: [PATCH 0057/1167] bsd: Add missing null-pointer check. Found by: Coverity scan. --- grub-core/loader/i386/bsd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 8f691e0e2..bc377b362 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -234,7 +234,8 @@ grub_bsd_add_meta_ptr (grub_uint32_t type, void **ptr, grub_uint32_t len) { struct bsd_tag *p; for (p = tags; - p->type != (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND); + p && p->type != (FREEBSD_MODINFO_METADATA + | FREEBSD_MODINFOMD_KERNEND); p = p->next); if (p) From ef02b4ca933fd4c215e169a23b2b069aab712677 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:43:52 +0100 Subject: [PATCH 0058/1167] multiboot: Simplify to avoid confusing assignment. Found by: Coverity scan. --- grub-core/loader/i386/multiboot_mbi.c | 29 +++++++++++++++--------- grub-core/loader/multiboot_mbi2.c | 32 +++++++++++++++++---------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index f10c087f7..956d0e37b 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -121,6 +121,24 @@ load_kernel (grub_file_t file, const char *filename, return grub_multiboot_load_elf (file, filename, buffer); } +static struct multiboot_header * +find_header (char *buffer, grub_ssize_t len) +{ + struct multiboot_header *header; + + /* Look for the multiboot header in the buffer. The header should + be at least 12 bytes and aligned on a 4-byte boundary. */ + for (header = (struct multiboot_header *) buffer; + ((char *) header <= buffer + len - 12); + header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN)) + { + if (header->magic == MULTIBOOT_HEADER_MAGIC + && !(header->magic + header->flags + header->checksum)) + return header; + } + return NULL; +} + grub_err_t grub_multiboot_load (grub_file_t file, const char *filename) { @@ -143,16 +161,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) return grub_errno; } - /* Look for the multiboot header in the buffer. The header should - be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct multiboot_header *) buffer; - ((char *) header <= buffer + len - 12) || (header = 0); - header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN)) - { - if (header->magic == MULTIBOOT_HEADER_MAGIC - && !(header->magic + header->flags + header->checksum)) - break; - } + header = find_header (buffer, len); if (header == 0) { diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 83e8919fa..6f74aeef7 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -79,6 +79,25 @@ grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, elf_sections = data; } +static struct multiboot_header * +find_header (grub_properly_aligned_t *buffer, grub_ssize_t len) +{ + struct multiboot_header *header; + /* Look for the multiboot header in the buffer. The header should + be at least 12 bytes and aligned on a 4-byte boundary. */ + for (header = (struct multiboot_header *) buffer; + ((char *) header <= (char *) buffer + len - 12); + header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) + { + if (header->magic == MULTIBOOT_HEADER_MAGIC + && !(header->magic + header->architecture + + header->header_length + header->checksum) + && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) + return header; + } + return NULL; +} + grub_err_t grub_multiboot_load (grub_file_t file, const char *filename) { @@ -107,18 +126,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - /* Look for the multiboot header in the buffer. The header should - be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct multiboot_header *) buffer; - ((char *) header <= (char *) buffer + len - 12) || (header = 0); - header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) - { - if (header->magic == MULTIBOOT_HEADER_MAGIC - && !(header->magic + header->architecture - + header->header_length + header->checksum) - && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) - break; - } + header = find_header (buffer, len); if (header == 0) { From e12c3bed90221fad33c4b08ce208745dd65bd782 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:44:33 +0100 Subject: [PATCH 0059/1167] plan9: Add missing grub_device_close. Found by: Coverity scan. --- grub-core/loader/i386/pc/plan9.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c index 0d10b1c24..814a49d50 100644 --- a/grub-core/loader/i386/pc/plan9.c +++ b/grub-core/loader/i386/pc/plan9.c @@ -342,6 +342,7 @@ fill_disk (const char *name, void *data) if (!plan9name) { grub_print_error (); + grub_device_close (dev); return 0; } if (grub_extend_alloc (fill_ctx->pmapptr + grub_strlen (plan9name) @@ -349,6 +350,7 @@ fill_disk (const char *name, void *data) &fill_ctx->pmap)) { grub_free (plan9name); + grub_device_close (dev); return 1; } grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, plan9name); @@ -366,12 +368,19 @@ fill_disk (const char *name, void *data) fill_ctx->noslash = 1; grub_memset (fill_ctx->prefixescnt, 0, sizeof (fill_ctx->prefixescnt)); if (grub_partition_iterate (dev->disk, fill_partition, fill_ctx)) - return 1; + { + grub_device_close (dev); + return 1; + } if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc, &fill_ctx->pmap)) - return 1; + { + grub_device_close (dev); + return 1; + } fill_ctx->pmap[fill_ctx->pmapptr++] = '\n'; + grub_device_close (dev); return 0; } From a05a6e6f92335236dc12339c73144ef8d03f07e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:44:57 +0100 Subject: [PATCH 0060/1167] xnu: Add missing error check. Found by: Coveriy scan. --- grub-core/loader/xnu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index cdd9715ce..bc89cdf6c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1378,6 +1378,8 @@ grub_xnu_fill_devicetree (void) name[len] = 0; curvalue = grub_xnu_create_value (curkey, name); + if (!curvalue) + return grub_errno; grub_free (name); data = grub_malloc (grub_strlen (var->value) + 1); From 73b1e8383906910e9da82fb3c79c590e450d598f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:48:46 +0100 Subject: [PATCH 0061/1167] normal/main: Fix error handling. Found by: Coverity scan. --- grub-core/normal/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index c41f175bd..623b93ba6 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -130,7 +130,7 @@ read_config_file (const char *config) file = grub_bufio_open (rawfile, 0); if (! file) { - grub_file_close (file); + grub_file_close (rawfile); return 0; } From 6603c22f3125185077d9e6431e1004aff83a473c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:49:32 +0100 Subject: [PATCH 0062/1167] normal/misc: Close device on all pathes. Found by: Coverity scan. --- grub-core/normal/misc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c index 34d505eda..38f91b9b9 100644 --- a/grub-core/normal/misc.c +++ b/grub-core/normal/misc.c @@ -184,10 +184,11 @@ grub_normal_print_device_info (const char *name) /* TRANSLATORS: Replace dot with appropriate decimal separator for your language. */ (grub_disk_get_size (dev->disk) & 1) ? _(".5") : ""); - - grub_device_close (dev); } + if (dev) + grub_device_close (dev); + grub_xputs ("\n"); return grub_errno; } From c14dff3ca722cc139cd9c44261aa99882d8a8ca3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:50:27 +0100 Subject: [PATCH 0063/1167] devmapper/getroot: Fix memory leak. Found by: Coverity scan. --- grub-core/osdep/devmapper/getroot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index d02386b34..0a77a04b9 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -160,7 +160,10 @@ grub_util_pull_devmapper (const char *os_dev) uuid = get_dm_uuid (os_dev); if (!grub_util_open_dm (os_dev, &tree, &node)) - return; + { + grub_free (uuid); + return; + } while ((child = dm_tree_next_child (&handle, node, 0))) { @@ -192,6 +195,7 @@ grub_util_pull_devmapper (const char *os_dev) } else dm_tree_free (tree); + grub_free (uuid); } char * @@ -253,6 +257,7 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) grub_free (uuid); return grub_dev; } + grub_free (uuid); return NULL; } @@ -279,6 +284,7 @@ grub_util_get_vg_uuid (const char *os_dev) } optr--; *optr = '\0'; + grub_free (uuid); return vgid; } From 5adc6d76d3c82ed7d85fc7aaa341743f5378314c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:50:58 +0100 Subject: [PATCH 0064/1167] linux/blocklist: Fix memory leak. Found by: Coverity scan. --- grub-core/osdep/linux/blocklist.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c index 10ddd11c1..c77d6085c 100644 --- a/grub-core/osdep/linux/blocklist.c +++ b/grub-core/osdep/linux/blocklist.c @@ -130,6 +130,7 @@ grub_install_get_blocklist (grub_device_t root_dev, & (GRUB_DISK_SECTOR_SIZE - 1), fie2->fm_extents[i].fe_length, hook_data); } + free (fie2); } close (fd); } From cba5a85a67f879b6431833e87ceb93d44b8ac48a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:51:48 +0100 Subject: [PATCH 0065/1167] linux/getroot: Fix error handling. Found by: Coverity scan. --- grub-core/osdep/linux/getroot.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 7007193d9..f48b81aed 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -226,7 +226,7 @@ grub_find_root_devices_from_btrfs (const char *dir) char **ret; fd = open (dir, 0); - if (!fd) + if (fd < 0) return NULL; if (ioctl (fd, BTRFS_IOC_FS_INFO, &fsi) < 0) @@ -274,11 +274,11 @@ get_btrfs_fs_prefix (const char *mount_path) args.objectid = GRUB_BTRFS_TREE_ROOT_OBJECTID; if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0) - return NULL; + goto fail; tree_id = args.treeid; if (fstat (fd, &st) < 0) - return NULL; + goto fail; inode_id = st.st_ino; while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID @@ -309,11 +309,11 @@ get_btrfs_fs_prefix (const char *mount_path) sargs.key.nr_items = 1; if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0) - return NULL; + goto fail; if (sargs.key.nr_items == 0) - return NULL; - + goto fail; + tree_id = sargs.buf[2]; br = (struct grub_btrfs_root_backref *) (sargs.buf + 4); inode_id = br->inode_id; @@ -336,10 +336,10 @@ get_btrfs_fs_prefix (const char *mount_path) sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_INODE_REF; if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0) - return NULL; + goto fail; if (sargs.key.nr_items == 0) - return NULL; + goto fail; inode_id = sargs.buf[2]; @@ -362,6 +362,10 @@ get_btrfs_fs_prefix (const char *mount_path) if (!ret) return xstrdup ("/"); return ret; + fail: + free (ret); + close (fd); + return NULL; } @@ -688,7 +692,7 @@ char * grub_util_part_to_disk (const char *os_dev, struct stat *st, int *is_part) { - char *path = xmalloc (PATH_MAX); + char *path; if (! S_ISBLK (st->st_mode)) { @@ -696,6 +700,8 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, return xstrdup (os_dev); } + path = xmalloc (PATH_MAX); + if (! realpath (os_dev, path)) return NULL; From 810254093959708aa6a260c59ad3cf3a1d250755 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:53:03 +0100 Subject: [PATCH 0066/1167] unix/password: Fix file descriptor leak. Found by: Coverity scan. --- grub-core/osdep/unix/password.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 470a6ea62..4b9507bce 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -53,7 +53,10 @@ grub_password_get (char buf[], unsigned buf_size) tty_changed = 0; grub_memset (buf, 0, buf_size); if (!fgets (buf, buf_size, stdin)) - return 0; + { + fclose (in); + return 0; + } ptr = buf + strlen (buf) - 1; while (buf <= ptr && (*ptr == '\n' || *ptr == '\r')) *ptr-- = 0; @@ -64,5 +67,7 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); + fclose (in); + return 1; } From c4fcfd8744f320635949d62ec0df4ea60ebe60e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:53:39 +0100 Subject: [PATCH 0067/1167] vbe: Fix incorrect register usage. Found by: Coverity scan. --- grub-core/video/i386/pc/vbe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 62b5c2245..07a614a20 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -304,8 +304,7 @@ grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size) struct grub_bios_int_registers regs; regs.eax = 0x4f08; - regs.ebx = (*dac_mask_size & 0xff) >> 8; - regs.ebx = set ? 1 : 0; + regs.ebx = ((*dac_mask_size & 0xff) << 8) | (set ? 1 : 0); regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x10, ®s); *dac_mask_size = (regs.ebx >> 8) & 0xff; From 866f469683a1cc99bb3adeee5b3eb07ec18a000c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:54:14 +0100 Subject: [PATCH 0068/1167] util/getroot: Add missing grub_disk_close. Found by: Coverity scan. --- util/getroot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/getroot.c b/util/getroot.c index 3958105d8..345d49ba8 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -417,7 +417,10 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) name = grub_util_get_ldm (disk, ctx.start); if (name) - return name; + { + grub_disk_close (disk); + return name; + } ctx.partname = NULL; From c3f52305976ffcdee679df4229b65d5f71a53023 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:54:50 +0100 Subject: [PATCH 0069/1167] grub-install-common: Fix sizeof usage. Found by: Coverity scan. --- util/grub-install-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index b6dec93ea..a4656994e 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -238,7 +238,7 @@ grub_install_push_module (const char *val) if (modules.n_alloc < 16) modules.n_alloc = 16; modules.entries = xrealloc (modules.entries, - modules.n_alloc * sizeof (modules.entries)); + modules.n_alloc * sizeof (*modules.entries)); } modules.entries[modules.n_entries++] = xstrdup (val); modules.entries[modules.n_entries] = NULL; From 3c6384832bb304078fcafc537195827710f9f6bf Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:55:30 +0100 Subject: [PATCH 0070/1167] grub-install: Fix memory leak. Found by: Coverity scan. --- util/grub-install.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index 7d61c32be..afbc55707 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -622,7 +622,10 @@ device_map_check_duplicates (const char *dev_map) fp = grub_util_fopen (dev_map, "r"); if (! fp) - return; + { + free (d); + return; + } while (fgets (buf, sizeof (buf), fp)) { From 5d61a6a6120954380a46a3c1a46a01fdf763e037 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:55:58 +0100 Subject: [PATCH 0071/1167] grub-macbless: Fix resource leak. Found by: Coverity scan. --- util/grub-macbless.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/grub-macbless.c b/util/grub-macbless.c index 742353a42..e57e13d5a 100644 --- a/util/grub-macbless.c +++ b/util/grub-macbless.c @@ -92,6 +92,8 @@ bless (const char *path, int x86) free (filebuf_via_grub); free (filebuf_via_sys); free (drive_name); + free (devices); + grub_device_close (dev); } static struct argp_option options[] = { From 11eed6abce6626edecdbc81876bc7f5b91458c0b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:56:24 +0100 Subject: [PATCH 0072/1167] util/misc.c: Check ftello return value. Found by: Coverity scan. --- util/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/misc.c b/util/misc.c index b0e023ecd..b8ec69108 100644 --- a/util/misc.c +++ b/util/misc.c @@ -89,6 +89,8 @@ grub_util_get_image_size (const char *path) fseeko (f, 0, SEEK_END); sz = ftello (f); + if (sz < 0) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); if (sz != (size_t) sz) grub_util_error (_("file `%s' is too big"), path); ret = (size_t) sz; From 6704abade6674a91d8c652a7e4596ca3421411b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:38:40 +0300 Subject: [PATCH 0073/1167] linux/getroot: fix descriptor leak. Found by: Coverity scan. --- grub-core/osdep/linux/getroot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index f48b81aed..a2e360f52 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -360,8 +360,10 @@ get_btrfs_fs_prefix (const char *mount_path) ret[1+namelen] = '\0'; } if (!ret) - return xstrdup ("/"); + ret = xstrdup ("/"); + close (fd); return ret; + fail: free (ret); close (fd); From e2a21238da913dd834b6b656170eb295c589e65d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:41:29 +0300 Subject: [PATCH 0074/1167] linux/ofpath: fix various memory leaks. Found by: Coverity scan. --- grub-core/osdep/linux/ofpath.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 8f24bc9e8..4cc171cb5 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -128,6 +128,8 @@ find_obppath (const char *sysfs_path_orig) if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); kill_trailing_dir(sysfs_path); if (!strcmp(sysfs_path, "/sys")) { @@ -147,6 +149,9 @@ find_obppath (const char *sysfs_path_orig) { grub_util_info (_("cannot read `%s': %s"), path, strerror (errno)); close(fd); + free (path); + free (of_path); + free (sysfs_path); return NULL; } close(fd); @@ -480,6 +485,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev snprintf(disk, sizeof (disk), "/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1)); } + free (lunstr); } } strcat(of_path, disk); @@ -530,7 +536,7 @@ grub_util_devname_to_ofpath (const char *sys_devname) else { grub_util_warn (_("unknown device type %s\n"), device); - return NULL; + ofpath = NULL; } free (devnode); From 64440daa21e150337ee285674eca3dd84de20958 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:07:19 +0300 Subject: [PATCH 0075/1167] util/setup: fix memory leak. Found by: Coverity scan. --- util/setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index 9fb91a82f..ed4bd1113 100644 --- a/util/setup.c +++ b/util/setup.c @@ -322,7 +322,10 @@ SETUP (const char *dir, continue; try_dev = grub_device_open (drive); if (! try_dev) - continue; + { + free (drive); + continue; + } if (!found && try_dev->disk->id == dest_dev->disk->id && try_dev->disk->dev->id == dest_dev->disk->dev->id) { From 5e27fb06f22eda7d7ffd86d16c27262aaf59e132 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:11:32 +0300 Subject: [PATCH 0076/1167] util/install: fix memory leak. Found by: Coverity scan. --- util/grub-install-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index a4656994e..37c1a98b9 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -490,6 +490,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, dir, prefix, outname, mkimage_target, compnames[compression], note ? "--note" : "", s); + free (s); tgt = grub_install_get_image_target (mkimage_target); if (!tgt) From e61f4eba1850c1c6576c0977fc1a305ad02ab0ce Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:08:13 +0300 Subject: [PATCH 0077/1167] linux/getroot: fix memory leak. Found by: Coverity scan. --- grub-core/osdep/unix/getroot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index e3887cbea..10fb56a2b 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -621,7 +621,10 @@ grub_util_pull_lvm_by_command (const char *os_dev) free (vgname); if (!pid) - return; + { + free (vgid); + return; + } /* Parent. Read vgs' output. */ vgs = fdopen (fd, "r"); @@ -653,6 +656,7 @@ out: close (fd); waitpid (pid, NULL, 0); free (buf); + free (vgid); } /* ZFS has similar problems to those of btrfs (see above). */ From be0743b052d76c27cc704d94cfd38cc54e7e02b3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:17:31 +0300 Subject: [PATCH 0078/1167] util/grub-install: rearrange code to avoid memory leak. Found by: Coverity scan. --- util/grub-install.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c index afbc55707..210f4a7e3 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -615,17 +615,14 @@ device_map_check_duplicates (const char *dev_map) char **d; size_t i; - d = xmalloc (alloced * sizeof (d[0])); - if (dev_map[0] == '\0') return; fp = grub_util_fopen (dev_map, "r"); if (! fp) - { - free (d); - return; - } + return; + + d = xmalloc (alloced * sizeof (d[0])); while (fgets (buf, sizeof (buf), fp)) { From bd4e20eedfaa3079a2efcb13559e916772365ee1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:20:51 +0300 Subject: [PATCH 0079/1167] util/grub-mkstandalone: fix memory leak. Found by: Coverity scan. --- util/grub-mkstandalone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 6017d7155..4907d44c0 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -284,6 +284,7 @@ add_tar_file (const char *from, grub_util_fd_close (in); write_pad (size); + free (tcn); } int From 1a87156e01e3cb873f3479c31c34c97fb690eb71 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:24:28 +0300 Subject: [PATCH 0080/1167] util/grub-mount: fix descriptor leak. Found by: Coverity scan. --- util/grub-mount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mount.c b/util/grub-mount.c index 19de2e620..4626e54ed 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -516,6 +516,7 @@ argp_parser (int key, char *arg, struct argp_state *state) return 0; } grub_zfs_add_key (buf, real_size, 0); + fclose (f); } return 0; From fe4efe0d50482b433b46de677546f796de46d5ae Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:39:08 +0300 Subject: [PATCH 0081/1167] util/mkimage: fix memory leaks. Found by: Coverity scan. --- util/mkimage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/mkimage.c b/util/mkimage.c index e6b799fd7..bccd70388 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1278,6 +1278,8 @@ grub_install_generate_image (const char *dir, const char *prefix, free (core_img); core_img = full_img; core_size = full_size; + free (decompress_img); + free (decompress_path); } switch (image_target->id) @@ -1744,6 +1746,8 @@ grub_install_generate_image (const char *dir, const char *prefix, free (core_img); core_img = rom_img; core_size = rom_size; + free (boot_img); + free (boot_path); } break; case IMAGE_QEMU_MIPS_FLASH: From bd196014ec4eed6b4671cac4f4cb73621b219afa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:44:45 +0300 Subject: [PATCH 0082/1167] util/setup: fix memory leak. Found by: Coverity scan. --- util/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index ed4bd1113..b2991595b 100644 --- a/util/setup.c +++ b/util/setup.c @@ -670,15 +670,17 @@ unable_to_embed: if (dest_dev->disk->id != root_dev->disk->id || dest_dev->disk->dev->id != root_dev->disk->dev->id) { - const char *dest_ofpath; + char *dest_ofpath; dest_ofpath = grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk)); + /* FIXME handle NULL result */ grub_util_info ("dest_ofpath is `%s'", dest_ofpath); strncpy (boot_devpath, dest_ofpath, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END - GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1); boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END - GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0; + free (dest_ofpath); } else { From 4192f2e3d1779b71f53580a59f280af1bfda1f3b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 10:20:54 +0100 Subject: [PATCH 0083/1167] commands/acpi: Use ALIGN_UP rather than manual expression. Improves readability and hopefully automatic scanning. Found by: Coverity Scan. --- grub-core/commands/acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index f66fa2db3..5507ffa08 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -265,7 +265,7 @@ grub_acpi_create_ebda (void) grub_memcpy (target, v2, v2->length); v2inebda = target; target += v2->length; - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v2 = 0; break; } @@ -282,7 +282,7 @@ grub_acpi_create_ebda (void) grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10)); v1inebda = target; target += sizeof (struct grub_acpi_rsdp_v10); - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v1 = 0; break; } From 69a52e95d425502945fe43892cebf6b183290e6e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 10:30:43 +0100 Subject: [PATCH 0084/1167] fs/{cbfs,cpio}: Remove useless check if mode is NULL. Callers already ensure that it's not null. Found by: Coverity Scan. --- grub-core/fs/cbfs.c | 3 +-- grub-core/fs/cpio_common.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 4ddd6832f..a34eb88cb 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -74,8 +74,7 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name, (void) mtime; offset = grub_be_to_cpu32 (hd.offset); - if (mode) - *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; + *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; namesize = offset; if (namesize >= sizeof (hd)) diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index 20230a741..50fea47d1 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -69,8 +69,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, return GRUB_ERR_NONE; } - if (mode) - *mode = modeval; + *mode = modeval; *name = grub_malloc (namesize + 1); if (*name == NULL) From 0daf46fdbd37627411f3a0dd99390ee4523de1bb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:31:35 +0100 Subject: [PATCH 0085/1167] fs/zfs: Fix error handling. Found by: Coverity Scan. --- grub-core/fs/zfs/zfs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c8c7b97a2..9edac5099 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -285,7 +285,7 @@ static const char *spa_feature_names[] = { static int check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx); -static int +static grub_err_t check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); static grub_err_t @@ -1975,7 +1975,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, dn->endian) << SPA_MINBLOCKSHIFT; *buf = grub_malloc (size); - if (*buf) + if (!*buf) { err = grub_errno; break; @@ -3979,7 +3979,12 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx) dnode_end_t dn; grub_memset (&info, 0, sizeof (info)); - dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data); + err = dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data); + if (err) + { + grub_print_error (); + return 0; + } if (dn.dn.dn_bonustype == DMU_OT_SA) { @@ -4200,11 +4205,11 @@ check_feature (const char *name, grub_uint64_t val, * errnum: Failure. */ -static int +static grub_err_t check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) { grub_uint64_t objnum; - grub_uint8_t errnum = 0; + grub_err_t errnum = 0; dnode_end_t dn,mosmdn; mzap_phys_t* mzp; grub_zfs_endian_t endianzap; From 916733ea6ae90c56797d39bb41b72427da3e1e4f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:35:37 +0100 Subject: [PATCH 0086/1167] fs/zfscrypt: Add missing explicit cast. Found by: Coverity scan. --- grub-core/fs/zfs/zfscrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 88dae72ef..91a0af64c 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -238,7 +238,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher, grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize); } for (j = 0; j < 8; j++) - mac[15 - j] ^= ((psize * 8) >> (8 * j)); + mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j)); grub_gcm_mul (mac, h); if (mac_out) From c2fc41990a77923c44a71d616561920ae186db56 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:48:53 +0100 Subject: [PATCH 0087/1167] linux/hostdisk: Limit strcpy size to buffer size. Found by: Coverity scan. --- grub-core/osdep/linux/hostdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index c96427a56..75cb8f55d 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -376,7 +376,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f part_start = grub_partition_get_start (disk->partition); - strcpy (dev, grub_util_biosdisk_get_osdev (disk)); + strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); if (disk->partition && strncmp (dev, "/dev/", 5) == 0) { @@ -439,7 +439,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f if (*max == 0) *max = ~0ULL; is_partition = 0; - strcpy (dev, grub_util_biosdisk_get_osdev (disk)); + strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); goto reopen; } sector -= part_start; From 8f95eae423fc7220af3c1f6150ac35e98281bb96 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:49:49 +0100 Subject: [PATCH 0088/1167] linux/ofpath: Fix error handling. Found by: Coverity Scan. --- grub-core/osdep/linux/ofpath.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 4cc171cb5..f716fd2fc 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -334,7 +334,7 @@ vendor_is_ATA(const char *path) } static void -check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address) +check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) { char *ed = strstr (sysfs_path, "end_device"); char *p, *q, *path; @@ -346,8 +346,10 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address) return; /* SAS devices are identified using disk@$PHY_ID */ - p = strdup (sysfs_path); + p = xstrdup (sysfs_path); ed = strstr(p, "end_device"); + if (!ed) + return; q = ed; while (*q && *q != '/') From 9ee5ae1fae1d7e19f76d4758d9658af90018b0f9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 17:17:58 +0100 Subject: [PATCH 0089/1167] Document intentional fallthroughs. Found by: Coverity scan. --- grub-core/disk/diskfilter.c | 3 +++ grub-core/font/font.c | 3 ++- grub-core/fs/udf.c | 1 + grub-core/lib/legacy_parse.c | 1 + grub-core/loader/i386/pc/linux.c | 3 +++ grub-core/normal/charset.c | 1 + grub-core/video/bochs.c | 1 + grub-core/video/cirrus.c | 1 + grub-core/video/i386/pc/vbe.c | 2 ++ util/getroot.c | 1 + util/grub-install.c | 2 +- 11 files changed, 17 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 612484607..80966ac01 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -71,10 +71,12 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily) case GRUB_DISKFILTER_RAID6: if (!easily) need--; + /* Fallthrough. */ case GRUB_DISKFILTER_RAID4: case GRUB_DISKFILTER_RAID5: if (!easily) need--; + /* Fallthrough. */ case GRUB_DISKFILTER_STRIPED: break; @@ -584,6 +586,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, if (seg->node_count == 1) return grub_diskfilter_read_node (&seg->nodes[0], sector, size, buf); + /* Fallthrough. */ case GRUB_DISKFILTER_MIRROR: case GRUB_DISKFILTER_RAID10: { diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 607964b90..53d76a64d 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -1286,7 +1286,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - grub_font_get_xheight (combining_glyphs[i]->font) - 1; if (space <= 0) space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; - + /* Fallthrough. */ case GRUB_UNICODE_STACK_ATTACHED_ABOVE: do_blit (combining_glyphs[i], targetx, -(ctx.bounds.height + ctx.bounds.y + space @@ -1327,6 +1327,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, + combining_glyphs[i]->height); if (space <= 0) space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; + /* Fallthrough. */ case GRUB_UNICODE_STACK_ATTACHED_BELOW: do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space), diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index fd412830c..839bff889 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -986,6 +986,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) case 1: if (ptr[1]) goto fail; + /* Fallthrough. */ case 2: /* in 4 bytes. out: 1 byte. */ optr = out; diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index 61266d95a..ef56150ac 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -664,6 +664,7 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix) { case TYPE_FILE_NO_CONSUME: hold_arg = 1; + /* Fallthrough. */ case TYPE_PARTITION: case TYPE_FILE: args[i] = adjust_file (curarg, curarglen); diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 870992b7d..a293b17aa 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -280,10 +280,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { case 'g': shift += 10; + /* Fallthrough. */ case 'm': shift += 10; + /* Fallthrough. */ case 'k': shift += 10; + /* Fallthrough. */ default: break; } diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c index 3e4c337da..eeb7ec18c 100644 --- a/grub-core/normal/charset.c +++ b/grub-core/normal/charset.c @@ -929,6 +929,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, case GRUB_BIDI_TYPE_R: case GRUB_BIDI_TYPE_AL: bidi_needed = 1; + /* Fallthrough. */ default: { if (join_state == JOIN_FORCE) diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c index 9098f90d1..3bcfa53a9 100644 --- a/grub-core/video/bochs.c +++ b/grub-core/video/bochs.c @@ -359,6 +359,7 @@ grub_video_bochs_setup (unsigned int width, unsigned int height, case 32: framebuffer.mode_info.reserved_mask_size = 8; framebuffer.mode_info.reserved_field_pos = 24; + /* Fallthrough. */ case 24: framebuffer.mode_info.red_mask_size = 8; diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c index 4913084fa..e2149e8ce 100644 --- a/grub-core/video/cirrus.c +++ b/grub-core/video/cirrus.c @@ -440,6 +440,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height, case 32: framebuffer.mode_info.reserved_mask_size = 8; framebuffer.mode_info.reserved_field_pos = 24; + /* Fallthrough. */ case 24: framebuffer.mode_info.red_mask_size = 8; diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 07a614a20..b7f911926 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -874,6 +874,7 @@ vbe2videoinfo (grub_uint32_t mode, /* CGA is basically 4-bit packed pixel. */ case GRUB_VBE_MEMORY_MODEL_CGA: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_CGA; + /* Fallthrough. */ case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; break; @@ -886,6 +887,7 @@ vbe2videoinfo (grub_uint32_t mode, /* Non chain 4 is a special case of planar. */ case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_NONCHAIN4; + /* Fallthrough. */ case GRUB_VBE_MEMORY_MODEL_PLANAR: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; diff --git a/util/getroot.c b/util/getroot.c index 345d49ba8..3c1f12dca 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -107,6 +107,7 @@ grub_util_pull_device (const char *os_dev) default: if (grub_util_pull_device_os (os_dev, ab)) return; + /* Fallthrough. */ case GRUB_DEV_ABSTRACTION_NONE: free (grub_util_biosdisk_get_grub_dev (os_dev)); return; diff --git a/util/grub-install.c b/util/grub-install.c index 210f4a7e3..cedc18809 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1809,7 +1809,7 @@ main (int argc, char *argv[]) grub_install_copy_file (imgfile, dst, 1); free (dst); } - + /* Fallthrough. */ case GRUB_INSTALL_PLATFORM_X86_64_EFI: if (efidir_is_mac) { From 7ba137f6286dcd17a1104f1dfc6eb1f58c5ef743 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:00:23 +0300 Subject: [PATCH 0090/1167] linux/hostdisk: use strncpy instead of strlcpy strlcpy is not available on Linux as part of standard libraries. It probably is not worth extra configure checks espicially as we need to handle missing function anyway. --- grub-core/osdep/linux/hostdisk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 75cb8f55d..06179fca7 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -376,7 +376,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f part_start = grub_partition_get_start (disk->partition); - strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); + strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1); + dev[sizeof(dev) - 1] = '\0'; if (disk->partition && strncmp (dev, "/dev/", 5) == 0) { @@ -439,7 +440,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f if (*max == 0) *max = ~0ULL; is_partition = 0; - strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); + strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1); + dev[sizeof(dev) - 1] = '\0'; goto reopen; } sector -= part_start; From 637fc62699e7ae3f0057e1c56d330eb193fd40b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:29:00 +0300 Subject: [PATCH 0091/1167] linux/ofpath: fix descriptor leak Found by: Coverity scan --- grub-core/osdep/linux/ofpath.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index f716fd2fc..05b1ecdf8 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -122,6 +122,8 @@ find_obppath (const char *sysfs_path_orig) fd = open(path, O_RDONLY); if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); snprintf(path, path_size, "%s/devspec", sysfs_path); fd = open(path, O_RDONLY); } From e871994849802889af1ad26ddde68e9a12466ba1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:52:27 +0300 Subject: [PATCH 0092/1167] fs/zfs/zfs.c: fix memory leak. Found by: Coverity scan. --- grub-core/fs/zfs/zfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 9edac5099..057b471e1 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2835,6 +2835,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, if (!path_buf) { grub_free (oldpathbuf); + if (free_symval) + grub_free (sym_value); return grub_errno; } grub_memcpy (path, sym_value, sym_sz); From 3db4f05a10e98a4835ddd87f9d1ef9185e8eef84 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:55:25 +0300 Subject: [PATCH 0093/1167] commands/parttool: fix memory leak. Found by: Coverity scan. --- grub-core/commands/parttool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index d907694dd..42c590e1a 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -282,8 +282,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), break; } if (! cur) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), args[i]); + } ptool = cur; pargs = (struct grub_parttool_args *) grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args)); From fa13e605270f46dc78cbfded62e4cc58a31dff50 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:12:19 +0300 Subject: [PATCH 0094/1167] fs/zfs/zfscrypt.c: fix memory leaks. Found by: Coverity scan. --- grub-core/fs/zfs/zfscrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 91a0af64c..834f858a0 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, if (err) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, if (err) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_dprintf ("zfs", "key loading failed\n"); grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -381,12 +384,14 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_dprintf ("zfs", "key loading failed\n"); grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } ret = grub_crypto_cipher_open (GRUB_CIPHER_AES); if (!ret) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } err = grub_crypto_cipher_set_key (ret, decrypted, keylen); @@ -394,8 +399,10 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_errno = GRUB_ERR_NONE; grub_crypto_cipher_close (ret); + grub_crypto_cipher_close (cipher); continue; } + grub_crypto_cipher_close (cipher); return ret; } return NULL; From 3900726fa8a794869c42a0a33fbd96b5cd4ba14f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:13:10 +0300 Subject: [PATCH 0095/1167] fs/zfs/zfscrypt.c: fix indentation. --- grub-core/fs/zfs/zfscrypt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 834f858a0..87eef621d 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -397,11 +397,11 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, err = grub_crypto_cipher_set_key (ret, decrypted, keylen); if (err) { - grub_errno = GRUB_ERR_NONE; - grub_crypto_cipher_close (ret); - grub_crypto_cipher_close (cipher); - continue; - } + grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (ret); + grub_crypto_cipher_close (cipher); + continue; + } grub_crypto_cipher_close (cipher); return ret; } From edc94e4b0bd026bf08861a4f4010a36bec0775cd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:19:28 +0300 Subject: [PATCH 0096/1167] fs/hfsplus: fix memory leak. Found by: Coverity scan. --- grub-core/fs/hfsplus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 950d8a1e1..8f07f8544 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -723,7 +723,10 @@ list_nodes (void *record, void *hook_arg) /* If the name is obviously invalid, skip this node. */ if (catkey->name[i] == 0) - return 0; + { + grub_free (filename); + return 0; + } } *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, @@ -745,7 +748,10 @@ list_nodes (void *record, void *hook_arg) callback function. */ node = grub_malloc (sizeof (*node)); if (!node) - return 1; + { + grub_free (filename); + return 1; + } node->data = ctx->dir->data; node->compressed = 0; node->cbuf = 0; From 11aae26cc374d01c9bf4fa33f792bff16b444ef5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:29:55 +0300 Subject: [PATCH 0097/1167] util/grub-probe: fix memory leaks. Found by: Coverity scan. --- util/grub-probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index ecb7b6bbd..8a0c4f35b 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -295,6 +295,7 @@ probe (const char *path, char **device_names, char delim) } printf ("%s", disk); putchar (delim); + free (disk); } return; } @@ -496,6 +497,7 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev); putchar (delim); + grub_device_close (dev); continue; } @@ -542,7 +544,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_IEEE1275_HINT) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); - const char *ofpath = grub_util_devname_to_ofpath (osdev); + char *ofpath = grub_util_devname_to_ofpath (osdev); const char *map; map = grub_util_biosdisk_get_compatibility_hint (dev->disk); @@ -560,6 +562,7 @@ probe (const char *path, char **device_names, char delim) strcpy (p, ofpath); grub_util_fprint_full_disk_name (stdout, tmp, dev); free (tmp); + free (ofpath); putchar (delim); } From fbb4aa1c050162bef5478b5441abeeaefb4d94f2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:49:45 +0300 Subject: [PATCH 0098/1167] loader/xnu: fix memory leak. Foound by: Coverity scan. --- grub-core/loader/xnu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index bc89cdf6c..c9885b1bc 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -689,10 +689,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, /* Allocate the space. */ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE); if (err) - return err; + goto fail; err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target); if (err) - return err; + goto fail; buf = buf0; exthead = (struct grub_xnu_extheader *) buf; @@ -709,10 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, else err = grub_macho_readfile32 (macho, filename, buf); if (err) - { - grub_macho_close (macho); - return err; - } + goto fail; grub_macho_close (macho); buf += machosize; } @@ -747,6 +744,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, /* Announce to kernel */ return grub_xnu_register_memory ("Driver-", &driversnum, buf_target, neededspace); +fail: + if (macho) + grub_macho_close (macho); + return err; } /* Load mkext. */ From 1a4e47879c55390bd80e6f06bee68317b4f16cfa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 22:34:50 +0300 Subject: [PATCH 0099/1167] Change quotes to match overall style in NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 55f09d6d7..e417ebad1 100644 --- a/NEWS +++ b/NEWS @@ -85,7 +85,7 @@ New in 2.02: * Support for USB debug dongles. * Support for *-emu on all platforms (previously only i386/x86_64 worked). * Support *-emu on Windows. - * New platform "none" which builds only user level utilities. This is now + * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. * Security: From 2efab86d5a45da41adbe20ac59cc4d5b946de61e Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 28 Jan 2015 20:09:25 +0300 Subject: [PATCH 0100/1167] syslinux_parse: fix memory leak. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index f6053267f..2c874b1fa 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -922,6 +922,8 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } + if (ptr && *ptr) + grub_free (cmdline); } break; case KERNEL_CHAINLOADER: From 9883307a527a0d0e39fe9d500c22ef3eccda83ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 28 Jan 2015 20:35:28 +0300 Subject: [PATCH 0101/1167] script/execute.c: fix memory leak. Make sure to continue loop over array after failure to free allocated strings. Found by: Coverity scan. --- grub-core/script/execute.c | 112 ++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index afd551320..bb70ebf17 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -635,57 +635,77 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, { case GRUB_SCRIPT_ARG_TYPE_VAR: case GRUB_SCRIPT_ARG_TYPE_DQVAR: - values = grub_script_env_get (arg->str, arg->type); - for (i = 0; values && values[i]; i++) - { - if (i != 0 && grub_script_argv_next (&result)) - goto fail; + { + int need_cleanup = 0; - if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR) - { - int len; - char ch; - char *p; - char *op; - const char *s = values[i]; + values = grub_script_env_get (arg->str, arg->type); + for (i = 0; values && values[i]; i++) + { + if (!need_cleanup) + { + if (i != 0 && grub_script_argv_next (&result)) + { + need_cleanup = 1; + goto cleanup; + } - len = grub_strlen (values[i]); - /* \? -> \\\? */ - /* \* -> \\\* */ - /* \ -> \\ */ - p = grub_malloc (len * 2 + 1); - if (! p) - goto fail; + if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR) + { + int len; + char ch; + char *p; + char *op; + const char *s = values[i]; - op = p; - while ((ch = *s++)) - { - if (ch == '\\') - { - *op++ = '\\'; - if (*s == '?' || *s == '*') - *op++ = '\\'; - } - *op++ = ch; - } - *op = '\0'; + len = grub_strlen (values[i]); + /* \? -> \\\? */ + /* \* -> \\\* */ + /* \ -> \\ */ + p = grub_malloc (len * 2 + 1); + if (! p) + { + need_cleanup = 1; + goto cleanup; + } - if (grub_script_argv_append (&result, p, op - p)) - { - grub_free (p); - goto fail; - } - } - else - { - if (append (&result, values[i], 1)) - goto fail; - } + op = p; + while ((ch = *s++)) + { + if (ch == '\\') + { + *op++ = '\\'; + if (*s == '?' || *s == '*') + *op++ = '\\'; + } + *op++ = ch; + } + *op = '\0'; - grub_free (values[i]); - } - grub_free (values); - break; + if (grub_script_argv_append (&result, p, op - p)) + { + grub_free (p); + need_cleanup = 1; + /* Fall through to cleanup */ + } + } + else + { + if (append (&result, values[i], 1)) + need_cleanup = 1; + /* Fall through to cleanup */ + } + } + +cleanup: + grub_free (values[i]); + } + grub_free (values); + + if (need_cleanup) + goto fail; + + break; + } case GRUB_SCRIPT_ARG_TYPE_BLOCK: { From 2da4171eabfe0d1b9b1be6146f628099d08aac02 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 28 Jan 2015 20:17:18 +0000 Subject: [PATCH 0102/1167] configure.ac: don't use -msoft-float for arm64 aarch64 toolchains do not support the -msoft-float option added by commit 3661261f. Insted, for arm64 use -march=armv8-a+nofp+nosimd. Reported-by: Ryan Harkin --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a3bca06ca..6d31ed01b 100644 --- a/configure.ac +++ b/configure.ac @@ -678,7 +678,11 @@ fi # that floats are a good fit to run instead of what's written in the code. # Given that floating point unit is disabled (if present to begin with) # when GRUB is running which may result in various hard crashes. -TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" +if test "x$target_cpu" = xarm64; then + TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" +else + TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" +fi # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need From d29259b134257458a98c1ddc05d2a36c677ded37 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:10:43 +0300 Subject: [PATCH 0103/1167] test: do not stop after first file test or closing bracket Closes: 44115 --- grub-core/commands/test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index c98c13d8c..f58b87c64 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc) get_fileinfo (args[*argn + 1], &ctx); update_val (ctx.file_exists && ctx.file_info.dir, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-e") == 0) @@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc) get_fileinfo (args[*argn + 1], &ctx); update_val (ctx.file_exists, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-f") == 0) @@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc) /* FIXME: check for other types. */ update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-s") == 0) @@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc) grub_file_close (file); grub_errno = GRUB_ERR_NONE; (*argn) += 2; - return ctx.or || ctx.and; + continue; } /* String tests. */ @@ -387,7 +387,7 @@ test_parse (char **args, int *argn, int argc) if (grub_strcmp (args[*argn], ")") == 0) { (*argn)++; - return ctx.or || ctx.and; + continue; } /* Recursively invoke if parenthesis. */ if (grub_strcmp (args[*argn], "(") == 0) From 958167b91cdebe55c6cccdd28ad007c554df56d7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:21:56 +0300 Subject: [PATCH 0104/1167] test: fix previous commit - we need to return from subexpression ( ... ) was processed recursively, we need to return from it. Revert this change. --- grub-core/commands/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index f58b87c64..5f06642f6 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -387,7 +387,7 @@ test_parse (char **args, int *argn, int argc) if (grub_strcmp (args[*argn], ")") == 0) { (*argn)++; - continue; + return ctx.or || ctx.and; } /* Recursively invoke if parenthesis. */ if (grub_strcmp (args[*argn], "(") == 0) From f153fcb5a5863d7ce190cfc531b7dff1000316a0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:31:20 +0300 Subject: [PATCH 0105/1167] test: consistently use TMPDIR and same name pattern for temp files --- tests/test_sha512sum.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in index 524c1d1c0..d5ef7f9ea 100644 --- a/tests/test_sha512sum.in +++ b/tests/test_sha512sum.in @@ -1,7 +1,7 @@ #! /bin/bash # create a randome file -file=`mktemp` +file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 cat >$file <$outfile1 <$outfile2 SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ ` From 1e047e53aeb684a3a21a4269a99c708c381b96b5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 21:42:46 +0300 Subject: [PATCH 0106/1167] tests: add test command file tests This requires access to files in both host and grub image, so implementing as separate test unit instead of script test was more easy. --- Makefile.util.def | 6 ++++ tests/grub_cmd_test.in | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/grub_cmd_test.in diff --git a/Makefile.util.def b/Makefile.util.def index fed96d864..378b5777a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1156,6 +1156,12 @@ script = { common = tests/file_filter_test.in; }; +script = { + testcase; + name = grub_cmd_test; + common = tests/grub_cmd_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in new file mode 100644 index 000000000..6269891c9 --- /dev/null +++ b/tests/grub_cmd_test.in @@ -0,0 +1,67 @@ +#! /bin/bash + +# create a randome file +empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 +non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 +cat >$non_empty <$outfile < /dev/null 2>&1; then + echo "GRUB test command file tests failed." + cat "$outfile" + exit 1 +else + rm -f "${outfile}" + exit 0 +fi From b40fde29a446d9fa5a6ebea7aafb34e3c958afbb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:09:51 +0300 Subject: [PATCH 0107/1167] net/ip: check result of grub_netbuff_push Found by: Coverity scan. --- grub-core/net/ip.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index 5a6095444..8c56baaf7 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -191,15 +191,18 @@ grub_net_send_ip4_packet (struct grub_net_network_level_interface *inf, grub_net_ip_protocol_t proto) { struct iphdr *iph; + grub_err_t err; COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV4_HEADER_SIZE == sizeof (*iph)); if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu) return send_fragmented (inf, target, nb, proto, *ll_target_addr); - grub_netbuff_push (nb, sizeof (*iph)); - iph = (struct iphdr *) nb->data; + err = grub_netbuff_push (nb, sizeof (*iph)); + if (err) + return err; + iph = (struct iphdr *) nb->data; iph->verhdrlen = ((4 << 4) | 5); iph->service = 0; iph->len = grub_cpu_to_be16 (nb->tail - nb->data); @@ -602,15 +605,18 @@ grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf, grub_net_ip_protocol_t proto) { struct ip6hdr *iph; + grub_err_t err; COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV6_HEADER_SIZE == sizeof (*iph)); if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu) return grub_error (GRUB_ERR_NET_PACKET_TOO_BIG, "packet too big"); - grub_netbuff_push (nb, sizeof (*iph)); - iph = (struct ip6hdr *) nb->data; + err = grub_netbuff_push (nb, sizeof (*iph)); + if (err) + return err; + iph = (struct ip6hdr *) nb->data; iph->version_class_flow = grub_cpu_to_be32_compile_time ((6 << 28)); iph->len = grub_cpu_to_be16 (nb->tail - nb->data - sizeof (*iph)); iph->protocol = proto; From 7aaed66455cc172bd9a3db1893925aa156ba2e14 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:26:05 +0300 Subject: [PATCH 0108/1167] grub-mkimage: fix potential NULL pointer dereference Move fatal check whether symtab_section is NULL before first reference. Found by: Coverity scan. --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0a1ac9e51..3c76d0708 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1539,6 +1539,8 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, symtab_section = s; break; } + if (! symtab_section) + grub_util_error ("%s", _("no symbol table")); #ifdef MKIMAGE_ELF32 if (image_target->elf_target == EM_ARM) @@ -1577,8 +1579,6 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, } #endif - if (! symtab_section) - grub_util_error ("%s", _("no symbol table")); } else { From 12abe75aa03695dfa5f6963013a5eb20f656224d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:39:11 +0300 Subject: [PATCH 0109/1167] net/pxe: fix error condition Test return value of grub_netbuff_reserve(), buf itself cannot be NULL here. Found by: Coverity scan. --- grub-core/net/drivers/i386/pc/pxe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c index e8c0b22e2..3f4152d03 100644 --- a/grub-core/net/drivers/i386/pc/pxe.c +++ b/grub-core/net/drivers/i386/pc/pxe.c @@ -218,8 +218,7 @@ grub_pxe_recv (struct grub_net_card *dev __attribute__ ((unused))) return NULL; /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible by 4. So that IP header is aligned on 4 bytes. */ - grub_netbuff_reserve (buf, 2); - if (!buf) + if (grub_netbuff_reserve (buf, 2)) { grub_netbuff_free (buf); return NULL; From 151c19a42a8ea76395fdb579221198156da9c026 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:45:58 +0300 Subject: [PATCH 0110/1167] grub-fstest: fix descriptor leak Found by: Coverity scan. --- util/grub-fstest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 31af2a7ad..02cd3e3e2 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -570,12 +570,12 @@ argp_parser (int key, char *arg, struct argp_state *state) return 0; } real_size = fread (buf, 1, 1024, f); + fclose (f); if (real_size < 0) { printf (_("%s: error:"), program_name); printf (_("cannot read `%s': %s"), arg, strerror (errno)); printf ("\n"); - fclose (f); return 0; } grub_zfs_add_key (buf, real_size, 0); From 016875dd52456c38c8dee55a8390c0f9fc092afe Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:57:39 +0300 Subject: [PATCH 0111/1167] setup: fix blocklist size calculation Found by: Coverity scan. --- util/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index b2991595b..8f20e9983 100644 --- a/util/setup.c +++ b/util/setup.c @@ -529,7 +529,7 @@ SETUP (const char *dir, bl.block = bl.first_block; while (bl.block->len) { - grub_memset (bl.block, 0, sizeof (bl.block)); + grub_memset (bl.block, 0, sizeof (*bl.block)); bl.block--; From c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 3 Feb 2015 21:16:36 +0000 Subject: [PATCH 0112/1167] arm: implement additional relocations generated by gcc 4.9 at -O3 GCC 4.9 also generates R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS, as an alternative to ABS32. Signed-off-by: Leif Lindholm --- grub-core/kern/arm/dl.c | 15 +++++++++++++ grub-core/kern/arm/dl_helper.c | 39 ++++++++++++++++++++++++++++++++++ include/grub/arm/reloc.h | 5 +++++ 3 files changed, 59 insertions(+) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index 57cac2e75..5cbd65e46 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -205,6 +205,21 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, */ case R_ARM_V4BX: break; + case R_ARM_THM_MOVW_ABS_NC: + case R_ARM_THM_MOVT_ABS: + { + grub_uint32_t offset; + offset = grub_arm_thm_movw_movt_get_value((grub_uint16_t *) target); + offset += sym_addr; + + if (ELF_R_TYPE (rel->r_info) == R_ARM_THM_MOVT_ABS) + offset >>= 16; + else + offset &= 0xffff; + + grub_arm_thm_movw_movt_set_value((grub_uint16_t *) target, offset); + } + break; case R_ARM_THM_JUMP19: { /* Thumb instructions can be 16-bit aligned */ diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c index 5721939c1..8a7263291 100644 --- a/grub-core/kern/arm/dl_helper.c +++ b/grub-core/kern/arm/dl_helper.c @@ -25,6 +25,20 @@ #include #include +static inline grub_uint32_t +thumb_get_instruction_word(grub_uint16_t *target) +{ + /* Extract instruction word in alignment-safe manner */ + return grub_le_to_cpu16 ((*target)) << 16 | grub_le_to_cpu16 (*(target + 1)); +} + +static inline void +thumb_set_instruction_word(grub_uint16_t *target, grub_uint32_t insword) +{ + *target = grub_cpu_to_le16 (insword >> 16); + *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); +} + /* * R_ARM_ABS32 * @@ -214,3 +228,28 @@ grub_arm_jump24_set_offset (grub_uint32_t *target, *target = grub_cpu_to_le32 (insword); } + +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + + return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ + ((insword & 0x7000) >> 4) | (insword & 0xff); +} + +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + insword &= 0xfbf08f00; + + insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ + ((value & 0x0700) << 4) | (value & 0xff); + + thumb_set_instruction_word (target, insword); +} diff --git a/include/grub/arm/reloc.h b/include/grub/arm/reloc.h index b938037a0..ae92e21f1 100644 --- a/include/grub/arm/reloc.h +++ b/include/grub/arm/reloc.h @@ -43,4 +43,9 @@ void grub_arm_jump24_set_offset (grub_uint32_t *target, grub_int32_t offset); +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target); +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value); + #endif From 32cd33bd19348afb77ab849846e0b6d6157ea308 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 12 Feb 2015 11:02:09 +0100 Subject: [PATCH 0113/1167] util: mkimage, fix gcc5 build failure gcc5 reports: ../util/mkimage.c: In function 'grub_install_get_image_target': ../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations] && j < ARRAY_SIZE (image_targets[i].names); j++) ^ ../util/mkimage.c:953:39: note: possible undefined statement is here for (j = 0; image_targets[i].names[j] ^ Well, let's move the index 'j' test before accesing the array to: 1) make the loop obvious 2) make gcc happy Signed-off-by: Jiri Slaby --- util/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index bccd70388..7821dc5ea 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -937,8 +937,8 @@ grub_install_get_image_target (const char *arg) { unsigned i, j; for (i = 0; i < ARRAY_SIZE (image_targets); i++) - for (j = 0; image_targets[i].names[j] - && j < ARRAY_SIZE (image_targets[i].names); j++) + for (j = 0; j < ARRAY_SIZE (image_targets[i].names) && + image_targets[i].names[j]; j++) if (strcmp (arg, image_targets[i].names[j]) == 0) return &image_targets[i]; return NULL; From e27fdbd6866a3dc9c6ee4d777d89c861f04368e7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 14 Feb 2015 17:55:35 +0300 Subject: [PATCH 0114/1167] diskfilter: fix crash in validate_lv for mdraid arrays Commit 750f4bacd3262376ced3f837d8dc78f834ca233a put LV validation before actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as happens in other cases for consistency. Also clean up redundant code and add explicit NULL lv->vg check in validate_lv. Also fix segment validation in validate_lv; it became obvious when crash was fixed. Closes: 44199 --- grub-core/disk/diskfilter.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 80966ac01..ad558fa14 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -496,13 +496,13 @@ validate_lv (struct grub_diskfilter_lv *lv) if (!lv) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume"); - if (lv->vg->extent_size == 0) + if (!lv->vg || lv->vg->extent_size == 0) return grub_error (GRUB_ERR_READ_ERROR, "invalid volume"); for (i = 0; i < lv->segment_count; i++) { grub_err_t err; - err = validate_segment (&lv->segments[1]); + err = validate_segment (&lv->segments[i]); if (err) return err; } @@ -941,8 +941,10 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) for (lv = vg->lvs; lv; lv = lv->next) { - /* RAID 1 and single-disk RAID 0 don't use a chunksize but code assumes one so set - one. */ + grub_err_t err; + + /* RAID 1 and single-disk RAID 0 don't use a chunksize but code + assumes one so set one. */ for (i = 0; i < lv->segment_count; i++) { if (lv->segments[i].type == 1) @@ -952,17 +954,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) && lv->segments[i].stripe_size == 0) lv->segments[i].stripe_size = 64; } - } - - for (lv = vg->lvs; lv; lv = lv->next) - { - grub_err_t err; - - /* RAID 1 doesn't use a chunksize but code assumes one so set - one. */ - for (i = 0; i < lv->segment_count; i++) - if (lv->segments[i].type == 1) - lv->segments[i].stripe_size = 64; err = validate_lv(lv); if (err) @@ -1007,7 +998,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) lv->fullname = tmp; } } - lv->vg = vg; } /* Add our new array to the list. */ vg->next = array_list; @@ -1101,6 +1091,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, array->lvs->visible = 1; array->lvs->name = array->name; array->lvs->fullname = array->name; + array->lvs->vg = array; array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen); if (!array->lvs->idname) From fc535b32b9fe0cd84213724ffba43b98e2da6ab4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 14 Feb 2015 19:08:58 +0300 Subject: [PATCH 0115/1167] diskfilter: fix double free of lv names for mdraid Avoid micro-optimization in grub_diskfilter_make_raid and make sure name and fullname are independent strings. This avoids need to special case it everywhere else. Also fix memory leak in failure case in grub_diskfilter_make_raid. Closes: 41582 --- grub-core/disk/diskfilter.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index ad558fa14..1b7464d74 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1089,8 +1089,15 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, goto fail; array->lvs->segment_count = 1; array->lvs->visible = 1; - array->lvs->name = array->name; - array->lvs->fullname = array->name; + if (array->name) + { + array->lvs->name = grub_strdup (array->name); + if (!array->lvs->name) + goto fail; + array->lvs->fullname = grub_strdup (array->name); + if (!array->lvs->fullname) + goto fail; + } array->lvs->vg = array; array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen); @@ -1141,7 +1148,18 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, return array; fail: - grub_free (array->lvs); + if (array->lvs) + { + grub_free (array->lvs->name); + grub_free (array->lvs->fullname); + grub_free (array->lvs->idname); + if (array->lvs->segments) + { + grub_free (array->lvs->segments->nodes); + grub_free (array->lvs->segments); + } + grub_free (array->lvs); + } while (array->pvs) { pv = array->pvs->next; @@ -1250,10 +1268,9 @@ free_array (void) { unsigned i; vg->lvs = lv->next; - if (lv->name != lv->fullname) - grub_free (lv->fullname); - if (lv->name != vg->name) - grub_free (lv->name); + grub_free (lv->fullname); + grub_free (lv->name); + grub_free (lv->idname); for (i = 0; i < lv->segment_count; i++) grub_free (lv->segments[i].nodes); grub_free (lv->segments); From 8e5bc2f4d3767485e729ed96ea943570d1cb1e45 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 30 Jan 2015 18:59:24 +0100 Subject: [PATCH 0116/1167] multiboot2: Fix information request tag size calculation Signed-off-by: Daniel Kiper --- grub-core/loader/multiboot_mbi2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 6f74aeef7..d7c19bc99 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) = (struct multiboot_header_tag_information_request *) tag; if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL) break; - for (i = 0; i < (request_tag->size - sizeof (request_tag)) + for (i = 0; i < (request_tag->size - sizeof (*request_tag)) / sizeof (request_tag->requests[0]); i++) switch (request_tag->requests[i]) { From 2ae9457e6eb4c352051fb32bc6fc931a22528ab2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 14 Feb 2015 20:31:00 +0100 Subject: [PATCH 0117/1167] disk/lvm: Use zalloc to ensure that segments are initialised to sane value. Reported by: EmanueL Czirai. --- grub-core/disk/lvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 862a9664f..1e7f197f0 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -426,7 +426,7 @@ grub_lvm_detect (grub_disk_t disk, #endif goto lvs_fail; } - lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count); + lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count); seg = lv->segments; for (i = 0; i < lv->segment_count; i++) From 8f5ebb1245446f8e26c64cf0ebbb514dfb1a8d57 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 15 Feb 2015 10:10:03 +0300 Subject: [PATCH 0118/1167] diskfilter_make_raid: more memory leaks in failure path --- grub-core/disk/diskfilter.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 1b7464d74..c4f6678b6 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1031,7 +1031,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, if (n == 1) n = (layout >> 8) & 0xFF; if (n == 0) - return NULL; + { + grub_free (uuid); + return NULL; + } totsize = grub_divmod64 (nmemb * disk_size, n, 0); } @@ -1045,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, break; default: + grub_free (uuid); return NULL; } @@ -1067,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, } array = grub_zalloc (sizeof (*array)); if (!array) - return NULL; + { + grub_free (uuid); + return NULL; + } array->uuid = uuid; array->uuid_len = uuidlen; if (name) @@ -1166,6 +1173,8 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, grub_free (array->pvs); array->pvs = pv; } + grub_free (array->name); + grub_free (array->uuid); grub_free (array); return NULL; } From b23635fcff62b68b6d5bfde541350095d743a13a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 10:54:20 +0100 Subject: [PATCH 0119/1167] syslinux_parse: Always output comments even if no entries are found. --- grub-core/lib/syslinux_parse.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 2c874b1fa..46eff1e5d 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -1430,6 +1430,13 @@ config_file (struct output_buffer *outbuf, print_string ("\n"); } + if (menu.comments) + { + err = print (outbuf, menu.comments, grub_strlen (menu.comments)); + if (err) + return err; + } + if (menu.timeout == 0 && menu.entries && menu.def) { err = print_entry (outbuf, &menu, menu.def); @@ -1446,12 +1453,6 @@ config_file (struct output_buffer *outbuf, if (err) return err; print_string ("\n"); - if (menu.comments) - { - err = print (outbuf, menu.comments, grub_strlen (menu.comments)); - if (err) - return err; - } if (menu.def) { From e29af836d02a267d6ad9bd6eba808d5bf0a96949 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 15:56:26 +0100 Subject: [PATCH 0120/1167] Don't remove initrd= parameter. Based on simplified patch by Lunar. Reported by: Lunar --- grub-core/lib/syslinux_parse.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 46eff1e5d..afc12b502 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -869,7 +869,6 @@ write_entry (struct output_buffer *outbuf, case KERNEL_LINUX: { char *ptr; - char *cmdline; char *initrd = NULL; for (ptr = curentry->append; ptr && *ptr; ptr++) if ((ptr == curentry->append || grub_isspace (ptr[-1])) @@ -879,31 +878,19 @@ write_entry (struct output_buffer *outbuf, if (ptr && *ptr) { char *ptr2; - grub_size_t totlen = grub_strlen (curentry->append); - initrd = ptr + sizeof ("initrd=") - 1; - for (ptr2 = ptr; *ptr2 && !grub_isspace (*ptr2); ptr2++); - if (*ptr2) - { - *ptr2 = 0; - ptr2++; - } - cmdline = grub_malloc (totlen + 1 - (ptr2 - ptr)); - if (!cmdline) + initrd = grub_strdup(ptr + sizeof ("initrd=") - 1); + if (!initrd) return grub_errno; - grub_memcpy (cmdline, curentry->append, ptr - curentry->append); - grub_memcpy (cmdline + (ptr - curentry->append), - ptr2, totlen - (ptr2 - curentry->append)); - *(cmdline + totlen - (ptr2 - ptr)) = 0; + for (ptr2 = initrd; *ptr2 && !grub_isspace (*ptr2); ptr2++); + *ptr2 = 0; } - else - cmdline = curentry->append; print_string (" if test x$grub_platform = xpc; then " "linux_suffix=16; else linux_suffix= ; fi\n"); print_string (" linux$linux_suffix "); print_file (outbuf, menu, curentry->kernel_file, NULL); print_string (" "); - if (cmdline) - print (outbuf, cmdline, grub_strlen (cmdline)); + if (curentry->append) + print (outbuf, curentry->append, grub_strlen (curentry->append)); print_string ("\n"); if (initrd || curentry->initrds) { @@ -922,8 +909,7 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } - if (ptr && *ptr) - grub_free (cmdline); + grub_free (initrd); } break; case KERNEL_CHAINLOADER: From d3d2e549119477d92b506477fd923c51162b9beb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 15:58:59 +0100 Subject: [PATCH 0121/1167] Add test for syslinux converter --- Makefile.util.def | 6 + tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg | 0 .../syslinux/ubuntu10.04/isolinux/dtmenu.cfg | 52 ++++ .../ubuntu10.04/isolinux/exithelp.cfg | 3 + .../syslinux/ubuntu10.04/isolinux/gfxboot.cfg | 12 + .../ubuntu10.04/isolinux/isolinux.cfg | 6 + tests/syslinux/ubuntu10.04/isolinux/menu.cfg | 23 ++ tests/syslinux/ubuntu10.04/isolinux/po4a.cfg | 3 + .../syslinux/ubuntu10.04/isolinux/prompt.cfg | 16 ++ tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg | 4 + .../syslinux/ubuntu10.04/isolinux/stdmenu.cfg | 15 ++ tests/syslinux/ubuntu10.04/isolinux/txt.cfg | 19 ++ tests/syslinux/ubuntu10.04_grub.cfg | 236 ++++++++++++++++++ tests/syslinux_test.in | 16 ++ 14 files changed, 411 insertions(+) create mode 100644 tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/menu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/po4a.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/prompt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/txt.cfg create mode 100644 tests/syslinux/ubuntu10.04_grub.cfg create mode 100644 tests/syslinux_test.in diff --git a/Makefile.util.def b/Makefile.util.def index 378b5777a..67dfb2976 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1162,6 +1162,12 @@ script = { common = tests/grub_cmd_test.in; }; +script = { + testcase; + name = syslinux_test; + common = tests/syslinux_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg b/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg new file mode 100644 index 000000000..2e107fade --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg @@ -0,0 +1,52 @@ +menu hshift 9 +menu width 58 + +menu begin desktop + include stdmenu.cfg + menu hshift 13 + menu width 49 + menu label Alternative desktop environments + menu title Desktop environment menu + label mainmenu-kde + menu label ^Back.. + text help + Higher level options install the GNOME desktop environment + endtext + menu exit + menu begin kde-desktop + include stdmenu.cfg + menu label ^KDE + menu title KDE desktop boot menu + text help + Select the 'K Desktop Environment' for the Desktop task + endtext + label mainmenu-kde + menu label ^Back.. + menu exit + include kde/menu.cfg + menu end + menu begin lxde-desktop + include stdmenu.cfg + menu label ^LXDE + menu title LXDE desktop boot menu + text help + Select the 'Lightweight X11 Desktop Environment' for the Desktop task + endtext + label mainmenu-lxde + menu label ^Back.. + menu exit + include lxde/menu.cfg + menu end + menu begin xfce-desktop + include stdmenu.cfg + menu label ^Xfce + menu title Xfce desktop boot menu + text help + Select the 'Xfce lightweight desktop environment' for the Desktop task + endtext + label mainmenu-xfce + menu label ^Back.. + menu exit + include xfce/menu.cfg + menu end +menu end diff --git a/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg new file mode 100644 index 000000000..3119e654a --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg @@ -0,0 +1,3 @@ +label menu + kernel vesamenu.c32 + config isolinux.cfg diff --git a/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg new file mode 100644 index 000000000..b799cb5cb --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg @@ -0,0 +1,12 @@ +foreground=0xFFFFFF +background=0x958490 +screen-colour=0x270A1E +hidden-timeout=2 +label normal=Normal +append normal= +label driverupdates=Use driver update disc +append driverupdates=debian-installer/driver-update=true +applies driverupdates=live live-install +label oem=OEM install (for manufacturers) +append oem=oem-config/enable=true +applies oem=live live-install install diff --git a/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg new file mode 100644 index 000000000..fd9c333b2 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg @@ -0,0 +1,6 @@ +# D-I config version 2.0 +include menu.cfg +default vesamenu.c32 +prompt 0 +timeout 50 +ui gfxboot bootlogo diff --git a/tests/syslinux/ubuntu10.04/isolinux/menu.cfg b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg new file mode 100644 index 000000000..9f5607dea --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg @@ -0,0 +1,23 @@ +menu hshift 13 +menu width 49 +menu margin 8 + +menu title Installer boot menu +include stdmenu.cfg +include txt.cfg +include gtk.cfg +menu begin advanced + menu title Advanced options + include stdmenu.cfg + label mainmenu + menu label ^Back.. + menu exit + include adtxt.cfg + include adgtk.cfg +menu end +label help + menu label ^Help + text help + Display help screens; type 'menu' at boot prompt to return to this menu + endtext + config prompt.cfg diff --git a/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg new file mode 100644 index 000000000..75f67881c --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg @@ -0,0 +1,3 @@ +[po4a_langs] ar bn ca cs da de es eu fi fr gl hu id it ja ka ko ku lv nb nl pl pt pt_BR ru sk sv ta tr vi zh_CN zh_TW +[po4a_paths] po/help.pot $lang:po/$lang.po +[type:docbook] help.xml diff --git a/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg new file mode 100644 index 000000000..f9984aedc --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg @@ -0,0 +1,16 @@ +prompt 1 +display f1.txt +timeout 50 +include menu.cfg +include exithelp.cfg + +f1 f1.txt +f2 f2.txt +f3 f3.txt +f4 f4.txt +f5 f5.txt +f6 f6.txt +f7 f7.txt +f8 f8.txt +f9 f9.txt +f0 f10.txt diff --git a/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg new file mode 100644 index 000000000..bdf6231ae --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg @@ -0,0 +1,4 @@ +label rescue + menu label ^Rescue mode + kernel /install/vmlinuz + append vga=788 initrd=/install/initrd.gz rescue/enable=true -- quiet diff --git a/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg new file mode 100644 index 000000000..671b16f78 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg @@ -0,0 +1,15 @@ +menu background splash.png +menu color title * #FFFFFFFF * +menu color border * #00000000 #00000000 none +menu color sel * #ffffffff #76a1d0ff * +menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff * +menu color tabmsg * #ffffffff #00000000 * +menu color help 37;40 #ffdddd00 #00000000 none +menu vshift 12 +menu rows 10 +menu helpmsgrow 15 +# The command line must be at least one line from the bottom. +menu cmdlinerow 16 +menu timeoutrow 16 +menu tabmsgrow 18 +menu tabmsg Press ENTER to boot or TAB to edit a menu entry diff --git a/tests/syslinux/ubuntu10.04/isolinux/txt.cfg b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg new file mode 100644 index 000000000..860daad80 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg @@ -0,0 +1,19 @@ +default live +label live + menu label ^Try Ubuntu without installing + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- +label live-install + menu label ^Install Ubuntu + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- +label check + menu label ^Check disc for defects + kernel /casper/vmlinuz + append boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- +label memtest + menu label Test ^memory + kernel /install/mt86plus +label hd + menu label ^Boot from first hard disk + localboot 0x80 diff --git a/tests/syslinux/ubuntu10.04_grub.cfg b/tests/syslinux/ubuntu10.04_grub.cfg new file mode 100644 index 000000000..e6bd82cbe --- /dev/null +++ b/tests/syslinux/ubuntu10.04_grub.cfg @@ -0,0 +1,236 @@ + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' +# D-I config version 2.0 + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='vesamenu.c32' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { + # UNSUPPORTED command 'ui gfxboot bootlogo' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' + # UNSUPPORTED command 'display f1.txt' + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='live' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' +} +menuentry 'menu' --id 'menu' { + # UNSUPPORTED command 'f1 f1.txt' + # UNSUPPORTED command 'f2 f2.txt' + # UNSUPPORTED command 'f3 f3.txt' + # UNSUPPORTED command 'f4 f4.txt' + # UNSUPPORTED command 'f5 f5.txt' + # UNSUPPORTED command 'f6 f6.txt' + # UNSUPPORTED command 'f7 f7.txt' + # UNSUPPORTED command 'f8 f8.txt' + # UNSUPPORTED command 'f9 f9.txt' + # UNSUPPORTED command 'f0 f10.txt' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' +# D-I config version 2.0 + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='vesamenu.c32' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { + # UNSUPPORTED command 'ui gfxboot bootlogo' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' +} +} +} diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in new file mode 100644 index 000000000..08d28da08 --- /dev/null +++ b/tests/syslinux_test.in @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 + +"@builddir@/grub-syslinux2cfg" -r "@srcdir@/tests/syslinux/ubuntu10.04" "@srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" + +echo "$outfile" + +if ! diff -u "$outfile" "@srcdir@/tests/syslinux/ubuntu10.04_grub.cfg"; then + echo "Mismatch in ubuntu10.04" + exit 1; +fi + +exit 0 From 251ddf26dc80d1fa91ca3f242da8613bc59c930d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Feb 2015 20:31:22 +0300 Subject: [PATCH 0122/1167] build-sys: add syslinux test files to tarball --- conf/Makefile.extra-dist | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 1b95ccd3f..8a65e37a6 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -121,3 +121,15 @@ EXTRA_DIST += tests/file_filter/file.xz.sig EXTRA_DIST += tests/file_filter/keys EXTRA_DIST += tests/file_filter/keys.pub EXTRA_DIST += tests/file_filter/test.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg From 35a492e4a2c70d27bc0a7f0c567b2a3405f31599 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Feb 2015 22:07:33 +0300 Subject: [PATCH 0123/1167] tests: remove hardcoded paths from syslinux_test abs_top_srcdir appeared in Autoconf 2.52f. Minimal grub requirement is 2.60 so we should be good here. --- Makefile.am | 6 ++++ conf/Makefile.extra-dist | 2 +- ...10.04_grub.cfg => ubuntu10.04_grub.cfg.in} | 30 +++++++++---------- tests/syslinux_test.in | 4 +-- 4 files changed, 24 insertions(+), 18 deletions(-) rename tests/syslinux/{ubuntu10.04_grub.cfg => ubuntu10.04_grub.cfg.in} (85%) diff --git a/Makefile.am b/Makefile.am index f702951af..994ebbd39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -452,3 +452,9 @@ ChangeLog: FORCE fi EXTRA_DIST += ChangeLog ChangeLog-2015 + +syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg + +tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in + (for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:- +CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 8a65e37a6..db6cfd12e 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -132,4 +132,4 @@ EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg -EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in diff --git a/tests/syslinux/ubuntu10.04_grub.cfg b/tests/syslinux/ubuntu10.04_grub.cfg.in similarity index 85% rename from tests/syslinux/ubuntu10.04_grub.cfg rename to tests/syslinux/ubuntu10.04_grub.cfg.in index e6bd82cbe..846e4acf0 100644 --- a/tests/syslinux/ubuntu10.04_grub.cfg +++ b/tests/syslinux/ubuntu10.04_grub.cfg.in @@ -1,4 +1,4 @@ - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' # D-I config version 2.0 # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -41,7 +41,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -63,15 +63,15 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' # UNSUPPORTED command 'display f1.txt' # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -114,7 +114,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -136,14 +136,14 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' } menuentry 'menu' --id 'menu' { # UNSUPPORTED command 'f1 f1.txt' @@ -156,8 +156,8 @@ menuentry 'menu' --id 'menu' { # UNSUPPORTED command 'f8 f8.txt' # UNSUPPORTED command 'f9 f9.txt' # UNSUPPORTED command 'f0 f10.txt' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' # D-I config version 2.0 # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -200,7 +200,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -222,15 +222,15 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' } } } diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in index 08d28da08..fc4edd8ef 100644 --- a/tests/syslinux_test.in +++ b/tests/syslinux_test.in @@ -4,11 +4,11 @@ set -e outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 -"@builddir@/grub-syslinux2cfg" -r "@srcdir@/tests/syslinux/ubuntu10.04" "@srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" +"@builddir@/grub-syslinux2cfg" -r "@abs_top_srcdir@/tests/syslinux/ubuntu10.04" "@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" echo "$outfile" -if ! diff -u "$outfile" "@srcdir@/tests/syslinux/ubuntu10.04_grub.cfg"; then +if ! diff -u "$outfile" "@builddir@/tests/syslinux/ubuntu10.04_grub.cfg"; then echo "Mismatch in ubuntu10.04" exit 1; fi From e20aa39ea4298011ba716087713cff26c6c52006 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 20:53:26 +0100 Subject: [PATCH 0124/1167] ext2: Support META_BG. This fixes bug that system would become unbootable after ext* online resize if no resize_inode was created at ext* format time. --- grub-core/fs/ext2.c | 61 +++++++++++++++++++++++++++++++++--- tests/ext234_test.in | 1 + tests/util/grub-fs-tester.in | 6 +++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 44c7974e3..4d45edcc5 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -107,6 +107,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \ | EXT4_FEATURE_INCOMPAT_EXTENTS \ | EXT4_FEATURE_INCOMPAT_FLEX_BG \ + | EXT2_FEATURE_INCOMPAT_META_BG \ | EXT4_FEATURE_INCOMPAT_64BIT) /* List of rationales for the ignored "incompatible" features: * needs_recovery: Not really back-incompatible - was added as such to forbid @@ -331,16 +332,68 @@ static grub_dl_t my_mod; +/* Check is a = b^x for some x. */ +static inline int +is_power_of (grub_uint64_t a, grub_uint32_t b) +{ + grub_uint64_t c; + /* Prevent overflow assuming b < 8. */ + if (a >= (1LL << 60)) + return 0; + for (c = 1; c <= a; c *= b); + return (c == a); +} + + +static inline int +group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group) +{ + if (!(data->sblock.feature_ro_compat + & grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))) + return 1; + /* Algorithm looked up in Linux source. */ + if (group <= 1) + return 1; + /* Even number is never a power of odd number. */ + if (!(group & 1)) + return 0; + return (is_power_of(group, 7) || is_power_of(group, 5) || + is_power_of(group, 3)); +} + /* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of the mounted filesystem DATA. */ inline static grub_err_t -grub_ext2_blockgroup (struct grub_ext2_data *data, int group, +grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group, struct grub_ext2_block_group *blkgrp) { + grub_uint64_t full_offset = (group << data->log_group_desc_size); + grub_uint64_t block, offset; + block = (full_offset >> LOG2_BLOCK_SIZE (data)); + offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1)); + if ((data->sblock.feature_incompat + & grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG)) + && block >= grub_le_to_cpu32(data->sblock.first_meta_bg)) + { + grub_uint64_t first_block_group; + /* Find the first block group for which a descriptor + is stored in given block. */ + first_block_group = (block << (LOG2_BLOCK_SIZE (data) + - data->log_group_desc_size)); + + block = (first_block_group + * grub_le_to_cpu32(data->sblock.blocks_per_group)); + + if (group_has_super_block (data, first_block_group)) + block++; + } + else + /* Superblock. */ + block++; return grub_disk_read (data->disk, - ((grub_le_to_cpu32 (data->sblock.first_data_block) + 1) - << LOG2_EXT2_BLOCK_SIZE (data)), - group << data->log_group_desc_size, + ((grub_le_to_cpu32 (data->sblock.first_data_block) + + block) + << LOG2_EXT2_BLOCK_SIZE (data)), offset, sizeof (struct grub_ext2_block_group), blkgrp); } diff --git a/tests/ext234_test.in b/tests/ext234_test.in index 8910b716f..c986960a8 100644 --- a/tests/ext234_test.in +++ b/tests/ext234_test.in @@ -29,3 +29,4 @@ fi "@builddir@/grub-fs-tester" ext2 "@builddir@/grub-fs-tester" ext3 "@builddir@/grub-fs-tester" ext4 +"@builddir@/grub-fs-tester" ext4_metabg diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 565692725..9ecbe0fd6 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -281,7 +281,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + #FSLABEL="g;/_é莭ð¯¦ðŸ˜ÐºÐ¸Ñ‚ u" ;; # FS LIMITATION: reiserfs, extN and jfs label is at most 16 UTF-8 characters - x"reiserfs_old" | x"reiserfs" | x"ext2" | xext2_old | x"ext3" | x"ext4" | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins") + x"reiserfs_old" | x"reiserfs" | x"ext"* | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins") FSLABEL="g;/éт 莭ðŸ˜";; # FS LIMITATION: No underscore, space, semicolon, slash or international characters in UFS* in label. Limited to 32 UTF-8 characters x"ufs1" | x"ufs1_sun" | x"ufs2") @@ -746,6 +746,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext2" -r 0 -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" MOUNTFS=ext2 ;; + xext4_metabg) + MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext4" -O meta_bg,^resize_inode -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" + MOUNTFS=ext4 + ;; xext*) MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; xxfs) From 5537a586e0b92b94910d0170a128ae8a85787713 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 21:08:37 +0100 Subject: [PATCH 0125/1167] ext2: Ignore INCOMPAT_MMP. It's not really incompatible as long as driver never writes to FS. --- grub-core/fs/ext2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 4d45edcc5..5199cb0c1 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -100,6 +100,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */ #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 +#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 /* The set of back-incompatible features this driver DOES support. Add (OR) @@ -115,8 +116,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); * journal because they will ignore the journal, but the next * ext3 driver to mount the volume will find the journal and * replay it, potentially corrupting the metadata written by - * the ext2 drivers. Safe to ignore for this RO driver. */ -#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER ) + * the ext2 drivers. Safe to ignore for this RO driver. + * mmp: Not really back-incompatible - was added as such to + * avoid multiple read-write mounts. Safe to ignore for this + * RO driver. + */ +#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \ + | EXT4_FEATURE_INCOMPAT_MMP) #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U From 86f05f1491b87550d69adbd003b9975ad7222557 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Feb 2015 21:29:35 +0100 Subject: [PATCH 0126/1167] configure: Add missing comma. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6d31ed01b..9f5415855 100644 --- a/configure.ac +++ b/configure.ac @@ -552,7 +552,7 @@ int main (void); TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags" -AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang] +AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang], [ CFLAGS="$TARGET_CFLAGS" AC_COMPILE_IFELSE( From b46bf3cd1c3682df0a6460dcee95ce4d9da4d1fd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Feb 2015 21:30:34 +0100 Subject: [PATCH 0127/1167] configure: Move adding of include options to the very end to avoid subshell. --- configure.ac | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9f5415855..8945afa29 100644 --- a/configure.ac +++ b/configure.ac @@ -78,12 +78,9 @@ fi # Default HOST_CPPFLAGS HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" -HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" -TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" -TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; @@ -1643,6 +1640,12 @@ fi TARGET_CPP="$TARGET_CC -E" TARGET_CCAS=$TARGET_CC +# Includes which include make-time substitutions. They must come last +# as to avoid executing top_builddir in shell. +HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" + GRUB_TARGET_CPU="${target_cpu}" GRUB_PLATFORM="${platform}" From e3c7aca76d5a3467f1bf0736dcd439a0d6f55ae9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:01:53 +0100 Subject: [PATCH 0128/1167] Strip .MIPS.abiflags which causes compile failure --- conf/Makefile.common | 2 +- gentpl.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 8c4d1483d..66c9fdb21 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -45,7 +45,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version +STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d diff --git a/gentpl.py b/gentpl.py index bdcae1a1c..c986cecb7 100644 --- a/gentpl.py +++ b/gentpl.py @@ -753,7 +753,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ fi """) From d93147abb70fba583091ac6ec0426a0bf504d697 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:03:11 +0100 Subject: [PATCH 0129/1167] INSTALL: Fix names of host flags to match actual behaviour --- INSTALL | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index f6f276c44..05cc4430c 100644 --- a/INSTALL +++ b/INSTALL @@ -175,9 +175,9 @@ corresponding platform are not needed for the platform in question. - For host 1. --host= to autoconf name of host. 2. CC= for gcc able to compile for host - 3. CFLAGS= for C options for host. - 4. CPPFLAGS= for C preprocessor options for host. - 5. LDFLAGS= for linker options for host. + 3. HOST_CFLAGS= for C options for host. + 4. HOST_CPPFLAGS= for C preprocessor options for host. + 5. HOST_LDFLAGS= for linker options for host. 6. FREETYPE= for freetype-config for host (optional). 7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional). 8. Libfuse if any must be in standard linker folders (-lfuse) (optional). From 2426ac36d3b42b6be507bde733c4bbd58883fe09 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:05:45 +0100 Subject: [PATCH 0130/1167] div_test: Don't try to divide by zero --- grub-core/tests/div_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/tests/div_test.c b/grub-core/tests/div_test.c index 1928f8507..7bdc80b40 100644 --- a/grub-core/tests/div_test.c +++ b/grub-core/tests/div_test.c @@ -34,6 +34,8 @@ static void test32 (grub_uint32_t a, grub_uint32_t b) { grub_uint64_t q, r; + if (b == 0) + return; q = grub_divmod64 (a, b, &r); grub_test_assert (r < b, "remainder is larger than dividend: 0x%llx %% 0x%llx = 0x%llx", (long long) a, (long long) b, (long long) r); From aee2502cb54d29d7d86240be7259895bdee15d07 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:07:59 +0100 Subject: [PATCH 0131/1167] Provide __aeabi_mem{cpy,set} Fixes ARM compilation --- grub-core/kern/misc.c | 4 ++++ include/grub/misc.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index c5c815d8d..883d35327 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -735,6 +735,10 @@ __ctzsi2 (grub_uint32_t x) grub_uint32_t __aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) __attribute__ ((alias ("__udivsi3"))); +void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memset (void *s, int c, grub_size_t n) + __attribute__ ((alias ("grub_memset"))); #endif #if defined (__ia64__) diff --git a/include/grub/misc.h b/include/grub/misc.h index 4b6ee06d4..e35934cbd 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -469,6 +469,11 @@ EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); grub_uint64_t EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); + #endif #if defined (__ia64__) From e5851b63e0b84cc648faaeff50d6300a16f9236a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:09:46 +0100 Subject: [PATCH 0132/1167] mips/startup_raw: Use more portable .asciz --- grub-core/boot/mips/startup_raw.S | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index 29e93c17e..c169ca36a 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -150,18 +150,18 @@ digcont: 1: jr $ra nop -busclockstr: .asciiz "busclock=" -cpuclockstr: .asciiz "cpuclock=" -memsizestr: .asciiz "memsize=" -highmemsizestr: .asciiz "highmemsize=" -machtype_yeeloong_str1: .asciiz "machtype=8.9" -machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-" -machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f" -machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e" -pmon_yeeloong_str: .asciiz "PMON_VER=LM8" -pmon_fuloong2f_str: .asciiz "PMON_VER=LM6" -pmon_yeeloong_verstr: .asciiz "Version=LM8" -pmon_fuloong2f_verstr: .asciiz "Version=LM6" +busclockstr: .asciz "busclock=" +cpuclockstr: .asciz "cpuclock=" +memsizestr: .asciz "memsize=" +highmemsizestr: .asciz "highmemsize=" +machtype_yeeloong_str1: .asciz "machtype=8.9" +machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-" +machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f" +machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e" +pmon_yeeloong_str: .asciz "PMON_VER=LM8" +pmon_fuloong2f_str: .asciz "PMON_VER=LM6" +pmon_yeeloong_verstr: .asciz "Version=LM8" +pmon_fuloong2f_verstr: .asciz "Version=LM6" .p2align 2 argdone: From ef7c843b443da6aac23cac6d73f90a951dff7436 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:13:11 +0100 Subject: [PATCH 0133/1167] configure: Add -msoft-float to CCASFLAGS Otherwise mismatch between API flags triggers linker failure --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 8945afa29..4ef67f060 100644 --- a/configure.ac +++ b/configure.ac @@ -679,6 +679,7 @@ if test "x$target_cpu" = xarm64; then TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" else TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -msoft-float" fi # By default, GCC 4.4 generates .eh_frame sections containing unwind From 967e5aa591cdd3bd462ffca4028c00e6a6dbc96d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:16:48 +0100 Subject: [PATCH 0134/1167] ofdisk: Exclude floppies from scanning. It causes similar hang as CD on at least the qemu. --- grub-core/disk/ieee1275/ofdisk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 6870b3958..5d8863782 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -34,7 +34,7 @@ struct ofdisk_hash_ent char *open_path; char *grub_devpath; int is_boot; - int is_cdrom; + int is_removable; /* Pointer to shortest available name on nodes representing canonical names, otherwise NULL. */ const char *shortest; @@ -123,7 +123,7 @@ ofdisk_hash_add_real (char *devpath) } static int -check_string_cdrom (const char *str) +check_string_removable (const char *str) { const char *ptr = grub_strrchr (str, '/'); @@ -131,7 +131,7 @@ check_string_cdrom (const char *str) ptr++; else ptr = str; - return (grub_strncmp (ptr, "cdrom", 5) == 0); + return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0); } static struct ofdisk_hash_ent * @@ -147,8 +147,8 @@ ofdisk_hash_add (char *devpath, char *curcan) { p->shortest = p->devpath; p->grub_shortest = p->grub_devpath; - if (check_string_cdrom (devpath)) - p->is_cdrom = 1; + if (check_string_removable (devpath)) + p->is_removable = 1; return p; } @@ -158,8 +158,8 @@ ofdisk_hash_add (char *devpath, char *curcan) else grub_free (curcan); - if (check_string_cdrom (devpath) || check_string_cdrom (curcan)) - pcan->is_cdrom = 1; + if (check_string_removable (devpath) || check_string_removable (curcan)) + pcan->is_removable = 1; if (!pcan) grub_errno = GRUB_ERR_NONE; @@ -330,7 +330,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, } } - if (!ent->is_boot && ent->is_cdrom) + if (!ent->is_boot && ent->is_removable) continue; if (hook (ent->grub_shortest, hook_data)) From ec65605af487d702577bfba214c27efd1a0d8b73 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:19:09 +0100 Subject: [PATCH 0135/1167] wildcard: Mark unused argument as such. --- grub-core/commands/wildcard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index d207acfed..9b4e72766 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -293,7 +293,8 @@ struct match_files_ctx /* Helper for match_files. */ static int -match_files_iter (const char *name, const struct grub_dirhook_info *info, +match_files_iter (const char *name, + const struct grub_dirhook_info *info __attribute__((unused)), void *data) { struct match_files_ctx *ctx = data; From 87a04adb6541c4bf169644bb2f84036a7c8558dd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:22:01 +0100 Subject: [PATCH 0136/1167] zfs/mzap_lookup: Fix argument types --- grub-core/fs/zfs/zfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 057b471e1..0cbb84bb3 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2013,12 +2013,14 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, */ static grub_err_t mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, - int objsize, const char *name, grub_uint64_t * value, + grub_uint16_t objsize, const char *name, grub_uint64_t * value, int case_insensitive) { - int i, chunks; + grub_uint16_t i, chunks; mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + if (objsize < MZAP_ENT_LEN) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name); chunks = objsize / MZAP_ENT_LEN - 1; for (i = 0; i < chunks; i++) { @@ -2426,7 +2428,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, struct grub_zfs_data *data, int case_insensitive) { grub_uint64_t block_type; - int size; + grub_uint16_t size; void *zapbuf; grub_err_t err; grub_zfs_endian_t endian; From 0b02bfa034be0102507fd1df56d577c9c1892df1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:22:48 +0100 Subject: [PATCH 0137/1167] INSTALL: clarify that clang support is experimental --- INSTALL | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INSTALL b/INSTALL index 05cc4430c..afbb660f3 100644 --- a/INSTALL +++ b/INSTALL @@ -13,6 +13,9 @@ configuring the GRUB. * GCC 4.1.3 or later Note: older versions may work but support is limited + + Experimental support for clang 3.3 or later (results in much bigger binaries) + for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc Note: clang 3.2 or later works for i386 and x86_64 targets but results in much bigger binaries. earlier versions not tested From 065ad910f1938fb8c02a14fe020819ed28429bad Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:29:28 +0100 Subject: [PATCH 0138/1167] Test which flags make our asm compile. Previously we relied on assumption that clang always needs -no-integrated-as but it's not always true. --- asm-tests/arm.S | 20 ++++++++++++++++ asm-tests/i386.S | 10 ++++++++ asm-tests/mips.S | 11 +++++++++ asm-tests/powerpc.S | 8 +++++++ asm-tests/sparc64.S | 9 +++++++ configure.ac | 58 ++++++++++++++++++++++++--------------------- 6 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 asm-tests/arm.S create mode 100644 asm-tests/i386.S create mode 100644 asm-tests/mips.S create mode 100644 asm-tests/powerpc.S create mode 100644 asm-tests/sparc64.S diff --git a/asm-tests/arm.S b/asm-tests/arm.S new file mode 100644 index 000000000..97c2546bf --- /dev/null +++ b/asm-tests/arm.S @@ -0,0 +1,20 @@ +/* on arm clang doesn't support .arch directive */ + + .text + .syntax unified + +#if !defined (__thumb2__) + .arch armv7a + .arm +#else + .arch armv7 + .thumb +#endif + mcr p15, 0, r11, c7, c14, 2 + + /* clang restricts access to dsb/isb despite .arch */ + dsb + isb + + + diff --git a/asm-tests/i386.S b/asm-tests/i386.S new file mode 100644 index 000000000..97cd32ae8 --- /dev/null +++ b/asm-tests/i386.S @@ -0,0 +1,10 @@ +/* on x86 old clang doesn't support .code16 + newer clang supports it but creates 6-byte jumps instead of 3-byte ones + which makes us go over boot sector size. */ + + .code16 + jmp far + .org 4 + .space 300 +far: + .byte 0 diff --git a/asm-tests/mips.S b/asm-tests/mips.S new file mode 100644 index 000000000..8233dfcc9 --- /dev/null +++ b/asm-tests/mips.S @@ -0,0 +1,11 @@ +/* on mips clang doesn't support privilegied instructions, doubleword store/load + and crashes with hand-written assembly + */ + + .set mips3 + sync + ld $t2, 0($t6) + +a: + addiu $t7, $s0, (b - a) +b: nop diff --git a/asm-tests/powerpc.S b/asm-tests/powerpc.S new file mode 100644 index 000000000..396a6cce9 --- /dev/null +++ b/asm-tests/powerpc.S @@ -0,0 +1,8 @@ +/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly + used by gcrypt */ +/* Cache invalidation loop is a fair test. */ + li 5, 0 +1: icbi 5, 3 + addi 5, 5, 32 + cmpw 5, 4 + blt 1b diff --git a/asm-tests/sparc64.S b/asm-tests/sparc64.S new file mode 100644 index 000000000..03c5fe02a --- /dev/null +++ b/asm-tests/sparc64.S @@ -0,0 +1,9 @@ + .text +1: + /* A small list of examples of what clang doesn't support. */ + clr %o0 + lduw [%o4 + 4], %o4 + and %o6, ~0xff, %o6 + stw %o5, [%o3] + bne,pt %icc, 1b + nop diff --git a/configure.ac b/configure.ac index 4ef67f060..40b732975 100644 --- a/configure.ac +++ b/configure.ac @@ -560,35 +560,39 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) -# on x86 clang doesn't support .code16 -# on arm clang doesn't support .arch directive -# on mips clang doesn't support privilegied instructions, doubleword store/load -# and crashes with hand-written assembly -if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \ - || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \ - || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" +AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ +test_program= +case "x$target_cpu" in + xmips | xmipsel) + test_program=mips + ;; + xi386 | xx86_64) + test_program=i386 + ;; + xpowerpc | xsparc64 | xarm) + test_program=$target_cpu + ;; +esac +if test x"$test_program" = x ; then + grub_cv_cc_target_asm_compile= +else + found=no + for arg in "" "-no-integrated-as"; do + cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S" + echo "Running $cmdline" >&AS_MESSAGE_LOG_FD + if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then + grub_cv_cc_target_asm_compile="$arg" + found=yes + break + fi + done + if test x"$found" = xno ; then + AC_MSG_ERROR([could not compile assembly]) + fi fi +]) -if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then -AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame] -[ -CFLAGS="$TARGET_CFLAGS" -AC_COMPILE_IFELSE( -[AC_LANG_PROGRAM([], [[ - unsigned int a = 0, b = 0; - asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b)); - if (a) - return 1; -]])], -[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])]) - # clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly - # used by gcrypt - if test x$grub_cv_cc_target_clang_ame = xno ; then - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" - TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as" - fi -fi +TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile" if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" From f571dc1af85e2044141a1dfff3af85a18c30fcd5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:13:23 +0100 Subject: [PATCH 0139/1167] i386: Move from explicit ADDR32/DATA32 prefixes to instruction suffixes. Is more portable. Binary is unchanged (verified). --- grub-core/boot/i386/pc/startup_raw.S | 4 ++-- grub-core/boot/i386/qemu/boot.S | 2 +- grub-core/kern/i386/pc/startup.S | 2 +- grub-core/kern/i386/realmode.S | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 279674030..812ff5494 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -95,7 +95,7 @@ LOCAL (codestart): int $0x13 /* transition to protected mode */ - DATA32 call real_to_prot + calll real_to_prot /* The ".code32" directive takes GAS out of 16-bit mode. */ .code32 @@ -149,7 +149,7 @@ gate_a20_try_bios: movw $0x2401, %ax int $0x15 - DATA32 call real_to_prot + calll real_to_prot .code32 popl %ebp diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index bdd68c704..8d97fc18c 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -48,7 +48,7 @@ VARIABLE(grub_core_entry_addr) /* Transition to protected mode. We use pushl to force generation of a flat return address. */ pushl $1f - DATA32 jmp real_to_prot + jmpl real_to_prot .code32 /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S index 6bb36c603..b8a9b33b4 100644 --- a/grub-core/kern/i386/pc/startup.S +++ b/grub-core/kern/i386/pc/startup.S @@ -135,7 +135,7 @@ LOCAL(prot_to_real_addr): .macro REAL_TO_PROT movl LOCAL(real_to_prot_addr), %eax - DATA32 call *%ax + calll *%eax .endm /* diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 541cedc87..732697c71 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -54,7 +54,7 @@ protstack: .endm .macro REAL_TO_PROT - DATA32 call real_to_prot + calll real_to_prot .endm /* @@ -137,7 +137,7 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds - DATA32 ADDR32 lgdt gdtdesc + ADDR32 lgdtl gdtdesc /* turn on protected mode */ movl %cr0, %eax @@ -145,7 +145,7 @@ real_to_prot: movl %eax, %cr0 /* jump to relocation, flush prefetch queue, and reload %cs */ - DATA32 ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg + ljmpl $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg .code32 protcseg: @@ -237,7 +237,7 @@ tmpcseg: movl %eax, %cr0 /* flush prefetch queue, reload %cs */ - DATA32 ljmp $0, $realcseg + ljmpl $0, $realcseg realcseg: /* we are in real mode now @@ -258,6 +258,6 @@ realcseg: #endif /* return on new stack! */ - DATA32 ret + retl .code32 From bc29c6d019c8645e6da843c78ba522f17165e808 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:19:01 +0100 Subject: [PATCH 0140/1167] Change dot assignmnet to more portable .org. Binary is unchanged (verified) --- grub-core/boot/i386/pc/boot.S | 20 ++++++++++---------- grub-core/boot/i386/pc/cdboot.S | 4 ++-- grub-core/boot/i386/pc/diskboot.S | 2 +- grub-core/boot/i386/pc/lnxboot.S | 4 ++-- grub-core/boot/i386/pc/pxeboot.S | 2 +- grub-core/boot/i386/pc/startup_raw.S | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index b4975e2d0..d17a1389e 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -165,8 +165,8 @@ start: * this area. */ - . = _start + GRUB_BOOT_MACHINE_BPB_START - . = _start + 4 + .org GRUB_BOOT_MACHINE_BPB_START + .org 4 #endif #ifdef HYBRID_BOOT floppy @@ -174,7 +174,7 @@ start: scratch #endif - . = _start + GRUB_BOOT_MACHINE_BPB_END + .org GRUB_BOOT_MACHINE_BPB_END /* * End of BIOS parameter block. */ @@ -183,14 +183,14 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #ifndef HYBRID_BOOT - . = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR + .org GRUB_BOOT_MACHINE_KERNEL_SECTOR kernel_sector: .long 1 kernel_sector_high: .long 0 #endif - . = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE + .org GRUB_BOOT_MACHINE_BOOT_DRIVE boot_drive: .byte 0xff /* the disk to load kernel from */ /* 0xff means use the boot drive */ @@ -208,7 +208,7 @@ LOCAL(after_BPB): * possible boot drive. If GRUB is installed into a floppy, * this does nothing (only jump). */ - . = _start + GRUB_BOOT_MACHINE_DRIVE_CHECK + .org GRUB_BOOT_MACHINE_DRIVE_CHECK boot_drive_check: jmp 3f /* grub-setup may overwrite this jump */ testb $0x80, %dl @@ -511,13 +511,13 @@ LOCAL(message): */ #ifdef HYBRID_BOOT - . = _start + 0x1b0 + .org 0x1b0 kernel_sector: .long 1 kernel_sector_high: .long 0 #endif - . = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC + .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC nt_magic: .long 0 .word 0 @@ -528,7 +528,7 @@ nt_magic: * sneaky, huh? */ - . = _start + GRUB_BOOT_MACHINE_PART_START + .org GRUB_BOOT_MACHINE_PART_START #ifndef HYBRID_BOOT floppy @@ -536,7 +536,7 @@ nt_magic: scratch #endif - . = _start + GRUB_BOOT_MACHINE_PART_END + .org GRUB_BOOT_MACHINE_PART_END /* the last 2 bytes in the sector 0 contain the signature */ .word GRUB_BOOT_MACHINE_SIGNATURE diff --git a/grub-core/boot/i386/pc/cdboot.S b/grub-core/boot/i386/pc/cdboot.S index 92df7c76f..de4f80929 100644 --- a/grub-core/boot/i386/pc/cdboot.S +++ b/grub-core/boot/i386/pc/cdboot.S @@ -43,7 +43,7 @@ _start: LOCAL(next): jmp 1f - . = start + 8 + .org 8 bi_pvd: .long 0 /* LBA of primary volume descriptor. */ @@ -168,6 +168,6 @@ err_noboot_msg: err_cdfail_msg: .ascii "cdrom read fails\0" - . = start + 0x7FF + .org 0x7FF .byte 0 diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S index d030a14c9..1ee4cf5b2 100644 --- a/grub-core/boot/i386/pc/diskboot.S +++ b/grub-core/boot/i386/pc/diskboot.S @@ -362,7 +362,7 @@ LOCAL(message): .word 0 .word 0 - . = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE + .org 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE LOCAL(firstlist): /* this label has to be before the first list entry!!! */ /* fill the first data listing with the default */ blocklist_default_start: diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S index 87e56a2fd..2dda0e06b 100644 --- a/grub-core/boot/i386/pc/lnxboot.S +++ b/grub-core/boot/i386/pc/lnxboot.S @@ -41,7 +41,7 @@ data_start: xorl %ebp, %ebp jmp LOCAL(linux_next) - . = data_start + 0x1F1 + .org 0x1F1 setup_sects: .byte CODE_SECTORS @@ -292,4 +292,4 @@ LOCAL(fail): err_int15_msg: .ascii "move memory fails\0" - . = _start + CODE_SECTORS * 512 + .org (CODE_SECTORS * 512 + 512) diff --git a/grub-core/boot/i386/pc/pxeboot.S b/grub-core/boot/i386/pc/pxeboot.S index 446bfc781..b695b24d0 100644 --- a/grub-core/boot/i386/pc/pxeboot.S +++ b/grub-core/boot/i386/pc/pxeboot.S @@ -38,5 +38,5 @@ start: /* This region is a junk. Do you say that this is wasteful? But I like that the memory layout of the body is consistent among different kernels rather than scamping just for 1.5KB. */ - . = _start + 0x8200 - 0x7C00 - 0x200 - 1 + .org 0x8200 - 0x7C00 - 0x200 - 1 .byte 0 diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 812ff5494..0f8806cd1 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -50,23 +50,23 @@ LOCAL (base): * This is a special data area. */ - . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE LOCAL(compressed_size): .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE LOCAL(uncompressed_size): .long 0 - . = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY + .org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY reed_solomon_redundancy: .long 0 - . = _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH + .org GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH .short (LOCAL(reed_solomon_part) - _start) /* * This is the area for all of the special variables. */ - . = _start + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE + .org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE LOCAL(boot_dev): .byte 0xFF, 0xFF, 0xFF LOCAL(boot_drive): From 1998d63688080e59abda2092ff4b58a1eeb19b90 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:20:10 +0100 Subject: [PATCH 0141/1167] i386-pc/boot: Explicitly mark kernel_address[_high] as local. Otherwise apple asm might try to make accesses relocatable. --- grub-core/boot/i386/pc/boot.S | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index d17a1389e..2bd0b2d28 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -179,14 +179,14 @@ start: * End of BIOS parameter block. */ -kernel_address: +LOCAL(kernel_address): .word GRUB_BOOT_MACHINE_KERNEL_ADDR #ifndef HYBRID_BOOT .org GRUB_BOOT_MACHINE_KERNEL_SECTOR -kernel_sector: +LOCAL(kernel_sector): .long 1 -kernel_sector_high: +LOCAL(kernel_sector_high): .long 0 #endif @@ -275,7 +275,7 @@ real_start: andw $1, %cx jz LOCAL(chs_mode) -lba_mode: +LOCAL(lba_mode): xorw %ax, %ax movw %ax, 4(%si) @@ -290,9 +290,9 @@ lba_mode: movw $0x0010, (%si) /* the absolute address */ - movl kernel_sector, %ebx + movl LOCAL(kernel_sector), %ebx movl %ebx, 8(%si) - movl kernel_sector_high, %ebx + movl LOCAL(kernel_sector_high), %ebx movl %ebx, 12(%si) /* the segment of buffer address */ @@ -361,13 +361,13 @@ LOCAL(final_init): setup_sectors: /* load logical sector start (top half) */ - movl kernel_sector_high, %eax + movl LOCAL(kernel_sector_high), %eax orl %eax, %eax jnz LOCAL(geometry_error) /* load logical sector start (bottom half) */ - movl kernel_sector, %eax + movl LOCAL(kernel_sector), %eax /* zero %edx */ xorl %edx, %edx @@ -452,7 +452,7 @@ LOCAL(copy_buffer): popa /* boot kernel */ - jmp *(kernel_address) + jmp *(LOCAL(kernel_address)) /* END OF MAIN LOOP */ @@ -512,9 +512,9 @@ LOCAL(message): #ifdef HYBRID_BOOT .org 0x1b0 -kernel_sector: +LOCAL(kernel_sector): .long 1 -kernel_sector_high: +LOCAL(kernel_sector_high): .long 0 #endif .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC From 37353f0ae5b9a4123ca9fe132a2336c08f30615a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:38:56 +0100 Subject: [PATCH 0142/1167] i386: Remove needless ADDR32 prefixes when address is known and fixed. Shaves off 6 bytes in lzma_decompress.img. --- grub-core/boot/i386/pc/startup_raw.S | 2 +- grub-core/kern/i386/realmode.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 0f8806cd1..8bce7985c 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -89,7 +89,7 @@ LOCAL (codestart): sti /* we're safe again */ /* save the boot drive */ - ADDR32 movb %dl, LOCAL(boot_drive) + movb %dl, LOCAL(boot_drive) /* reset disk system (%ah = 0) */ int $0x13 diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 732697c71..1384d5220 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -137,7 +137,7 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds - ADDR32 lgdtl gdtdesc + lgdtl gdtdesc /* turn on protected mode */ movl %cr0, %eax From 6505b241fd86456626dda85651f22467df8294fa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:44:41 +0100 Subject: [PATCH 0143/1167] Remove obsolete ADDR32 and DATA32 checks. --- acinclude.m4 | 74 ----------------------------------------- config.h.in | 4 --- configure.ac | 4 --- grub-core/modinfo.sh.in | 2 -- 4 files changed, 84 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index b2bb88d83..609c4f2f6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -210,80 +210,6 @@ fi ]) -dnl Mass confusion! -dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit -dnl instructions, but implicitly insert addr32 and data32 bytes so -dnl that the code works in real mode''. -dnl -dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit -dnl instructions,'' which seems right. This requires the programmer -dnl to explicitly insert addr32 and data32 instructions when they want -dnl them. -dnl -dnl We only support the newer versions, because the old versions cause -dnl major pain, by requiring manual assembly to get 16-bit instructions into -dnl asm files. -AC_DEFUN([grub_I386_ASM_ADDR32], -[AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT]) -AC_MSG_CHECKING([for .code16 addr32 assembler support]) -AC_CACHE_VAL(grub_cv_i386_asm_addr32, -[cat > conftest.s.in <<\EOF - .code16 -l1: @ADDR32@ movb %al, l1 -EOF - -if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then - sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s -else - sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s -fi - -if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then - grub_cv_i386_asm_addr32=yes -else - grub_cv_i386_asm_addr32=no -fi - -rm -f conftest*]) - -AC_MSG_RESULT([$grub_cv_i386_asm_addr32])]) - -dnl Later versions of GAS requires that addr32 and data32 prefixes -dnl appear in the same lines as the instructions they modify, while -dnl earlier versions requires that they appear in separate lines. -AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT], -[AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING(dnl -[whether addr32 must be in the same line as the instruction]) -AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement, -[cat > conftest.s <<\EOF - .code16 -l1: addr32 movb %al, l1 -EOF - -if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then - grub_cv_i386_asm_prefix_requirement=yes -else - grub_cv_i386_asm_prefix_requirement=no -fi - -rm -f conftest*]) - -if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then - grub_tmp_addr32="addr32" - grub_tmp_data32="data32" -else - grub_tmp_addr32="addr32;" - grub_tmp_data32="data32;" -fi - -ADDR32=$grub_tmp_addr32 -DATA32=$grub_tmp_data32 - -AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])]) - - dnl Check what symbol is defined as a bss start symbol. dnl Written by Michael Hohmoth and Yoshinori K. Okuji. AC_DEFUN([grub_CHECK_BSS_START_SYMBOL], diff --git a/config.h.in b/config.h.in index 4b6301441..d93b687dc 100644 --- a/config.h.in +++ b/config.h.in @@ -31,10 +31,6 @@ #define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@ /* Define if C symbols get an underscore after compilation. */ #define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ -/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */ -#define ADDR32 @ADDR32@ -/* Define it to \"data32\" or \"data32;\" to make GAS happy. */ -#define DATA32 @DATA32@ /* Define it to one of __bss_start, edata and _edata. */ #define BSS_START_SYMBOL @BSS_START_SYMBOL@ /* Define it to either end or _end. */ diff --git a/configure.ac b/configure.ac index 40b732975..8ddb5d3cc 100644 --- a/configure.ac +++ b/configure.ac @@ -1096,8 +1096,6 @@ if test "x$target_cpu" = xi386; then grub_CHECK_END_SYMBOL fi CFLAGS="$TARGET_CFLAGS" - grub_I386_ASM_PREFIX_REQUIREMENT - grub_I386_ASM_ADDR32 fi grub_PROG_NM_WORKS @@ -1621,8 +1619,6 @@ AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu], [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)]) AC_SUBST(HAVE_ASM_USCORE) -AC_SUBST(ADDR32) -AC_SUBST(DATA32) AC_SUBST(BSS_START_SYMBOL) AC_SUBST(END_SYMBOL) AC_SUBST(PACKAGE) diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in index 69d833432..09d22f922 100644 --- a/grub-core/modinfo.sh.in +++ b/grub-core/modinfo.sh.in @@ -9,8 +9,6 @@ grub_have_font_source=@HAVE_FONT_SOURCE@ # Autodetected config grub_have_asm_uscore=@HAVE_ASM_USCORE@ -grub_i8086_addr32="@ADDR32@" -grub_i8086_data32="@DATA32@" grub_bss_start_symbol="@BSS_START_SYMBOL@" grub_end_symbol="@END_SYMBOL@" From 44ff462e836cb24bde0de184fb1e3cdeedcdd572 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 19:53:18 +0100 Subject: [PATCH 0144/1167] Remove realmode.S from coreboot and qemu. It's not used there. --- grub-core/kern/i386/coreboot/startup.S | 5 ----- grub-core/kern/i386/qemu/startup.S | 2 -- 2 files changed, 7 deletions(-) diff --git a/grub-core/kern/i386/coreboot/startup.S b/grub-core/kern/i386/coreboot/startup.S index 8c3283846..c8486548d 100644 --- a/grub-core/kern/i386/coreboot/startup.S +++ b/grub-core/kern/i386/coreboot/startup.S @@ -61,8 +61,3 @@ multiboot_header: /* checksum */ .long -0x1BADB002 - MULTIBOOT_MEMORY_INFO -/* - * prot_to_real and associated structures (but NOT real_to_prot, that is - * only needed for BIOS gates). - */ -#include "../realmode.S" diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S index 3d47d1e4f..17aace9d4 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -73,5 +73,3 @@ codestart: 1: hlt jmp 1b - -#include "../realmode.S" From e62ca2a870ecec4d46fcc03556e8e61592e9dd18 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 19:55:53 +0100 Subject: [PATCH 0145/1167] qemu: Fix compilation --- grub-core/boot/i386/qemu/boot.S | 2 +- grub-core/kern/i386/realmode.S | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index 8d97fc18c..354436eeb 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -48,7 +48,7 @@ VARIABLE(grub_core_entry_addr) /* Transition to protected mode. We use pushl to force generation of a flat return address. */ pushl $1f - jmpl real_to_prot + jmp real_to_prot .code32 /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 1384d5220..998fdc756 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -137,7 +137,22 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds +#ifdef GRUB_MACHINE_QEMU + /* + qemu is special: gdtdesc is in ROM. + %cs = 0xf000 + _start + GRUB_BOOT_MACHINE_SIZE = 0x100000 + So + _start + GRUB_BOOT_MACHINE_SIZE - 0x10000 points to the same point + as %cs. + gdtdesc - (_start + GRUB_BOOT_MACHINE_SIZE - 0x10000) + = gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000 + but the later can be computed by assembly. + */ + lgdtl %cs:(gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000) +#else lgdtl gdtdesc +#endif /* turn on protected mode */ movl %cr0, %eax @@ -178,6 +193,9 @@ protcseg: /* return on the old (or initialized) stack! */ ret + /* prot_to_real assumes that this code is under 64K which is not + true for qemu. */ +#ifndef GRUB_MACHINE_QEMU /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc. @@ -259,5 +277,5 @@ realcseg: /* return on new stack! */ retl - +#endif .code32 From 8afd8f3b641aaa80b70bb6629ea8eecae5d359df Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:00:18 +0100 Subject: [PATCH 0146/1167] qemu: Fix GateA20 enabling. GateA20 code was inactive due to address error. --- grub-core/boot/i386/qemu/boot.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index 354436eeb..c5343bfb5 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -50,6 +50,7 @@ VARIABLE(grub_core_entry_addr) pushl $1f jmp real_to_prot .code32 +1: /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's all emulated. */ @@ -57,7 +58,6 @@ VARIABLE(grub_core_entry_addr) andb $(~0x03), %al orb $0x02, %al outb $0x92 -1: movl EXT_C(grub_core_entry_addr), %edx jmp *%edx From 3c6043245e9618a499766fdb0e51c4953d5d3da9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:13:58 +0100 Subject: [PATCH 0147/1167] qemu: Switch to more portable .org Binary is checked identical. --- grub-core/boot/i386/qemu/boot.S | 6 +++--- grub-core/kern/i386/qemu/startup.S | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index c5343bfb5..8c3a1db71 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -31,7 +31,7 @@ _start: jmp 1f - . = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR + .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR VARIABLE(grub_core_entry_addr) .long 0 1: @@ -66,9 +66,9 @@ VARIABLE(grub_core_entry_addr) /* Intel, in its infinite wisdom, decided to put the i8086 entry point *right here* and this is why we need this kludge. */ - . = GRUB_BOOT_MACHINE_SIZE - 16 + .org GRUB_BOOT_MACHINE_SIZE - 16 .code16 jmp _start - . = GRUB_BOOT_MACHINE_SIZE + .org GRUB_BOOT_MACHINE_SIZE diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S index 17aace9d4..0d89858d9 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -28,7 +28,7 @@ _start: jmp codestart - . = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR + .org GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR VARIABLE(grub_core_entry_addr) .long 0 From f16b8c04057925270d765532fa5710757119c6da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:18:18 +0100 Subject: [PATCH 0148/1167] Relax requirements on asm for non-BIOS i386 platforms. These platforms don't have a hard limit on size of resulting code16 code, so we don't care if assembly is bigger than necessarry. --- asm-tests/i386-pc.S | 10 ++++++++++ asm-tests/i386.S | 10 ++-------- configure.ac | 11 +++++++---- 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 asm-tests/i386-pc.S diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S new file mode 100644 index 000000000..97cd32ae8 --- /dev/null +++ b/asm-tests/i386-pc.S @@ -0,0 +1,10 @@ +/* on x86 old clang doesn't support .code16 + newer clang supports it but creates 6-byte jumps instead of 3-byte ones + which makes us go over boot sector size. */ + + .code16 + jmp far + .org 4 + .space 300 +far: + .byte 0 diff --git a/asm-tests/i386.S b/asm-tests/i386.S index 97cd32ae8..30adc4fe2 100644 --- a/asm-tests/i386.S +++ b/asm-tests/i386.S @@ -1,10 +1,4 @@ -/* on x86 old clang doesn't support .code16 - newer clang supports it but creates 6-byte jumps instead of 3-byte ones - which makes us go over boot sector size. */ +/* on x86 old clang doesn't support .code16 */ .code16 - jmp far - .org 4 - .space 300 -far: - .byte 0 + movb %al, %bl diff --git a/configure.ac b/configure.ac index 8ddb5d3cc..8b94d346e 100644 --- a/configure.ac +++ b/configure.ac @@ -562,14 +562,17 @@ AC_COMPILE_IFELSE( AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= -case "x$target_cpu" in - xmips | xmipsel) +case "x$target_cpu-$platform" in + xmips-* | xmipsel-*) test_program=mips ;; - xi386 | xx86_64) + xi386-pc) + test_program=i386-pc + ;; + xi386-* | xx86_64-*) test_program=i386 ;; - xpowerpc | xsparc64 | xarm) + xpowerpc-* | xsparc64-* | xarm-*) test_program=$target_cpu ;; esac From e77dc3d9a0b672d933f328fce4332a61a9f5f707 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:24:59 +0100 Subject: [PATCH 0149/1167] kernel-8086: Switch to more portable .org. --- grub-core/tests/boot/kernel-8086.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/tests/boot/kernel-8086.S b/grub-core/tests/boot/kernel-8086.S index 510897c88..5ec5368ff 100644 --- a/grub-core/tests/boot/kernel-8086.S +++ b/grub-core/tests/boot/kernel-8086.S @@ -46,5 +46,5 @@ message: .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n" .byte 0 - . = base + 510 - .short 0xaa55 \ No newline at end of file + .org 510 + .short 0xaa55 From 49e5fcb9fb1efd1c9b9622d1bc0fe5fa23e99b81 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:32:03 +0100 Subject: [PATCH 0150/1167] sparc64: Switch to more portable .org. Binaries are unchanged. --- grub-core/boot/sparc64/ieee1275/boot.S | 8 ++++---- grub-core/boot/sparc64/ieee1275/diskboot.S | 2 +- grub-core/kern/sparc64/ieee1275/crt0.S | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 507367749..586efb401 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -41,9 +41,9 @@ pic_base: * After loading in that block we will execute it by jumping to the * load address plus the size of the prepended A.OUT header (32 bytes). */ - . = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH + .org GRUB_BOOT_MACHINE_BOOT_DEVPATH boot_path: - . = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE + .org GRUB_BOOT_MACHINE_KERNEL_BYTE boot_path_end: kernel_byte: .xword (2 << 9) kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR @@ -52,7 +52,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #define boot_path_end (_start + 1024) #include - . = _start + 8 + .org 8 kernel_byte: .xword (2 << 9) kernel_size: .word 512 kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS @@ -224,7 +224,7 @@ bootpath_known: #else nop #endif - . = _start + GRUB_BOOT_MACHINE_CODE_END + .org GRUB_BOOT_MACHINE_CODE_END /* the last 4 bytes in the sector 0 contain the signature */ .word GRUB_BOOT_MACHINE_SIGNATURE diff --git a/grub-core/boot/sparc64/ieee1275/diskboot.S b/grub-core/boot/sparc64/ieee1275/diskboot.S index e020f6221..35e02c1b6 100644 --- a/grub-core/boot/sparc64/ieee1275/diskboot.S +++ b/grub-core/boot/sparc64/ieee1275/diskboot.S @@ -136,7 +136,7 @@ lastlist: .word 0 .word 0 - . = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) + .org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) blocklist_default_start: .word 0 .word 2 diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S index 79b6bb325..03b916f05 100644 --- a/grub-core/kern/sparc64/ieee1275/crt0.S +++ b/grub-core/kern/sparc64/ieee1275/crt0.S @@ -27,7 +27,7 @@ _start: ba codestart mov %o4, %o0 - . = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE + .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE VARIABLE(grub_total_module_size) .word 0 From da9f30b455a3d1b9e52ae6875b4724c0784c9e8a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:43:57 +0100 Subject: [PATCH 0151/1167] mips: Switch to more portable .org Binary is unchanged. --- grub-core/boot/mips/loongson/fwstart.S | 6 +++--- grub-core/boot/mips/startup_raw.S | 6 +++--- grub-core/kern/mips/startup.S | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 6ae326990..71bab6dc8 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -162,7 +162,7 @@ retry_cs5536: b continue - . = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START tlb_refill: mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR @@ -196,13 +196,13 @@ tlb_refill: b fatal addiu $a0, $a0, %lo(unhandled_tlb_refill) - . = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START cache_error: lui $a0, %hi(unhandled_cache_error) b fatal addiu $a0, $a0, %lo(unhandled_cache_error) - . = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START other_exception: mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index c169ca36a..ca3413bbe 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -39,13 +39,13 @@ start: bal codestart nop base: - . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE compressed_size: .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE uncompressed_size: .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR uncompressed_addr: .long 0 codestart: diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 709a91afa..339ab337e 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -36,7 +36,7 @@ start: bal cont nop - . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE + .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE VARIABLE(grub_total_modules_size) .long 0 From ebe316e4dfebb83c2e1de437b316b60195470961 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 23:46:47 +0100 Subject: [PATCH 0152/1167] Discover which option provides soft-float on configure stage. Deals with clang needing other arguments to stop issuing floating instructions than gcc. --- configure.ac | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 8b94d346e..10a6bf9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -682,11 +682,39 @@ fi # that floats are a good fit to run instead of what's written in the code. # Given that floating point unit is disabled (if present to begin with) # when GRUB is running which may result in various hard crashes. -if test "x$target_cpu" = xarm64; then - TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" -else - TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -msoft-float" +if test x"$platform" != xemu ; then + AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ + grub_cv_target_cc_soft_float=no + if test "x$target_cpu" = xarm64; then + CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) + fi + for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ + "-Xclang -msoft-float" "-msoft-float"; do + if test x"$grub_cv_target_cc_soft_float" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_soft_float" = xno ; then + AC_MSG_ERROR([could not force soft-float]) + fi + + case x"$grub_cv_target_cc_soft_float" in + x"-Xclang"*) + # A trick so that clang doesn't see it on link stаge + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float" + ;; + *) + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" + ;; + esac + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi # By default, GCC 4.4 generates .eh_frame sections containing unwind From 155f334f5740a33948ee92432a9eacfd0bf4a398 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 01:53:00 +0100 Subject: [PATCH 0153/1167] Experimental support for clang for sparc64. Automatically discover command line options to make clang and gcc behave in same way. Tested with qemu. --- INSTALL | 5 +++-- conf/Makefile.common | 7 +----- configure.ac | 53 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/INSTALL b/INSTALL index afbb660f3..846ac38df 100644 --- a/INSTALL +++ b/INSTALL @@ -15,7 +15,7 @@ configuring the GRUB. Note: older versions may work but support is limited Experimental support for clang 3.3 or later (results in much bigger binaries) - for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc + for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64 Note: clang 3.2 or later works for i386 and x86_64 targets but results in much bigger binaries. earlier versions not tested @@ -29,7 +29,8 @@ configuring the GRUB. fail. Note: clang 3.2 or later works for powerpc earlier versions not tested - Note: clang doesn't support -mno-app-regs and so can't be used for sparc64 + Note: clang 3.5 or later works for sparc64 + earlier versions return "error: unable to interface with target machine" Note: clang has no support for ia64 and hence you can't compile GRUB for ia64 with clang * GNU Make diff --git a/conf/Makefile.common b/conf/Makefile.common index 66c9fdb21..8861096a5 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -7,12 +7,7 @@ unexport LC_ALL # Platform specific options if COND_sparc64_ieee1275 - CFLAGS_PLATFORM += -mno-app-regs - LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax -endif -if COND_sparc64_emu - CFLAGS_PLATFORM += -mno-app-regs - LDFLAGS_PLATFORM = -Wl,--no-relax + LDFLAGS_PLATFORM = -Wl,-melf64_sparc endif if COND_arm if !COND_emu diff --git a/configure.ac b/configure.ac index 10a6bf9c1..4d59fbee0 100644 --- a/configure.ac +++ b/configure.ac @@ -717,6 +717,55 @@ if test x"$platform" != xemu ; then TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi +if test x"$target_cpu" = xsparc64 ; then + AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [ + grub_cv_target_cc_mno_app_regs=no + for cand in "-mllvm -sparc-reserve-app-registers" \ + "-mno-app-regs"; do + if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_mno_app_regs="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then + AC_MSG_ERROR([could not reserve application registers]) + fi + if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then + # A trick so that clang doesn't see it on link stаge + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs" + else + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs" + fi + + AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [ + grub_cv_target_cc_mno_relax=no + for cand in "-mno-relax" "-Wl,--no-relax"; do + if test x"$grub_cv_target_cc_mno_relax" != xno ; then + break + fi + LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static" + CFLAGS="$TARGET_CFLAGS -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + asm (".globl start; start:"); + void __main (void); + void __main (void) {} + int main (void); + ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], []) + done + ]) + LDFLAGS="$TARGET_LDFLAGS" + CFLAGS="$TARGET_CFLAGS" + + if test x"$grub_cv_target_cc_mno_relax" = xno ; then + AC_MSG_ERROR([could not find no-relax options]) + fi + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" +fi + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler @@ -918,7 +967,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) LDFLAGS="$TARGET_LDFLAGS" -if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then +if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then # Use large model to support 4G memory AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ CFLAGS="$TARGET_CFLAGS -mcmodel=large" @@ -928,7 +977,7 @@ if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; t ]) if test "x$grub_cv_cc_mcmodel" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" - elif test "$target_cpu-$platform" = sparc64-emu; then + elif test "$target_cpu" = sparc64; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" fi fi From 50ebc8f5f35a322b3736c03e16de7108932126b0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 13:12:44 +0100 Subject: [PATCH 0154/1167] i386/tsc: Fix unused function warning on xen. --- grub-core/kern/i386/tsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index d7d1783e4..bc441d0d3 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -57,6 +57,8 @@ grub_get_tsc (void) return (((grub_uint64_t) hi) << 32) | lo; } +#ifndef GRUB_MACHINE_XEN + static __inline int grub_cpu_is_tsc_supported (void) { @@ -69,8 +71,6 @@ grub_cpu_is_tsc_supported (void) return (d & (1 << 4)) != 0; } -#ifndef GRUB_MACHINE_XEN - static void grub_pit_wait (grub_uint16_t tics) { From ea39b87a8b258a0f19752f5e5607e14deec54c44 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 14:42:19 +0100 Subject: [PATCH 0155/1167] configure.ac: Add ia64-specific way to disable floats. --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 4d59fbee0..94f96c47d 100644 --- a/configure.ac +++ b/configure.ac @@ -690,6 +690,11 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) fi + if test "x$target_cpu" = xia64; then + CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], []) + fi for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float" "-msoft-float"; do if test x"$grub_cv_target_cc_soft_float" != xno ; then From e1d4520bfb63aa669fc197f44623f6c9228f7757 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 14:42:43 +0100 Subject: [PATCH 0156/1167] acpi: Fix unused function warning. --- grub-core/commands/acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 5507ffa08..05a6dcad4 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -131,6 +131,8 @@ grub_acpi_get_rsdpv1 (void) return grub_machine_acpi_get_rsdpv1 (); } +#if defined (__i386__) || defined (__x86_64__) + static inline int iszero (grub_uint8_t *reg, int size) { @@ -141,7 +143,6 @@ iszero (grub_uint8_t *reg, int size) return 1; } -#if defined (__i386__) || defined (__x86_64__) /* Context for grub_acpi_create_ebda. */ struct grub_acpi_create_ebda_ctx { int ebda_len; From f034fab6206173d411407fab6eb9a44c90e02dca Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:24:28 +0100 Subject: [PATCH 0157/1167] Supply signed division to fix ARM compilation. Previously we supplied only unsigned divisions on platforms that need software division. Yet compiler may itself use a signed division. A typical example would be a difference between 2 pointers which involves division by object size. --- gentpl.py | 6 +++ grub-core/Makefile.core.def | 8 ++++ grub-core/kern/arm/misc.S | 13 +++---- grub-core/kern/misc.c | 71 ++++++++++++++++++++++----------- grub-core/tests/div_test.c | 73 +++++++++++++++++++++++++++++++--- include/grub/misc.h | 78 +++++++++++++++++++++++++++++-------- 6 files changed, 198 insertions(+), 51 deletions(-) diff --git a/gentpl.py b/gentpl.py index c986cecb7..d2aa03586 100644 --- a/gentpl.py +++ b/gentpl.py @@ -76,6 +76,12 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) # Flattened Device Trees (FDT) GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ] +# Needs software helpers for division +# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h +GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] +GROUPS["no_softdiv"] = GRUB_PLATFORMS[:] +for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i) + # Miscelaneous groups schedulded to disappear in future GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 42443bc00..b539ccf9d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -159,6 +159,8 @@ kernel = { terminfoinkernel = commands/extcmd.c; terminfoinkernel = lib/arg.c; + softdiv = lib/division.c; + i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; @@ -1969,6 +1971,12 @@ module = { enable = xen; }; +module = { + name = div; + common = lib/division.c; + enable = no_softdiv; +}; + module = { name = div_test; common = tests/div_test.c; diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S index 16b6f8e60..645b42f50 100644 --- a/grub-core/kern/arm/misc.S +++ b/grub-core/kern/arm/misc.S @@ -58,15 +58,11 @@ FUNCTION(__aeabi_lmul) ldmfd sp!, {r4, fp} bx lr - .macro division parent + .macro division32 parent sub sp, sp, #8 @ Allocate naturally aligned 64-bit space stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment - add r3, sp, #8 @ Set r3 to address of 64-bit space - str r3, [sp] @ Stack parameter, pointer to 64-bit space - mov r2, r1 - mov r1, #0 - mov r3, #0 + add r2, sp, #8 @ Set r2 to address of 64-bit space bl \parent ldr r1, [sp, #8] @ Extract remainder ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register @@ -75,8 +71,9 @@ FUNCTION(__aeabi_lmul) .endm FUNCTION(__aeabi_uidivmod) - division grub_divmod64 - + division32 grub_divmod32 +FUNCTION(__aeabi_idivmod) + division32 grub_divmod32s /* * Null divide-by-zero handler diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 883d35327..b0347e7e2 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -594,10 +594,10 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) grub_uint64_t m = 0; /* ARM and IA64 don't have a fast 32-bit division. - Using that code would just make us use libgcc routines, calling - them twice (once for modulo and once for quotient. + Using that code would just make us use software division routines, calling + ourselves indirectly and hence getting infinite recursion. */ -#if !defined (__arm__) && !defined (__ia64__) +#if !GRUB_DIVISION_IN_SOFTWARE /* Skip the slow computation if 32-bit arithmetic is possible. */ if (n < 0xffffffff && d < 0xffffffff) { @@ -633,7 +633,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) #if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) -#if defined (__arm__) +#if GRUB_DIVISION_IN_SOFTWARE grub_uint32_t __udivsi3 (grub_uint32_t a, grub_uint32_t b) @@ -641,6 +641,12 @@ __udivsi3 (grub_uint32_t a, grub_uint32_t b) return grub_divmod64 (a, b, 0); } +grub_int32_t +__divsi3 (grub_int32_t a, grub_int32_t b) +{ + return grub_divmod64s (a, b, 0); +} + grub_uint32_t __umodsi3 (grub_uint32_t a, grub_uint32_t b) { @@ -649,6 +655,42 @@ __umodsi3 (grub_uint32_t a, grub_uint32_t b) return ret; } +grub_int32_t +__modsi3 (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +grub_uint64_t +__udivdi3 (grub_uint64_t a, grub_uint64_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_uint64_t +__umoddi3 (grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int64_t +__divdi3 (grub_int64_t a, grub_int64_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_int64_t +__moddi3 (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + #endif #ifdef NEED_CTZDI2 @@ -735,30 +777,15 @@ __ctzsi2 (grub_uint32_t x) grub_uint32_t __aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) __attribute__ ((alias ("__udivsi3"))); +grub_int32_t +__aeabi_idiv (grub_int32_t a, grub_int32_t b) + __attribute__ ((alias ("__divsi3"))); void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) __attribute__ ((alias ("grub_memcpy"))); void *__aeabi_memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("grub_memset"))); #endif -#if defined (__ia64__) - -grub_uint64_t -__udivdi3 (grub_uint64_t a, grub_uint64_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_uint64_t -__umoddi3 (grub_uint64_t a, grub_uint64_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -#endif - #endif /* GRUB_UTIL */ /* Convert a long long value to a string. This function avoids 64-bit diff --git a/grub-core/tests/div_test.c b/grub-core/tests/div_test.c index 7bdc80b40..9abc6d5c4 100644 --- a/grub-core/tests/div_test.c +++ b/grub-core/tests/div_test.c @@ -97,6 +97,72 @@ test64 (grub_uint64_t a, grub_uint64_t b) #endif } +static grub_int64_t +abs64(grub_int64_t a) +{ + return a > 0 ? a : -a; +} + +static void +test32s (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t q, r; + if (b == 0) + return; + + q = grub_divmod64s (a, b, &r); + grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld", + (long long) a, (long long) b, (long long) q); + grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (q * b + r == a, "division doesn't satisfy base property: %lld * %lld + %lld != %lld", (long long) q, (long long) b, (long long) r, + (long long) a); + if (0) { grub_test_assert (q == (a / b), + "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + grub_test_assert (r == (a % b), + "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + } +} + +static void +test64s (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t q, r; + q = grub_divmod64s (a, b, &r); + + grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld", + (long long) a, (long long) b, (long long) q); + grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (q * b + r == a, "division doesn't satisfy base property: 0x%llx * 0x%llx + 0x%llx != 0x%llx", (long long) q, (long long) b, (long long) r, + (long long) a); +#if GRUB_TARGET_SIZEOF_VOID_P == 8 + grub_test_assert (q == (a / b), + "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + grub_test_assert (r == (a % b), + "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b); +#endif +} + +static void +test_all(grub_uint64_t a, grub_uint64_t b) +{ + test64 (a, b); + test32 (a, b); + test64s (a, b); + test32s (a, b); + test64s (a, -b); + test32s (a, -b); + test64s (-a, b); + test32s (-a, b); + test64s (-a, -b); + test32s (-a, -b); +} + static void div_test (void) { @@ -105,8 +171,7 @@ div_test (void) for (i = 0; i < ARRAY_SIZE (vectors); i++) { - test64 (vectors[i][0], vectors[i][1]); - test32 (vectors[i][0], vectors[i][1]); + test_all (vectors[i][0], vectors[i][1]); } for (i = 0; i < 40000; i++) { @@ -116,9 +181,7 @@ div_test (void) b = 1; if (a == 0) a = 1; - test64 (a, b); - test32 (a, b); - + test_all (a, b); } } diff --git a/include/grub/misc.h b/include/grub/misc.h index e35934cbd..a05b3fd39 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -358,6 +358,64 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r); +/* Must match softdiv group in gentpl.py. */ +#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__)) +#define GRUB_DIVISION_IN_SOFTWARE 1 +#else +#define GRUB_DIVISION_IN_SOFTWARE 0 +#endif + +/* Some division functions need to be in kernel if compiler generates calls + to them. Otherwise we still need them for consistent tests but they go + into a separate module. */ +#if GRUB_DIVISION_IN_SOFTWARE +#define EXPORT_FUNC_IF_SOFTDIV EXPORT_FUNC +#else +#define EXPORT_FUNC_IF_SOFTDIV(x) x +#endif + +grub_int64_t +EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n, + grub_int64_t d, + grub_int64_t *r); +grub_uint32_t +EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n, + grub_uint32_t d, + grub_uint32_t *r); + +grub_int32_t +EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n, + grub_int32_t d, + grub_int32_t *r); + +#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); + +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); + +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); + +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); + +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); + +#endif + #if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) void EXPORT_FUNC (__register_frame_info) (void); void EXPORT_FUNC (__deregister_frame_info) (void); @@ -437,12 +495,6 @@ grub_error_load (const struct grub_error_saved *save) #if defined (__arm__) -grub_uint32_t -EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_uint32_t -EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); - #endif #if defined (__sparc__) || defined (__powerpc__) @@ -460,8 +512,12 @@ EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); #ifdef __arm__ grub_uint32_t EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); grub_uint32_t EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); /* Needed for allowing modules to be compiled as thumb. */ grub_uint64_t @@ -476,16 +532,6 @@ EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); #endif -#if defined (__ia64__) - -grub_uint64_t -EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); - -grub_uint64_t -EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); - -#endif - #endif /* GRUB_UTIL */ From 345076a78a15a61e1545eec60e7661e13b2dc62f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:41:12 +0100 Subject: [PATCH 0158/1167] arm64: Fix compilation failure. Don't supply +nosimd to asm files. Otherwise +nosimd coming from flags forbids some of instructions used in cache_flush. --- configure.ac | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 94f96c47d..35f430a0a 100644 --- a/configure.ac +++ b/configure.ac @@ -719,7 +719,16 @@ if test x"$platform" != xemu ; then TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" ;; esac - TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" + case x"$grub_cv_target_cc_soft_float" in + x"-march=armv8-a+nofp+nosimd") + # +nosimd disables also the cache opcodes that we need in asm. + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp" + ;; + *) + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" + ;; + esac + fi if test x"$target_cpu" = xsparc64 ; then From 2066c35b3ff6e35edf2a4e903f9aa79a23b6aefe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:45:30 +0100 Subject: [PATCH 0159/1167] Allow clang compilation for thumb with -mthumb-interwork. clang already uses -mthumb-interwork behaviour even thout it doesn't support the option. --- configure.ac | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 35f430a0a..8f9ab8133 100644 --- a/configure.ac +++ b/configure.ac @@ -1029,20 +1029,9 @@ if test "x$target_cpu" = xarm; then ]) if test "x$grub_cv_cc_mthumb_interwork" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork" + # Clang defaults to thumb interworking elif test "x$grub_cv_cc_target_clang" = xno ; then AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork]) - else - CFLAGS="$TARGET_CFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ -#if defined (__thumb__) && !defined (__thumb2__) -#error thumb without interworking -#endif -]])], - [no_interwork_ok=yes], - [no_interwork_ok=no]) - if test x$no_interwork_ok = xno ; then - AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork]) - fi fi fi From 7ea452a142d55e80b2a33d59958eef41559fb8eb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 19:34:46 +0100 Subject: [PATCH 0160/1167] Add missing grub_ prefix in memcpy invocation --- grub-core/kern/dl.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 6850e0497..3a438e92f 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -340,7 +340,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) mod->symtab = grub_malloc (s->sh_size); if (!mod->symtab) return grub_errno; - memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size); + grub_memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size); #else mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset); #endif diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 6389170e6..63d6a1f33 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -110,7 +110,7 @@ grub_linux_boot (void) int len = grub_strlen (linux_args) + 1; if (bp->len < len) len = bp->len; - memcpy(bp->buf, linux_args, len); + grub_memcpy(bp->buf, linux_args, len); bp->buf[len-1] = '\0'; bp->valid = 1; } From 6a4ecd276ed39f66be0ad6ff0f8ff67598098605 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Feb 2015 22:33:28 +0100 Subject: [PATCH 0161/1167] mips: Fix soft-float handling. Add -msoft-float alongside clang arguments to specify ABI. Specify ABI in asm files explicitly. This trigers asm warning due to gcc failing to propagate -msoft-float but it's tolerable. --- configure.ac | 5 +++-- grub-core/boot/mips/startup_raw.S | 2 ++ grub-core/kern/mips/cache.S | 4 +++- grub-core/kern/mips/startup.S | 2 ++ grub-core/lib/mips/relocator_asm.S | 2 ++ include/grub/mips/kernel.h | 4 ++++ 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8f9ab8133..908bb81e7 100644 --- a/configure.ac +++ b/configure.ac @@ -695,7 +695,8 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], []) fi - for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ + for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \ + "-Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float" "-msoft-float"; do if test x"$grub_cv_target_cc_soft_float" != xno ; then break @@ -711,7 +712,7 @@ if test x"$platform" != xemu ; then fi case x"$grub_cv_target_cc_soft_float" in - x"-Xclang"*) + x*"-Xclang"*) # A trick so that clang doesn't see it on link stаge TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float" ;; diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index ca3413bbe..fd95c3134 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BASE_ADDR 8 @@ -32,6 +33,7 @@ .globl __start, _start, start .set noreorder .set nomacro + mips_attributes __start: _start: start: diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S index 78e40bcea..e83960fcc 100644 --- a/grub-core/kern/mips/cache.S +++ b/grub-core/kern/mips/cache.S @@ -1,8 +1,10 @@ #include +#include .set noreorder .set nomacro + mips_attributes FUNCTION (grub_arch_sync_caches) #include "cache_flush.S" @@ -65,4 +67,4 @@ FUNCTION (grub_arch_sync_dma_caches) #endif sync_op - jr $ra \ No newline at end of file + jr $ra diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 339ab337e..337aca914 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BASE_ADDR 8 @@ -28,6 +29,7 @@ .globl __start, _start, start .set noreorder .set nomacro + mips_attributes __start: _start: start: diff --git a/grub-core/lib/mips/relocator_asm.S b/grub-core/lib/mips/relocator_asm.S index 1d142a4f3..959893ca9 100644 --- a/grub-core/lib/mips/relocator_asm.S +++ b/grub-core/lib/mips/relocator_asm.S @@ -17,11 +17,13 @@ */ #include +#include .p2align 4 /* force 16-byte alignment */ .set noreorder .set nomacro + mips_attributes VARIABLE (grub_relocator_forward_start) move $a0, $9 diff --git a/include/grub/mips/kernel.h b/include/grub/mips/kernel.h index 07b08848d..d0e09ddc6 100644 --- a/include/grub/mips/kernel.h +++ b/include/grub/mips/kernel.h @@ -21,4 +21,8 @@ #include +#ifdef ASM_FILE +#define mips_attributes .gnu_attribute 4, 3 +#endif + #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ From c5a4e79335cebc026684de623bdd327312139330 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:11:53 +0100 Subject: [PATCH 0162/1167] minilzo: Skip parts tha we don't need. --- config.h.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config.h.in b/config.h.in index d93b687dc..ea0f3834e 100644 --- a/config.h.in +++ b/config.h.in @@ -12,6 +12,14 @@ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ #define BOOT_TIME_STATS @BOOT_TIME_STATS@ +/* We don't need those. */ +#define MINILZO_CFG_SKIP_LZO_PTR 1 +#define MINILZO_CFG_SKIP_LZO_UTIL 1 +#define MINILZO_CFG_SKIP_LZO_STRING 1 +#define MINILZO_CFG_SKIP_LZO_INIT 1 +#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1 +#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1 + #if defined (GRUB_BUILD) #undef ENABLE_NLS #define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@ From dd4889f727c535948fd6ab67154a52b10bc544c9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:13:36 +0100 Subject: [PATCH 0163/1167] bitmap_scale: Optimize by moving division out of the loop. --- grub-core/video/bitmap_scale.c | 114 ++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c index 0b93d0206..70c32f029 100644 --- a/grub-core/video/bitmap_scale.c +++ b/grub-core/video/bitmap_scale.c @@ -361,35 +361,46 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) unsigned dh = dst->mode_info.height; unsigned sw = src->mode_info.width; unsigned sh = src->mode_info.height; - unsigned dstride = dst->mode_info.pitch; - unsigned sstride = src->mode_info.pitch; + int dstride = dst->mode_info.pitch; + int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ - unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel; + int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, sy, ystep, yfrac, yover; + unsigned sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; - unsigned dy; - for (dy = 0; dy < dh; dy++) + xstep = sw / dw; + xover = sw % dw; + ystep = sh / dh; + yover = sh % dh; + + for (dy = 0, sy = 0, yfrac = 0; dy < dh; dy++, sy += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + sy++; + } + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sx = 0, xfrac = 0; dptr < dline_end; sx += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; - unsigned comp; + int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sx++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sptr = sline + sx * bytes_per_pixel; - /* Copy the pixel color value. */ - for (comp = 0; comp < bytes_per_pixel; comp++) - dptr[comp] = sptr[comp]; + /* Copy the pixel color value. */ + for (comp = 0; comp < bytes_per_pixel; comp++) + dptr[comp] = sptr[comp]; } } return GRUB_ERR_NONE; @@ -422,27 +433,40 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, syf, sy, ystep, yfrac, yover; + unsigned sxf, sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; - unsigned dy; - for (dy = 0; dy < dh; dy++) + xstep = (sw << 8) / dw; + xover = (sw << 8) % dw; + ystep = (sh << 8) / dh; + yover = (sh << 8) % dh; + + for (dy = 0, syf = 0, yfrac = 0; dy < dh; dy++, syf += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + syf++; + } + sy = syf >> 8; + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sxf = 0, xfrac = 0; dptr < dline_end; sxf += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sxf++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sx = sxf >> 8; + sptr = sline + sx * bytes_per_pixel; /* If we have enough space to do so, use bilinear interpolation. Otherwise, fall back to nearest neighbor for this pixel. */ @@ -453,27 +477,27 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) /* Fixed-point .8 numbers representing the fraction of the distance in the x (u) and y (v) direction within the box of 4 pixels in the source. */ - int u = (256 * sw * dx / dw) - (sx * 256); - int v = (256 * sh * dy / dh) - (sy * 256); + unsigned u = sxf & 0xff; + unsigned v = syf & 0xff; for (comp = 0; comp < bytes_per_pixel; comp++) { /* Get the component's values for the four source corner pixels. */ - int f00 = sptr[comp]; - int f10 = sptr[comp + bytes_per_pixel]; - int f01 = sptr[comp + sstride]; - int f11 = sptr[comp + sstride + bytes_per_pixel]; + unsigned f00 = sptr[comp]; + unsigned f10 = sptr[comp + bytes_per_pixel]; + unsigned f01 = sptr[comp + sstride]; + unsigned f11 = sptr[comp + sstride + bytes_per_pixel]; /* Count coeffecients. */ - int c00 = (256 - u) * (256 - v); - int c10 = u * (256 - v); - int c01 = (256 - u) * v; - int c11 = u * v; + unsigned c00 = (256 - u) * (256 - v); + unsigned c10 = u * (256 - v); + unsigned c01 = (256 - u) * v; + unsigned c11 = u * v; /* Interpolate. */ - int fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; - fxy = fxy / (256 * 256); + unsigned fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; + fxy = fxy >> 16; dptr[comp] = fxy; } From f51218bc15ff7b82894a2096ec1cdb7c8f0084f4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:14:28 +0100 Subject: [PATCH 0164/1167] fbblit: Optimize by replacing division with additions and shifts. --- grub-core/video/fb/fbblit.c | 71 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/grub-core/video/fb/fbblit.c b/grub-core/video/fb/fbblit.c index 3a073cea7..d55924837 100644 --- a/grub-core/video/fb/fbblit.c +++ b/grub-core/video/fb/fbblit.c @@ -1145,6 +1145,20 @@ grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst, } } +static inline grub_uint8_t +alpha_dilute (grub_uint8_t bg, grub_uint8_t fg, grub_uint8_t alpha) +{ + grub_uint16_t s; + grub_uint16_t h, l; + s = (fg * alpha) + (bg * (255 ^ alpha)); + /* Optimised division by 255. */ + h = s >> 8; + l = s & 0xff; + if (h + l >= 255) + h++; + return h; +} + /* Generic blending blitter. Works for every supported format. */ static void grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, @@ -1190,12 +1204,9 @@ grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, grub_video_fb_unmap_color_int (dst, dst_color, &dst_red, &dst_green, &dst_blue, &dst_alpha); - dst_red = (((src_red * src_alpha) - + (dst_red * (255 ^ src_alpha))) / 255U); - dst_green = (((src_green * src_alpha) - + (dst_green * (255 ^ src_alpha))) / 255U); - dst_blue = (((src_blue * src_alpha) - + (dst_blue * (255 ^ src_alpha))) / 255U); + dst_red = alpha_dilute (dst_red, src_red, src_alpha); + dst_green = alpha_dilute (dst_green, src_green, src_alpha); + dst_blue = alpha_dilute (dst_blue, src_blue, src_alpha); dst_alpha = src_alpha; dst_color = grub_video_fb_map_rgba (dst_red, dst_green, dst_blue, @@ -1270,11 +1281,11 @@ grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst, color = *dstptr; dr = (color >> 16) & 0xFF; - dr = (dr * (255 ^ a) + sr * a) / 255U; + dr = alpha_dilute (dr, sr, a); dg = (color >> 8) & 0xFF; - dg = (dg * (255 ^ a) + sg * a) / 255U; + dg = alpha_dilute (dg, sg, a); db = (color >> 0) & 0xFF; - db = (db * (255 ^ a) + sb * a) / 255U; + db = alpha_dilute (db, sb, a); } color = (a << 24) | (dr << 16) | (dg << 8) | db; @@ -1360,9 +1371,9 @@ grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst, db = dstptr[2]; #endif - db = (db * (255 ^ a) + sb * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - dr = (dr * (255 ^ a) + sr * a) / 255U; + db = alpha_dilute (db, sb, a); + dg = alpha_dilute (dg, sg, a); + dr = alpha_dilute (dr, sr, a); } #ifndef GRUB_CPU_WORDS_BIGENDIAN @@ -1440,9 +1451,9 @@ grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst, dg = (color >> 8) & 0xFF; db = (color >> 16) & 0xFF; - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); color = (a << 24) | (db << 16) | (dg << 8) | dr; @@ -1525,9 +1536,9 @@ grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst, dr = dstptr[2]; #endif - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); #ifndef GRUB_CPU_WORDS_BIGENDIAN *dstptr++ = dr; @@ -1601,9 +1612,9 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, grub_video_fb_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da); - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); color = grub_video_fb_map_rgb(dr, dg, db); @@ -1683,9 +1694,9 @@ grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*dstptr >> 8) & 0xFF; grub_uint8_t d3 = (*dstptr >> 16) & 0xFF; - d1 = (d1 * (255 ^ a) + s1 * a) / 255U; - d2 = (d2 * (255 ^ a) + s2 * a) / 255U; - d3 = (d3 * (255 ^ a) + s3 * a) / 255U; + d1 = alpha_dilute (d1, s1, a); + d2 = alpha_dilute (d2, s2, a); + d3 = alpha_dilute (d3, s3, a); *dstptr = (a << 24) | (d3 << 16) | (d2 << 8) | d1; } @@ -1791,9 +1802,9 @@ grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*(grub_uint32_t *) dstptr >> 8) & 0xFF; grub_uint8_t d3 = (*(grub_uint32_t *) dstptr >> 16) & 0xFF; - ((grub_uint8_t *) dstptr)[0] = (d1 * (255 ^ a) + s1 * a) / 255U; - ((grub_uint8_t *) dstptr)[1] = (d2 * (255 ^ a) + s2 * a) / 255U; - ((grub_uint8_t *) dstptr)[2] = (d3 * (255 ^ a) + s3 * a) / 255U; + ((grub_uint8_t *) dstptr)[0] = alpha_dilute (d1, s1, a); + ((grub_uint8_t *) dstptr)[1] = alpha_dilute (d2, s2, a); + ((grub_uint8_t *) dstptr)[2] = alpha_dilute (d3, s3, a); } srcmask >>= 1; @@ -1887,9 +1898,9 @@ grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*dstptr >> 5) & 0x3F; grub_uint8_t d3 = (*dstptr >> 11) & 0x1F; - d1 = (d1 * (255 ^ a) + s1 * a) / 255U; - d2 = (d2 * (255 ^ a) + s2 * a) / 255U; - d3 = (d3 * (255 ^ a) + s3 * a) / 255U; + d1 = alpha_dilute (d1, s1, a); + d2 = alpha_dilute (d2, s2, a); + d3 = alpha_dilute (d3, s3, a); *dstptr = (d1 & 0x1f) | ((d2 & 0x3f) << 5) | ((d3 & 0x1f) << 11); } From 80310ad07dfbd682ade52f2db2e536e0e7ccc471 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:22:40 +0100 Subject: [PATCH 0165/1167] Add missing lib/division.c --- grub-core/lib/division.c | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 grub-core/lib/division.c diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c new file mode 100644 index 000000000..920a79f18 --- /dev/null +++ b/grub-core/lib/division.c @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 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 . + */ + +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t +abs64(grub_int64_t a) +{ + return a > 0 ? a : -a; +} + +grub_int64_t +grub_divmod64s (grub_int64_t n, + grub_int64_t d, + grub_int64_t *ro) +{ + grub_uint64_t ru; + grub_int64_t q, r; + q = grub_divmod64 (abs64(n), abs64(d), &ru); + r = ru; + /* Now: |n| = |d| * q + r */ + if (n < 0) + { + /* -|n| = |d| * (-q) + (-r) */ + q = -q; + r = -r; + } + /* Now: n = |d| * q + r */ + if (d < 0) + { + /* n = (-|d|) * (-q) + r */ + q = -q; + } + /* Now: n = d * q + r */ + *ro = r; + return q; +} + +grub_uint32_t +grub_divmod32 (grub_uint32_t n, grub_uint32_t d, grub_uint32_t *ro) +{ + grub_uint64_t q, r; + q = grub_divmod64 (n, d, &r); + *ro = r; + return q; +} + +grub_int32_t +grub_divmod32s (grub_int32_t n, grub_int32_t d, grub_int32_t *ro) +{ + grub_int64_t q, r; + q = grub_divmod64s (n, d, &r); + *ro = r; + return q; +} From 18125877eec4e6d7b0b6567b6c92eab1df946f47 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:27:43 +0100 Subject: [PATCH 0166/1167] png: Optimize by avoiding divisions. --- grub-core/video/readers/png.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c index 1f03f88d3..e1a01e99f 100644 --- a/grub-core/video/readers/png.c +++ b/grub-core/video/readers/png.c @@ -227,7 +227,7 @@ grub_png_decode_image_palette (struct grub_png_data *data, { unsigned i = 0, j; - if (len == 0 || len % 3 != 0) + if (len == 0) return GRUB_ERR_NONE; for (i = 0; 3 * i < len && i < 256; i++) @@ -851,15 +851,26 @@ grub_png_convert_image (struct grub_png_data *data) int mask = (1 << data->color_bits) - 1; unsigned j; if (data->is_gray) - for (i = 0; i < (1U << data->color_bits); i++) - { - grub_uint8_t col = (0xff * i) / ((1U << data->color_bits) - 1); - palette[i][0] = col; - palette[i][1] = col; - palette[i][2] = col; - } + { + /* Generic formula is + (0xff * i) / ((1U << data->color_bits) - 1) + but for allowed bit depth of 1, 2 and for it's + equivalent to + (0xff / ((1U << data->color_bits) - 1)) * i + Precompute the multipliers to avoid division. + */ + + const grub_uint8_t multipliers[5] = { 0xff, 0xff, 0x55, 0x24, 0x11 }; + for (i = 0; i < (1U << data->color_bits); i++) + { + grub_uint8_t col = multipliers[data->color_bits] * i; + palette[i][0] = col; + palette[i][1] = col; + palette[i][2] = col; + } + } else - grub_memcpy (palette, data->palette, 16 * 3); + grub_memcpy (palette, data->palette, 3 << data->color_bits); d1c = d1; d2c = d2; for (j = 0; j < data->image_height; j++, d1c += data->image_width * 3, From 7213c1e02807e760febec06a0f19b11173abc55a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 21:27:32 +0100 Subject: [PATCH 0167/1167] jpeg: Optimise by replacing division with shifts. --- grub-core/video/readers/jpeg.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index 38ea2395a..c3e0df240 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -94,7 +94,7 @@ struct grub_jpeg_data jpeg_data_unit_t crdu; jpeg_data_unit_t cbdu; - unsigned vs, hs; + unsigned log_vs, log_hs; int dri; unsigned r1; @@ -315,11 +315,14 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data) ss = grub_jpeg_get_byte (data); /* Sampling factor. */ if (!id) { - data->vs = ss & 0xF; /* Vertical sampling. */ - data->hs = ss >> 4; /* Horizontal sampling. */ - if ((data->vs > 2) || (data->hs > 2) || (data->vs == 0) || (data->hs == 0)) + grub_uint8_t vs, hs; + vs = ss & 0xF; /* Vertical sampling. */ + hs = ss >> 4; /* Horizontal sampling. */ + if ((vs > 2) || (hs > 2) || (vs == 0) || (hs == 0)) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: sampling method not supported"); + data->log_vs = (vs == 2); + data->log_hs = (hs == 2); } else if (ss != JPEG_SAMPLING_1x1) return grub_error (GRUB_ERR_BAD_FILE_TYPE, @@ -616,10 +619,10 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned c1, vb, hb, nr1, nc1; int rst = data->dri; - vb = data->vs * 8; - hb = data->hs * 8; - nr1 = (data->image_height + vb - 1) / vb; - nc1 = (data->image_width + hb - 1) / hb; + vb = 8 << data->log_vs; + hb = 8 << data->log_hs; + nr1 = (data->image_height + vb - 1) >> (3 + data->log_vs); + nc1 = (data->image_width + hb - 1) >> (3 + data->log_hs); for (; data->r1 < nr1 && (!data->dri || rst); data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3) @@ -629,8 +632,8 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned r2, c2, nr2, nc2; grub_uint8_t *ptr2; - for (r2 = 0; r2 < data->vs; r2++) - for (c2 = 0; c2 < data->hs; c2++) + for (r2 = 0; r2 < (1U << data->log_vs); r2++) + for (c2 = 0; c2 < (1U << data->log_hs); c2++) grub_jpeg_decode_du (data, 0, data->ydu[r2 * 2 + c2]); if (data->color_components >= 3) @@ -652,7 +655,7 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned i0; int yy; - i0 = (r2 / data->vs) * 8 + (c2 / data->hs); + i0 = (r2 >> data->log_vs) * 8 + (c2 >> data->log_hs); yy = data->ydu[(r2 / 8) * 2 + (c2 / 8)][(r2 % 8) * 8 + (c2 % 8)]; if (data->color_components >= 3) From 94f701a826b54e6652044bdba9a8b6a9aa2b479e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:04:40 +0100 Subject: [PATCH 0168/1167] crypto: restrict cipher block size to power of 2. All current ciphers have blocks which are power of 2 and it's unlikely to change. Other block length would be tricky to handle anyway. This restriction allows avoiding extra divisions. --- grub-core/disk/cryptodisk.c | 36 ++++++++++++++++++------------- grub-core/lib/crypto.c | 42 ++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 376ab8326..82a3dcb63 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -110,20 +110,23 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher, { grub_uint8_t *inptr, *outptr, *end; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) - return GPG_ERR_INV_ARG; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) + return GPG_ERR_INV_ARG; + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); - grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); + grub_crypto_xor (iv, ivt, outptr, blocksize); } return GPG_ERR_NO_ERROR; } @@ -135,20 +138,23 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher, { grub_uint8_t *inptr, *outptr, *end; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) - return GPG_ERR_INV_ARG; - if (!cipher->cipher->decrypt) + grub_size_t blocksize; + if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) + return GPG_ERR_INV_ARG; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); cipher->cipher->encrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); + grub_crypto_xor (iv, ivt, outptr, blocksize); } return GPG_ERR_NO_ERROR; } diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 8e8426c4a..010e550d1 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -205,13 +205,16 @@ grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, { const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) cipher->cipher->decrypt (cipher->ctx, outptr, inptr); return GPG_ERR_NO_ERROR; } @@ -222,13 +225,16 @@ grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, { const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; + grub_size_t blocksize; if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) cipher->cipher->encrypt (cipher->ctx, outptr, inptr); return GPG_ERR_NO_ERROR; } @@ -241,20 +247,23 @@ grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, grub_uint8_t *outptr; const grub_uint8_t *inptr, *end; void *iv; - if (!cipher->cipher->decrypt) + grub_size_t blocksize; + if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; iv = iv_in; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize); + grub_crypto_xor (outptr, inptr, iv, blocksize); cipher->cipher->encrypt (cipher->ctx, outptr, outptr); iv = outptr; } - grub_memcpy (iv_in, iv, cipher->cipher->blocksize); + grub_memcpy (iv_in, iv, blocksize); return GPG_ERR_NO_ERROR; } @@ -266,20 +275,23 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); - grub_memcpy (iv, ivt, cipher->cipher->blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); + grub_memcpy (iv, ivt, blocksize); } return GPG_ERR_NO_ERROR; } From f76c98b79eabccd1bdbd0d7c2763e09aa1e58e06 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:06:19 +0100 Subject: [PATCH 0169/1167] dmraid_nvidia: Fix division by 0 and missing byte-swap. --- grub-core/disk/dmraid_nvidia.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index fc02f5715..881508cf2 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_nv_super sb; int level; grub_uint64_t disk_size; + grub_uint32_t capacity; + grub_uint8_t total_volumes; char *uuid; if (disk->partition) @@ -124,14 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk, return NULL; } + capacity = grub_le_to_cpu32 (sb.capacity); + total_volumes = sb.array.total_volumes; + switch (sb.array.raid_level) { case NV_LEVEL_0: level = 0; - disk_size = sb.capacity / sb.array.total_volumes; - if (sb.array.total_volumes == 0) + if (total_volumes == 0) /* Not RAID. */ return NULL; + disk_size = capacity / total_volumes; break; case NV_LEVEL_1: @@ -141,10 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk, case NV_LEVEL_5: level = 5; - disk_size = sb.capacity / (sb.array.total_volumes - 1); - if (sb.array.total_volumes == 0 || sb.array.total_volumes == 1) + if (total_volumes == 0 || total_volumes == 1) /* Not RAID. */ return NULL; + disk_size = capacity / (total_volumes - 1); break; default: From 67a6a9512a52fee34a452752787dc80577fa7838 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:07:22 +0100 Subject: [PATCH 0170/1167] raid6: Optimize by removing division. --- grub-core/disk/raid6_recover.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index f9ec632fb..aa674f6ca 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -63,6 +63,16 @@ grub_raid6_init_table (void) } } +static unsigned +mod_255 (unsigned x) +{ + while (x > 0xff) + x = (x >> 8) + (x & 0xff); + if (x == 0xff) + return 0; + return x; +} + static grub_err_t grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, char *buf, grub_disk_addr_t sector, grub_size_t size) @@ -162,11 +172,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, grub_crypto_xor (qbuf, qbuf, buf, size); - c = ((255 ^ bad1) - + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255; + c = mod_255((255 ^ bad1) + + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])); grub_raid_block_mulx (c, qbuf, size); - c = ((unsigned) bad2 + c) % 255; + c = mod_255((unsigned) bad2 + c); grub_raid_block_mulx (c, pbuf, size); grub_crypto_xor (pbuf, pbuf, qbuf, size); From 7ba066419a2e0f777a0c103b058fba49e1492f04 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:10:09 +0100 Subject: [PATCH 0171/1167] gzio: Optimize by removing division. --- grub-core/io/gzio.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 129209e37..0f2ea6bd8 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1161,6 +1161,19 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) return file; } +static grub_uint8_t +mod_31 (grub_uint16_t v) +{ + /* At most 2 iterations for any number that + we can get here. + In any case faster than real division. */ + while (v > 0x1f) + v = (v & 0x1f) + (v >> 5); + if (v == 0x1f) + return 0; + return v; +} + static int test_zlib_header (grub_gzio_t gzio) { @@ -1178,7 +1191,10 @@ test_zlib_header (grub_gzio_t gzio) return 0; } - if ((cmf * 256U + flg) % 31U) + /* Usually it would be: (cmf * 256 + flg) % 31 != 0. */ + /* But 256 == 8 (31). */ + /* By multiplying by 4 and using 32 == 1 (31). We get our formula. */ + if (mod_31 (cmf + flg * 4) != 0) { grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format")); return 0; From 38b7a3026900670159f299f2daa7e35957752942 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:10:29 +0100 Subject: [PATCH 0172/1167] arm/dl: Fix handling of nonstandard relocation sizes --- grub-core/kern/arm/dl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index 5cbd65e46..24364e189 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -78,9 +78,9 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, const Elf_Rel *rel, *max; for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset), - max = rel + s->sh_size / s->sh_entsize; - rel < max; - rel++) + max = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_size); + rel + 1 <= max; + rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize)) switch (ELF_R_TYPE (rel->r_info)) { case R_ARM_CALL: From 66b0e6649b8aa169db1b026abc4dd4167bb312e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:20:59 +0100 Subject: [PATCH 0173/1167] emu/cache: Change declaration of __clear_cache to match builtin declaration. Fixes compile of arm64-emu. --- grub-core/kern/emu/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/emu/cache.c b/grub-core/kern/emu/cache.c index 07be6756f..6f89e871a 100644 --- a/grub-core/kern/emu/cache.c +++ b/grub-core/kern/emu/cache.c @@ -8,7 +8,7 @@ #include "../ia64/cache.c" #elif defined (__arm__) || defined (__aarch64__) -void __clear_cache (char *beg, char *end); +void __clear_cache (void *beg, void *end); void grub_arch_sync_caches (void *address, grub_size_t len) From 050505ab8f695c10b3e4e768a4188688ebe5e366 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 15:13:41 +0100 Subject: [PATCH 0174/1167] ntfs_test: Skip is setfattr is unavailable. --- tests/ntfs_test.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/ntfs_test.in b/tests/ntfs_test.in index 6bf09e691..e25c6384a 100644 --- a/tests/ntfs_test.in +++ b/tests/ntfs_test.in @@ -15,5 +15,10 @@ if ! which mkfs.ntfs >/dev/null 2>&1; then exit 77 fi +if ! which setfattr >/dev/null 2>&1; then + echo "setfattr not installed; cannot test ntfs." + exit 77 +fi + "@builddir@/grub-fs-tester" ntfs -"@builddir@/grub-fs-tester" ntfscomp \ No newline at end of file +"@builddir@/grub-fs-tester" ntfscomp From ddde9ca71ac7e0c42a445f5a37085c5895098e34 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 15:14:16 +0100 Subject: [PATCH 0175/1167] grub-shell: Add missing --locale-directory. Fixes the language tests is no make install was done. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 5b66139a9..6d2b1327e 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -349,6 +349,7 @@ fi if [ x$boot != xnet ] && [ x$boot != xemu ]; then pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \ --rom-directory="${rom_directory}" \ + --locale-directory="@srcdir@/po" \ --themes-directory="@srcdir@/themes" \ $mkimage_extra_arg ${mkrescue_args} \ "/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \ From afd6b6bbaedfd7724e6ccc0401c76021a429779b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 16:22:46 +0100 Subject: [PATCH 0176/1167] grub-probe: Mark a "[default=]" for translation. --- util/grub-probe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 8a0c4f35b..08d477f5f 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -728,10 +728,12 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) case 't': { - char *ret, *t = get_targets_string (); + char *ret, *t = get_targets_string (), *def; - ret = xasprintf ("%s\n%s %s [default=%s]", _("print TARGET"), - _("available targets:"), t, targets[print]); + def = xasprintf (_("[default=%s]"), targets[print]); + + ret = xasprintf ("%s\n%s %s %s", _("print TARGET"), + _("available targets:"), t, def); free (t); return ret; } From 0d6498a67d4542244c2ca183e05cfc3d858218be Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 16:23:27 +0100 Subject: [PATCH 0177/1167] exclude.pot: Add new technical strings --- po/exclude.pot | 311 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 291 insertions(+), 20 deletions(-) diff --git a/po/exclude.pot b/po/exclude.pot index 1659eb01b..ab52e9990 100644 --- a/po/exclude.pot +++ b/po/exclude.pot @@ -2296,10 +2296,6 @@ msgstr "" msgid "WEEKDAY" msgstr "" -#: grub-core/io/lzopio.c:30 -msgid "‰LZO" -msgstr "" - #: grub-core/kern/dl.c:412 msgid "grub_mod_init" msgstr "" @@ -4215,22 +4211,10 @@ msgstr "" msgid "ext*" msgstr "" -#: grub-core/partmap/msdos.c:74 -msgid "ÔA õ" -msgstr "" - -#: grub-core/partmap/msdos.c:80 -msgid "ØA õ" -msgstr "" - #: grub-core/partmap/msdos.c:86 msgid "HP Backup and Recovery Manager (?)" msgstr "" -#: grub-core/partmap/msdos.c:87 -msgid "pŠ]F5Å“®=†ý±U>à" -msgstr "" - #: grub-core/partmap/msdos.c:94 msgid "ycgl" msgstr "" @@ -4574,10 +4558,6 @@ msgstr "" msgid " failed: %ld\n" msgstr "" -#: grub-core/lib/xzembed/xz_stream.h:35 -msgid "ý7zXZ" -msgstr "" - #: grub-core/lib/xzembed/xz_stream.h:38 msgid "YZ" msgstr "" @@ -7173,3 +7153,294 @@ msgstr "" #: util/grub-mkimagexx.c:845 msgid "CALL26 Relocation out of range" msgstr "" + +#: grub-core/commands/verify.c:313 +msgid "\x99" +msgstr "" + +#: grub-core/commands/videotest.c:122 +msgid "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00" + " \xC2\xA1\xCF\x84\xC3\xA4u! " + " \xE2\x84\xA4\xE2\x8A\x86\xE2\x84\x9D" +msgstr "" + +#: grub-core/disk/luks.c:40 +msgid "LUKS\xBA\xBE" +msgstr "" + +#: grub-core/disk/lvmparse.c:67 grub-core/disk/lvmparse.c:69 +msgid " = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:115 grub-core/disk/lvmparse.c:123 +#: grub-core/disk/lvmparse.c:167 grub-core/disk/lvmparse.c:170 +msgid "id = \"" +msgstr "" + +#: grub-core/disk/lvmparse.c:127 +msgid "extent_size = " +msgstr "" + +#: grub-core/disk/lvmparse.c:143 grub-core/disk/lvmparse.c:146 +msgid "physical_volumes {" +msgstr "" + +#: grub-core/disk/lvmparse.c:174 +msgid "pe_start = " +msgstr "" + +#: grub-core/disk/lvmparse.c:199 +msgid "logical_volumes" +msgstr "" + +#: grub-core/disk/lvmparse.c:202 +msgid "logical_volumes = " +msgstr "" + +#: grub-core/disk/lvmparse.c:226 grub-core/disk/lvmparse.c:227 +msgid "status" +msgstr "" + +#: grub-core/disk/lvmparse.c:226 +msgid "VISIBLE" +msgstr "" + +#: grub-core/disk/lvmparse.c:227 +msgid "PVMOVE" +msgstr "" + +#: grub-core/disk/lvmparse.c:228 +msgid "segment_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:246 +msgid "segment" +msgstr "" + +#: grub-core/disk/lvmparse.c:255 +msgid "start_extent = " +msgstr "" + +#: grub-core/disk/lvmparse.c:263 +msgid "extent_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:272 grub-core/disk/lvmparse.c:275 +msgid "type = \"" +msgstr "" + +#: grub-core/disk/lvmparse.c:277 grub-core/disk/lvmparse.c:278 +msgid "striped\"" +msgstr "" + +#: grub-core/disk/lvmparse.c:282 +msgid "stripe_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:292 grub-core/disk/lvmparse.c:396 +msgid "stripe_size = " +msgstr "" + +#: grub-core/disk/lvmparse.c:299 grub-core/disk/lvmparse.c:307 +msgid "stripes = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:332 +msgid "mirror\"" +msgstr "" + +#: grub-core/disk/lvmparse.c:336 +msgid "mirror_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:350 grub-core/disk/lvmparse.c:358 +msgid "mirrors = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:375 grub-core/disk/lvmparse.c:376 +#: grub-core/disk/lvmparse.c:377 grub-core/disk/lvmparse.c:384 +msgid "raid" +msgstr "" + +#: grub-core/disk/lvmparse.c:378 +msgid "raidX" +msgstr "" + +#: grub-core/disk/lvmparse.c:386 +msgid "device_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:410 grub-core/disk/lvmparse.c:418 +msgid "raids = [" +msgstr "" + +#: grub-core/fs/cpio.c:24 +msgid "\xc7\x71" +msgstr "" + +#: grub-core/fs/cpio_be.c:23 +msgid "\x71\xc7" +msgstr "" + +#: grub-core/gfxmenu/gui_circular_progress.c:244 +msgid "\xc2\xb0" +msgstr "" + +#: grub-core/kern/ieee1275/cmain.c:88 +msgid "IBM pSeries (emulated by qemu)" +msgstr "" + +#: grub-core/lib/all_video.c:36 +msgid "/video.lst" +msgstr "" + +#: grub-core/osdep/unix/config.c:108 +#, c-format +msgid "" +"'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" " +"\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\"" +msgstr "" + +#: include/grub/dl.h:141 +msgid "license" +msgstr "" + +#: util/grub-install.c:1106 +msgid "BOOTAA64.EFI" +msgstr "" + +#: util/grub-install.c:1133 +msgid "grubaa64.efi" +msgstr "" + +#: util/grub-install.c:1274 +msgid "GRUB_ENABLE_CRYPTODISK=y" +msgstr "" + +#: util/grub-mkrescue.c:656 +msgid "part_gpt" +msgstr "" + +#: util/grub-mkrescue.c:657 +msgid "part_msdos" +msgstr "" + +#: util/grub-mkrescue.c:663 util/grub-mkrescue.c:668 util/grub-mkrescue.c:723 +msgid "part_apple" +msgstr "" + +#: util/grub-mkrescue.c:677 +msgid "bootaa64.efi" +msgstr "" + +#: util/grub-probe.c:136 util/grub-probe.c:151 util/grub-probe.c:190 +#: util/grub-probe.c:247 +#, c-format +msgid "%s%c" +msgstr "" + +#: util/grub-probe.c:233 +#, c-format +msgid "lvm%c" +msgstr "" + +#: util/grub-probe.c:237 +#, c-format +msgid "ldm%c" +msgstr "" + +#: util/grub-probe.c:245 +#, c-format +msgid "diskfilter%c" +msgstr "" + +#: util/grub-probe.c:250 +#, c-format +msgid "raid5rec%c" +msgstr "" + +#: util/grub-probe.c:252 +#, c-format +msgid "raid6rec%c" +msgstr "" + +#: util/grub-mkrescue.c:136 +#, c-format +msgid "%s\n\n%s\n\n%s" +msgstr "" + +#: grub-core/kern/arm/cache.c:133 +msgid "couldn't get memory map, not enabling caches" +msgstr "" + +#: grub-core/kern/arm/cache.c:149 +#, c-format +msgid "%d crossers\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:154 +msgid "couldn't allocate place for MMU table, not enabling caches" +msgstr "" + +#: grub-core/kern/arm/cache.c:212 +msgid "MMU tables generated\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:216 +msgid "enabling MMU\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:218 +msgid "MMU enabled\n" +msgstr "" + +#: grub-core/commands/verify.c:313 +msgid "™" +msgstr "" + +#: grub-core/commands/videotest.c:122 +msgid "Unicode test: happy☺ £ 5.00 ¡Ã„äu! ℤ⊆â„Â" +msgstr "" + +#: grub-core/disk/luks.c:40 +msgid "LUKSº¾" +msgstr "" + +#: grub-core/fs/cpio.c:24 +msgid "Çq" +msgstr "" + +#: grub-core/fs/cpio_be.c:23 +msgid "qÇ" +msgstr "" + +#: grub-core/gfxmenu/gui_circular_progress.c:244 +msgid "°" +msgstr "" + +#: grub-core/lib/xzembed/xz_stream.h:35 +msgid "ý7zXZ" +msgstr "" + +#: grub-core/partmap/msdos.c:74 +msgid "ÔA õ" +msgstr "" + +#: grub-core/partmap/msdos.c:80 +msgid "ØA õ" +msgstr "" + +#: grub-core/partmap/msdos.c:87 +msgid "pŠ]F5Ã…“®=†ý±U>à" +msgstr "" + +#: grub-core/io/lzopio.c:30 +msgid "" +"‰LZO\n" +"\n" +msgstr "" + +#: util/grub-probe.c:735 +#, c-format +msgid "%s\n%s %s %s" +msgstr "" From 018f79da6f6f0aab34ce501e62db77c89a23aca1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Feb 2015 20:19:57 +0300 Subject: [PATCH 0178/1167] grub-probe: free temporary variable --- util/grub-probe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-probe.c b/util/grub-probe.c index 08d477f5f..8f4aa6138 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -735,6 +735,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) ret = xasprintf ("%s\n%s %s %s", _("print TARGET"), _("available targets:"), t, def); free (t); + free (def); return ret; } From 87ec3b7fa9061f470616ed927fc140e995831c00 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Feb 2015 14:26:00 +0100 Subject: [PATCH 0179/1167] Don't continue to query block-size if disk doesn't have it. Stops poluting screen with a lot of "block-size: exception -21". --- grub-core/disk/ieee1275/ofdisk.c | 62 ++++++++++++++++++++++---------- include/grub/ieee1275/ofdisk.h | 3 -- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 5d8863782..331769b12 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -35,6 +35,7 @@ struct ofdisk_hash_ent char *grub_devpath; int is_boot; int is_removable; + int block_size_fails; /* Pointer to shortest available name on nodes representing canonical names, otherwise NULL. */ const char *shortest; @@ -42,6 +43,10 @@ struct ofdisk_hash_ent struct ofdisk_hash_ent *next; }; +static grub_err_t +grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, + struct ofdisk_hash_ent *op); + #define OFDISK_HASH_SZ 8 static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ]; @@ -375,6 +380,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) /* XXX: This should be large enough for any possible case. */ char prop[64]; grub_ssize_t actual; + grub_uint32_t block_size = 0; + grub_err_t err; if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, @@ -405,14 +412,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device"); } - grub_uint32_t block_size = 0; - if (grub_ofdisk_get_block_size (devpath, &block_size) == 0) - { - for (disk->log_sector_size = 0; - (1U << disk->log_sector_size) < block_size; - disk->log_sector_size++); - } - /* XXX: There is no property to read the number of blocks. There should be a property `#blocks', but it is not there. Perhaps it is possible to use seek for this. */ @@ -429,6 +428,18 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) return grub_errno; disk->id = (unsigned long) op; disk->data = op->open_path; + + err = grub_ofdisk_get_block_size (devpath, &block_size, op); + if (err) + return err; + if (block_size != 0) + { + for (disk->log_sector_size = 0; + (1U << disk->log_sector_size) < block_size; + disk->log_sector_size++); + } + else + disk->log_sector_size = 9; } return 0; @@ -589,8 +600,9 @@ grub_ofdisk_init (void) grub_disk_dev_register (&grub_ofdisk_dev); } -grub_err_t -grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) +static grub_err_t +grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, + struct ofdisk_hash_ent *op) { struct size_args_ieee1275 { @@ -612,20 +624,34 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) if (! last_ihandle) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); + *block_size = 0; + + if (op->block_size_fails >= 2) + return GRUB_ERR_NONE; + INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); args_ieee1275.method = (grub_ieee1275_cell_t) "block-size"; args_ieee1275.ihandle = last_ihandle; args_ieee1275.result = 1; - *block_size = GRUB_DISK_SECTOR_SIZE; - - if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result)) - grub_dprintf ("disk", "can't get block size\n"); - else - if (args_ieee1275.size1 - && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) - && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) + if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) + { + grub_dprintf ("disk", "can't get block size: failed call-method\n"); + op->block_size_fails++; + } + else if (args_ieee1275.result) + { + grub_dprintf ("disk", "can't get block size: %lld\n", + (long long) args_ieee1275.result); + op->block_size_fails++; + } + else if (args_ieee1275.size1 + && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) + && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) + { + op->block_size_fails = 0; *block_size = args_ieee1275.size1; + } return 0; } diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h index 3f5831787..2f69e3f19 100644 --- a/include/grub/ieee1275/ofdisk.h +++ b/include/grub/ieee1275/ofdisk.h @@ -22,7 +22,4 @@ extern void grub_ofdisk_init (void); extern void grub_ofdisk_fini (void); -extern grub_err_t grub_ofdisk_get_block_size (const char *device, - grub_uint32_t *block_size); - #endif /* ! GRUB_INIT_HEADER */ From aa6ccc05c10df14bc39a6a7d9d928d8180e3ef79 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 09:07:53 +0100 Subject: [PATCH 0180/1167] configure.ac: Set $CPPFLAGS when checking for no_app_regs. Fixes compilation for sparc64 with clang. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 908bb81e7..9e24d896d 100644 --- a/configure.ac +++ b/configure.ac @@ -741,6 +741,7 @@ if test x"$target_cpu" = xsparc64 ; then break fi CFLAGS="$TARGET_CFLAGS $cand -Werror" + CPPFLAGS="$TARGET_CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_mno_app_regs="$cand"], []) done From 77697d14e55eaf878639a630ab45563fa9556a97 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 09:12:10 +0100 Subject: [PATCH 0181/1167] types.h: Use __builtin_bswap* with clang. clang pretends to be GCC 4.2 but we use __builtin_bswap* only with GCC 4.3+. clang support __builtin_bswap*, so use it. --- include/grub/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/types.h b/include/grub/types.h index 79f765c62..e732efb5c 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -179,7 +179,7 @@ static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x) | (_x >> 56)); \ }) -#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) +#if (defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)) || defined(__clang__) static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x) { return __builtin_bswap32(x); From 064360e6671e0c5f2f47b73fd03b33be8a81f72c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:23:42 +0100 Subject: [PATCH 0182/1167] Remove libgcc dependency. libgcc for boot environment isn't always present and compatible. libgcc is often absent if endianness or bit-size at boot is different from running OS. libgcc may use optimised opcodes that aren't available on boot time. So instead of relying on libgcc shipped with the compiler, supply the functions in GRUB directly. Tests are present to ensure that those replacement functions behave the way compiler expects them to. --- conf/Makefile.common | 4 +- config.h.in | 1 + configure.ac | 25 +- grub-core/Makefile.am | 8 +- grub-core/Makefile.core.def | 43 +- grub-core/boot/decompressor/minilib.c | 11 +- grub-core/kern/arm/{misc.S => compiler-rt.S} | 0 grub-core/kern/compiler-rt.c | 404 +++++++++++++++++++ grub-core/kern/misc.c | 232 ----------- grub-core/kern/powerpc/compiler-rt.S | 130 ++++++ grub-core/lib/posix_wrap/string.h | 20 +- grub-core/tests/bswap_test.c | 121 ++++++ grub-core/tests/cmp_test.c | 190 +++++++++ grub-core/tests/ctz_test.c | 111 +++++ grub-core/tests/lib/functional_test.c | 5 + grub-core/tests/mul_test.c | 73 ++++ grub-core/tests/shift_test.c | 157 +++++++ include/grub/compiler-rt.h | 193 +++++++++ include/grub/libgcc.h | 91 ----- include/grub/misc.h | 99 +---- include/grub/xen.h | 2 + 21 files changed, 1441 insertions(+), 479 deletions(-) rename grub-core/kern/arm/{misc.S => compiler-rt.S} (100%) create mode 100644 grub-core/kern/compiler-rt.c create mode 100644 grub-core/kern/powerpc/compiler-rt.S create mode 100644 grub-core/tests/bswap_test.c create mode 100644 grub-core/tests/cmp_test.c create mode 100644 grub-core/tests/ctz_test.c create mode 100644 grub-core/tests/mul_test.c create mode 100644 grub-core/tests/shift_test.c create mode 100644 include/grub/compiler-rt.h delete mode 100644 include/grub/libgcc.h diff --git a/conf/Makefile.common b/conf/Makefile.common index 8861096a5..96e58c9a4 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -34,10 +34,8 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/ CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1 BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) -LDADD_KERNEL = $(TARGET_LIBGCC) - CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags diff --git a/config.h.in b/config.h.in index ea0f3834e..9e8f9911b 100644 --- a/config.h.in +++ b/config.h.in @@ -7,6 +7,7 @@ #endif #define GCRYPT_NO_DEPRECATED 1 +#define HAVE_MEMMOVE 1 /* Define to 1 to enable disk cache statistics. */ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ diff --git a/configure.ac b/configure.ac index 9e24d896d..be980adbb 100644 --- a/configure.ac +++ b/configure.ac @@ -1131,22 +1131,17 @@ fi # Set them to their new values for the tests below. CC="$TARGET_CC" -if test "x$TARGET_APPLE_LINKER" = x1 ; then +if test x"$platform" = xemu ; then +CFLAGS="$TARGET_CFLAGS -Wno-error" +elif test "x$TARGET_APPLE_LINKER" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then -TARGET_LIBGCC= -else -TARGET_LIBGCC=-lgcc -fi - -LIBS="$TARGET_LIBGCC" grub_ASM_USCORE -if test "x$TARGET_APPLE_LINKER" = x0 ; then +if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then if test x$grub_cv_asm_uscore = xyes; then DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" else @@ -1156,7 +1151,9 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" fi # Check for libgcc symbols -AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) +if test x"$platform" = xemu; then +AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) +fi if test "x$TARGET_APPLE_LINKER" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib -static" @@ -1717,12 +1714,6 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi -if test "x$grub_cv_cc_target_clang" = xno; then - TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" -else - TARGET_LDFLAGS_STATIC_LIBGCC= -fi - TARGET_CPP="$TARGET_CC -E" TARGET_CCAS=$TARGET_CC @@ -1739,8 +1730,6 @@ AC_SUBST(GRUB_TARGET_CPU) AC_SUBST(GRUB_PLATFORM) AC_SUBST(TARGET_OBJCONV) -AC_SUBST(TARGET_LIBGCC) -AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC) AC_SUBST(TARGET_CPP) AC_SUBST(TARGET_CCAS) AC_SUBST(TARGET_OBJ2ELF) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 5c087c83b..57c0b64e7 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -76,6 +76,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h +if COND_emu +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h +else +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h +endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h @@ -83,9 +88,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h -if !COND_clang -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h -endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h if COND_i386_pc diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index b539ccf9d..7a6fa21a4 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -132,6 +132,7 @@ kernel = { common = kern/rescue_reader.c; common = kern/term.c; + noemu = kern/compiler-rt.c; noemu = kern/mm.c; noemu = kern/time.c; noemu = kern/generic/millisleep.c; @@ -254,6 +255,7 @@ kernel = { powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; + powerpc_ieee1275 = kern/powerpc/compiler-rt.S; sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c; @@ -265,7 +267,7 @@ kernel = { arm = kern/arm/cache_armv7.S; extra_dist = kern/arm/cache.S; arm = kern/arm/cache.c; - arm = kern/arm/misc.S; + arm = kern/arm/compiler-rt.S; arm64 = kern/arm64/cache.c; arm64 = kern/arm64/cache_flush.S; @@ -443,13 +445,13 @@ image = { common = lib/xzembed/xz_dec_bcj.c; common = lib/xzembed/xz_dec_lzma2.c; common = lib/xzembed/xz_dec_stream.c; + common = kern/compiler-rt.c; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '$(TARGET_LIBGCC)'; - cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)'; + mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; + cflags = '-Wno-unreachable-code'; enable = mips; }; @@ -461,9 +463,7 @@ image = { cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '$(TARGET_LIBGCC)'; - cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)'; + mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; enable = mips; }; @@ -481,7 +481,7 @@ image = { name = fwstart; mips_loongson = boot/mips/loongson/fwstart.S; objcopyflags = '-O binary'; - ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; }; @@ -489,7 +489,7 @@ image = { name = fwstart_fuloong2f; mips_loongson = boot/mips/loongson/fuloong2f.S; objcopyflags = '-O binary'; - ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; }; @@ -1982,6 +1982,31 @@ module = { common = tests/div_test.c; }; +module = { + name = mul_test; + common = tests/mul_test.c; +}; + +module = { + name = shift_test; + common = tests/shift_test.c; +}; + +module = { + name = cmp_test; + common = tests/cmp_test.c; +}; + +module = { + name = ctz_test; + common = tests/ctz_test.c; +}; + +module = { + name = bswap_test; + common = tests/bswap_test.c; +}; + module = { name = videotest_checksum; common = tests/videotest_checksum.c; diff --git a/grub-core/boot/decompressor/minilib.c b/grub-core/boot/decompressor/minilib.c index 94edfd561..fc46ee07b 100644 --- a/grub-core/boot/decompressor/minilib.c +++ b/grub-core/boot/decompressor/minilib.c @@ -21,7 +21,7 @@ #include void * -memset (void *s, int c, grub_size_t len) +grub_memset (void *s, int c, grub_size_t len) { grub_uint8_t *ptr; for (ptr = s; len; ptr++, len--) @@ -68,15 +68,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n) return 0; } -int memcmp (const void *s1, const void *s2, grub_size_t n) - __attribute__ ((alias ("grub_memcmp"))); - -void *memmove (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); - -void *memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); - void *grub_decompressor_scratch; void diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/compiler-rt.S similarity index 100% rename from grub-core/kern/arm/misc.S rename to grub-core/kern/arm/compiler-rt.S diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c new file mode 100644 index 000000000..d4cc15513 --- /dev/null +++ b/grub-core/kern/compiler-rt.c @@ -0,0 +1,404 @@ +/* compiler-rt.c - compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010-2014 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 . + */ + +#include +#include + +#ifndef GRUB_EMBED_DECOMPRESSOR +void * GRUB_BUILTIN_ATTR +memcpy (void *dest, const void *src, grub_size_t n) +{ + return grub_memmove (dest, src, n); +} +void * GRUB_BUILTIN_ATTR +memmove (void *dest, const void *src, grub_size_t n) +{ + return grub_memmove (dest, src, n); +} +int GRUB_BUILTIN_ATTR +memcmp (const void *s1, const void *s2, grub_size_t n) +{ + return grub_memcmp (s1, s2, n); +} +void * GRUB_BUILTIN_ATTR +memset (void *s, int c, grub_size_t n) +{ + return grub_memset (s, c, n); +} + +#ifdef __APPLE__ + +void GRUB_BUILTIN_ATTR +__bzero (void *s, grub_size_t n) +{ + grub_memset (s, 0, n); +} + +#endif + +#if GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +__udivsi3 (grub_uint32_t a, grub_uint32_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_int32_t +__divsi3 (grub_int32_t a, grub_int32_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_uint32_t +__umodsi3 (grub_uint32_t a, grub_uint32_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int32_t +__modsi3 (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +grub_uint64_t +__udivdi3 (grub_uint64_t a, grub_uint64_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_uint64_t +__umoddi3 (grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int64_t +__divdi3 (grub_int64_t a, grub_int64_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_int64_t +__moddi3 (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +#endif + +#endif + +#ifdef NEED_CTZDI2 + +unsigned +__ctzdi2 (grub_uint64_t x) +{ + unsigned ret = 0; + if (!x) + return 64; + if (!(x & 0xffffffff)) + { + x >>= 32; + ret |= 32; + } + if (!(x & 0xffff)) + { + x >>= 16; + ret |= 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret |= 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret |= 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret |= 2; + } + if (!(x & 0x1)) + { + x >>= 1; + ret |= 1; + } + return ret; +} +#endif + +#ifdef NEED_CTZSI2 +unsigned +__ctzsi2 (grub_uint32_t x) +{ + unsigned ret = 0; + if (!x) + return 32; + + if (!(x & 0xffff)) + { + x >>= 16; + ret |= 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret |= 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret |= 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret |= 2; + } + if (!(x & 0x1)) + { + x >>= 1; + ret |= 1; + } + return ret; +} + +#endif + + +#if defined (__clang__) && !defined(GRUB_EMBED_DECOMPRESSOR) +/* clang emits references to abort(). */ +void __attribute__ ((noreturn)) +abort (void) +{ + grub_fatal ("compiler abort"); +} +#endif + +#if (defined (__MINGW32__) || defined (__CYGWIN__)) +void __register_frame_info (void) +{ +} + +void __deregister_frame_info (void) +{ +} + +void ___chkstk_ms (void) +{ +} + +void __chkstk_ms (void) +{ +} +#endif + +union component64 +{ + grub_uint64_t full; + struct + { +#ifdef GRUB_CPU_WORDS_BIGENDIAN + grub_uint32_t high; + grub_uint32_t low; +#else + grub_uint32_t low; + grub_uint32_t high; +#endif + }; +}; + +#if defined (__powerpc__) || defined (__arm__) || defined(__mips__) + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__lshrdi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + w.high = 0; + w.low = (grub_uint32_t) uu.high >> -bm; + } + else + { + const grub_uint32_t carries = (grub_uint32_t) uu.high << bm; + + w.high = (grub_uint32_t) uu.high >> b; + w.low = ((grub_uint32_t) uu.low >> b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__ashrdi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + /* w.high = 1..1 or 0..0 */ + w.high = ((grub_int32_t) uu.high) >> (32 - 1); + w.low = ((grub_int32_t) uu.high) >> -bm; + } + else + { + const grub_uint32_t carries = ((grub_uint32_t) uu.high) << bm; + + w.high = ((grub_int32_t) uu.high) >> b; + w.low = ((grub_uint32_t) uu.low >> b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__ashldi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + w.low = 0; + w.high = (grub_uint32_t) uu.low << -bm; + } + else + { + const grub_uint32_t carries = (grub_uint32_t) uu.low >> bm; + + w.low = (grub_uint32_t) uu.low << b; + w.high = ((grub_uint32_t) uu.high << b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +int +__ucmpdi2 (grub_uint64_t a, grub_uint64_t b) +{ + union component64 ac, bc; + ac.full = a; + bc.full = b; + + if (ac.high < bc.high) + return 0; + else if (ac.high > bc.high) + return 2; + + if (ac.low < bc.low) + return 0; + else if (ac.low > bc.low) + return 2; + return 1; +} + +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined(__arm__) + +/* Based on libgcc2.c from gcc suite. */ +grub_uint32_t +__bswapsi2 (grub_uint32_t u) +{ + return ((((u) & 0xff000000) >> 24) + | (((u) & 0x00ff0000) >> 8) + | (((u) & 0x0000ff00) << 8) + | (((u) & 0x000000ff) << 24)); +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__bswapdi2 (grub_uint64_t u) +{ + return ((((u) & 0xff00000000000000ull) >> 56) + | (((u) & 0x00ff000000000000ull) >> 40) + | (((u) & 0x0000ff0000000000ull) >> 24) + | (((u) & 0x000000ff00000000ull) >> 8) + | (((u) & 0x00000000ff000000ull) << 8) + | (((u) & 0x0000000000ff0000ull) << 24) + | (((u) & 0x000000000000ff00ull) << 40) + | (((u) & 0x00000000000000ffull) << 56)); +} + + +#endif + +#ifdef __arm__ +grub_uint32_t +__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) + __attribute__ ((alias ("__udivsi3"))); +grub_int32_t +__aeabi_idiv (grub_int32_t a, grub_int32_t b) + __attribute__ ((alias ("__divsi3"))); +void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memset (void *s, int c, grub_size_t n) + __attribute__ ((alias ("memset"))); + +int +__aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b) +{ + return __ucmpdi2 (a, b) - 1; +} + +grub_uint64_t +__aeabi_lasr (grub_uint64_t u, int b) + __attribute__ ((alias ("__ashrdi3"))); +grub_uint64_t +__aeabi_llsr (grub_uint64_t u, int b) + __attribute__ ((alias ("__lshrdi3"))); + +grub_uint64_t +__aeabi_llsl (grub_uint64_t u, int b) + __attribute__ ((alias ("__ashldi3"))); + +#endif diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index b0347e7e2..906d2c2f7 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -95,25 +95,6 @@ grub_memmove (void *dest, const void *src, grub_size_t n) return dest; } -#ifndef __APPLE__ -void *memmove (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); -/* GCC emits references to memcpy() for struct copies etc. */ -void *memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); -#else -void * GRUB_BUILTIN_ATTR -memcpy (void *dest, const void *src, grub_size_t n) -{ - return grub_memmove (dest, src, n); -} -void * GRUB_BUILTIN_ATTR -memmove (void *dest, const void *src, grub_size_t n) -{ - return grub_memmove (dest, src, n); -} -#endif - char * grub_strcpy (char *dest, const char *src) { @@ -253,16 +234,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n) return 0; } -#ifndef __APPLE__ -int memcmp (const void *s1, const void *s2, grub_size_t n) - __attribute__ ((alias ("grub_memcmp"))); -#else -int GRUB_BUILTIN_ATTR -memcmp (const void *s1, const void *s2, grub_size_t n) -{ - return grub_memcmp (s1, s2, n); -} -#endif int grub_strcmp (const char *s1, const char *s2) @@ -532,26 +503,6 @@ grub_memset (void *s, int c, grub_size_t len) return s; } -#ifndef __APPLE__ -void *memset (void *s, int c, grub_size_t n) - __attribute__ ((alias ("grub_memset"))); -#else -void * GRUB_BUILTIN_ATTR -memset (void *s, int c, grub_size_t n) -{ - return grub_memset (s, c, n); -} - -#endif - -#if !defined(GRUB_UTIL) && defined(__APPLE__) -void GRUB_BUILTIN_ATTR -__bzero (void *s, grub_size_t n) -{ - grub_memset (s, 0, n); -} - -#endif grub_size_t grub_strlen (const char *s) @@ -631,163 +582,6 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) return q; } -#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) - -#if GRUB_DIVISION_IN_SOFTWARE - -grub_uint32_t -__udivsi3 (grub_uint32_t a, grub_uint32_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_int32_t -__divsi3 (grub_int32_t a, grub_int32_t b) -{ - return grub_divmod64s (a, b, 0); -} - -grub_uint32_t -__umodsi3 (grub_uint32_t a, grub_uint32_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -grub_int32_t -__modsi3 (grub_int32_t a, grub_int32_t b) -{ - grub_int64_t ret; - grub_divmod64s (a, b, &ret); - return ret; -} - -grub_uint64_t -__udivdi3 (grub_uint64_t a, grub_uint64_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_uint64_t -__umoddi3 (grub_uint64_t a, grub_uint64_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -grub_int64_t -__divdi3 (grub_int64_t a, grub_int64_t b) -{ - return grub_divmod64s (a, b, 0); -} - -grub_int64_t -__moddi3 (grub_int64_t a, grub_int64_t b) -{ - grub_int64_t ret; - grub_divmod64s (a, b, &ret); - return ret; -} - -#endif - -#ifdef NEED_CTZDI2 - -unsigned -__ctzdi2 (grub_uint64_t x) -{ - unsigned ret = 0; - if (!x) - return 64; - if (!(x & 0xffffffff)) - { - x >>= 32; - ret |= 32; - } - if (!(x & 0xffff)) - { - x >>= 16; - ret |= 16; - } - if (!(x & 0xff)) - { - x >>= 8; - ret |= 8; - } - if (!(x & 0xf)) - { - x >>= 4; - ret |= 4; - } - if (!(x & 0x3)) - { - x >>= 2; - ret |= 2; - } - if (!(x & 0x1)) - { - x >>= 1; - ret |= 1; - } - return ret; -} -#endif - -#ifdef NEED_CTZSI2 -unsigned -__ctzsi2 (grub_uint32_t x) -{ - unsigned ret = 0; - if (!x) - return 32; - - if (!(x & 0xffff)) - { - x >>= 16; - ret |= 16; - } - if (!(x & 0xff)) - { - x >>= 8; - ret |= 8; - } - if (!(x & 0xf)) - { - x >>= 4; - ret |= 4; - } - if (!(x & 0x3)) - { - x >>= 2; - ret |= 2; - } - if (!(x & 0x1)) - { - x >>= 1; - ret |= 1; - } - return ret; -} - -#endif - -#ifdef __arm__ -grub_uint32_t -__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) - __attribute__ ((alias ("__udivsi3"))); -grub_int32_t -__aeabi_idiv (grub_int32_t a, grub_int32_t b) - __attribute__ ((alias ("__divsi3"))); -void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memcpy"))); -void *__aeabi_memset (void *s, int c, grub_size_t n) - __attribute__ ((alias ("grub_memset"))); -#endif - -#endif /* GRUB_UTIL */ - /* Convert a long long value to a string. This function avoids 64-bit modular arithmetic or divisions. */ static inline char * @@ -1296,15 +1090,6 @@ grub_abort (void) grub_exit (); } -#if defined (__clang__) && !defined (GRUB_UTIL) -/* clang emits references to abort(). */ -void __attribute__ ((noreturn)) -abort (void) -{ - grub_abort (); -} -#endif - void grub_fatal (const char *fmt, ...) { @@ -1317,23 +1102,6 @@ grub_fatal (const char *fmt, ...) grub_abort (); } -#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) -void __register_frame_info (void) -{ -} - -void __deregister_frame_info (void) -{ -} -void ___chkstk_ms (void) -{ -} - -void __chkstk_ms (void) -{ -} -#endif - #if BOOT_TIME_STATS #include diff --git a/grub-core/kern/powerpc/compiler-rt.S b/grub-core/kern/powerpc/compiler-rt.S new file mode 100644 index 000000000..b3b912db6 --- /dev/null +++ b/grub-core/kern/powerpc/compiler-rt.S @@ -0,0 +1,130 @@ +/* + * Special support for eabi and SVR4 + * + * Copyright (C) 1995-2014 Free Software Foundation, Inc. + * Written By Michael Meissner + * 64-bit support written by David Edelsohn + * + * This file 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, or (at your option) any + * later version. + * + * This file 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. + * + * Under Section 7 of GPL version 3, you are granted additional + * permissions described in the GCC Runtime Library Exception, version + * 3.1, as published by the Free Software Foundation. + * + * You should have received a copy of the GNU General Public License and + * a copy of the GCC Runtime Library Exception along with this program; + * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * . + */ + +/* Do any initializations needed for the eabi environment */ + +#include +#include + + .section ".text" + +#define CFI_RESTORE(reg) .cfi_restore reg +#define CFI_OFFSET(reg, off) .cfi_offset reg, off +#define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg +#define CFI_STARTPROC .cfi_startproc +#define CFI_ENDPROC .cfi_endproc + +/* Routines for restoring integer registers, called by the compiler. */ +/* Called with r11 pointing to the stack header word of the caller of the */ +/* function, just beyond the end of the integer restore area. */ + +CFI_STARTPROC +CFI_DEF_CFA_REGISTER (11) +CFI_OFFSET (65, 4) +CFI_OFFSET (14, -72) +CFI_OFFSET (15, -68) +CFI_OFFSET (16, -64) +CFI_OFFSET (17, -60) +CFI_OFFSET (18, -56) +CFI_OFFSET (19, -52) +CFI_OFFSET (20, -48) +CFI_OFFSET (21, -44) +CFI_OFFSET (22, -40) +CFI_OFFSET (23, -36) +CFI_OFFSET (24, -32) +CFI_OFFSET (25, -28) +CFI_OFFSET (26, -24) +CFI_OFFSET (27, -20) +CFI_OFFSET (28, -16) +CFI_OFFSET (29, -12) +CFI_OFFSET (30, -8) +CFI_OFFSET (31, -4) +FUNCTION(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */ +CFI_RESTORE (14) +FUNCTION(_restgpr_15_x) lwz 15,-68(11) +CFI_RESTORE (15) +FUNCTION(_restgpr_16_x) lwz 16,-64(11) +CFI_RESTORE (16) +FUNCTION(_restgpr_17_x) lwz 17,-60(11) +CFI_RESTORE (17) +FUNCTION(_restgpr_18_x) lwz 18,-56(11) +CFI_RESTORE (18) +FUNCTION(_restgpr_19_x) lwz 19,-52(11) +CFI_RESTORE (19) +FUNCTION(_restgpr_20_x) lwz 20,-48(11) +CFI_RESTORE (20) +FUNCTION(_restgpr_21_x) lwz 21,-44(11) +CFI_RESTORE (21) +FUNCTION(_restgpr_22_x) lwz 22,-40(11) +CFI_RESTORE (22) +FUNCTION(_restgpr_23_x) lwz 23,-36(11) +CFI_RESTORE (23) +FUNCTION(_restgpr_24_x) lwz 24,-32(11) +CFI_RESTORE (24) +FUNCTION(_restgpr_25_x) lwz 25,-28(11) +CFI_RESTORE (25) +FUNCTION(_restgpr_26_x) lwz 26,-24(11) +CFI_RESTORE (26) +FUNCTION(_restgpr_27_x) lwz 27,-20(11) +CFI_RESTORE (27) +FUNCTION(_restgpr_28_x) lwz 28,-16(11) +CFI_RESTORE (28) +FUNCTION(_restgpr_29_x) lwz 29,-12(11) +CFI_RESTORE (29) +FUNCTION(_restgpr_30_x) lwz 30,-8(11) +CFI_RESTORE (30) +FUNCTION(_restgpr_31_x) lwz 0,4(11) + lwz 31,-4(11) +CFI_RESTORE (31) + mtlr 0 +CFI_RESTORE (65) + mr 1,11 +CFI_DEF_CFA_REGISTER (1) + blr +CFI_ENDPROC + +CFI_STARTPROC +FUNCTION(_savegpr_14) stw 14,-72(11) /* save gp registers */ +FUNCTION(_savegpr_15) stw 15,-68(11) +FUNCTION(_savegpr_16) stw 16,-64(11) +FUNCTION(_savegpr_17) stw 17,-60(11) +FUNCTION(_savegpr_18) stw 18,-56(11) +FUNCTION(_savegpr_19) stw 19,-52(11) +FUNCTION(_savegpr_20) stw 20,-48(11) +FUNCTION(_savegpr_21) stw 21,-44(11) +FUNCTION(_savegpr_22) stw 22,-40(11) +FUNCTION(_savegpr_23) stw 23,-36(11) +FUNCTION(_savegpr_24) stw 24,-32(11) +FUNCTION(_savegpr_25) stw 25,-28(11) +FUNCTION(_savegpr_26) stw 26,-24(11) +FUNCTION(_savegpr_27) stw 27,-20(11) +FUNCTION(_savegpr_28) stw 28,-16(11) +FUNCTION(_savegpr_29) stw 29,-12(11) +FUNCTION(_savegpr_30) stw 30,-8(11) +FUNCTION(_savegpr_31) stw 31,-4(11) + blr +CFI_ENDPROC diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h index c4b9bf089..7ae6eee97 100644 --- a/grub-core/lib/posix_wrap/string.h +++ b/grub-core/lib/posix_wrap/string.h @@ -42,21 +42,6 @@ strcasecmp (const char *s1, const char *s2) return grub_strcasecmp (s1, s2); } -#ifdef GRUB_UTIL -static inline void * -memcpy (void *dest, const void *src, grub_size_t n) -{ - return grub_memcpy (dest, src, n); -} - -static inline int -memcmp (const void *s1, const void *s2, grub_size_t n) -{ - return grub_memcmp (s1, s2, n); -} - -#endif - static inline void bcopy (const void *src, void *dest, grub_size_t n) { @@ -99,4 +84,9 @@ memchr (const void *s, int c, grub_size_t n) return grub_memchr (s, c, n); } +#define memcmp grub_memcmp +#define memcpy grub_memcpy +#define memmove grub_memmove +#define memset grub_memset + #endif diff --git a/grub-core/tests/bswap_test.c b/grub-core/tests/bswap_test.c new file mode 100644 index 000000000..4eb3a9814 --- /dev/null +++ b/grub-core/tests/bswap_test.c @@ -0,0 +1,121 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +static void +test16 (grub_uint16_t a) +{ + grub_uint16_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes16 (a); + c = grub_swap_bytes16 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 2; i++) + { + grub_test_assert (ap[i] == bp[1 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test32 (grub_uint32_t a) +{ + grub_uint32_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes32 (a); + c = grub_swap_bytes32 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 4; i++) + { + grub_test_assert (ap[i] == bp[3 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test64 (grub_uint64_t a) +{ + grub_uint64_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes64 (a); + c = grub_swap_bytes64 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 4; i++) + { + grub_test_assert (ap[i] == bp[7 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test_all(grub_uint64_t a) +{ + test64 (a); + test32 (a); + test16 (a); +} + +static void +bswap_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (bswap_test, bswap_test); diff --git a/grub-core/tests/cmp_test.c b/grub-core/tests/cmp_test.c new file mode 100644 index 000000000..af5b39576 --- /dev/null +++ b/grub-core/tests/cmp_test.c @@ -0,0 +1,190 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[][2] = { + { 0xffffffffffffffffULL, 1}, + { 1, 0xffffffffffffffffULL}, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL}, + { 1, 1 }, + { 2, 1 } +}; + +/* Don't change those to use shift as shift may call to compile rt + functions and we're not testing them now. + */ +static int +leading_bit64 (grub_uint64_t a) +{ + return !!(a & 0x8000000000000000LL); +} + +static int +leading_bit32 (grub_uint32_t a) +{ + return !!(a & 0x80000000); +} + +/* Computes (a < b) without involving comparison operator. */ +static int +is_less32 (grub_uint32_t a, grub_uint32_t b) +{ + if (leading_bit32(a) && !leading_bit32(b)) + return 0; + if (!leading_bit32(a) && leading_bit32(b)) + return 1; + return leading_bit32(a - b); +} + +static void +test32 (grub_uint32_t a, grub_uint32_t b) +{ + grub_test_assert ((a < b) == is_less32(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less32(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less32(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less32(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less32(a, b) && is_less32(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less32s (grub_int32_t a, grub_int32_t b) +{ + if (leading_bit32(a) && !leading_bit32(b)) + return 1; /* a < 0 && b >= 0. */ + if (!leading_bit32(a) && leading_bit32(b)) + return 0; /* b < 0 && a >= 0. */ + return leading_bit32(a - b); +} + +static void +test32s (grub_int32_t a, grub_int32_t b) +{ + grub_test_assert ((a < b) == is_less32s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less32s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less32s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less32s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less32s(a, b) && is_less32s(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less64 (grub_uint64_t a, grub_uint64_t b) +{ + if (leading_bit64(a) && !leading_bit64(b)) + return 0; + if (!leading_bit64(a) && leading_bit64(b)) + return 1; + return leading_bit64(a - b); +} + +static void +test64 (grub_uint64_t a, grub_uint64_t b) +{ + grub_test_assert ((a < b) == is_less64(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less64(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less64(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less64(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less64(a, b) && is_less64(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less64s (grub_int64_t a, grub_int64_t b) +{ + if (leading_bit64(a) && !leading_bit64(b)) + return 1; /* a < 0 && b >= 0. */ + if (!leading_bit64(a) && leading_bit64(b)) + return 0; /* b < 0 && a >= 0. */ + return leading_bit64(a - b); +} + +static void +test64s (grub_int64_t a, grub_int64_t b) +{ + grub_test_assert ((a < b) == is_less64s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less64s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less64s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less64s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less64s(a, b) && is_less64s(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +static void +test_all(grub_uint64_t a, grub_uint64_t b) +{ + test64 (a, b); + test32 (a, b); + test64s (a, b); + test32s (a, b); + test64s (a, -b); + test32s (a, -b); + test64s (-a, b); + test32s (-a, b); + test64s (-a, -b); + test32s (-a, -b); +} + +static void +cmp_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i][0], vectors[i][1]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a, b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (cmp_test, cmp_test); diff --git a/grub-core/tests/ctz_test.c b/grub-core/tests/ctz_test.c new file mode 100644 index 000000000..eb7a1df38 --- /dev/null +++ b/grub-core/tests/ctz_test.c @@ -0,0 +1,111 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +/* ull version is not used on i386 other than in this test. + Avoid requiring extra function. + */ +#if defined (__i386__) +#define SKIP_ULL 1 +#endif + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +static void +test_ui (unsigned int a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctz(a << i) == i, + "ctz mismatch: ctz(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} + +static void +test_ul (unsigned long a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctzl(a << i) == i, + "ctzl mismatch: ctzl(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} + +#ifndef SKIP_ULL +static void +test_ull (unsigned long long a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctzll(a << i) == i, + "ctzll mismatch: ctzll(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} +#endif + +static void +test_all(grub_uint64_t a) +{ + test_ui (a); + test_ul (a); +#ifndef SKIP_ULL + test_ull (a); +#endif +} + +static void +ctz_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (ctz_test, ctz_test); diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index 5be7a58e5..d4822a124 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -65,6 +65,11 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)), grub_dl_load ("pbkdf2_test"); grub_dl_load ("signature_test"); grub_dl_load ("sleep_test"); + grub_dl_load ("bswap_test"); + grub_dl_load ("ctz_test"); + grub_dl_load ("cmp_test"); + grub_dl_load ("mul_test"); + grub_dl_load ("shift_test"); FOR_LIST_ELEMENTS (test, grub_test_list) ok = !grub_test_run (test) && ok; diff --git a/grub-core/tests/mul_test.c b/grub-core/tests/mul_test.c new file mode 100644 index 000000000..cd6423192 --- /dev/null +++ b/grub-core/tests/mul_test.c @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[][2] = { + { 0xffffffffffffffffULL, 1}, + { 1, 0xffffffffffffffffULL}, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL}, + { 1, 1 }, + { 2, 1 } +}; + +static void +test64(grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t r1 = a * b, r2 = 0, r3; + int i; + for (i = 0; i < 64; i++) + if ((a & (1LL << i))) + r2 += b << i; + r3 = ((grub_int64_t) a) * ((grub_int64_t) b); + grub_test_assert (r1 == r2, + "multiplication mismatch (u): 0x%llx x 0x%llx = 0x%llx != 0x%llx", + (long long) a, (long long) b, (long long) r2, (long long) r1); + grub_test_assert (r3 == r2, + "multiplication mismatch (s): 0x%llx x 0x%llx = 0x%llx != 0x%llx", + (long long) a, (long long) b, (long long) r2, (long long) r3); +} + +static void +mul_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test64 (vectors[i][0], vectors[i][1]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test64 (a, b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (mul_test, mul_test); diff --git a/grub-core/tests/shift_test.c b/grub-core/tests/shift_test.c new file mode 100644 index 000000000..4120f520a --- /dev/null +++ b/grub-core/tests/shift_test.c @@ -0,0 +1,157 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +/* We're testing shifts, don't replace access to this with a shift. */ +static const grub_uint8_t bitmask[] = + { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; + +typedef union { + grub_uint64_t v64; + grub_uint8_t v8[8]; +} grub_raw_u64_t; + +static int +get_bit64 (grub_uint64_t v, int b) +{ + grub_raw_u64_t vr = { .v64 = v }; + grub_uint8_t *p = vr.v8; + if (b >= 64) + return 0; +#ifdef GRUB_CPU_WORDS_BIGENDIAN + p += 7 - b / 8; +#else + p += b / 8; +#endif + return !!(*p & bitmask[b % 8]); +} + +static grub_uint64_t +set_bit64 (grub_uint64_t v, int b) +{ + grub_raw_u64_t vr = { .v64 = v }; + grub_uint8_t *p = vr.v8; + if (b >= 64) + return v; +#ifdef GRUB_CPU_WORDS_BIGENDIAN + p += 7 - b / 8; +#else + p += b / 8; +#endif + *p |= bitmask[b % 8]; + return vr.v64; +} + +static grub_uint64_t +left_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = 0; i + s < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i + s); + return r; +} + +static grub_uint64_t +right_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = s; i < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i - s); + return r; +} + +static grub_uint64_t +arithmetic_right_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = s; i < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i - s); + if (get_bit64 (v, 63)) + for (i -= s; i < 64; i++) + r = set_bit64 (r, i); + + return r; +} + +static void +test64 (grub_uint64_t v) +{ + int i; + for (i = 0; i < 64; i++) + { + grub_test_assert ((v << i) == left_shift64 (v, i), + "lshift wrong: 0x%llx << %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (v << i), (long long) left_shift64 (v, i)); + grub_test_assert ((v >> i) == right_shift64 (v, i), + "rshift wrong: 0x%llx >> %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (v >> i), (long long) right_shift64 (v, i)); + grub_test_assert ((((grub_int64_t) v) >> i) == (grub_int64_t) arithmetic_right_shift64 (v, i), + "arithmetic rshift wrong: ((grub_int64_t) 0x%llx) >> %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (((grub_int64_t) v) >> i), (long long) arithmetic_right_shift64 (v, i)); + } +} + +static void +test_all(grub_uint64_t a) +{ + test64 (a); +} + +static void +shift_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 4000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (shift_test, shift_test); diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h new file mode 100644 index 000000000..9265c7e80 --- /dev/null +++ b/include/grub/compiler-rt.h @@ -0,0 +1,193 @@ +/* compiler-rt.h - prototypes for compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 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 . + */ + +#ifndef GRUB_COMPILER_RT_HEADER +#define GRUB_COMPILER_RT_HEADER 1 + +#include +#include +#include +#include + +#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); + +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); + +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); + +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); + +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); + +#endif + +#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || defined (__arm__) +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +#define NEED_CTZDI2 1 +#endif + +#if defined (__mips__) || defined (__arm__) +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); +#define NEED_CTZSI2 1 +#endif + +#ifdef __arm__ +grub_uint32_t +EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +grub_uint32_t +EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); + +int +EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b); + +/* Needed for allowing modules to be compiled as thumb. */ +grub_uint64_t +EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); +grub_uint64_t +EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); + +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); + +grub_uint64_t +EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); + +#endif + + +#if defined (__powerpc__) + +void EXPORT_FUNC (_restgpr_14_x) (void); +void EXPORT_FUNC (_restgpr_15_x) (void); +void EXPORT_FUNC (_restgpr_16_x) (void); +void EXPORT_FUNC (_restgpr_17_x) (void); +void EXPORT_FUNC (_restgpr_18_x) (void); +void EXPORT_FUNC (_restgpr_19_x) (void); +void EXPORT_FUNC (_restgpr_20_x) (void); +void EXPORT_FUNC (_restgpr_21_x) (void); +void EXPORT_FUNC (_restgpr_22_x) (void); +void EXPORT_FUNC (_restgpr_23_x) (void); +void EXPORT_FUNC (_restgpr_24_x) (void); +void EXPORT_FUNC (_restgpr_25_x) (void); +void EXPORT_FUNC (_restgpr_26_x) (void); +void EXPORT_FUNC (_restgpr_27_x) (void); +void EXPORT_FUNC (_restgpr_28_x) (void); +void EXPORT_FUNC (_restgpr_29_x) (void); +void EXPORT_FUNC (_restgpr_30_x) (void); +void EXPORT_FUNC (_restgpr_31_x) (void); +void EXPORT_FUNC (_savegpr_14) (void); +void EXPORT_FUNC (_savegpr_15) (void); +void EXPORT_FUNC (_savegpr_16) (void); +void EXPORT_FUNC (_savegpr_17) (void); +void EXPORT_FUNC (_savegpr_18) (void); +void EXPORT_FUNC (_savegpr_19) (void); +void EXPORT_FUNC (_savegpr_20) (void); +void EXPORT_FUNC (_savegpr_21) (void); +void EXPORT_FUNC (_savegpr_22) (void); +void EXPORT_FUNC (_savegpr_23) (void); +void EXPORT_FUNC (_savegpr_24) (void); +void EXPORT_FUNC (_savegpr_25) (void); +void EXPORT_FUNC (_savegpr_26) (void); +void EXPORT_FUNC (_savegpr_27) (void); +void EXPORT_FUNC (_savegpr_28) (void); +void EXPORT_FUNC (_savegpr_29) (void); +void EXPORT_FUNC (_savegpr_30) (void); +void EXPORT_FUNC (_savegpr_31) (void); + +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) + +int +EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b); +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined (__arm__) +grub_uint32_t +EXPORT_FUNC(__bswapsi2) (grub_uint32_t u); + +grub_uint64_t +EXPORT_FUNC(__bswapdi2) (grub_uint64_t u); +#endif + +#if defined (__APPLE__) && defined(__i386__) +#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) +#else +#define GRUB_BUILTIN_ATTR +#endif + +/* Prototypes for aliases. */ +int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + +#ifdef __APPLE__ +void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); +#endif + +#if defined (__MINGW32__) || defined (__CYGWIN__) +void EXPORT_FUNC (__register_frame_info) (void); +void EXPORT_FUNC (__deregister_frame_info) (void); +void EXPORT_FUNC (___chkstk_ms) (void); +void EXPORT_FUNC (__chkstk_ms) (void); +#endif + +#endif + diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h deleted file mode 100644 index 8e93b6792..000000000 --- a/include/grub/libgcc.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2007,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 . - */ - -/* We need to include config-util.h.in for HAVE_*. */ -#ifndef __STDC_VERSION__ -#define __STDC_VERSION__ 0 -#endif -#include - -/* On x86 these functions aren't really needed. Save some space. */ -#if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 -void EXPORT_FUNC (__ashldi3) (void); -# endif -# ifdef HAVE___ASHRDI3 -void EXPORT_FUNC (__ashrdi3) (void); -# endif -# ifdef HAVE___LSHRDI3 -void EXPORT_FUNC (__lshrdi3) (void); -# endif -# ifdef HAVE___UCMPDI2 -void EXPORT_FUNC (__ucmpdi2) (void); -# endif -# ifdef HAVE___BSWAPSI2 -void EXPORT_FUNC (__bswapsi2) (void); -# endif -# ifdef HAVE___BSWAPDI2 -void EXPORT_FUNC (__bswapdi2) (void); -# endif -#endif - -#ifdef HAVE__RESTGPR_14_X -void EXPORT_FUNC (_restgpr_14_x) (void); -void EXPORT_FUNC (_restgpr_15_x) (void); -void EXPORT_FUNC (_restgpr_16_x) (void); -void EXPORT_FUNC (_restgpr_17_x) (void); -void EXPORT_FUNC (_restgpr_18_x) (void); -void EXPORT_FUNC (_restgpr_19_x) (void); -void EXPORT_FUNC (_restgpr_20_x) (void); -void EXPORT_FUNC (_restgpr_21_x) (void); -void EXPORT_FUNC (_restgpr_22_x) (void); -void EXPORT_FUNC (_restgpr_23_x) (void); -void EXPORT_FUNC (_restgpr_24_x) (void); -void EXPORT_FUNC (_restgpr_25_x) (void); -void EXPORT_FUNC (_restgpr_26_x) (void); -void EXPORT_FUNC (_restgpr_27_x) (void); -void EXPORT_FUNC (_restgpr_28_x) (void); -void EXPORT_FUNC (_restgpr_29_x) (void); -void EXPORT_FUNC (_restgpr_30_x) (void); -void EXPORT_FUNC (_restgpr_31_x) (void); -void EXPORT_FUNC (_savegpr_14) (void); -void EXPORT_FUNC (_savegpr_15) (void); -void EXPORT_FUNC (_savegpr_16) (void); -void EXPORT_FUNC (_savegpr_17) (void); -void EXPORT_FUNC (_savegpr_18) (void); -void EXPORT_FUNC (_savegpr_19) (void); -void EXPORT_FUNC (_savegpr_20) (void); -void EXPORT_FUNC (_savegpr_21) (void); -void EXPORT_FUNC (_savegpr_22) (void); -void EXPORT_FUNC (_savegpr_23) (void); -void EXPORT_FUNC (_savegpr_24) (void); -void EXPORT_FUNC (_savegpr_25) (void); -void EXPORT_FUNC (_savegpr_26) (void); -void EXPORT_FUNC (_savegpr_27) (void); -void EXPORT_FUNC (_savegpr_28) (void); -void EXPORT_FUNC (_savegpr_29) (void); -void EXPORT_FUNC (_savegpr_30) (void); -void EXPORT_FUNC (_savegpr_31) (void); -#endif - -#if defined (__arm__) -void EXPORT_FUNC (__aeabi_lasr) (void); -void EXPORT_FUNC (__aeabi_llsl) (void); -void EXPORT_FUNC (__aeabi_llsr) (void); -void EXPORT_FUNC (__aeabi_ulcmp) (void); -#endif diff --git a/include/grub/misc.h b/include/grub/misc.h index a05b3fd39..2a9f87cc2 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -71,12 +71,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n) return grub_memmove (dest, src, n); } -#if defined (__APPLE__) && defined(__i386__) && !defined (GRUB_UTIL) -#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) -#else -#define GRUB_BUILTIN_ATTR -#endif - #if defined(__x86_64__) && !defined (GRUB_UTIL) #if defined (__MINGW32__) || defined (__CYGWIN__) || defined (__MINGW64__) #define GRUB_ASM_ATTR __attribute__ ((sysv_abi)) @@ -85,19 +79,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n) #endif #endif -/* Prototypes for aliases. */ -#ifndef GRUB_UTIL -int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); - -#ifdef __APPLE__ -void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); -#endif - -#endif - int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n); int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2); int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); @@ -378,6 +359,7 @@ grub_int64_t EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n, grub_int64_t d, grub_int64_t *r); + grub_uint32_t EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n, grub_uint32_t d, @@ -388,41 +370,6 @@ EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n, grub_int32_t d, grub_int32_t *r); -#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE - -grub_uint32_t -EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_uint32_t -EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_int32_t -EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); - -grub_int32_t -EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); - -grub_int64_t -EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); - -grub_int64_t -EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); - -grub_uint64_t -EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); - -grub_uint64_t -EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); - -#endif - -#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) -void EXPORT_FUNC (__register_frame_info) (void); -void EXPORT_FUNC (__deregister_frame_info) (void); -void EXPORT_FUNC (___chkstk_ms) (void); -void EXPORT_FUNC (__chkstk_ms) (void); -#endif - /* Inline functions. */ static inline char * @@ -491,50 +438,6 @@ grub_error_load (const struct grub_error_saved *save) grub_errno = save->grub_errno; } -#ifndef GRUB_UTIL - -#if defined (__arm__) - -#endif - -#if defined (__sparc__) || defined (__powerpc__) -unsigned -EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); -#define NEED_CTZDI2 1 -#endif - -#if defined (__mips__) || defined (__arm__) -unsigned -EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); -#define NEED_CTZSI2 1 -#endif - -#ifdef __arm__ -grub_uint32_t -EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); -grub_int32_t -EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); -grub_uint32_t -EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); -grub_int32_t -EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); - -/* Needed for allowing modules to be compiled as thumb. */ -grub_uint64_t -EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); -grub_uint64_t -EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); - -void * -EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); -void * -EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); - -#endif - -#endif /* GRUB_UTIL */ - - #if BOOT_TIME_STATS struct grub_boot_time { diff --git a/include/grub/xen.h b/include/grub/xen.h index 6035d1a10..9ba3b8e6b 100644 --- a/include/grub/xen.h +++ b/include/grub/xen.h @@ -21,6 +21,8 @@ #define __XEN_INTERFACE_VERSION__ 0x0003020a +#define memset grub_memset + #ifdef ASM_FILE #define __ASSEMBLY__ #include From 9f95d12153098f8b3e4c34ad106c6402cd4dc0ff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:49:48 +0100 Subject: [PATCH 0183/1167] configure.ac: Remove unused COND_clang --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index be980adbb..16fa0da63 100644 --- a/configure.ac +++ b/configure.ac @@ -1759,7 +1759,6 @@ AC_SUBST(BUILD_LIBM) AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) -AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes]) AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) From 9d25b0da9a8cce9b3766f4e1b449d7936d5ba124 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:59:36 +0100 Subject: [PATCH 0184/1167] Remove emu libusb support. It's disabled by default and has been broken for a long time. As nobody is interested in fixing and maintaining it, remove it. --- configure.ac | 44 -------- gentpl.py | 2 +- grub-core/Makefile.am | 3 - grub-core/Makefile.core.def | 14 --- grub-core/bus/usb/emu/usb.c | 203 ------------------------------------ include/grub/libusb.h | 29 ------ 6 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 grub-core/bus/usb/emu/usb.c delete mode 100644 include/grub/libusb.h diff --git a/configure.ac b/configure.ac index 16fa0da63..2200776d3 100644 --- a/configure.ac +++ b/configure.ac @@ -1255,10 +1255,6 @@ else fi AC_SUBST([BOOT_TIME_STATS]) -AC_ARG_ENABLE([grub-emu-usb], - [AS_HELP_STRING([--enable-grub-emu-usb], - [build and install the `grub-emu' debugging utility with USB support (default=guessed)])]) - AC_ARG_ENABLE([grub-emu-sdl], [AS_HELP_STRING([--enable-grub-emu-sdl], [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) @@ -1269,34 +1265,6 @@ AC_ARG_ENABLE([grub-emu-pci], if test "$platform" = emu; then -if test x"$enable_grub_emu_usb" != xyes ; then - grub_emu_usb_excuse="not enabled" -fi - -if test x"$enable_grub_emu_pci" = xyes ; then - grub_emu_usb_excuse="conflicts with PCI support" -fi - -[if [ x"$grub_emu_usb_excuse" = x ]; then - # Check for libusb libraries.] -AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"], - [grub_emu_usb_excuse=["need libusb library"]]) - AC_SUBST([LIBUSB]) -[fi] -[if [ x"$grub_emu_usb_excuse" = x ]; then - # Check for headers.] - AC_CHECK_HEADERS([usb.h], [], - [grub_emu_usb_excuse=["need libusb headers"]]) -[fi] -if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then - AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)]) -fi -if test x"$grub_emu_usb_excuse" = x ; then -enable_grub_emu_usb=yes -else -enable_grub_emu_usb=no -fi - if test x"$enable_grub_emu_sdl" = xno ; then grub_emu_sdl_excuse="explicitly disabled" fi @@ -1326,10 +1294,6 @@ if test x"$enable_grub_emu_pci" != xyes ; then grub_emu_pci_excuse="not enabled" fi -if test x"$enable_grub_emu_usb" = xyes ; then - grub_emu_pci_excuse="conflicts with USB support" -fi - [if [ x"$grub_emu_pci_excuse" = x ]; then # Check for libpci libraries.] AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], @@ -1350,14 +1314,12 @@ enable_grub_emu_pci=no fi AC_SUBST([enable_grub_emu_sdl]) -AC_SUBST([enable_grub_emu_usb]) AC_SUBST([enable_grub_emu_pci]) else # Ignore --enable-emu-* if platform is not emu enable_grub_emu_sdl=no -enable_grub_emu_usb=no enable_grub_emu_pci=no fi @@ -1793,7 +1755,6 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu]) AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) -AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) @@ -1871,11 +1832,6 @@ echo "*******************************************************" echo GRUB2 will be compiled with following components: echo Platform: "$target_cpu"-"$platform" if [ x"$platform" = xemu ]; then -if [ x"$grub_emu_usb_excuse" = x ]; then -echo USB support for grub-emu: Yes -else -echo USB support for grub-emu: No "($grub_emu_usb_excuse)" -fi if [ x"$grub_emu_sdl_excuse" = x ]; then echo SDL support for grub-emu: Yes else diff --git a/gentpl.py b/gentpl.py index d2aa03586..f177883f8 100644 --- a/gentpl.py +++ b/gentpl.py @@ -606,7 +606,7 @@ def foreach_enabled_platform(defn, closure): # enable = emu; # enable = i386; # enable = mips_loongson; -# emu_condition = COND_GRUB_EMU_USB; +# emu_condition = COND_GRUB_EMU_SDL; # }; # def under_platform_specific_conditionals(defn, platform, closure): diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 57c0b64e7..af0c7f47c 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -250,9 +250,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h if COND_GRUB_EMU_SDL KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h endif -if COND_GRUB_EMU_USB -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h -endif if COND_GRUB_EMU_PCI KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h endif diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 7a6fa21a4..8eaae458c 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -511,13 +511,6 @@ module = { enable = x86; }; -module = { - name = libusb; - emu = bus/usb/emu/usb.c; - enable = emu; - condition = COND_GRUB_EMU_USB; -}; - module = { name = lsspd; mips_loongson = commands/mips/loongson/lsspd.c; @@ -532,13 +525,6 @@ module = { enable = usb; }; -module = { - name = emuusb; - common = bus/usb/usb.c; - enable = emu; - condition = COND_GRUB_EMU_USB; -}; - module = { name = usbserial_common; common = bus/usb/serial/common.c; diff --git a/grub-core/bus/usb/emu/usb.c b/grub-core/bus/usb/emu/usb.c deleted file mode 100644 index 3ad2fc312..000000000 --- a/grub-core/bus/usb/emu/usb.c +++ /dev/null @@ -1,203 +0,0 @@ -/* usb.c -- libusb USB support for GRUB. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 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 . - */ - -#include -#include -#include -#include -#include -#include - -GRUB_MOD_LICENSE ("GPLv3+"); - - -static struct grub_usb_controller_dev usb_controller = -{ - .name = "libusb" -}; - -static struct grub_usb_device *grub_usb_devs[128]; - -struct usb_bus *busses; - -static grub_err_t -grub_libusb_devices (void) - -{ - struct usb_bus *bus; - int last = 0; - - busses = usb_get_busses(); - - for (bus = busses; bus; bus = bus->next) - { - struct usb_device *usbdev; - struct grub_usb_device *dev; - - for (usbdev = bus->devices; usbdev; usbdev = usbdev->next) - { - struct usb_device_descriptor *desc = &usbdev->descriptor; - grub_err_t err; - - if (! desc->bcdUSB) - continue; - - dev = grub_malloc (sizeof (*dev)); - if (! dev) - return grub_errno; - - dev->data = usbdev; - - /* Fill in all descriptors. */ - err = grub_usb_device_initialize (dev); - if (err) - { - grub_errno = GRUB_ERR_NONE; - continue; - } - - /* Register the device. */ - grub_usb_devs[last++] = dev; - } - } - - return GRUB_USB_ERR_NONE; -} - -void -grub_usb_poll_devices (void) -{ - /* TODO: recheck grub_usb_devs */ -} - - -int -grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data) -{ - int i; - - for (i = 0; i < 128; i++) - { - if (grub_usb_devs[i]) - { - if (hook (grub_usb_devs[i], hook_data)) - return 1; - } - } - - return 0; -} - -grub_usb_err_t -grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused))) -{ - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype, - grub_uint8_t request, grub_uint16_t value, - grub_uint16_t idx, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_control_msg (devh, reqtype, request, - value, idx, data, size, 20) < 0) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - usb_close (devh); - - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_bulk_read (grub_usb_device_t dev, - int endpoint, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_claim_interface (devh, 0) < 1) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - if (usb_bulk_read (devh, endpoint, data, size, 20) < 1) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - usb_release_interface (devh, 0); - usb_close (devh); - - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_bulk_write (grub_usb_device_t dev, - int endpoint, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_claim_interface (devh, 0) < 0) - goto fail; - - if (usb_bulk_write (devh, endpoint, data, size, 20) < 0) - goto fail; - - if (usb_release_interface (devh, 0) < 0) - goto fail; - - usb_close (devh); - - return GRUB_USB_ERR_NONE; - - fail: - usb_close (devh); - return GRUB_USB_ERR_STALL; -} - -GRUB_MOD_INIT (libusb) -{ - usb_init(); - usb_find_busses(); - usb_find_devices(); - - if (grub_libusb_devices ()) - return; - - grub_usb_controller_dev_register (&usb_controller); - - return; -} - -GRUB_MOD_FINI (libusb) -{ - return; -} diff --git a/include/grub/libusb.h b/include/grub/libusb.h deleted file mode 100644 index 26548bccb..000000000 --- a/include/grub/libusb.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2010 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 . - */ - -void EXPORT_FUNC (usb_bulk_write) (void); -void EXPORT_FUNC (usb_find_busses) (void); -void EXPORT_FUNC (usb_init) (void); -void EXPORT_FUNC (usb_find_devices) (void); -void EXPORT_FUNC (usb_open) (void); -void EXPORT_FUNC (usb_get_busses) (void); -void EXPORT_FUNC (usb_control_msg) (void); -void EXPORT_FUNC (usb_release_interface) (void); -void EXPORT_FUNC (usb_close) (void); -void EXPORT_FUNC (usb_bulk_read) (void); -void EXPORT_FUNC (usb_claim_interface) (void); From 27d1a67f8a99e62b0900c68198477143f5bfbaa5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 01:00:19 +0100 Subject: [PATCH 0185/1167] Fix canonicalize_file_name clash. canonicalize_file_name clashed with gnulib function. Additionally it was declared in 2 places: emu/misc.h and util/misc.h. Added grub_ prefix and removed second declaration. --- grub-core/bus/emu/pci.c | 7 ++++--- grub-core/kern/emu/hostdisk.c | 4 ++-- grub-core/osdep/aros/hostdisk.c | 2 +- grub-core/osdep/unix/getroot.c | 4 ++-- grub-core/osdep/unix/hostdisk.c | 2 +- grub-core/osdep/unix/relpath.c | 2 +- grub-core/osdep/windows/hostdisk.c | 2 +- grub-core/osdep/windows/init.c | 2 +- include/grub/emu/misc.h | 3 +-- include/grub/util/misc.h | 2 +- util/getroot.c | 2 +- util/grub-file.c | 2 +- util/grub-fstest.c | 2 +- util/grub-install.c | 4 ++-- util/grub-macbless.c | 2 +- util/grub-mount.c | 2 +- util/grub-probe.c | 2 +- util/grub-syslinux2cfg.c | 6 +++--- util/probe.c | 6 +++--- util/render-label.c | 2 +- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c index 9d3296395..663e5540c 100644 --- a/grub-core/bus/emu/pci.c +++ b/grub-core/bus/emu/pci.c @@ -55,7 +55,8 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base, int err; err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr); if (err) - grub_util_error ("mapping 0x%x failed (error %d)\n", base, err); + grub_util_error ("mapping 0x%llx failed (error %d)\n", + (unsigned long long) base, err); return addr; } @@ -66,12 +67,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem, pci_device_unmap_range (dev, mem, size); } -GRUB_MOD_INIT (pci) +GRUB_MOD_INIT (emupci) { pci_system_init (); } -GRUB_MOD_FINI (pci) +GRUB_MOD_FINI (emupci) { pci_system_cleanup (); } diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index a4ebf78a9..a3b00c8f6 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -184,7 +184,7 @@ grub_hostdisk_os_dev_to_grub_drive (const char *os_disk, int add) unsigned int i; char *canon; - canon = canonicalize_file_name (os_disk); + canon = grub_canonicalize_file_name (os_disk); if (!canon) canon = xstrdup (os_disk); @@ -535,7 +535,7 @@ read_device_map (const char *dev_map) /* On Linux, the devfs uses symbolic links horribly, and that confuses the interface very much, so use realpath to expand symbolic links. */ - map[drive].device = canonicalize_file_name (p); + map[drive].device = grub_canonicalize_file_name (p); if (! map[drive].device) map[drive].device = xstrdup (p); diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c index e1eeea7d0..7d99b54b8 100644 --- a/grub-core/osdep/aros/hostdisk.c +++ b/grub-core/osdep/aros/hostdisk.c @@ -61,7 +61,7 @@ static ULONG *bounce; char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { char *ret; BPTR lck; diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 10fb56a2b..ccee7ce16 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -491,7 +491,7 @@ grub_guess_root_devices (const char *dir_in) char **os_dev = NULL; struct stat st; dev_t dev; - char *dir = canonicalize_file_name (dir_in); + char *dir = grub_canonicalize_file_name (dir_in); if (!dir) grub_util_error (_("failed to get canonical path of `%s'"), dir_in); @@ -516,7 +516,7 @@ grub_guess_root_devices (const char *dir_in) *cur = tmp; else { - *cur = canonicalize_file_name (tmp); + *cur = grub_canonicalize_file_name (tmp); if (*cur == NULL) grub_util_error (_("failed to get canonical path of `%s'"), tmp); free (tmp); diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index b3bc0e425..2a8c5882e 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -198,7 +198,7 @@ grub_util_fd_close (grub_util_fd_t fd) } char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { #if defined (PATH_MAX) char *ret; diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c index 71c19d867..8fdc3a73a 100644 --- a/grub-core/osdep/unix/relpath.c +++ b/grub-core/osdep/unix/relpath.c @@ -44,7 +44,7 @@ grub_make_system_path_relative_to_its_root (const char *path) char *poolfs = NULL; /* canonicalize. */ - p = canonicalize_file_name (path); + p = grub_canonicalize_file_name (path); if (p == NULL) grub_util_error (_("failed to get canonical path of `%s'"), path); diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c index d390b25fc..85507af88 100644 --- a/grub-core/osdep/windows/hostdisk.c +++ b/grub-core/osdep/windows/hostdisk.c @@ -328,7 +328,7 @@ grub_util_fd_strerror (void) } char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { char *ret; LPTSTR windows_path; diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c index 98c325c20..e8ffd62c6 100644 --- a/grub-core/osdep/windows/init.c +++ b/grub-core/osdep/windows/init.c @@ -170,7 +170,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)), #error "Unsupported TCHAR size" #endif - grub_util_base_directory = canonicalize_file_name ((*argv)[0]); + grub_util_base_directory = grub_canonicalize_file_name ((*argv)[0]); if (!grub_util_base_directory) grub_util_base_directory = xstrdup ((*argv)[0]); for (ptr = grub_util_base_directory + strlen (grub_util_base_directory) - 1; diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index a588ba21d..df6085bcb 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -27,6 +27,7 @@ #include #include #include +#include extern int verbosity; extern const char *program_name; @@ -61,8 +62,6 @@ void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); -extern char * canonicalize_file_name (const char *path); - #ifdef HAVE_DEVICE_MAPPER int grub_device_mapper_supported (void); #endif diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h index 192874d42..e9e0a6724 100644 --- a/include/grub/util/misc.h +++ b/include/grub/util/misc.h @@ -41,7 +41,7 @@ void grub_util_write_image_at (const void *img, size_t size, off_t offset, char *make_system_path_relative_to_its_root (const char *path); -char *canonicalize_file_name (const char *path); +char *grub_canonicalize_file_name (const char *path); void grub_util_init_nls (void); diff --git a/util/getroot.c b/util/getroot.c index 3c1f12dca..36f1730c0 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -406,7 +406,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) os_dev); grub_errno = GRUB_ERR_NONE; - canon = canonicalize_file_name (os_dev); + canon = grub_canonicalize_file_name (os_dev); drive = grub_hostdisk_os_dev_to_grub_drive (canon ? : os_dev, 1); if (canon) free (canon); diff --git a/util/grub-file.c b/util/grub-file.c index 9989dfe7b..50c18b683 100644 --- a/util/grub-file.c +++ b/util/grub-file.c @@ -77,7 +77,7 @@ main (int argc, char *argv[]) } if (had_file) grub_util_error ("one argument expected"); - argv2[i - 1] = canonicalize_file_name (argv[i]); + argv2[i - 1] = grub_canonicalize_file_name (argv[i]); if (!argv2[i - 1]) { grub_util_error (_("cannot open `%s': %s"), argv[i], diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 02cd3e3e2..a358ae471 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -651,7 +651,7 @@ argp_parser (int key, char *arg, struct argp_state *state) { if (args_count == 0) images = xmalloc (num_disks * sizeof (images[0])); - images[args_count] = canonicalize_file_name (arg); + images[args_count] = grub_canonicalize_file_name (arg); args_count++; return 0; } diff --git a/util/grub-install.c b/util/grub-install.c index cedc18809..7b394c997 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -967,7 +967,7 @@ main (int argc, char *argv[]) { char * t = grub_util_path_concat (2, bootdir, GRUB_DIR_NAME); grub_install_mkdir_p (t); - grubdir = canonicalize_file_name (t); + grubdir = grub_canonicalize_file_name (t); if (!grubdir) grub_util_error (_("failed to get canonical path of `%s'"), t); free (t); @@ -1299,7 +1299,7 @@ main (int argc, char *argv[]) { char *t = grub_util_path_concat (2, grubdir, platname); - platdir = canonicalize_file_name (t); + platdir = grub_canonicalize_file_name (t); if (!platdir) grub_util_error (_("failed to get canonical path of `%s'"), t); diff --git a/util/grub-macbless.c b/util/grub-macbless.c index e57e13d5a..e9b15a053 100644 --- a/util/grub-macbless.c +++ b/util/grub-macbless.c @@ -64,7 +64,7 @@ bless (const char *path, int x86) grub_err_t err; struct stat st; - grub_path = canonicalize_file_name (path); + grub_path = grub_canonicalize_file_name (path); if (stat (grub_path, &st) < 0) grub_util_error (N_("cannot stat `%s': %s"), diff --git a/util/grub-mount.c b/util/grub-mount.c index 4626e54ed..0d0fea5f2 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -547,7 +547,7 @@ argp_parser (int key, char *arg, struct argp_state *state) } images = xrealloc (images, (num_disks + 1) * sizeof (images[0])); - images[num_disks] = canonicalize_file_name (arg); + images[num_disks] = grub_canonicalize_file_name (arg); num_disks++; return 0; diff --git a/util/grub-probe.c b/util/grub-probe.c index 8f4aa6138..6075cb3fc 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -262,7 +262,7 @@ probe (const char *path, char **device_names, char delim) if (path != NULL) { - grub_path = canonicalize_file_name (path); + grub_path = grub_canonicalize_file_name (path); if (! grub_path) grub_util_error (_("failed to get canonical path of `%s'"), path); device_names = grub_guess_root_devices (grub_path); diff --git a/util/grub-syslinux2cfg.c b/util/grub-syslinux2cfg.c index f4fda6db9..85fa0da14 100644 --- a/util/grub-syslinux2cfg.c +++ b/util/grub-syslinux2cfg.c @@ -175,7 +175,7 @@ main (int argc, char *argv[]) grub_host_init (); char *t, *inpfull, *rootfull, *res; - t = canonicalize_file_name (arguments.input); + t = grub_canonicalize_file_name (arguments.input); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.input, @@ -185,7 +185,7 @@ main (int argc, char *argv[]) inpfull = xasprintf ("(host)/%s", t); free (t); - t = canonicalize_file_name (arguments.root ? : "/"); + t = grub_canonicalize_file_name (arguments.root ? : "/"); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.root, @@ -206,7 +206,7 @@ main (int argc, char *argv[]) cwd = xstrdup ("."); } - t = canonicalize_file_name (arguments.cwd ? : cwd); + t = grub_canonicalize_file_name (arguments.cwd ? : cwd); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.root, diff --git a/util/probe.c b/util/probe.c index c389f5dcf..fa7ca34d1 100644 --- a/util/probe.c +++ b/util/probe.c @@ -73,7 +73,7 @@ grub_util_guess_bios_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); @@ -102,7 +102,7 @@ grub_util_guess_efi_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); @@ -131,7 +131,7 @@ grub_util_guess_baremetal_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); diff --git a/util/render-label.c b/util/render-label.c index 39663a8a7..91c080c9c 100644 --- a/util/render-label.c +++ b/util/render-label.c @@ -157,7 +157,7 @@ grub_util_render_label (const char *label_font, ieee1275_palette[cptr].a = 0xff; char * t; - t = canonicalize_file_name (label_font); + t = grub_canonicalize_file_name (label_font); if (!t) { grub_util_error (_("cannot open `%s': %s"), label_font, From 5959b15c1cf2113999968291e0723337888d4979 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 01:01:45 +0100 Subject: [PATCH 0186/1167] configure.ac: Fix the name of pciaccess header. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2200776d3..891c14ff3 100644 --- a/configure.ac +++ b/configure.ac @@ -1302,7 +1302,7 @@ fi [fi] [if [ x"$grub_emu_pci_excuse" = x ]; then # Check for headers.] - AC_CHECK_HEADERS([pci/pci.h], [], + AC_CHECK_HEADERS([pciaccess.h], [], [grub_emu_pci_excuse=["need libpciaccess headers"]]) [fi] From dc06aa949b7ff25cec78e6c415a65b444c11d8d9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 14:19:29 +0100 Subject: [PATCH 0187/1167] syslinux_parse: Fix the case of unknown localboot. Reported by: Jordan Uggla --- grub-core/lib/syslinux_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index afc12b502..22389eb97 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -945,6 +945,7 @@ write_entry (struct output_buffer *outbuf, break; } print_string (" # UNSUPPORTED localboot type "); + print_string ("\ntrue;\n"); if (print_num (outbuf, n)) return grub_errno; print_string ("\n"); From 20f21d897858d827210d67c75f42d18887cbce81 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 5 Mar 2015 19:25:56 +0300 Subject: [PATCH 0188/1167] update m4/extern-inline.m4 to upstream version to fix compilation on FreeBSD In file included from util/grub-mkimage.c:54:0: ./grub-core/gnulib/argp.h:627:49: error: '__sbistype' is static but used in inline function '_option_is_short' which is not static [-Werror] cc1: all warnings being treated as errors gmake[2]: *** [util/grub_mkimage-grub-mkimage.o] Error 1 Update m4/extern-inline.m4 to current upstream gnulib version that contains fix for this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d). Reported-By: Beeblebrox --- m4/extern-inline.m4 | 71 +++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index 0152f2932..e74339a16 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -1,6 +1,6 @@ dnl 'extern inline' a la ISO C99. -dnl Copyright 2012-2013 Free Software Foundation, Inc. +dnl Copyright 2012-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,42 +8,77 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_EXTERN_INLINE], [ AH_VERBATIM([extern_inline], -[/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'. - _GL_EXTERN_INLINE is a portable alternative to 'extern inline'. - _GL_INLINE_HEADER_BEGIN contains useful stuff to put - in an include file, before uses of _GL_INLINE. - It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic, - when FOO is an inline function in the header; see - . - _GL_INLINE_HEADER_END contains useful stuff to put - in the same include file, after uses of _GL_INLINE. +[/* Please see the Gnulib manual for how to use these macros. Suppress extern inline with HP-UX cc, as it appears to be broken; see . - Suppress the use of extern inline on Apple's platforms, - as Libc-825.25 (2012-09-19) is incompatible with it; see - . - Perhaps Apple will fix this some day. */ + Suppress extern inline with Sun C in standards-conformance mode, as it + mishandles inline functions that call each other. E.g., for 'inline void f + (void) { } inline void g (void) { f (); }', c99 incorrectly complains + 'reference to static identifier "f" in extern inline function'. + This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. + + Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) + on configurations that mistakenly use 'static inline' to implement + functions or macros in standard C headers like . For example, + if isdigit is mistakenly implemented via a static inline function, + a program containing an extern inline function that calls isdigit + may not work since the C standard prohibits extern inline functions + from calling static functions. This bug is known to occur on: + + OS X 10.8 and earlier; see: + http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html + + DragonFly; see + http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log + + FreeBSD; see: + http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html + + OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and + for clang but remains for g++; see . + Assume DragonFly and FreeBSD will be similar. */ +#if (((defined __APPLE__ && defined __MACH__) \ + || defined __DragonFly__ || defined __FreeBSD__) \ + && (defined __header_inline \ + ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ + && ! defined __clang__) \ + : ((! defined _DONT_USE_CTYPE_INLINE_ \ + && (defined __GNUC__ || defined __cplusplus)) \ + || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ + && defined __GNUC__ && ! defined __cplusplus)))) +# define _GL_EXTERN_INLINE_STDHEADER_BUG +#endif #if ((__GNUC__ \ ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ - : 199901L <= __STDC_VERSION__ && !defined __HP_cc) \ - && !defined __APPLE__) + : (199901L <= __STDC_VERSION__ \ + && !defined __HP_cc \ + && !(defined __SUNPRO_C && __STDC__))) \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # define _GL_INLINE inline # define _GL_EXTERN_INLINE extern inline -#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__ -# if __GNUC_GNU_INLINE__ +# define _GL_EXTERN_INLINE_IN_USE +#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) # else # define _GL_INLINE extern inline # endif # define _GL_EXTERN_INLINE extern +# define _GL_EXTERN_INLINE_IN_USE #else # define _GL_INLINE static _GL_UNUSED # define _GL_EXTERN_INLINE static _GL_UNUSED #endif +/* In GCC, suppress bogus "no previous prototype for 'FOO'" + and "no previous declaration for 'FOO'" diagnostics, + when FOO is an inline function in the header; see + and + . */ #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ # define _GL_INLINE_HEADER_CONST_PRAGMA From 8842991a56f062c6bff03da9c2f7dcffa7e31492 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 5 Mar 2015 20:19:47 +0300 Subject: [PATCH 0189/1167] update gnulib/argp-help.c to fix garbage in grub-mknetdir --help output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit argp_help attempts to translate empty string, which results in printing meta information about translation, like in bor@opensuse:~/build/grub> grub2-mknetdir --help ИÑпользование: grub2-mknetdir [ПÐРÐМЕТР…] Project-Id-Version: grub 2.02-pre2 Report-Msgid-Bugs-To: bug-grub@gnu.org ... Update gnulib/argp-help.c to the current version which fixes this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d). --- grub-core/gnulib/argp-help.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c index 2914f4723..b9be63f40 100644 --- a/grub-core/gnulib/argp-help.c +++ b/grub-core/gnulib/argp-help.c @@ -1,5 +1,5 @@ /* Hierarchical argument parsing help output - Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -650,7 +650,7 @@ hol_find_entry (struct hol *hol, const char *name) return 0; } -/* If an entry with the long option NAME occurs in HOL, set it's special +/* If an entry with the long option NAME occurs in HOL, set its special sort position to GROUP. */ static void hol_set_group (struct hol *hol, const char *name, int group) @@ -1507,11 +1507,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state, if (vt) { if (post) - inp_text = vt + 1; + { + inp_text = vt + 1; + if (! *inp_text) + inp_text = 0; + } else { inp_text_len = vt - argp->doc; - inp_text = __strndup (argp->doc, inp_text_len); + inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0; } } else From be41c1cf11313bc433eaad4792f1e5a90d30e5b5 Mon Sep 17 00:00:00 2001 From: Jon McCune Date: Fri, 6 Mar 2015 00:33:41 +0100 Subject: [PATCH 0190/1167] autogen.sh: Allow overriding the python to be used by setting $PYTHON. Some installations have several python versions installed. Allow user to choose which one to use by setting $PYTHON. --- INSTALL | 3 +++ autogen.sh | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 846ac38df..e5b081105 100644 --- a/INSTALL +++ b/INSTALL @@ -104,6 +104,9 @@ The simplest way to compile this package is: 3. Type `./autogen.sh'. + * autogen.sh uses python. By default invocation is "python" but can be + overriden by setting variable $PYTHON. + 4. Type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying diff --git a/autogen.sh b/autogen.sh index 7424428d6..5020456bc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,9 @@ set -e +# Set ${PYTHON} to plain 'python' if not set already +: ${PYTHON:=python} + export LC_COLLATE=C unset LC_ALL @@ -9,10 +12,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in echo "Importing unicode..." -python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c +${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c echo "Importing libgcrypt..." -python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core +${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h if [ -f include/grub/gcrypt/g10lib.h ]; then rm include/grub/gcrypt/g10lib.h @@ -54,8 +57,8 @@ for extra in contrib/*/Makefile.core.def; do fi done -python gentpl.py $UTIL_DEFS > Makefile.util.am -python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am +${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am +${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am for extra in contrib/*/Makefile.common; do if test -e "$extra"; then From 5fe21c996893b9ef4d22a728b40f75d4b4cd7566 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Mar 2015 22:33:20 +0100 Subject: [PATCH 0191/1167] hfsplus: Fix potential access to uninited memory on invalid FS --- grub-core/fs/hfsplus.c | 6 ++++++ include/grub/hfsplus.h | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 8f07f8544..110d85815 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -336,6 +336,9 @@ grub_hfsplus_mount (grub_disk_t disk) data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) && (header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE)); + if (data->catalog_tree.nodesize < 2) + goto fail; + if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, sizeof (struct grub_hfsplus_btnode), sizeof (header), (char *) &header) <= 0) @@ -350,6 +353,9 @@ grub_hfsplus_mount (grub_disk_t disk) data->extoverflow_tree.root = grub_be_to_cpu32 (header.root); data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize); + if (data->extoverflow_tree.nodesize < 2) + goto fail; + if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0, sizeof (struct grub_hfsplus_btnode), sizeof (header), (char *) &header) <= 0) diff --git a/include/grub/hfsplus.h b/include/grub/hfsplus.h index 8ba8f3246..117740ae2 100644 --- a/include/grub/hfsplus.h +++ b/include/grub/hfsplus.h @@ -171,7 +171,7 @@ struct grub_hfsplus_catkey grub_uint16_t keylen; grub_uint32_t parent; grub_uint16_t namelen; - grub_uint16_t name[30]; + grub_uint16_t name[0]; } GRUB_PACKED; /* The on disk layout of an extent overflow file key. */ @@ -207,12 +207,14 @@ struct grub_hfsplus_btnode /* Return the offset of the record with the index INDEX, in the node NODE which is part of the B+ tree BTREE. */ -static inline grub_off_t +static inline grub_uint16_t grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree, - struct grub_hfsplus_btnode *node, int index) + struct grub_hfsplus_btnode *node, unsigned index) { char *cnode = (char *) node; void *recptr; + if (btree->nodesize < index * sizeof (grub_uint16_t) + 2) + index = 0; recptr = (&cnode[btree->nodesize - index * sizeof (grub_uint16_t) - 2]); return grub_be_to_cpu16 (grub_get_unaligned16 (recptr)); } @@ -221,11 +223,13 @@ grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree, NODE which is part of the B+ tree BTREE. */ static inline struct grub_hfsplus_key * grub_hfsplus_btree_recptr (struct grub_hfsplus_btree *btree, - struct grub_hfsplus_btnode *node, int index) + struct grub_hfsplus_btnode *node, unsigned index) { char *cnode = (char *) node; - grub_off_t offset; + grub_uint16_t offset; offset = grub_hfsplus_btree_recoffset (btree, node, index); + if (offset > btree->nodesize - sizeof (struct grub_hfsplus_key)) + offset = 0; return (struct grub_hfsplus_key *) &cnode[offset]; } From fa07d919d1ff868b18d8a42276d094b63a58e299 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 15 Mar 2015 21:06:26 +0300 Subject: [PATCH 0192/1167] grub-fs-tester: better estimation of filesystem time for LVM/RAID Write activity with LVM/RAID can happen after filesystem is unmounted. In my testing modification time of loop files was 15 - 20 seconds after unmount. So use time as close to unmount as possible as reference instead. --- tests/util/grub-fs-tester.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 9ecbe0fd6..4f7f9203a 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -993,6 +993,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi sleep 1; done + UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S") sleep 1 vgchange -a n grub_test ;; @@ -1004,6 +1005,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi sleep 1; done + UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S") sleep 1 mdadm --stop /dev/md/"${fs}_$NDEVICES" ;; @@ -1214,10 +1216,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x$fs in xiso9660 | xziso9660 | xrockridge | xjoliet | xrockridge_joliet | xiso9660_1999 | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) FSTIME="$(date -d "$(echo ${FSUUID} | awk -F - '{ print $1"-"$2"-"$3" "$4":"$5":"$6 ;}')" '+%Y-%m-%d %H:%M:%S')";; + xlvm*|xmdraid*) + # With some abstractions like mdraid flushing to disk + # may be delayed for a long time. + FSTIME="$UMOUNT_TIME";; *) FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGES[0]}"|awk '{print $6; }'|sed 's,_, ,g')";; esac - # With some abstractions like mdraid it may take up to 2 seconds for the data to reach the disks after it was flushed by FS in these tests. + # With some abstractions like mdraid computing of UMOUNT_TIME + # is not precise. Account for small difference here. FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")" FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")" From 7c9309e50a124817e67de38b30c6291acecad560 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Mar 2015 21:16:19 +0300 Subject: [PATCH 0193/1167] grub-fs-tester: explicitly set segment type for LVM mirror LVM mirror defaults to RAID1 today and can be different on different systems as set in lvm.conf. --- tests/util/grub-fs-tester.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 4f7f9203a..f63ed0b08 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -729,9 +729,9 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + elif [ x$fs = xlvm_stripe ] ; then lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -i "$NDEVICES" -n testvol grub_test elif [ x$fs = xlvm_mirror1 ] ; then - lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" -n testvol grub_test + lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type mirror -n testvol grub_test elif [ x$fs = xlvm_mirrorall ] ; then - lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" -n testvol grub_test + lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" --type mirror -n testvol grub_test elif [ x$fs = xlvm_raid4 ] || [ x$fs = xlvm_raid5 ]; then lvcreate -l "$(((NDEVICES-1) * 5*LVMBLKMUL))" -i "$((NDEVICES-1))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_raid6 ]; then From 527eeeeee6c8d3d8e3bb1fac408d47bb1dcbec95 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 19 Mar 2015 21:30:27 +0300 Subject: [PATCH 0194/1167] core: add LVM RAID1 support Closes 44534. --- grub-core/disk/lvm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 1e7f197f0..9b97004d8 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -577,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk, if (is_pvmove) seg->node_count = 1; } - else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) - == 0 && (p[sizeof ("raid") - 1] >= '4' - && p[sizeof ("raid") - 1] <= '6') + else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0 + && ((p[sizeof ("raid") - 1] >= '4' + && p[sizeof ("raid") - 1] <= '6') + || p[sizeof ("raid") - 1] == '1') && p[sizeof ("raidX") - 1] == '"') { switch (p[sizeof ("raid") - 1]) { + case '1': + seg->type = GRUB_DISKFILTER_MIRROR; + break; case '4': seg->type = GRUB_DISKFILTER_RAID4; seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC; @@ -608,16 +612,18 @@ grub_lvm_detect (grub_disk_t disk, goto lvs_segment_fail; } - seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); - if (p == NULL) + if (seg->type != GRUB_DISKFILTER_MIRROR) { + seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); + if (p == NULL) + { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_size\n"); + grub_util_info ("unknown stripe_size\n"); #endif - goto lvs_segment_fail; + goto lvs_segment_fail; + } } - seg->nodes = grub_zalloc (sizeof (seg->nodes[0]) * seg->node_count); @@ -625,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirrors\n"); + grub_util_info ("unknown raids\n"); #endif goto lvs_segment_fail2; } From 19c4156d1694e3ab82e412d280d1d6677b711d2c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 19 Mar 2015 21:31:26 +0300 Subject: [PATCH 0195/1167] grub-fs-tester: add LVM RAID1 support LVM miscalculates bitmap size with small extent, so start with 16K as for other RAID types. Until version 2.02.103 LVM counts metadata segments twice when checking available space, reduce segment count by one to account for this bug. --- tests/util/grub-fs-tester.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index f63ed0b08..e9e85c2a8 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -102,7 +102,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # OS LIMITATION: Linux oopses with >=32768K MAXBLKSIZE=$((16384*1024)) ;; - x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6") + x"lvm_raid1"* | x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6") # OS LIMITATION: Linux crashes with less than 16384 MINBLKSIZE=16384 # Could go further but what's the point? @@ -166,7 +166,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + x"zfs_raidz" | x"zfs_stripe" | x"zfs_mirror" | xbtrfs_raid0 \ | xbtrfs_raid1 | x"mdraid"*"_raid4" | x"mdraid"*"_raid5" \ | x"mdraid"*"_linear" \ - | x"mdraid"*"_raid10" | xlvm_mirror1 | xlvm_mirrorall) + | x"mdraid"*"_raid10" | xlvm_raid1* | xlvm_mirror1 | xlvm_mirrorall) MINDEVICES=2 MAXDEVICES=7 ;; @@ -199,7 +199,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x$fs in # RAID 1 has to work with even one device of the set. - xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall) + xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall | xlvm_raid1all) NEED_IMAGES_N=1;; # Degrade raidz by removing 3 devices xzfs_raidz3) @@ -210,7 +210,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # Degrade raidz and btrfs RAID1 by removing one device xbtrfs_raid1 | xbtrfs_raid10 | xzfs_raidz | x"mdraid"*"_raid4" \ | x"mdraid"*"_raid5" | x"mdraid"*"_raid10" | xlvm_mirror1 \ - | x"lvm_raid4" | x"lvm_raid5") + | x"lvm_raid1" | x"lvm_raid4" | x"lvm_raid5") NEED_IMAGES_N=$((NDEVICES-1));; *) NEED_IMAGES_N=$NDEVICES;; @@ -728,10 +728,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -n testvol grub_test elif [ x$fs = xlvm_stripe ] ; then lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -i "$NDEVICES" -n testvol grub_test - elif [ x$fs = xlvm_mirror1 ] ; then - lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type mirror -n testvol grub_test + elif [ x$fs = xlvm_mirror1 ] || [ x$fs = xlvm_raid1 ] ; then + lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_mirrorall ] ; then lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" --type mirror -n testvol grub_test + elif [ x$fs = xlvm_raid1all ] ; then + # Until version 2.02.103 LVM counts metadata segments + # twice when checking available space. Reduce segment + # count to work around it. + lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL - 1))" --type raid1 -n testvol grub_test elif [ x$fs = xlvm_raid4 ] || [ x$fs = xlvm_raid5 ]; then lvcreate -l "$(((NDEVICES-1) * 5*LVMBLKMUL))" -i "$((NDEVICES-1))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_raid6 ]; then From 9c07daaf917ddbcb738233aa1d3a209b179f3444 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 11:13:58 +0100 Subject: [PATCH 0196/1167] cacheinfo: Add missing license information. --- grub-core/commands/cacheinfo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/cacheinfo.c b/grub-core/commands/cacheinfo.c index ead6ff82c..d34a34696 100644 --- a/grub-core/commands/cacheinfo.c +++ b/grub-core/commands/cacheinfo.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), From cf47a2fba5852014bc59959c5e357e8313933414 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:55:27 +0100 Subject: [PATCH 0197/1167] grub-mkrescue: pass all unrecognized options unchanged to xorriso. --- util/grub-mkrescue.c | 103 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 14 deletions(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index e02340f06..5d3ec0d4e 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -44,9 +44,6 @@ static char *label_color; static char *label_bgcolor; static char *product_name; static char *product_version; -static int xorriso_tail_argc; -static int xorriso_tail_arg_alloc; -static char **xorriso_tail_argv; static char *output_image; static char *xorriso; static char *boot_grub; @@ -215,16 +212,6 @@ argp_parser (int key, char *arg, struct argp_state *state) xorriso = xstrdup (arg); return 0; - case ARGP_KEY_ARG: - if (xorriso_tail_arg_alloc <= xorriso_tail_argc) - { - xorriso_tail_arg_alloc = 2 * (4 + xorriso_tail_argc); - xorriso_tail_argv = xrealloc (xorriso_tail_argv, - sizeof (xorriso_tail_argv[0]) - * xorriso_tail_arg_alloc); - } - xorriso_tail_argv[xorriso_tail_argc++] = xstrdup (arg); - return 0; default: return ARGP_ERR_UNKNOWN; } @@ -374,12 +361,70 @@ make_image_fwdisk (enum grub_install_plat plat, free (out); } +static int +option_is_end (const struct argp_option *opt) +{ + return !opt->key && !opt->name && !opt->doc && !opt->group; +} + + +static int +args_to_eat (const char *arg) +{ + int j; + + if (arg[0] != '-') + return 0; + + if (arg[1] == '-') + { + for (j = 0; !option_is_end(&options[j]); j++) + { + size_t len = strlen (options[j].name); + if (strncmp (arg + 2, options[j].name, len) == 0) + { + if (arg[2 + len] == '=') + return 1; + if (arg[2 + len] == '\0' && options[j].arg) + return 2; + if (arg[2 + len] == '\0') + return 1; + } + } + if (strcmp (arg, "--help") == 0) + return 1; + if (strcmp (arg, "--usage") == 0) + return 1; + if (strcmp (arg, "--version") == 0) + return 1; + return 0; + } + if (arg[2] && arg[3]) + return 0; + for (j = 0; !option_is_end(&options[j]); j++) + { + if (options[j].key > 0 && options[j].key < 128 && arg[1] == options[j].key) + { + if (options[j].arg) + return 2; + return 1; + } + if (arg[1] == '?' || arg[1] == 'V') + return 1; + } + return 0; +} + int main (int argc, char *argv[]) { char *romdir; char *sysarea_img = NULL; const char *pkgdatadir; + int argp_argc; + char **argp_argv; + int xorriso_tail_argc; + char **xorriso_tail_argv; grub_util_host_init (&argc, &argv); grub_util_disable_fd_syncs (); @@ -391,7 +436,37 @@ main (int argc, char *argv[]) xorriso = xstrdup ("xorriso"); label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2"); - argp_parse (&argp, argc, argv, 0, 0, 0); + argp_argv = xmalloc (sizeof (argp_argv[0]) * argc); + xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc); + + xorriso_tail_argc = 0; + /* Program name */ + argp_argv[0] = argv[0]; + argp_argc = 1; + + /* argp doesn't allow us to catch unknwon arguments, + so catch them before passing to argp + */ + { + int i; + for (i = 1; i < argc; i++) + { + switch (args_to_eat (argv[i])) + { + case 2: + argp_argv[argp_argc++] = argv[i++]; + /* Fallthrough */ + case 1: + argp_argv[argp_argc++] = argv[i]; + break; + case 0: + xorriso_tail_argv[xorriso_tail_argc++] = argv[i]; + break; + } + } + } + + argp_parse (&argp, argp_argc, argp_argv, 0, 0, 0); if (!output_image) grub_util_error ("%s", _("output file must be specified")); From 237510486af6e2d73fa57075f72b407d24ad8874 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:58:08 +0100 Subject: [PATCH 0198/1167] fddboot_test: Add -no-pad to xorriso. --- tests/fddboot_test.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in index a05eb3e75..a59645b7f 100644 --- a/tests/fddboot_test.in +++ b/tests/fddboot_test.in @@ -46,6 +46,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in exit 0;; esac -if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes=")" != "Hello World" ]; then +if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")" != "Hello World" ]; then exit 1 fi From fe6695b7d6cd8beae55981b5efbd21f592a0afc0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:59:00 +0100 Subject: [PATCH 0199/1167] emunet: Fix init error checking. Otherwise emunet doesn't expose any cards. --- grub-core/net/drivers/emu/emunet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c index 7c977cd52..b19492086 100644 --- a/grub-core/net/drivers/emu/emunet.c +++ b/grub-core/net/drivers/emu/emunet.c @@ -98,7 +98,7 @@ static int registered = 0; GRUB_MOD_INIT(emunet) { - if (grub_emunet_create (&emucard.mtu)) + if (!grub_emunet_create (&emucard.mtu)) { grub_net_card_register (&emucard); registered = 1; From e9f68f1f4cc1a07d94d200f1e7bdcfb1c4d7e40d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 13:00:53 +0100 Subject: [PATCH 0200/1167] compiler-rt-emu: Add missing file. --- include/grub/compiler-rt-emu.h | 235 +++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 include/grub/compiler-rt-emu.h diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h new file mode 100644 index 000000000..edc82999e --- /dev/null +++ b/include/grub/compiler-rt-emu.h @@ -0,0 +1,235 @@ +/* compiler-rt-emu.h - prototypes for compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 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 . + */ + +#ifndef GRUB_COMPILER_RT_HEADER +#define GRUB_COMPILER_RT_HEADER 1 + +#include +#include +#include + +#ifdef HAVE___UDIVSI3 +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___UMODSI3 +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___DIVSI3 +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___MODSI3 +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___DIVDI3 +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); +#endif + +#ifdef HAVE___MODDI3 +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); +#endif + +#ifdef HAVE___UDIVDI3 +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___UMODDI3 +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___CTZDI2 +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +#endif + +#ifdef HAVE___CTZSI2 +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); +#endif + +#ifdef HAVE___AEABI_UIDIV +grub_uint32_t +EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___AEABI_UIDIVMOD +grub_uint32_t +EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___AEABI_IDIV +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___AEABI_IDIVMOD +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___AEABI_ULCMP +int +EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b); +#endif + +/* Needed for allowing modules to be compiled as thumb. */ +#ifdef HAVE___MULDI3 +grub_uint64_t +EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___AEABI_LMUL +grub_uint64_t +EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___AEABI_MEMCPY +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMSET +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_LASR +grub_uint64_t +EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___AEABI_LLSL +grub_uint64_t +EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___AEABI_LLSR +grub_uint64_t +EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); +#endif + + +#ifdef HAVE__RESTGPR_14_X + +void EXPORT_FUNC (_restgpr_14_x) (void); +void EXPORT_FUNC (_restgpr_15_x) (void); +void EXPORT_FUNC (_restgpr_16_x) (void); +void EXPORT_FUNC (_restgpr_17_x) (void); +void EXPORT_FUNC (_restgpr_18_x) (void); +void EXPORT_FUNC (_restgpr_19_x) (void); +void EXPORT_FUNC (_restgpr_20_x) (void); +void EXPORT_FUNC (_restgpr_21_x) (void); +void EXPORT_FUNC (_restgpr_22_x) (void); +void EXPORT_FUNC (_restgpr_23_x) (void); +void EXPORT_FUNC (_restgpr_24_x) (void); +void EXPORT_FUNC (_restgpr_25_x) (void); +void EXPORT_FUNC (_restgpr_26_x) (void); +void EXPORT_FUNC (_restgpr_27_x) (void); +void EXPORT_FUNC (_restgpr_28_x) (void); +void EXPORT_FUNC (_restgpr_29_x) (void); +void EXPORT_FUNC (_restgpr_30_x) (void); +void EXPORT_FUNC (_restgpr_31_x) (void); +void EXPORT_FUNC (_savegpr_14) (void); +void EXPORT_FUNC (_savegpr_15) (void); +void EXPORT_FUNC (_savegpr_16) (void); +void EXPORT_FUNC (_savegpr_17) (void); +void EXPORT_FUNC (_savegpr_18) (void); +void EXPORT_FUNC (_savegpr_19) (void); +void EXPORT_FUNC (_savegpr_20) (void); +void EXPORT_FUNC (_savegpr_21) (void); +void EXPORT_FUNC (_savegpr_22) (void); +void EXPORT_FUNC (_savegpr_23) (void); +void EXPORT_FUNC (_savegpr_24) (void); +void EXPORT_FUNC (_savegpr_25) (void); +void EXPORT_FUNC (_savegpr_26) (void); +void EXPORT_FUNC (_savegpr_27) (void); +void EXPORT_FUNC (_savegpr_28) (void); +void EXPORT_FUNC (_savegpr_29) (void); +void EXPORT_FUNC (_savegpr_30) (void); +void EXPORT_FUNC (_savegpr_31) (void); + +#endif + +#ifdef HAVE___UCMPDI2 +int +EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___ASHLDI3 +grub_uint64_t +EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___ASHRDI3 +grub_uint64_t +EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___LSHRDI3 +grub_uint64_t +EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___BSWAPSI2 +grub_uint32_t +EXPORT_FUNC(__bswapsi2) (grub_uint32_t u); +#endif + +#ifdef HAVE___BSWAPDI2 +grub_uint64_t +EXPORT_FUNC(__bswapdi2) (grub_uint64_t u); +#endif + +int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + +#ifdef HAVE___BZERO +void EXPORT_FUNC (__bzero) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___REGISTER_FRAME_INFO +void EXPORT_FUNC (__register_frame_info) (void); +#endif + +#ifdef HAVE___DEREGISTER_FRAME_INFO +void EXPORT_FUNC (__deregister_frame_info) (void); +#endif +#ifdef HAVE____CHKSTK_MS +void EXPORT_FUNC (___chkstk_ms) (void); +#endif + +#ifdef HAVE___CHKSTK_MS +void EXPORT_FUNC (__chkstk_ms) (void); +#endif + +#endif + From 5974d4ba65fc5ad9253857bf992ffd3c635baf2a Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 23 Mar 2015 14:27:41 +0000 Subject: [PATCH 0201/1167] hostfs: Drop unnecessary feature test macros _BSD_SOURCE was added to allow the use of DT_DIR, but that was removed in e768b77068a0b030a07576852bd0f121c9a077eb. While adding _DEFAULT_SOURCE as well works around problems with current glibc, neither is in fact needed nowadays. --- grub-core/kern/emu/hostfs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c index 823116da6..7b28c001f 100644 --- a/grub-core/kern/emu/hostfs.c +++ b/grub-core/kern/emu/hostfs.c @@ -19,11 +19,6 @@ #include -/* Legacy feature macro.*/ -#define _BSD_SOURCE -/* New feature macro that provides everything _BSD_SOURCE and - * _SVID_SOURCE provided and possibly more. */ -#define _DEFAULT_SOURCE #include #include #include From 63034d32612dd34f577605dfa8b417ee9144d8cb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:14:23 +0100 Subject: [PATCH 0202/1167] arp, icmp: Fix handling in case of oversized or invalid packets. This restrict ARP handling to MAC and IP addresses but in practice we need only this case anyway and other cases are very rar if exist at all. It makes code much simpler and less error-prone. --- grub-core/net/arp.c | 141 ++++++++++++++++++------------------- grub-core/net/icmp.c | 14 +--- grub-core/net/netbuff.c | 20 ++++++ include/grub/net/netbuff.h | 1 + 4 files changed, 90 insertions(+), 86 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 8cc390b0e..46a56e07f 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -37,12 +37,16 @@ enum GRUB_NET_ARPHRD_ETHERNET = 1 }; -struct arphdr { +struct arppkt { grub_uint16_t hrd; grub_uint16_t pro; grub_uint8_t hln; grub_uint8_t pln; grub_uint16_t op; + grub_uint8_t sender_mac[6]; + grub_uint32_t sender_ip; + grub_uint8_t recv_mac[6]; + grub_uint32_t recv_ip; } GRUB_PACKED; static int have_pending; @@ -53,21 +57,14 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, const grub_net_network_level_address_t *proto_addr) { struct grub_net_buff nb; - struct arphdr *arp_header; - grub_net_link_level_address_t target_hw_addr; - grub_uint8_t *aux, arp_data[128]; + struct arppkt *arp_packet; + grub_net_link_level_address_t target_mac_addr; grub_err_t err; int i; - grub_size_t addrlen; - grub_uint16_t etherpro; grub_uint8_t *nbd; + grub_uint8_t arp_data[128]; - if (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4) - { - addrlen = 4; - etherpro = GRUB_NET_ETHERTYPE_IP; - } - else + if (proto_addr->type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4) return grub_error (GRUB_ERR_BUG, "unsupported address family"); /* Build a request packet. */ @@ -76,34 +73,26 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, grub_netbuff_clear (&nb); grub_netbuff_reserve (&nb, 128); - err = grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + addrlen)); + err = grub_netbuff_push (&nb, sizeof (*arp_packet)); if (err) return err; - arp_header = (struct arphdr *) nb.data; - arp_header->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); - arp_header->hln = 6; - arp_header->pro = grub_cpu_to_be16 (etherpro); - arp_header->pln = addrlen; - arp_header->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); - aux = (grub_uint8_t *) arp_header + sizeof (*arp_header); + arp_packet = (struct arppkt *) nb.data; + arp_packet->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); + arp_packet->hln = 6; + arp_packet->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP); + arp_packet->pln = 4; + arp_packet->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); /* Sender hardware address. */ - grub_memcpy (aux, &inf->hwaddress.mac, 6); - - aux += 6; - /* Sender protocol address */ - grub_memcpy (aux, &inf->address.ipv4, 4); - aux += addrlen; - /* Target hardware address */ - for (i = 0; i < 6; i++) - aux[i] = 0x00; - aux += 6; + grub_memcpy (arp_packet->sender_mac, &inf->hwaddress.mac, 6); + arp_packet->sender_ip = inf->address.ipv4; + grub_memset (arp_packet->recv_mac, 0, 6); + arp_packet->recv_ip = proto_addr->ipv4; /* Target protocol address */ - grub_memcpy (aux, &proto_addr->ipv4, 4); - grub_memset (&target_hw_addr.mac, 0xff, 6); + grub_memset (&target_mac_addr.mac, 0xff, 6); nbd = nb.data; - send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP); for (i = 0; i < GRUB_NET_TRIES; i++) { if (grub_net_link_layer_resolve_check (inf, proto_addr)) @@ -115,7 +104,7 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, if (grub_net_link_layer_resolve_check (inf, proto_addr)) return GRUB_ERR_NONE; nb.data = nbd; - send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP); } return GRUB_ERR_NONE; @@ -125,63 +114,67 @@ grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card) { - struct arphdr *arp_header = (struct arphdr *) nb->data; - grub_uint8_t *sender_hardware_address; - grub_uint8_t *target_hardware_address; + struct arppkt *arp_packet = (struct arppkt *) nb->data; grub_net_network_level_address_t sender_addr, target_addr; - grub_net_link_level_address_t sender_hw_addr; + grub_net_link_level_address_t sender_mac_addr; struct grub_net_network_level_interface *inf; - grub_uint8_t *sender_protocol_address, *target_protocol_address; - sender_hardware_address = - (grub_uint8_t *) arp_header + sizeof (*arp_header); - sender_protocol_address = sender_hardware_address + arp_header->hln; - target_hardware_address = sender_protocol_address + arp_header->pln; - target_protocol_address = target_hardware_address + arp_header->hln; - if (grub_be_to_cpu16 (arp_header->pro) == GRUB_NET_ETHERTYPE_IP - && arp_header->pln == 4) - { - sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - grub_memcpy (&sender_addr.ipv4, sender_protocol_address, 4); - grub_memcpy (&target_addr.ipv4, target_protocol_address, 4); - if (grub_memcmp (sender_protocol_address, &pending_req, 4) == 0) - have_pending = 1; - } - else + if (arp_packet->pro != grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP) + || arp_packet->pln != 4 || arp_packet->hln != 6 + || nb->tail - nb->data < (int) sizeof (*arp_packet)) return GRUB_ERR_NONE; - sender_hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - grub_memcpy (sender_hw_addr.mac, sender_hardware_address, - sizeof (sender_hw_addr.mac)); - grub_net_link_layer_add_address (card, &sender_addr, &sender_hw_addr, 1); + sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + sender_addr.ipv4 = arp_packet->sender_ip; + target_addr.ipv4 = arp_packet->recv_ip; + if (arp_packet->sender_ip == pending_req) + have_pending = 1; + + sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac, + sizeof (sender_mac_addr.mac)); + grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { /* Am I the protocol address target? */ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST) + && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) { grub_net_link_level_address_t target; - /* We've already checked that pln is either 4 or 16. */ - char tmp[16]; - grub_size_t pln = arp_header->pln; + struct grub_net_buff nb_reply; + struct arppkt *arp_reply; + grub_uint8_t arp_data[128]; + grub_err_t err; - if (pln > 16) - pln = 16; + nb_reply.head = arp_data; + nb_reply.end = arp_data + sizeof (arp_data); + grub_netbuff_clear (&nb_reply); + grub_netbuff_reserve (&nb_reply, 128); + + err = grub_netbuff_push (&nb_reply, sizeof (*arp_packet)); + if (err) + return err; + + arp_reply = (struct arppkt *) nb_reply.data; + + arp_reply->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); + arp_reply->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP); + arp_reply->pln = 4; + arp_reply->hln = 6; + arp_reply->op = grub_cpu_to_be16_compile_time (ARP_REPLY); + arp_reply->sender_ip = arp_packet->recv_ip; + arp_reply->recv_ip = arp_packet->sender_ip; + arp_reply->hln = 6; target.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - grub_memcpy (target.mac, sender_hardware_address, 6); - grub_memcpy (target_hardware_address, target.mac, 6); - grub_memcpy (sender_hardware_address, inf->hwaddress.mac, 6); - - grub_memcpy (tmp, sender_protocol_address, pln); - grub_memcpy (sender_protocol_address, target_protocol_address, pln); - grub_memcpy (target_protocol_address, tmp, pln); + grub_memcpy (target.mac, arp_packet->sender_mac, 6); + grub_memcpy (arp_reply->sender_mac, inf->hwaddress.mac, 6); + grub_memcpy (arp_reply->recv_mac, arp_packet->sender_mac, 6); /* Change operation to REPLY and send packet */ - arp_header->op = grub_be_to_cpu16 (ARP_REPLY); - send_ethernet_packet (inf, nb, target, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP); } } return GRUB_ERR_NONE; diff --git a/grub-core/net/icmp.c b/grub-core/net/icmp.c index 28d825ba0..b1eef114e 100644 --- a/grub-core/net/icmp.c +++ b/grub-core/net/icmp.c @@ -85,22 +85,13 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb, struct icmp_header *icmphr; if (icmph->code) break; - nb_reply = grub_netbuff_alloc (nb->tail - nb->data + 512); + nb_reply = grub_netbuff_make_pkt (nb->tail - nb->data + sizeof (*icmphr)); if (!nb_reply) { grub_netbuff_free (nb); return grub_errno; } - err = grub_netbuff_reserve (nb_reply, nb->tail - nb->data + 512); - if (err) - goto ping_fail; - err = grub_netbuff_push (nb_reply, nb->tail - nb->data); - if (err) - goto ping_fail; - grub_memcpy (nb_reply->data, nb->data, nb->tail - nb->data); - err = grub_netbuff_push (nb_reply, sizeof (*icmphr)); - if (err) - goto ping_fail; + grub_memcpy (nb_reply->data + sizeof (*icmphr), nb->data, nb->tail - nb->data); icmphr = (struct icmp_header *) nb_reply->data; icmphr->type = ICMP_ECHO_REPLY; icmphr->code = 0; @@ -110,7 +101,6 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb, err = grub_net_send_ip_packet (inf, src, ll_src, nb_reply, GRUB_NET_IP_ICMP); - ping_fail: grub_netbuff_free (nb); grub_netbuff_free (nb_reply); return err; diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c index e97ecd23e..dbeeefe47 100644 --- a/grub-core/net/netbuff.c +++ b/grub-core/net/netbuff.c @@ -97,6 +97,26 @@ grub_netbuff_alloc (grub_size_t len) return nb; } +struct grub_net_buff * +grub_netbuff_make_pkt (grub_size_t len) +{ + struct grub_net_buff *nb; + grub_err_t err; + nb = grub_netbuff_alloc (len + 512); + if (!nb) + return NULL; + err = grub_netbuff_reserve (nb, len + 512); + if (err) + goto fail; + err = grub_netbuff_push (nb, len); + if (err) + goto fail; + return nb; + fail: + grub_netbuff_free (nb); + return NULL; +} + void grub_netbuff_free (struct grub_net_buff *nb) { diff --git a/include/grub/net/netbuff.h b/include/grub/net/netbuff.h index 9ac168c89..1177c1220 100644 --- a/include/grub/net/netbuff.h +++ b/include/grub/net/netbuff.h @@ -25,6 +25,7 @@ grub_err_t grub_netbuff_pull (struct grub_net_buff *net_buff, grub_size_t len); grub_err_t grub_netbuff_reserve (struct grub_net_buff *net_buff, grub_size_t len); grub_err_t grub_netbuff_clear (struct grub_net_buff *net_buff); struct grub_net_buff * grub_netbuff_alloc (grub_size_t len); +struct grub_net_buff * grub_netbuff_make_pkt (grub_size_t len); void grub_netbuff_free (struct grub_net_buff *net_buff); #endif From 94222b72b53cc5fc36aa15346ff389f37302aa85 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:41:17 +0100 Subject: [PATCH 0203/1167] Makefile.core.def: Remove obsolete LDADD_KERNEL --- grub-core/Makefile.core.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 8eaae458c..a6101dec7 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -83,8 +83,6 @@ kernel = { x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0'; - ldadd = '$(LDADD_KERNEL)'; - mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400'; From c14f8a9366517270c2171757e1b9a13fe0205dd3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:42:48 +0100 Subject: [PATCH 0204/1167] modinfo.sh.in: Add missing config variables. --- grub-core/modinfo.sh.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in index 09d22f922..faf0ad30e 100644 --- a/grub-core/modinfo.sh.in +++ b/grub-core/modinfo.sh.in @@ -19,11 +19,17 @@ grub_target_cflags='@TARGET_CFLAGS@' grub_target_cppflags='@TARGET_CPPFLAGS@' grub_target_ccasflags='@TARGET_CCASFLAGS@' grub_target_ldflags='@TARGET_LDFLAGS@' +grub_cflags='@CFLAGS@' +grub_cppflags='@CPPFLAGS@' +grub_ccasflags='@CCASFLAGS@' +grub_ldflags='@LDFLAGS@' grub_target_strip='@TARGET_STRIP@' grub_target_nm='@TARGET_NM@' grub_target_ranlib='@TARGET_RANLIB@' grub_target_objconf='@TARGET_OBJCONV@' grub_target_obj2elf='@TARGET_OBJ2ELF@' +grub_target_img_base_ldopt='@TARGET_IMG_BASE_LDOPT@' +grub_target_img_ldflags='@TARGET_IMG_BASE_LDFLAGS@' # Version grub_version="@VERSION@" From 85a7be2414c4718e96d81a2ebaa70d0d42152e62 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 27 Mar 2015 13:26:48 +0100 Subject: [PATCH 0205/1167] util/mkimage: Use stable timestamp when generating binaries. --- util/mkimage.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index 7821dc5ea..52265b557 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -55,6 +55,9 @@ #define TARGET_NO_FIELD 0xffffffff +/* use 2015-01-01T00:00:00+0000 as a stock timestamp */ +#define STABLE_EMBEDDING_TIMESTAMP 1420070400 + struct grub_install_image_target_desc { const char *dirname; @@ -1439,7 +1442,7 @@ grub_install_generate_image (const char *dir, const char *prefix, c->machine = grub_host_to_target16 (image_target->pe_target); c->num_sections = grub_host_to_target16 (4); - c->time = grub_host_to_target32 (time (0)); + c->time = grub_host_to_target32 (STABLE_EMBEDDING_TIMESTAMP); c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE | GRUB_PE32_LINE_NUMS_STRIPPED | ((image_target->voidp_sizeof == 4) @@ -1782,7 +1785,7 @@ grub_install_generate_image (const char *dir, const char *prefix, memset (hdr, 0, sizeof (*hdr)); hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC); - hdr->ih_time = grub_cpu_to_be32 (time (0)); + hdr->ih_time = grub_cpu_to_be32 (STABLE_EMBEDDING_TIMESTAMP); hdr->ih_size = grub_cpu_to_be32 (core_size); hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr); hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr); From 1f23c87c19b3002231c2939a8d03fa4b67f7bcb6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Mar 2015 14:04:41 +0100 Subject: [PATCH 0206/1167] Make Makefile.util.def independent of platform. --- Makefile.util.def | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.util.def b/Makefile.util.def index 67dfb2976..3cb6b21d3 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -613,7 +613,6 @@ program = { common = grub-core/disk/host.c; common = util/resolve.c; - enable = noemu; common = grub-core/kern/emu/argp_common.c; common = grub-core/osdep/init.c; From cf2b4a36c408084852c44dea045331f039b895d2 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Fri, 27 Mar 2015 14:27:56 +0100 Subject: [PATCH 0207/1167] efinet: Check for immediate completition. This both speeds GRUB up and workarounds unexpected EFI behaviour. --- grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 2b344d6ef..f171f20bf 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -37,11 +37,12 @@ send_card_buffer (struct grub_net_card *dev, grub_efi_status_t st; grub_efi_simple_network_t *net = dev->efi_net; grub_uint64_t limit_time = grub_get_time_ms () + 4000; + void *txbuf; if (dev->txbusy) while (1) { - void *txbuf = NULL; + txbuf = NULL; st = efi_call_3 (net->get_status, net, 0, &txbuf); if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, @@ -74,7 +75,18 @@ send_card_buffer (struct grub_net_card *dev, dev->txbuf, NULL, NULL, NULL); if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")); - dev->txbusy = 1; + + /* + The card may have sent out the packet immediately - set txbusy + to 0 in this case. + Cases were observed where checking txbuf at the next call + of send_card_buffer() is too late: 0 is returned in txbuf and + we run in the GRUB_ERR_TIMEOUT case above. + Perhaps a timeout in the FW has discarded the recycle buffer. + */ + st = efi_call_3 (net->get_status, net, 0, &txbuf); + dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf); + return GRUB_ERR_NONE; } From d47e8ab4b945d1dd50bc7d7ebbbf6f1f255f8f58 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 27 Mar 2015 14:37:16 +0100 Subject: [PATCH 0208/1167] dl_helper: Cleanup Use the new thumb_get_instruction_word/thumb_set_instruction_word helpers throughout. Style cleanup (missing spaces). Move Thumb MOVW/MOVT handlers into Thumb relocation section of file. --- grub-core/kern/arm/dl_helper.c | 78 +++++++++++++++------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c index 8a7263291..21d77f763 100644 --- a/grub-core/kern/arm/dl_helper.c +++ b/grub-core/kern/arm/dl_helper.c @@ -26,14 +26,14 @@ #include static inline grub_uint32_t -thumb_get_instruction_word(grub_uint16_t *target) +thumb_get_instruction_word (grub_uint16_t *target) { /* Extract instruction word in alignment-safe manner */ return grub_le_to_cpu16 ((*target)) << 16 | grub_le_to_cpu16 (*(target + 1)); } static inline void -thumb_set_instruction_word(grub_uint16_t *target, grub_uint32_t insword) +thumb_set_instruction_word (grub_uint16_t *target, grub_uint32_t insword) { *target = grub_cpu_to_le16 (insword >> 16); *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); @@ -70,9 +70,7 @@ grub_arm_thm_call_get_offset (grub_uint16_t *target) grub_uint32_t insword; grub_int32_t offset; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); /* Extract bitfields from instruction words */ sign = (insword >> 26) & 1; @@ -97,9 +95,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset) grub_uint32_t insword; int is_blx; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); if (((insword >> 12) & 0xd) == 0xc) is_blx = 1; @@ -122,9 +118,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset) (((offset >> 12) & 0x03ff) << 16) | (j1 << 13) | (j2 << 11) | ((offset >> 1) & 0x07ff); - /* Write instruction word back in alignment-safe manner */ - *target = grub_cpu_to_le16 ((insword >> 16) & 0xffff); - *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); + thumb_set_instruction_word (target, insword); grub_dprintf ("dl", " *insword = 0x%08x", insword); @@ -137,9 +131,7 @@ grub_arm_thm_jump19_get_offset (grub_uint16_t *target) grub_int32_t offset; grub_uint32_t insword; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); /* Extract and sign extend offset */ offset = ((insword >> 26) & 1) << 19 @@ -163,9 +155,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset) offset >>= 1; offset &= 0xfffff; - /* Extract instruction word in alignment-safe manner */ - insword = grub_le_to_cpu16 ((*target)) << 16 - | grub_le_to_cpu16 (*(target + 1)); + insword = thumb_get_instruction_word (target); /* Reassemble instruction word and write back */ insword &= insmask; @@ -174,8 +164,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset) | ((offset >> 17) & 1) << 13 | ((offset >> 11) & 0x3f) << 16 | (offset & 0x7ff); - *target = grub_cpu_to_le16 (insword >> 16); - *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); + thumb_set_instruction_word (target, insword); } int @@ -186,6 +175,32 @@ grub_arm_thm_jump19_check_offset (grub_int32_t offset) return 1; } +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + + return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ + ((insword & 0x7000) >> 4) | (insword & 0xff); +} + +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) +{ + grub_uint32_t insword; + const grub_uint32_t insmask = 0xfbf08f00; + + insword = thumb_get_instruction_word (target); + insword &= insmask; + + insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ + ((value & 0x0700) << 4) | (value & 0xff); + + thumb_set_instruction_word (target, insword); +} + /*********************************************************** * ARM (A32) relocations: * @@ -228,28 +243,3 @@ grub_arm_jump24_set_offset (grub_uint32_t *target, *target = grub_cpu_to_le32 (insword); } - -grub_uint16_t -grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) -{ - grub_uint32_t insword; - - insword = thumb_get_instruction_word (target); - - return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ - ((insword & 0x7000) >> 4) | (insword & 0xff); -} - -void -grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) -{ - grub_uint32_t insword; - - insword = thumb_get_instruction_word (target); - insword &= 0xfbf08f00; - - insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ - ((value & 0x0700) << 4) | (value & 0xff); - - thumb_set_instruction_word (target, insword); -} From ed07b7e1289dd00b9d6dc8ac5dd56130f3376bc9 Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Fri, 27 Mar 2015 14:44:41 +0100 Subject: [PATCH 0209/1167] Add missing initializers to silence suprious warnings. --- grub-core/commands/verify.c | 2 +- grub-core/fs/hfsplus.c | 8 ++++---- grub-core/normal/main.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 656939189..9620a3b4c 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -454,7 +454,7 @@ grub_verify_signature_real (char *buf, grub_size_t size, grub_err_t err; grub_size_t i; gcry_mpi_t mpis[10]; - grub_uint8_t type; + grub_uint8_t type = 0; err = read_packet_header (sig, &type, &len); if (err) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 110d85815..21159e858 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -792,8 +792,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir, }; struct grub_hfsplus_key_internal intern; - struct grub_hfsplus_btnode *node; - grub_disk_addr_t ptr; + struct grub_hfsplus_btnode *node = NULL; + grub_disk_addr_t ptr = 0; { struct grub_fshelp_node *fsnode; @@ -976,8 +976,8 @@ grub_hfsplus_label (grub_device_t device, char **label) struct grub_hfsplus_catkey *catkey; int i, label_len; struct grub_hfsplus_key_internal intern; - struct grub_hfsplus_btnode *node; - grub_disk_addr_t ptr; + struct grub_hfsplus_btnode *node = NULL; + grub_disk_addr_t ptr = 0; *label = 0; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 623b93ba6..78a70a8bf 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -445,7 +445,7 @@ grub_cmdline_run (int nested, int force_auth) while (1) { - char *line; + char *line = NULL; if (grub_normal_exit_level) break; From 1a33de8b5612f8d7ab344546f8a91fa814f712b5 Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Fri, 27 Mar 2015 14:51:51 +0100 Subject: [PATCH 0210/1167] Recognize EFI platform even in case of mismatch between Linux and EFI. Some x86 systems might be capable of running a 64-bit Linux kernel but only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for grub-install to be able to recognise such systems, to set the default x86 platform correctly. To allow grub-install to know the size of the firmware rather than just the size of the kernel, there is now an extra EFI sysfs file to describe the underlying firmware. Read that if possible, otherwise fall back to the kernel type as before. Signed-off-by: Steve McIntyre --- grub-core/osdep/linux/platform.c | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c index 4b9f6ef9d..775b6c031 100644 --- a/grub-core/osdep/linux/platform.c +++ b/grub-core/osdep/linux/platform.c @@ -60,6 +60,43 @@ is_64_kernel (void) return strcmp (un.machine, "x86_64") == 0; } +static int +read_platform_size (void) +{ + FILE *fp; + char *buf = NULL; + size_t len = 0; + int ret = 0; + + /* Newer kernels can tell us directly about the size of the + * underlying firmware - let's see if that interface is there. */ + fp = grub_util_fopen ("/sys/firmware/efi/fw_platform_size", "r"); + if (fp != NULL) + { + if (getline (&buf, &len, fp) >= 3) /* 2 digits plus newline */ + { + if (strncmp (buf, "32", 2) == 0) + ret = 32; + else if (strncmp (buf, "64", 2) == 0) + ret = 64; + } + free (buf); + fclose (fp); + } + + if (ret == 0) + { + /* Unrecognised - fall back to matching the kernel size + * instead */ + if (is_64_kernel ()) + ret = 64; + else + ret = 32; + } + + return ret; +} + const char * grub_install_get_default_x86_platform (void) { @@ -77,7 +114,7 @@ grub_install_get_default_x86_platform (void) if (is_not_empty_directory ("/sys/firmware/efi")) { grub_util_info ("...found"); - if (is_64_kernel ()) + if (read_platform_size() == 64) return "x86_64-efi"; else return "i386-efi"; From c9ee9bedefe71df6bb18868e47ff2189e79d821e Mon Sep 17 00:00:00 2001 From: Lunar Date: Fri, 27 Mar 2015 15:15:13 +0100 Subject: [PATCH 0211/1167] syslinux: Support {vesa,}menu.c32. --- grub-core/lib/syslinux_parse.c | 165 +++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 58 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 22389eb97..153260b54 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -839,6 +839,82 @@ simplify_filename (char *str) *optr = '\0'; } +static grub_err_t +print_config (struct output_buffer *outbuf, + struct syslinux_menu *menu, + const char *filename, const char *basedir) +{ + struct syslinux_menu *menuptr; + grub_err_t err = GRUB_ERR_NONE; + char *new_cwd = NULL; + char *new_target_cwd = NULL; + char *newname = NULL; + int depth = 0; + + new_cwd = get_read_filename (menu, basedir); + if (!new_cwd) + { + err = grub_errno; + goto out; + } + new_target_cwd = get_target_filename (menu, basedir); + if (!new_target_cwd) + { + err = grub_errno; + goto out; + } + newname = get_read_filename (menu, filename); + if (!newname) + { + err = grub_errno; + goto out; + } + simplify_filename (newname); + + print_string ("#"); + print_file (outbuf, menu, filename, NULL); + print_string (" "); + print (outbuf, newname, grub_strlen (newname)); + print_string (":\n"); + + for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) + if (grub_strcmp (menuptr->filename, newname) == 0 + || depth > 20) + break; + if (menuptr) + { + print_string (" syslinux_configfile -r "); + print_file (outbuf, menu, "/", NULL); + print_string (" -c "); + print_file (outbuf, menu, basedir, NULL); + print_string (" "); + print_file (outbuf, menu, filename, NULL); + print_string ("\n"); + } + else + { + err = config_file (outbuf, menu->root_read_directory, + menu->root_target_directory, new_cwd, new_target_cwd, + newname, menu, menu->flavour); + if (err == GRUB_ERR_FILE_NOT_FOUND + || err == GRUB_ERR_BAD_FILENAME) + { + grub_errno = err = GRUB_ERR_NONE; + print_string ("# File "); + err = print (outbuf, newname, grub_strlen (newname)); + if (err) + goto out; + print_string (" not found\n"); + } + } + + out: + grub_free (newname); + grub_free (new_cwd); + grub_free (new_target_cwd); + return err; +} + static grub_err_t write_entry (struct output_buffer *outbuf, struct syslinux_menu *menu, @@ -1227,6 +1303,36 @@ write_entry (struct output_buffer *outbuf, break; } + if (grub_strcasecmp (basename, "menu.c32") == 0 || + grub_strcasecmp (basename, "vesamenu.c32") == 0) + { + char *ptr; + char *end; + + ptr = curentry->append; + if (!ptr) + return grub_errno; + + while (*ptr) + { + end = ptr; + for (end = ptr; *end && !grub_isspace (*end); end++); + if (*end) + *end++ = '\0'; + + /* "~" is supposed to be current file, so let's skip it */ + if (grub_strcmp (ptr, "~") != 0) + { + err = print_config (outbuf, menu, ptr, ""); + if (err != GRUB_ERR_NONE) + break; + } + for (ptr = end; *ptr && grub_isspace (*ptr); ptr++); + } + err = GRUB_ERR_NONE; + break; + } + /* FIXME: gdb, GFXBoot, Hdt, Ifcpu, Ifplop, Kbdmap, FIXME: Linux, Lua, Meminfo, rosh, Sanbboot */ @@ -1239,70 +1345,13 @@ write_entry (struct output_buffer *outbuf, } case KERNEL_CONFIG: { - char *new_cwd, *new_target_cwd; const char *ap; ap = curentry->append; if (!ap) ap = curentry->argument; if (!ap) ap = ""; - new_cwd = get_read_filename (menu, ap); - if (!new_cwd) - return grub_errno; - new_target_cwd = get_target_filename (menu, ap); - if (!new_target_cwd) - return grub_errno; - - struct syslinux_menu *menuptr; - char *newname; - int depth = 0; - - newname = get_read_filename (menu, curentry->kernel_file); - if (!newname) - return grub_errno; - simplify_filename (newname); - - print_string ("#"); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string (" "); - print (outbuf, newname, grub_strlen (newname)); - print_string (":\n"); - - for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) - if (grub_strcmp (menuptr->filename, newname) == 0 - || depth > 20) - break; - if (menuptr) - { - print_string (" syslinux_configfile -r "); - print_file (outbuf, menu, "/", NULL); - print_string (" -c "); - print_file (outbuf, menu, ap, NULL); - print_string (" "); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string ("\n"); - } - else - { - err = config_file (outbuf, menu->root_read_directory, - menu->root_target_directory, new_cwd, new_target_cwd, - newname, menu, menu->flavour); - if (err == GRUB_ERR_FILE_NOT_FOUND - || err == GRUB_ERR_BAD_FILENAME) - { - grub_errno = err = GRUB_ERR_NONE; - print_string ("# File "); - err = print (outbuf, newname, grub_strlen (newname)); - if (err) - return err; - print_string (" not found\n"); - } - if (err) - return err; - } - grub_free (newname); - grub_free (new_cwd); - grub_free (new_target_cwd); + print_config (outbuf, menu, curentry->kernel_file, ap); } break; case KERNEL_NO_KERNEL: From ebd92af8c3f8fc30c48bbf36a1875fda1246981c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Mar 2015 18:58:57 +0300 Subject: [PATCH 0212/1167] net: trivial grub_cpu_to_XX_compile_time cleanup --- grub-core/net/arp.c | 2 +- grub-core/net/icmp6.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 46a56e07f..4b68c4151 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -80,7 +80,7 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, arp_packet = (struct arppkt *) nb.data; arp_packet->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); arp_packet->hln = 6; - arp_packet->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP); + arp_packet->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP); arp_packet->pln = 4; arp_packet->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); /* Sender hardware address. */ diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 782239460..7953e68ec 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -552,8 +552,8 @@ grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf struct icmp_header *icmphr; multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; - multicast.ipv6[0] = grub_cpu_to_be64 (0xff02ULL << 48); - multicast.ipv6[1] = grub_cpu_to_be64 (0x02ULL); + multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48); + multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x02ULL); err = grub_net_link_layer_resolve (inf, &multicast, &ll_multicast); if (err) From 7d3993847466435bcc8c82267f101c5e8193f4be Mon Sep 17 00:00:00 2001 From: Sarah Newman Date: Fri, 27 Mar 2015 12:56:43 -0700 Subject: [PATCH 0213/1167] grub-core/loader/i386/xen.c: Initialized initrd_ctx so we don't free a random pointer from the stack. Signed-off-by: Sarah Newman --- grub-core/loader/i386/xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index c16b4b249..c4d9689f7 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -521,7 +521,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_size_t size = 0; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; grub_relocator_chunk_t ch; if (argc == 0) From 12bf55703940cde06448a1c1a19001556c1450f9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Mar 2015 22:13:35 +0300 Subject: [PATCH 0214/1167] do not emit cryptomount without crypto UUID --- util/grub-mkconfig_lib.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 29ef865d4..60b31cadd 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -145,7 +145,7 @@ prepare_grub_to_access_device () done if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then - for uuid in "`"${grub_probe}" --device $@ --target=cryptodisk_uuid`"; do + for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do echo "cryptomount -u $uuid" done fi From f11db3c7fc50b0b7de22e5ccdcb06bcbccb22a46 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 6 Apr 2015 19:25:02 +0300 Subject: [PATCH 0215/1167] core: avoid NULL derefrence in grub_divmod64s It can be called with NULL for third argument. grub_divmod32* for now are called only from within wrappers, so skip check. Reported-By: Michael Zimmermann --- grub-core/lib/division.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c index 920a79f18..35606fea7 100644 --- a/grub-core/lib/division.c +++ b/grub-core/lib/division.c @@ -50,7 +50,8 @@ grub_divmod64s (grub_int64_t n, q = -q; } /* Now: n = d * q + r */ - *ro = r; + if (ro) + *ro = r; return q; } From e97f5f4968c4b92c43985833604118149cbba128 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sat, 11 Apr 2015 21:40:50 +0200 Subject: [PATCH 0216/1167] docs/grub.texi: Fix spelling of cbfstool --- docs/grub.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index 46b9e7f8e..4af22aff8 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5848,7 +5848,7 @@ Following variables must be defined: @multitable @columnfractions .30 .65 @item GRUB_PAYLOADS_DIR @tab directory containing the required kernels -@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only) +@item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only) @item GRUB_COREBOOT_ROM @tab empty Coreboot ROM @item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU @end multitable From 5b5d8666a748109a3a0175f8140382d295a7938a Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 13 Apr 2015 19:49:15 +0300 Subject: [PATCH 0217/1167] core/partmap: rename 'sun' to avoid clash with predefined symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the symbol “sun†is defined macro in solaris derived systems, from gcc -dM -E: and therefore can not be used as name. --- grub-core/partmap/sun.c | 14 +++++++------- grub-core/partmap/sunpc.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/grub-core/partmap/sun.c b/grub-core/partmap/sun.c index dae360269..aac30a320 100644 --- a/grub-core/partmap/sun.c +++ b/grub-core/partmap/sun.c @@ -91,7 +91,7 @@ sun_partition_map_iterate (grub_disk_t disk, struct grub_partition p; union { - struct grub_sun_block sun; + struct grub_sun_block sun_block; grub_uint16_t raw[0]; } block; int partnum; @@ -103,7 +103,7 @@ sun_partition_map_iterate (grub_disk_t disk, if (err) return err; - if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun.magic)) + if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun_block.magic)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partition table"); if (! grub_sun_is_valid (block.raw)) @@ -115,14 +115,14 @@ sun_partition_map_iterate (grub_disk_t disk, { struct grub_sun_partition_descriptor *desc; - if (block.sun.infos[partnum].id == 0 - || block.sun.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID) + if (block.sun_block.infos[partnum].id == 0 + || block.sun_block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID) continue; - desc = &block.sun.partitions[partnum]; + desc = &block.sun_block.partitions[partnum]; p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder) - * grub_be_to_cpu16 (block.sun.ntrks) - * grub_be_to_cpu16 (block.sun.nsect)); + * grub_be_to_cpu16 (block.sun_block.ntrks) + * grub_be_to_cpu16 (block.sun_block.nsect)); p.len = grub_be_to_cpu32 (desc->num_sectors); p.number = p.index = partnum; if (p.len) diff --git a/grub-core/partmap/sunpc.c b/grub-core/partmap/sunpc.c index 442763ee5..73a430c14 100644 --- a/grub-core/partmap/sunpc.c +++ b/grub-core/partmap/sunpc.c @@ -74,7 +74,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk, grub_partition_t p; union { - struct grub_sun_pc_block sun; + struct grub_sun_pc_block sun_block; grub_uint16_t raw[0]; } block; int partnum; @@ -92,7 +92,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk, return err; } - if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic)) + if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun_block.magic)) { grub_free (p); return grub_error (GRUB_ERR_BAD_PART_TABLE, @@ -111,12 +111,12 @@ sun_pc_partition_map_iterate (grub_disk_t disk, { struct grub_sun_pc_partition_descriptor *desc; - if (block.sun.partitions[partnum].id == 0 - || block.sun.partitions[partnum].id + if (block.sun_block.partitions[partnum].id == 0 + || block.sun_block.partitions[partnum].id == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID) continue; - desc = &block.sun.partitions[partnum]; + desc = &block.sun_block.partitions[partnum]; p->start = grub_le_to_cpu32 (desc->start_sector); p->len = grub_le_to_cpu32 (desc->num_sectors); p->number = partnum; From 677dcaa92bdd31f38d49a4d5575f2adca8479d94 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 13 Apr 2015 19:52:28 +0300 Subject: [PATCH 0218/1167] getroot: include sys/mkdev.h for makedev Solaris (like) systems need to include sys/mkdev.h for makedev() function. --- grub-core/osdep/unix/getroot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index ccee7ce16..b98b2dfb0 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -57,6 +57,9 @@ #endif #include +#if defined(HAVE_SYS_MKDEV_H) +#include +#endif #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) # include From 70b002de55abbfd6b2d2f2ea4408078d93c9e0de Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Apr 2015 17:52:30 +0200 Subject: [PATCH 0219/1167] Remove -V in grub-mkrescue.c It clashhes with -V which is alias to -volid. --- util/grub-mkrescue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 5d3ec0d4e..815fc9175 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -409,7 +409,7 @@ args_to_eat (const char *arg) return 2; return 1; } - if (arg[1] == '?' || arg[1] == 'V') + if (arg[1] == '?') return 1; } return 0; From 104dff36eabe25dec143838167466fd6a8ddbc79 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 29 Apr 2015 19:18:54 +0300 Subject: [PATCH 0220/1167] grub-mkconfig: use $pkgdatadir in scripts Otherwise scripts will source wrong grub-mkconfig_lib. --- util/grub-mkconfig.in | 3 +++ util/grub.d/00_header.in | 2 +- util/grub.d/10_hurd.in | 2 +- util/grub.d/10_illumos.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/10_netbsd.in | 2 +- util/grub.d/10_windows.in | 2 +- util/grub.d/10_xnu.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- util/grub.d/30_os-prober.in | 2 +- 11 files changed, 13 insertions(+), 10 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index d1fae4937..3183744bf 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -33,6 +33,9 @@ datadir="@datadir@" if [ "x$pkgdatadir" = x ]; then pkgdatadir="${datadir}/@PACKAGE@" fi +# export it for scripts +export pkgdatadir + grub_cfg="" grub_mkconfig_dir="${sysconfdir}"/grub.d diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index ce2ec819d..93a90233e 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -25,7 +25,7 @@ grub_lang=`echo $LANG | cut -d . -f 1` export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" # Do this as early as possible, since other commands might depend on it. # (e.g. the `loadfont' command might need lvm or raid modules) diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 29b455423..59a9a48a2 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" CLASS="--class gnu --class os" diff --git a/util/grub.d/10_illumos.in b/util/grub.d/10_illumos.in index 0de616e89..a133e1b3f 100644 --- a/util/grub.d/10_illumos.in +++ b/util/grub.d/10_illumos.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index 65f6c32a0..9d8e8fd85 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index a2a84dce4..859b608f6 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -21,7 +21,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 9988a42bc..874f59969 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 48bd95546..554c5614b 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" case "`uname 2>/dev/null`" in CYGWIN*) ;; diff --git a/util/grub.d/10_xnu.in b/util/grub.d/10_xnu.in index 4270385f3..51ee2f427 100644 --- a/util/grub.d/10_xnu.in +++ b/util/grub.d/10_xnu.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" osx_entry() { if [ x$2 = x32 ]; then diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index de34c8d73..f532fb98f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -21,7 +21,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 4ee601565..5fc4f0c83 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then exit 0 From a1007c6af296172c788f3346ff3ad30b9020f723 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:22:08 +0300 Subject: [PATCH 0221/1167] zfs: com.delphix:hole_birth feature support In the past birth was always zero for holes. This feature started to make use of birth for holes as well, so change code to test for valid DVA address instead. --- grub-core/fs/zfs/zfs.c | 6 ++++-- include/grub/zfs/spa.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 0cbb84bb3..71c155df2 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -280,7 +280,9 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key */ #define MAX_SUPPORTED_FEATURE_STRLEN 50 static const char *spa_feature_names[] = { - "org.illumos:lz4_compress",NULL + "org.illumos:lz4_compress", + "com.delphix:hole_birth", + NULL }; static int @@ -1751,7 +1753,7 @@ zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf, for (i = 0; i < SPA_GBH_NBLKPTRS; i++) { - if (zio_gb->zg_blkptr[i].blk_birth == 0) + if (BP_IS_HOLE(&zio_gb->zg_blkptr[i])) continue; err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data); diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h index 7edb8ab7d..df43b6b32 100644 --- a/include/grub/zfs/spa.h +++ b/include/grub/zfs/spa.h @@ -279,7 +279,9 @@ typedef struct blkptr { #define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) #define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) -#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) +#define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \ + (dva)->dva_word[1] == 0ULL) +#define BP_IS_HOLE(bp) DVA_IS_EMPTY(BP_IDENTITY(bp)) /* BP_IS_RAIDZ(bp) assumes no block compression */ #define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \ From 4a7ea4003bd9f39e9bf2ebadbe4ab38f8874be66 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:23:22 +0300 Subject: [PATCH 0222/1167] zfs: com.delphix:embedded_data feature support --- grub-core/fs/zfs/zfs.c | 84 +++++++++++++++++++++++++++++++++++------- include/grub/zfs/spa.h | 27 ++++++++++++-- 2 files changed, 93 insertions(+), 18 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 71c155df2..03d587d8c 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -282,6 +282,7 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key static const char *spa_feature_names[] = { "org.illumos:lz4_compress", "com.delphix:hole_birth", + "com.delphix:embedded_data", NULL }; @@ -1802,6 +1803,39 @@ zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, return err; } +/* + * buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be + * more than BPE_PAYLOAD_SIZE bytes). + */ +static grub_err_t +decode_embedded_bp_compressed(const blkptr_t *bp, void *buf) +{ + grub_size_t psize, i; + grub_uint8_t *buf8 = buf; + grub_uint64_t w = 0; + const grub_uint64_t *bp64 = (const grub_uint64_t *)bp; + + psize = BPE_GET_PSIZE(bp); + + /* + * Decode the words of the block pointer into the byte array. + * Low bits of first word are the first byte (little endian). + */ + for (i = 0; i < psize; i++) + { + if (i % sizeof (w) == 0) + { + /* beginning of a word */ + w = *bp64; + bp64++; + if (!BPE_IS_PAYLOADWORD(bp, bp64)) + bp64++; + } + buf8[i] = BF64_GET(w, (i % sizeof (w)) * 8, 8); + } + return GRUB_ERR_NONE; +} + /* * Read in a block of data, verify its checksum, decompress if needed, * and put the uncompressed data in buf. @@ -1820,12 +1854,26 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, *buf = NULL; checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; - comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff; + comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7f; encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3); - lsize = (BP_IS_HOLE(bp) ? 0 : - (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) - << SPA_MINBLOCKSHIFT)); - psize = get_psize (bp, endian); + if (BP_IS_EMBEDDED(bp)) + { + if (BPE_GET_ETYPE(bp) != BP_EMBEDDED_TYPE_DATA) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unsupported embedded BP (type=%u)\n", + BPE_GET_ETYPE(bp)); + lsize = BPE_GET_LSIZE(bp); + psize = BF64_GET_SB(grub_zfs_to_cpu64 ((bp)->blk_prop, endian), 25, 7, 0, 1); + } + else + { + lsize = (BP_IS_HOLE(bp) ? 0 : + (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT)); + psize = get_psize (bp, endian); + } + grub_dprintf("zfs", "zio_read: E %d: size %" PRIdGRUB_SSIZE "/%" + PRIdGRUB_SSIZE "\n", (int)BP_IS_EMBEDDED(bp), lsize, psize); if (size) *size = lsize; @@ -1849,23 +1897,31 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, compbuf = *buf = grub_malloc (lsize); grub_dprintf ("zfs", "endian = %d\n", endian); - err = zio_read_data (bp, endian, compbuf, data); + if (BP_IS_EMBEDDED(bp)) + err = decode_embedded_bp_compressed(bp, compbuf); + else + { + err = zio_read_data (bp, endian, compbuf, data); + grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); + } if (err) { grub_free (compbuf); *buf = NULL; return err; } - grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); - err = zio_checksum_verify (zc, checksum, endian, - compbuf, psize); - if (err) + if (!BP_IS_EMBEDDED(bp)) { - grub_dprintf ("zfs", "incorrect checksum\n"); - grub_free (compbuf); - *buf = NULL; - return err; + err = zio_checksum_verify (zc, checksum, endian, + compbuf, psize); + if (err) + { + grub_dprintf ("zfs", "incorrect checksum\n"); + grub_free (compbuf); + *buf = NULL; + return err; + } } if (encrypted) diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h index df43b6b32..8dd1fa8e3 100644 --- a/include/grub/zfs/spa.h +++ b/include/grub/zfs/spa.h @@ -126,7 +126,7 @@ typedef struct zio_cksum { * +-------+-------+-------+-------+-------+-------+-------+-------+ * 5 |G| offset3 | * +-------+-------+-------+-------+-------+-------+-------+-------+ - * 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE | + * 6 |BDX|lvl| type | cksum |E| comp| PSIZE | LSIZE | * +-------+-------+-------+-------+-------+-------+-------+-------+ * 7 | padding | * +-------+-------+-------+-------+-------+-------+-------+-------+ @@ -160,7 +160,8 @@ typedef struct zio_cksum { * G gang block indicator * B byteorder (endianness) * D dedup - * X unused + * X encryption + * E blkptr_t contains embedded data * lvl level of indirection * type DMU object type * phys birth txg of block allocation; zero if same as logical birth txg @@ -203,8 +204,8 @@ typedef struct blkptr { #define BP_SET_LSIZE(bp, x) \ BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) -#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) -#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 7) +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 7, x) #define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) #define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) @@ -215,6 +216,8 @@ typedef struct blkptr { #define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) #define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) +#define BP_IS_EMBEDDED(bp) BF64_GET((bp)->blk_prop, 39, 1) + #define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1) #define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x) @@ -277,6 +280,22 @@ typedef struct blkptr { (zcp)->zc_word[3] = w3; \ } +#define BPE_GET_ETYPE(bp) BP_GET_CHECKSUM(bp) +#define BPE_GET_LSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1) +#define BPE_GET_PSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1) + +typedef enum bp_embedded_type { + BP_EMBEDDED_TYPE_DATA, + NUM_BP_EMBEDDED_TYPES +} bp_embedded_type_t; + +#define BPE_NUM_WORDS 14 +#define BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof(grub_uint64_t)) +#define BPE_IS_PAYLOADWORD(bp, wp) \ + ((wp) != &(bp)->blk_prop && (wp) != &(bp)->blk_birth) + #define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) #define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) #define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \ From 6210b8e8f7b4640711dd449ca8301d06fee62334 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 3 May 2015 18:55:13 +0300 Subject: [PATCH 0223/1167] zfs: add missing NULL check and fix incorrect buffer overwrite grub_memset should zero out padding after data end. It is not clear why it is needed at all - ZFS block is at least 512 bytes and power of two, so it is always multiple of 16 bytes. This grub_memset apparently never did anything. --- grub-core/fs/zfs/zfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 03d587d8c..08ed453a6 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -1887,14 +1887,12 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, "compression algorithm %s not supported\n", decomp_table[comp].name); if (comp != ZIO_COMPRESS_OFF) - { - /* It's not really necessary to align to 16, just for safety. */ - compbuf = grub_malloc (ALIGN_UP (psize, 16)); - if (! compbuf) - return grub_errno; - } + /* It's not really necessary to align to 16, just for safety. */ + compbuf = grub_malloc (ALIGN_UP (psize, 16)); else compbuf = *buf = grub_malloc (lsize); + if (! compbuf) + return grub_errno; grub_dprintf ("zfs", "endian = %d\n", endian); if (BP_IS_EMBEDDED(bp)) @@ -1902,7 +1900,9 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, else { err = zio_read_data (bp, endian, compbuf, data); - grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); + /* FIXME is it really necessary? */ + if (comp != ZIO_COMPRESS_OFF) + grub_memset (compbuf + psize, 0, ALIGN_UP (psize, 16) - psize); } if (err) { From 8d3c4544ffdd0289a4b0bdeb0cdc6355f801a4b3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 08:08:57 +0300 Subject: [PATCH 0224/1167] efinet: memory leak on module removal --- grub-core/net/drivers/efi/efinet.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index f171f20bf..eb1e682fa 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -278,6 +278,12 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) - grub_net_card_unregister (card); + { + grub_net_card_unregister (card); + grub_free (card->txbuf); + grub_free (card->rcvbuf); + grub_free (card->name); + grub_free (card); + } } From 47b2bee3ef0ea60fc3f5bfc37f3784e559385297 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 08:39:29 +0300 Subject: [PATCH 0225/1167] efinet: cannot free const char * pointer --- grub-core/net/drivers/efi/efinet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index eb1e682fa..a879decdb 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -282,7 +282,7 @@ GRUB_MOD_FINI(efinet) grub_net_card_unregister (card); grub_free (card->txbuf); grub_free (card->rcvbuf); - grub_free (card->name); + grub_free ((char *)card->name); grub_free (card); } } From cc699535e57e0d0f099090e64a63037c7834f104 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 09:13:53 +0300 Subject: [PATCH 0226/1167] Revert "efinet: memory leak on module removal" This reverts commits 47b2bee3ef0ea60fc3f5bfc37f3784e559385297 and 8d3c4544ffdd0289a4b0bdeb0cdc6355f801a4b3. It is not safe to free allocated cards, dangling pointers main remain. Such cleanup requires more changes in net core. --- grub-core/net/drivers/efi/efinet.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index a879decdb..f171f20bf 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -278,12 +278,6 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) - { - grub_net_card_unregister (card); - grub_free (card->txbuf); - grub_free (card->rcvbuf); - grub_free ((char *)card->name); - grub_free (card); - } + grub_net_card_unregister (card); } From f8451af8251a3866cb8b7307b9917dd5d34fbd0a Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 7 May 2015 15:11:04 +0200 Subject: [PATCH 0227/1167] arm64: Export useful functions from linux.c Signed-off-by: Fu Wei --- gentpl.py | 2 +- grub-core/loader/arm64/linux.c | 59 +++++++++++++++++----------------- grub-core/loader/i386/linux.c | 11 +++---- grub-core/loader/linux.c | 3 +- include/grub/arm64/linux.h | 11 +++++++ 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/gentpl.py b/gentpl.py index f177883f8..0fd5ba427 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .hash -R .dynsym -R .dynstr -R .rel.text $< $@; \ fi """) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 564a75a80..987f5b9ee 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -33,12 +33,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); -#define GRUB_EFI_PAGE_SHIFT 12 -#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) -#define GRUB_EFI_PE_MAGIC 0x5A4D - -static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - static grub_dl_t my_mod; static int loaded; @@ -58,6 +52,7 @@ static void * get_firmware_fdt (void) { grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; void *firmware_fdt = NULL; unsigned int i; @@ -75,8 +70,8 @@ get_firmware_fdt (void) return firmware_fdt; } -static void -get_fdt (void) +void * +grub_linux_get_fdt (void) { void *raw_fdt; grub_size_t size; @@ -99,7 +94,7 @@ get_fdt (void) grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size)); if (!fdt) - return; + return NULL; if (raw_fdt) { @@ -110,10 +105,11 @@ get_fdt (void) { grub_fdt_create_empty_tree (fdt, size); } + return fdt; } -static grub_err_t -check_kernel (struct grub_arm64_linux_kernel_header *lh) +grub_err_t +grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) { if (lh->magic != GRUB_ARM64_LINUX_MAGIC) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); @@ -131,14 +127,14 @@ check_kernel (struct grub_arm64_linux_kernel_header *lh) } static grub_err_t -finalize_params (void) +finalize_params_linux (void) { grub_efi_boot_services_t *b; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; grub_efi_status_t status; int node, retval; - get_fdt (); - if (!fdt) + if (!grub_linux_get_fdt ()) goto failure; node = grub_fdt_find_subnode (fdt, 0, "chosen"); @@ -240,21 +236,16 @@ out: return grub_errno; } -static grub_err_t -grub_linux_boot (void) +grub_err_t +grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; grub_efi_boot_services_t *b; grub_efi_status_t status; - grub_err_t retval; grub_efi_loaded_image_t *loaded_image; int len; - retval = finalize_params(); - if (retval != GRUB_ERR_NONE) - return retval; - mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); if (!mempath) return grub_errno; @@ -263,8 +254,8 @@ grub_linux_boot (void) mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); mempath[0].memory_type = GRUB_EFI_LOADER_DATA; - mempath[0].start_address = (grub_addr_t) kernel_addr; - mempath[0].end_address = (grub_addr_t) kernel_addr + kernel_size; + mempath[0].start_address = addr; + mempath[0].end_address = addr + size; mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; @@ -273,16 +264,16 @@ grub_linux_boot (void) b = grub_efi_system_table->boot_services; status = b->load_image (0, grub_efi_image_handle, (grub_efi_device_path_t *) mempath, - kernel_addr, kernel_size, &image_handle); + (void *) addr, size, &image_handle); if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); - grub_dprintf ("linux", "linux command line: '%s'\n", linux_args); + grub_dprintf ("linux", "linux command line: '%s'\n", args); /* Convert command line to UCS-2 */ loaded_image = grub_efi_get_loaded_image (image_handle); loaded_image->load_options_size = len = - (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); + (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = grub_efi_allocate_pages (0, BYTES_TO_PAGES (loaded_image->load_options_size)); @@ -291,9 +282,9 @@ grub_linux_boot (void) loaded_image->load_options_size = 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, - (grub_uint8_t *) linux_args, len, NULL); + (grub_uint8_t *) args, len, NULL); - grub_dprintf("linux", "starting image %p\n", image_handle); + grub_dprintf ("linux", "starting image %p\n", image_handle); status = b->start_image (image_handle, 0, NULL); /* When successful, not reached */ @@ -304,6 +295,16 @@ grub_linux_boot (void) return grub_errno; } +static grub_err_t +grub_linux_boot (void) +{ + if (finalize_params_linux () != GRUB_ERR_NONE) + return grub_errno; + + return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); +} + static grub_err_t grub_linux_unload (void) { @@ -400,7 +401,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (check_kernel (&lh) != GRUB_ERR_NONE) + if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 291f7289f..fddcc461d 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,7 +69,6 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; -static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1046,7 +1045,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0; + grub_size_t size = 0, aligned_size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1068,8 +1067,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - - initrd_pages = (page_align (size) >> 12); + aligned_size = ALIGN_UP (size, 4096); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1097,7 +1095,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - size) & ~0xFFF; + addr = (addr_max - aligned_size) & ~0xFFF; if (addr < addr_min) { @@ -1108,7 +1106,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, size, 0x1000, + addr_min, addr, aligned_size, + 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 117232f0c..a63a11a7f 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -205,7 +205,8 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + if (argc != 1) + initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); } if (newc) diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 864e5dc36..65796d907 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,6 +23,10 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ +#define GRUB_EFI_PAGE_SHIFT 12 +#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) +#define GRUB_EFI_PE_MAGIC 0x5A4D + /* From linux/Documentation/arm64/booting.txt */ struct grub_arm64_linux_kernel_header { @@ -38,4 +42,11 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; +/* Declare the functions for getting dtb and checking/booting image */ +void *grub_linux_get_fdt (void); +grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header + *lh); +grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, + char *args); + #endif /* ! GRUB_LINUX_CPU_HEADER */ From cfe2ae89360954f0cbc585f5c72e60a07eb066a2 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 7 May 2015 15:13:25 +0200 Subject: [PATCH 0228/1167] fdt.h: Add grub_fdt_set_reg64 macro Signed-off-by: Fu Wei --- include/grub/fdt.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 301699830..fdfca75bf 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -117,4 +117,16 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \ }) +/* Setup "reg" property for + * #address-cells = <0x2> + * #size-cells = <0x2> + */ +#define grub_fdt_set_reg64(fdt, nodeoffset, addr, size) \ +({ \ + grub_uint64_t reg_64[2]; \ + reg_64[0] = grub_cpu_to_be64(addr); \ + reg_64[1] = grub_cpu_to_be64(size); \ + grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \ +}) + #endif /* ! GRUB_FDT_HEADER */ From 9f731abc7f960a96a4c58d89717915e632837389 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:21:34 +0200 Subject: [PATCH 0229/1167] Revert parts accidentally committed 2 commits ago. --- gentpl.py | 2 +- grub-core/loader/i386/linux.c | 11 ++++++----- grub-core/loader/linux.c | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gentpl.py b/gentpl.py index 0fd5ba427..f177883f8 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .hash -R .dynsym -R .dynstr -R .rel.text $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ fi """) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index fddcc461d..291f7289f 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,6 +69,7 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; +static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1045,7 +1046,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0, aligned_size = 0; + grub_size_t size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1067,7 +1068,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - aligned_size = ALIGN_UP (size, 4096); + + initrd_pages = (page_align (size) >> 12); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1095,7 +1097,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - aligned_size) & ~0xFFF; + addr = (addr_max - size) & ~0xFFF; if (addr < addr_min) { @@ -1106,8 +1108,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, aligned_size, - 0x1000, + addr_min, addr, size, 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index a63a11a7f..117232f0c 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -205,8 +205,7 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - if (argc != 1) - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); } if (newc) From e5b4ba8c2b2cfbb84e5b8254fb7d0b15b799fe78 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:23:39 +0200 Subject: [PATCH 0230/1167] linux.c: Ensure that initrd is page-aligned. --- grub-core/loader/i386/linux.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 291f7289f..fddcc461d 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,7 +69,6 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; -static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1046,7 +1045,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0; + grub_size_t size = 0, aligned_size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1068,8 +1067,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - - initrd_pages = (page_align (size) >> 12); + aligned_size = ALIGN_UP (size, 4096); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1097,7 +1095,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - size) & ~0xFFF; + addr = (addr_max - aligned_size) & ~0xFFF; if (addr < addr_min) { @@ -1108,7 +1106,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, size, 0x1000, + addr_min, addr, aligned_size, + 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) From 5fd1cb980af603126b82f421417f15326b0ca38d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:34:34 +0200 Subject: [PATCH 0231/1167] grub-mkrescue: Recognize -output as an alias of --output. This helps us to be in line with xorriso -as mkisofs. Suggested by: Thomas Schmitt --- util/grub-mkrescue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 815fc9175..5a7993fbb 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -451,6 +451,12 @@ main (int argc, char *argv[]) int i; for (i = 1; i < argc; i++) { + if (strcmp (argv[i], "-output") == 0) { + argp_argv[argp_argc++] = "--output"; + i++; + argp_argv[argp_argc++] = argv[i]; + continue; + } switch (args_to_eat (argv[i])) { case 2: From 9916ed6f82d12b203b61cbc6d6bb9c56af707c02 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 17:09:58 +0200 Subject: [PATCH 0232/1167] grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger. --- util/grub-install-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 37c1a98b9..0364b327c 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -902,7 +902,7 @@ grub_install_get_target (const char *src) { char *fn; grub_util_fd_t f; - char buf[2048]; + char buf[8192]; ssize_t r; char *c, *pl, *p; size_t i; From 71783dc9780c1e1897a59ec3273e6259807f47eb Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 7 May 2015 18:00:47 +0200 Subject: [PATCH 0233/1167] i386/relocator: Remove unused extern grub_relocator64_rip_addr Signed-off-by: Daniel Kiper --- grub-core/lib/i386/relocator.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index ffaf25f08..71dd4f0ab 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -64,7 +64,6 @@ extern grub_uint64_t grub_relocator64_rbx; extern grub_uint64_t grub_relocator64_rcx; extern grub_uint64_t grub_relocator64_rdx; extern grub_uint64_t grub_relocator64_rip; -extern grub_uint64_t grub_relocator64_rip_addr; extern grub_uint64_t grub_relocator64_rsp; extern grub_uint64_t grub_relocator64_rsi; extern grub_addr_t grub_relocator64_cr3; From a8c473288d3f0a5e17a903a5121dea1a695dda3b Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:24:24 +0300 Subject: [PATCH 0234/1167] loader/linux: do not pad initrd with zeroes at the end Syslinux memdisk is using initrd image and needs to know uncompressed size in advance. For gzip uncompressed size is at the end of compressed stream. Grub padded each input file to 4 bytes at the end, which means syslinux got wrong size. Linux initramfs loader apparently does not care about trailing alignment. So change code to align beginning of each file instead which atomatically gives us the correct size for single file. Reported-By: David Shaw --- grub-core/loader/linux.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 117232f0c..d2cd591f6 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -161,6 +161,9 @@ grub_initrd_init (int argc, char *argv[], for (i = 0; i < argc; i++) { const char *fname = argv[i]; + + initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); + if (grub_memcmp (argv[i], "newc:", 5) == 0) { const char *ptr, *eptr; @@ -205,7 +208,7 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + initrd_ctx->size += initrd_ctx->components[i].size; } if (newc) @@ -248,10 +251,12 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, int i; int newc = 0; struct dir *root = 0; + grub_ssize_t cursize = 0; for (i = 0; i < initrd_ctx->nfiles; i++) { - grub_ssize_t cursize; + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); if (initrd_ctx->components[i].newc_name) { @@ -283,8 +288,6 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, return grub_errno; } ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); } if (newc) ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); From 16a7e723ea37d4596348a76f54a6675c6e03fedc Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:33:28 +0300 Subject: [PATCH 0235/1167] convert to, not from, CPU byte order in DNS receive function --- grub-core/net/dns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 0b771fb10..9d0c8fcea 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -262,7 +262,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), grub_netbuff_free (nb); return GRUB_ERR_NONE; } - for (i = 0; i < grub_cpu_to_be16 (head->qdcount); i++) + for (i = 0; i < grub_be_to_cpu16 (head->qdcount); i++) { if (ptr >= nb->tail) { @@ -277,7 +277,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), ptr += 4; } *data->addresses = grub_malloc (sizeof ((*data->addresses)[0]) - * grub_cpu_to_be16 (head->ancount)); + * grub_be_to_cpu16 (head->ancount)); if (!*data->addresses) { grub_errno = GRUB_ERR_NONE; @@ -286,7 +286,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), } reparse_ptr = ptr; reparse: - for (i = 0, ptr = reparse_ptr; i < grub_cpu_to_be16 (head->ancount); i++) + for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++) { int ignored = 0; grub_uint8_t class; From 7b386b703154c0901c4616badf18ddb260954bc1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:16 +0300 Subject: [PATCH 0236/1167] efidisk: move device path helpers in core for efinet --- grub-core/disk/efi/efidisk.c | 61 ++++++------------------------------ grub-core/kern/efi/efi.c | 41 ++++++++++++++++++++++++ include/grub/efi/efi.h | 4 +++ 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 60a6d3c50..a8783a3c1 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices; static struct grub_efidisk_data *hd_devices; static struct grub_efidisk_data *cd_devices; -/* Duplicate a device path. */ -static grub_efi_device_path_t * -duplicate_device_path (const grub_efi_device_path_t *dp) -{ - grub_efi_device_path_t *p; - grub_size_t total_size = 0; - - for (p = (grub_efi_device_path_t *) dp; - ; - p = GRUB_EFI_NEXT_DEVICE_PATH (p)) - { - total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); - if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) - break; - } - - p = grub_malloc (total_size); - if (! p) - return 0; - - grub_memcpy (p, dp, total_size); - return p; -} - -/* Return the device path node right before the end node. */ -static grub_efi_device_path_t * -find_last_device_path (const grub_efi_device_path_t *dp) -{ - grub_efi_device_path_t *next, *p; - - if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) - return 0; - - for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p); - ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next); - p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next)) - ; - - return p; -} - static struct grub_efidisk_data * make_devices (void) { @@ -110,7 +69,7 @@ make_devices (void) if (! dp) continue; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); if (! ldp) /* This is empty. Why? */ continue; @@ -150,11 +109,11 @@ find_parent_device (struct grub_efidisk_data *devices, grub_efi_device_path_t *dp, *ldp; struct grub_efidisk_data *parent; - dp = duplicate_device_path (d->device_path); + dp = grub_efi_duplicate_device_path (d->device_path); if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); @@ -180,11 +139,11 @@ is_child (struct grub_efidisk_data *child, grub_efi_device_path_t *dp, *ldp; int ret; - dp = duplicate_device_path (child->device_path); + dp = grub_efi_duplicate_device_path (child->device_path); if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); @@ -207,8 +166,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d) { int ret; - ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path), - find_last_device_path (d->device_path)); + ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path), + grub_efi_find_last_device_path (d->device_path)); if (ret == 0) ret = grub_efi_compare_device_paths ((*p)->device_path, d->device_path); @@ -795,7 +754,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); if (! ldp) return 0; @@ -810,14 +769,14 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) /* It is necessary to duplicate the device path so that GRUB can overwrite it. */ - dup_dp = duplicate_device_path (dp); + dup_dp = grub_efi_duplicate_device_path (dp); if (! dup_dp) return 0; while (1) { grub_efi_device_path_t *dup_ldp; - dup_ldp = find_last_device_path (dup_dp); + dup_ldp = grub_efi_find_last_device_path (dup_dp); if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index b9eb1ab1e..49a150133 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -394,6 +394,47 @@ grub_efi_get_device_path (grub_efi_handle_t handle) GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); } +/* Return the device path node right before the end node. */ +grub_efi_device_path_t * +grub_efi_find_last_device_path (const grub_efi_device_path_t *dp) +{ + grub_efi_device_path_t *next, *p; + + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) + return 0; + + for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p); + ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next); + p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next)) + ; + + return p; +} + +/* Duplicate a device path. */ +grub_efi_device_path_t * +grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp) +{ + grub_efi_device_path_t *p; + grub_size_t total_size = 0; + + for (p = (grub_efi_device_path_t *) dp; + ; + p = GRUB_EFI_NEXT_DEVICE_PATH (p)) + { + total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) + break; + } + + p = grub_malloc (total_size); + if (! p) + return 0; + + grub_memcpy (p, dp, total_size); + return p; +} + static void dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor) { diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 489cf9e6d..0e6fd86b0 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -53,6 +53,10 @@ void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); grub_efi_device_path_t * EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle); +grub_efi_device_path_t * +EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp); +grub_efi_device_path_t * +EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp); grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf, grub_efi_uintn_t *map_key, grub_efi_uintn_t *efi_desc_size, From c52ae40570c3bfbcca22d2195f5e6b31009d8a3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:17 +0300 Subject: [PATCH 0237/1167] efinet: skip virtual IPv4 and IPv6 devices when enumerating cards EDK2 PXE driver creates two child devices - IPv4 and IPv6 - with bound SNP instance. This means we get three cards for every physical adapter when enumerating. Not only is this confusing, this may result in grub ignoring packets that come in via the "wrong" card. Example of device hierarchy is Ctrl[91] PciRoot(0x0)/Pci(0x3,0x0) Ctrl[95] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1) Ctrl[B4] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv4(0.0.0.0) Ctrl[BC] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000) Skip PXE created virtual devices when enumerating cards. Make sure to find real card when applying initial autoconfiguration during PXE boot, this information is associated with one of child devices. --- grub-core/net/drivers/efi/efinet.c | 51 +++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index f171f20bf..2b53e9ef6 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -174,6 +174,29 @@ grub_efinet_findcards (void) { grub_efi_simple_network_t *net; struct grub_net_card *card; + grub_efi_device_path_t *dp, *parent = NULL, *child = NULL; + + /* EDK2 UEFI PXE driver creates IPv4 and IPv6 messaging devices as + children of main MAC messaging device. We only need one device with + bound SNP per physical card, otherwise they compete with each other + when polling for incoming packets. + */ + dp = grub_efi_get_device_path (*handle); + if (!dp) + continue; + for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) + { + parent = child; + child = dp; + } + if (child + && GRUB_EFI_DEVICE_PATH_TYPE (child) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && (GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE + || GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) + && parent + && GRUB_EFI_DEVICE_PATH_TYPE (parent) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (parent) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE) + continue; net = grub_efi_open_protocol (*handle, &net_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -251,7 +274,33 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (! cdp) continue; if (grub_efi_compare_device_paths (dp, cdp) != 0) - continue; + { + grub_efi_device_path_t *ldp, *dup_dp, *dup_ldp; + int match; + + /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 + as children of Ethernet card and binds PXE and Load File protocols + to it. Loaded Image Device Path protocol will point to these pseudo + devices. We skip them when enumerating cards, so here we need to + find matching MAC device. + */ + ldp = grub_efi_find_last_device_path (dp); + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) + continue; + dup_dp = grub_efi_duplicate_device_path (dp); + if (!dup_dp) + continue; + dup_ldp = grub_efi_find_last_device_path (dup_dp); + dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + dup_ldp->length = sizeof (*dup_ldp); + match = grub_efi_compare_device_paths (dup_dp, cdp) == 0; + grub_free (dup_dp); + if (!match) + continue; + } pxe = grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (! pxe) From 49426e9fd2e562c73a4f1206f32eff9e424a1a73 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:17 +0300 Subject: [PATCH 0238/1167] efinet: open Simple Network Protocol exclusively EDK2 network stack is based on Managed Network Protocol which is layered on top of Simple Management Protocol and does background polling. This polling races with grub for received (and probably trasmitted) packets which causes either serious slowdown or complete failure to load files. Open SNP device exclusively. This destroys all child MNP instances and stops background polling. Exclusive open cannot be done when enumerating cards, as it would destroy PXE information we need to autoconfigure interface; and it cannot be done during autoconfiguration as we need to do it for non-PXE boot as well. So move SNP open to card ->open method and add matching ->close to clean up. Based on patch from Mark Salter Also-By: Mark Salter Closes: 41731 --- grub-core/net/drivers/efi/efinet.c | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 2b53e9ef6..5533515fd 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -142,9 +142,55 @@ get_card_packet (struct grub_net_card *dev) return nb; } +static grub_err_t +open_card (struct grub_net_card *dev) +{ + grub_efi_simple_network_t *net; + + /* Try to reopen SNP exlusively to close any active MNP protocol instance + that may compete for packet polling + */ + net = grub_efi_open_protocol (dev->efi_handle, &net_io_guid, + GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); + if (net) + { + if (net->mode->state == GRUB_EFI_NETWORK_STOPPED + && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net start failed", + dev->name); + + if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: card stopped", + dev->name); + + if (net->mode->state == GRUB_EFI_NETWORK_STARTED + && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed", + dev->name); + + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, + dev->efi_net, &net_io_guid, + grub_efi_image_handle, dev->efi_handle); + dev->efi_net = net; + } + + /* If it failed we just try to run as best as we can */ + return GRUB_ERR_NONE; +} + +static void +close_card (struct grub_net_card *dev) +{ + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, + dev->efi_net, &net_io_guid, + grub_efi_image_handle, dev->efi_handle); +} + static struct grub_net_card_driver efidriver = { .name = "efinet", + .open = open_card, + .close = close_card, .send = send_card_buffer, .recv = get_card_packet }; From 2dcf260d899f65cd84e4f676e03d76f51ae01736 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 19:45:06 +0200 Subject: [PATCH 0239/1167] util/grub-mkrescue: Fix compilation --- util/grub-mkrescue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 5a7993fbb..451182647 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -452,7 +452,7 @@ main (int argc, char *argv[]) for (i = 1; i < argc; i++) { if (strcmp (argv[i], "-output") == 0) { - argp_argv[argp_argc++] = "--output"; + argp_argv[argp_argc++] = (char *) "--output"; i++; argp_argv[argp_argc++] = argv[i]; continue; From 6a5c78c8c85c890034974a297bfb009dff0954c6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 22:13:34 +0300 Subject: [PATCH 0240/1167] Add asm-tests to tarball --- conf/Makefile.extra-dist | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index db6cfd12e..ea6b9df3a 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -5,6 +5,7 @@ EXTRA_DIST += gentpl.py EXTRA_DIST += Makefile.util.def EXTRA_DIST += Makefile.utilgcry.def +EXTRA_DIST += asm-tests EXTRA_DIST += unicode EXTRA_DIST += util/import_gcry.py From 07258815e96aab2c72593d0129d17051cbf68d27 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 May 2015 06:15:16 +0300 Subject: [PATCH 0241/1167] acpi: do not skip BIOS scan if EBDA length is zero EBDA layout is not standardized so we cannot assume first two bytes are length. Neither is it required by ACPI standard. HP 8710W is known to contain zeroes here. Closes: 45002 --- grub-core/commands/acpi.c | 4 ++++ grub-core/commands/i386/pc/acpi.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 05a6dcad4..c3861f594 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -180,8 +180,10 @@ grub_acpi_create_ebda (void) struct grub_acpi_rsdp_v20 *v2; ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4); + grub_dprintf ("acpi", "EBDA @%p\n", ebda); if (ebda) ebda_kb_len = *(grub_uint16_t *) ebda; + grub_dprintf ("acpi", "EBDA length 0x%x\n", ebda_kb_len); if (ebda_kb_len > 16) ebda_kb_len = 0; ctx.ebda_len = (ebda_kb_len + 1) << 10; @@ -495,6 +497,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) if (! rsdp) rsdp = grub_machine_acpi_get_rsdpv1 (); + grub_dprintf ("acpi", "RSDP @%p\n", rsdp); + if (rsdp) { grub_uint32_t *entry_ptr; diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/commands/i386/pc/acpi.c index d415d2305..297f5d05f 100644 --- a/grub-core/commands/i386/pc/acpi.c +++ b/grub-core/commands/i386/pc/acpi.c @@ -29,14 +29,15 @@ grub_machine_acpi_get_rsdpv1 (void) grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda_len = * (grub_uint16_t *) ebda; - if (! ebda_len) - return 0; + if (! ebda_len) /* FIXME do we really need this check? */ + goto scan_bios; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) return (struct grub_acpi_rsdp_v10 *) ptr; +scan_bios: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) @@ -56,8 +57,8 @@ grub_machine_acpi_get_rsdpv2 (void) grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda_len = * (grub_uint16_t *) ebda; - if (! ebda_len) - return 0; + if (! ebda_len) /* FIXME do we really need this check? */ + goto scan_bios; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 @@ -67,6 +68,7 @@ grub_machine_acpi_get_rsdpv2 (void) == 0) return (struct grub_acpi_rsdp_v20 *) ptr; +scan_bios: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) From 1570140f0362d9936f97a014a9fa5cecbca54f07 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 14 Jul 2014 17:21:29 +0200 Subject: [PATCH 0242/1167] xfs: Fix termination loop for directory iteration Directory iteration used wrong position (sizeof wrong structure) for termination of iteration inside a directory block. Luckily the position ended up being wrong by just 1 byte and directory entries are larger so things worked out fine in practice. But fix the problem anyway. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 16ffd3f1e..4bd52d1e0 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -603,8 +603,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - grub_be_to_cpu32 (tail->leaf_stale)); /* Iterate over all entries within this block. */ - while (pos < (dirblk_size - - (int) sizeof (struct grub_xfs_dir2_entry))) + while (pos < tail_start) { struct grub_xfs_dir2_entry *direntry; grub_uint8_t *freetag; From a139188eb559ee23f51540948ec84ef5948fb2d1 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 14 Jul 2014 17:21:30 +0200 Subject: [PATCH 0243/1167] xfs: Convert inode numbers to cpu endianity immediately after reading Currently XFS driver converted inode numbers to native endianity only when using them to compute inode position. Although this works, it is somewhat confusing. So convert inode numbers when reading them from disk structures as every other field. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 4bd52d1e0..0d704e9a4 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -180,14 +180,14 @@ static inline grub_uint64_t GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); + return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); } static inline grub_uint64_t GRUB_XFS_INO_AG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)); + return (ino >> GRUB_XFS_INO_AGBITS (data)); } static inline grub_disk_addr_t @@ -506,13 +506,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, if (smallino) { parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4); - parent = grub_cpu_to_be64 (parent); /* The header is a bit smaller than usual. */ de = (struct grub_xfs_dir_entry *) ((char *) de - 4); } else { - parent = diro->inode.data.dir.dirhead.parent.i8; + parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); } /* Synthesize the direntries for `.' and `..'. */ @@ -545,7 +544,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, | (((grub_uint64_t) inopos[5]) << 16) | (((grub_uint64_t) inopos[6]) << 8) | (((grub_uint64_t) inopos[7]) << 0); - ino = grub_cpu_to_be64 (ino); c = de->name[de->len]; de->name[de->len] = '\0'; @@ -627,7 +625,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, is not used by GRUB. So it can be overwritten. */ filename[direntry->len] = '\0'; - if (iterate_dir_call_hook (direntry->inode, filename, &ctx)) + if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), + filename, &ctx)) { grub_free (dirblock); return 1; @@ -689,7 +688,7 @@ grub_xfs_mount (grub_disk_t disk) goto fail; data->diropen.data = data; - data->diropen.ino = data->sblock.rootino; + data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino); data->diropen.inode_read = 1; data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize); From 5082ea618439fe59956d071777be0c9c74fbbcf5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 13 May 2015 09:47:17 +0300 Subject: [PATCH 0244/1167] remove extra newlines in grub_util_* strings grub_util_{info,warn,error} already add trailing newlines, so remove them from format strings. Also trailing full stops are already added. --- grub-core/bus/emu/pci.c | 2 +- grub-core/disk/lvm.c | 40 +++++++++++++++++----------------- grub-core/osdep/linux/ofpath.c | 2 +- util/grub-install-common.c | 2 +- util/grub-install.c | 6 ++--- util/grub-mknetdir.c | 2 +- util/grub-pe2elf.c | 2 +- util/mkimage.c | 4 ++-- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c index 663e5540c..267f2622d 100644 --- a/grub-core/bus/emu/pci.c +++ b/grub-core/bus/emu/pci.c @@ -55,7 +55,7 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base, int err; err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr); if (err) - grub_util_error ("mapping 0x%llx failed (error %d)\n", + grub_util_error ("mapping 0x%llx failed (error %d)", (unsigned long long) base, err); return addr; } diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 9b97004d8..7b265c780 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -160,7 +160,7 @@ grub_lvm_detect (grub_disk_t disk, "we don't support multiple LVM data areas"); #ifdef GRUB_UTIL - grub_util_info ("we don't support multiple LVM data areas\n"); + grub_util_info ("we don't support multiple LVM data areas"); #endif goto fail; } @@ -189,7 +189,7 @@ grub_lvm_detect (grub_disk_t disk, grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unknown LVM metadata header"); #ifdef GRUB_UTIL - grub_util_info ("unknown LVM metadata header\n"); + grub_util_info ("unknown LVM metadata header"); #endif goto fail2; } @@ -213,7 +213,7 @@ grub_lvm_detect (grub_disk_t disk, if (q == metadatabuf + mda_size) { #ifdef GRUB_UTIL - grub_util_info ("error parsing metadata\n"); + grub_util_info ("error parsing metadata"); #endif goto fail2; } @@ -230,7 +230,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("couldn't find ID\n"); + grub_util_info ("couldn't find ID"); #endif goto fail3; } @@ -258,7 +258,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown extent size\n"); + grub_util_info ("unknown extent size"); #endif goto fail4; } @@ -306,7 +306,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown pe_start\n"); + grub_util_info ("unknown pe_start"); #endif goto pvs_fail; } @@ -315,7 +315,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("error parsing pe_start\n"); + grub_util_info ("error parsing pe_start"); #endif goto pvs_fail; } @@ -402,7 +402,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("couldn't find ID\n"); + grub_util_info ("couldn't find ID"); #endif goto lvs_fail; } @@ -422,7 +422,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown segment_count\n"); + grub_util_info ("unknown segment_count"); #endif goto lvs_fail; } @@ -436,7 +436,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown segment\n"); + grub_util_info ("unknown segment"); #endif goto lvs_segment_fail; } @@ -445,7 +445,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown start_extent\n"); + grub_util_info ("unknown start_extent"); #endif goto lvs_segment_fail; } @@ -453,7 +453,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown extent_count\n"); + grub_util_info ("unknown extent_count"); #endif goto lvs_segment_fail; } @@ -475,7 +475,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_count\n"); + grub_util_info ("unknown stripe_count"); #endif goto lvs_segment_fail; } @@ -491,7 +491,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripes\n"); + grub_util_info ("unknown stripes"); #endif goto lvs_segment_fail2; } @@ -533,7 +533,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirror_count\n"); + grub_util_info ("unknown mirror_count"); #endif goto lvs_segment_fail; } @@ -545,7 +545,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirrors\n"); + grub_util_info ("unknown mirrors"); #endif goto lvs_segment_fail2; } @@ -607,7 +607,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown device_count\n"); + grub_util_info ("unknown device_count"); #endif goto lvs_segment_fail; } @@ -618,7 +618,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_size\n"); + grub_util_info ("unknown stripe_size"); #endif goto lvs_segment_fail; } @@ -631,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown raids\n"); + grub_util_info ("unknown raids"); #endif goto lvs_segment_fail2; } @@ -678,7 +678,7 @@ grub_lvm_detect (grub_disk_t disk, p2 = grub_strchr (p, '"'); if (p2) *p2 = 0; - grub_util_info ("unknown LVM type %s\n", p); + grub_util_info ("unknown LVM type %s", p); if (p2) *p2 ='"'; #endif diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 05b1ecdf8..a79682a5e 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -539,7 +539,7 @@ grub_util_devname_to_ofpath (const char *sys_devname) ofpath = xstrdup ("floppy"); else { - grub_util_warn (_("unknown device type %s\n"), device); + grub_util_warn (_("unknown device type %s"), device); ofpath = NULL; } diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 0364b327c..25983089f 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -494,7 +494,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, tgt = grub_install_get_image_target (mkimage_target); if (!tgt) - grub_util_error (_("unknown target format %s\n"), mkimage_target); + grub_util_error (_("unknown target format %s"), mkimage_target); grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, diff --git a/util/grub-install.c b/util/grub-install.c index 7b394c997..566272600 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -773,7 +773,7 @@ bless (grub_device_t dev, const char *path, int x86) err = grub_mac_bless_inode (dev, st.st_ino, S_ISDIR (st.st_mode), x86); if (err) grub_util_error ("%s", grub_errmsg); - grub_util_info ("blessed\n"); + grub_util_info ("blessed"); } static void @@ -1070,7 +1070,7 @@ main (int argc, char *argv[]) efidir_is_mac = 1; if (!efidir_is_mac && grub_strcmp (fs->name, "fat") != 0) - grub_util_error (_("%s doesn't look like an EFI partition.\n"), efidir); + grub_util_error (_("%s doesn't look like an EFI partition"), efidir); /* The EFI specification requires that an EFI System Partition must contain an "EFI" subdirectory, and that OS loaders are stored in @@ -1271,7 +1271,7 @@ main (int argc, char *argv[]) if (!config.is_cryptodisk_enabled && have_cryptodisk) grub_util_error (_("attempt to install to encrypted disk without cryptodisk enabled. " - "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=y", + "Set `%s' in file `%s'"), "GRUB_ENABLE_CRYPTODISK=y", grub_util_get_config_filename ()); if (disk_module && grub_strcmp (disk_module, "ata") == 0) diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c index 8366a1121..3813e8bc0 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -140,7 +140,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) prefix = xasprintf ("/%s", subdir); if (!targets[platform].mkimage_target) - grub_util_error (_("unsupported platform %s\n"), platsub); + grub_util_error (_("unsupported platform %s"), platsub); grub_cfg = grub_util_path_concat (2, grubdir, "grub.cfg"); cfg = grub_util_fopen (grub_cfg, "wb"); diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index f4abf70a3..0d4084a10 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -279,7 +279,7 @@ write_reloc_section (FILE* fp, const char *name, char *image, break; #endif default: - grub_util_error ("unknown pe relocation type %d\n", pe_rel->type); + grub_util_error ("unknown pe relocation type %d", pe_rel->type); } if (type == diff --git a/util/mkimage.c b/util/mkimage.c index 52265b557..35df99871 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -823,7 +823,7 @@ compress_kernel (const struct grub_install_image_target_desc *image_target, char if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS && (comp != GRUB_COMPRESSION_NONE)) - grub_util_error (_("unknown compression %d\n"), comp); + grub_util_error (_("unknown compression %d"), comp); *core_img = xmalloc (kernel_size); memcpy (*core_img, kernel_img, kernel_size); @@ -1234,7 +1234,7 @@ grub_install_generate_image (const char *dir, const char *prefix, name = "none_decompress.img"; break; default: - grub_util_error (_("unknown compression %d\n"), comp); + grub_util_error (_("unknown compression %d"), comp); } decompress_path = grub_util_get_path (dir, name); From 5370dcfdae66b60cff3507ad925300a679fe4117 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 14 May 2015 07:50:33 +0300 Subject: [PATCH 0245/1167] zfs: fix integer truncation in zap_lookup Size after shift could exceed 16 bits; use grub_unit32_t for result. Reported and tested by: Kostya Berger Closes: 44448 --- grub-core/fs/zfs/zfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 08ed453a6..aac6f2876 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2071,10 +2071,10 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, */ static grub_err_t mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, - grub_uint16_t objsize, const char *name, grub_uint64_t * value, + grub_uint32_t objsize, const char *name, grub_uint64_t * value, int case_insensitive) { - grub_uint16_t i, chunks; + grub_uint32_t i, chunks; mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; if (objsize < MZAP_ENT_LEN) @@ -2486,7 +2486,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, struct grub_zfs_data *data, int case_insensitive) { grub_uint64_t block_type; - grub_uint16_t size; + grub_uint32_t size; void *zapbuf; grub_err_t err; grub_zfs_endian_t endian; @@ -2494,7 +2494,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, grub_dprintf ("zfs", "looking for '%s'\n", name); /* Read in the first block of the zap object data. */ - size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + size = (grub_uint32_t) grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << SPA_MINBLOCKSHIFT; err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); if (err) From 2498dc7a3aee638215ad47899031496b50633d55 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 17 May 2015 14:16:36 +0300 Subject: [PATCH 0246/1167] hostdisk: fix crash with NULL device.map grub-macbless calls grub_util_biosdisk_init with NULL device.map. --- grub-core/kern/emu/hostdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index a3b00c8f6..610518d0c 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -422,7 +422,7 @@ read_device_map (const char *dev_map) char buf[1024]; /* XXX */ int lineno = 0; - if (dev_map[0] == '\0') + if (!dev_map || dev_map[0] == '\0') { grub_util_info ("no device.map"); return; From a666c8bd18aee7bf1b202b6b8c0ffe953bd2c1b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 17 May 2015 22:38:30 +0300 Subject: [PATCH 0247/1167] bootp: ignore gateway_ip (relay) field. From RFC1542: The 'giaddr' field is rather poorly named. It exists to facilitate the transfer of BOOTREQUEST messages from a client, through BOOTP relay agents, to servers on different networks than the client. Similarly, it facilitates the delivery of BOOTREPLY messages from the servers, through BOOTP relay agents, back to the client. In no case does it represent a general IP router to be used by the client. A BOOTP client MUST set the 'giaddr' field to zero (0.0.0.0) in all BOOTREQUEST messages it generates. A BOOTP client MUST NOT interpret the 'giaddr' field of a BOOTREPLY message to be the IP address of an IP router. A BOOTP client SHOULD completely ignore the contents of the 'giaddr' field in BOOTREPLY messages. Leave code ifdef'd out for the time being in case we see regression. Suggested by: Rink Springer Closes: 43396 --- docs/grub.texi | 6 ++++-- grub-core/net/bootp.c | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 4af22aff8..88bd75f38 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5162,8 +5162,10 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}). Perform configuration of @var{card} using DHCP protocol. If no card name is specified, try to configure all existing cards. If configuration was successful, interface with name @var{card}@samp{:dhcp} and configured -address is added to @var{card}. If server provided gateway information in -DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed: +address is added to @var{card}. +@comment If server provided gateway information in +@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. +Additionally the following DHCP options are recognized and processed: @table @samp @item 1 (Subnet Mask) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 613675533..4fdeac3ef 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -157,6 +157,12 @@ grub_net_configure_by_dhcp_ack (const char *name, hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags); +#if 0 + /* This is likely based on misunderstanding. gateway_ip refers to + address of BOOTP relay and should not be used after BOOTP transaction + is complete. + See RFC1542, 3.4 Interpretation of the 'giaddr' field + */ if (bp->gateway_ip) { grub_net_network_level_netaddress_t target; @@ -178,6 +184,7 @@ grub_net_configure_by_dhcp_ack (const char *name, target.ipv4.masksize = 32; grub_net_add_route (name, target, inter); } +#endif if (size > OFFSET_OF (boot_file, bp)) grub_env_set_net_property (name, "boot_file", bp->boot_file, From f4e62af000116de93f0c9d1c5f8aaf40934d5a01 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 15 May 2015 17:35:00 +0200 Subject: [PATCH 0248/1167] cb_timestamps.c: Add new time stamp descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the descriptions of the “coreâ€, that means no vendorcode or payload, coreboot time stamps added up to coreboot commit a7d92441 (timestamps: You can never have enough of them!) [1]. Running `coreboot_boottime` in the GRUB command line interface now shows descriptions for all time stamps again on the ASRock E350M1. [1] http://review.coreboot.org/9608 --- grub-core/commands/i386/coreboot/cb_timestamps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c index 07fbb0283..e72f38d6e 100644 --- a/grub-core/commands/i386/coreboot/cb_timestamps.c +++ b/grub-core/commands/i386/coreboot/cb_timestamps.c @@ -39,9 +39,17 @@ static const char *descs[] = { [2] = "before RAM init", [3] = "after RAM init", [4] = "end of romstage", + [5] = "start of verified boot", + [6] = "end of verified boot", [8] = "start of RAM copy", [9] = "end of RAM copy", [10] = "start of ramstage", + [11] = "start of bootblock", + [12] = "end of bootblock", + [13] = "starting to load romstage", + [14] = "finished loading romstage", + [15] = "starting LZMA decompress (ignore for x86)", + [16] = "finished LZMA decompress (ignore for x86)", [30] = "device enumerate", [40] = "device configure", [50] = "device enable", From 5e74a3e6dfc4e5992c423bf740a4b3604030b007 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sun, 24 May 2015 11:11:25 +0200 Subject: [PATCH 0249/1167] disk/ahci: Use defines `GRUB_ATA_STATUS_BUSY` and `GRUB_ATA_STATUS_DRQ` Instead of hard coding `0x88` use the macros defined in `disk/ata.h`. --- grub-core/disk/ahci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index d6bdbddf6..7f7572404 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -565,14 +565,14 @@ grub_ahci_pciinit (grub_pci_device_t dev, while (grub_get_time_ms () < endtime) { for (i = 0; i < nports; i++) - if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) + if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ))) break; if (i == nports) break; } for (i = 0; i < nports; i++) - if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) + if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ))) { grub_dprintf ("ahci", "port %d is busy\n", i); failed_adevs[i] = adevs[i]; From c856be6bca6f963a9a2c91eda954ab687bc7e573 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 27 May 2015 08:37:55 +0200 Subject: [PATCH 0250/1167] multiboot1: never place modules in low memory. While in theory permitted by the spec, modules rarely fit in low memory anyway and not every kernel is able to handle modules in low memory anyway. At least VMWare is known not to be able to handle modules at arbitrary locations. --- grub-core/loader/multiboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 4b71f3363..fd8f28e21 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -333,6 +333,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), return grub_errno; #ifndef GRUB_USE_MULTIBOOT2 + lowest_addr = 0x100000; if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL) lowest_addr = ALIGN_UP (highest_load + 1048576, 4096); #endif From cad5cc0f5d3d3630ccfbe242552958b13f2120d6 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:24:38 +0300 Subject: [PATCH 0251/1167] zfs extensible_dataset and large_blocks feature support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit large blocks basically use extensible dataset feature, or to be exact, setting recordsize above 128k will trigger large_block feature to be enabled and storing such blocks is using feature extensible dataset. so the extensible dataset is prerequisite. Changes implement read support extensible dataset… instead of fixed DMU types they dont specify type, making it possible to use fat zap objects from bonus area. --- grub-core/fs/zfs/zfs.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index aac6f2876..f9ca0e75e 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -283,6 +283,8 @@ static const char *spa_feature_names[] = { "org.illumos:lz4_compress", "com.delphix:hole_birth", "com.delphix:embedded_data", + "com.delphix:extensible_dataset", + "org.open-zfs:large_blocks", NULL }; @@ -3080,7 +3082,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, grub_dprintf ("zfs", "alive\n"); - err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + err = dnode_get (mosmdn, objnum, 0, mdn, data); if (err) return err; @@ -3113,7 +3115,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, if (err) return err; - err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + err = dnode_get (mosmdn, objnum, 0, mdn, data); if (err) return err; @@ -3268,8 +3270,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian); - err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &subvol->mdn, - data); + err = dnode_get (&(data->mos), headobj, 0, &subvol->mdn, data); if (err) { grub_free (fsname); @@ -3665,8 +3666,11 @@ zfs_mount (grub_device_t dev) if (ub->ub_version >= SPA_VERSION_FEATURES && check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian, data) != 0) - return NULL; - + { + grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool"); + return NULL; + } + /* Got the MOS. Save it at the memory addr MOS. */ grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE); @@ -3963,7 +3967,7 @@ fill_fs_info (struct grub_dirhook_info *info, { headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian); - err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data); + err = dnode_get (&(data->mos), headobj, 0, &mdn, data); if (err) { grub_dprintf ("zfs", "failed here\n"); From fd73b3d00881abae3daf820fe0009434edf2e3d4 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sun, 24 May 2015 23:27:46 +0200 Subject: [PATCH 0252/1167] Correct spelling of *scheduled* Run the command below $ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g' and revert the change in `ChangeLog-2015`. Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com --- gentpl.py | 2 +- grub-core/disk/ahci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gentpl.py b/gentpl.py index f177883f8..37b1f45bf 100644 --- a/gentpl.py +++ b/gentpl.py @@ -82,7 +82,7 @@ GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] GROUPS["no_softdiv"] = GRUB_PLATFORMS[:] for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i) -# Miscelaneous groups schedulded to disappear in future +# Miscellaneous groups scheduled to disappear in future GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 7f7572404..4e8619ce3 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -1002,7 +1002,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, if (parms->write) grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size); - grub_dprintf ("ahci", "AHCI command schedulded\n"); + grub_dprintf ("ahci", "AHCI command scheduled\n"); grub_dprintf ("ahci", "AHCI tfd = %x\n", dev->hba->ports[dev->port].task_file_data); grub_dprintf ("ahci", "AHCI inten = %x\n", From dec7718878f8a4566cd2894ab8970e1bec19dbb9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 30 May 2015 19:36:41 +0300 Subject: [PATCH 0253/1167] Clarify use of superusers variable and menu entry access superusers controls both CLI and editing. Also explicitly mention that empty superusers disables them. "Access to menuentry" is a bit vague - change to "execute menuentry" to make it obvious, what access is granted. --- docs/grub.texi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 88bd75f38..b9f41a73e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5428,10 +5428,12 @@ In order to enable authentication support, the @samp{superusers} environment variable must be set to a list of usernames, separated by any of spaces, commas, semicolons, pipes, or ampersands. Superusers are permitted to use the GRUB command line, edit menu entries, and execute any menu entry. If -@samp{superusers} is set, then use of the command line is automatically -restricted to superusers. +@samp{superusers} is set, then use of the command line and editing of menu +entries are automatically restricted to superusers. Setting @samp{superusers} +to empty string effectively disables both access to CLI and editing of menu +entries. -Other users may be given access to specific menu entries by giving a list of +Other users may be allowed to execute specific menu entries by giving a list of usernames (as above) using the @option{--users} option to the @samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted} option is used for a menu entry, then that entry is unrestricted. From ca59c24bd0e2a90db764065e24829775aa2b363c Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 27 May 2015 22:48:57 +0200 Subject: [PATCH 0254/1167] disk/ahci.c: Add port number to port debug messages Currently, some messages cannot be mapped to the port they belong to as the port number is missing from the output. So add `port: n` to the debug messages. --- grub-core/disk/ahci.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 4e8619ce3..da5fead26 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -355,7 +355,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, if (adevs[i]) { adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32); @@ -440,7 +440,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0; // adevs[i]->hba->ports[adevs[i]->port].fbs = 0; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->rfis = grub_memalign_dma32 (4096, @@ -480,7 +480,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); fr_running |= (1 << i); @@ -488,7 +488,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); } @@ -515,26 +515,26 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); - grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", + grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port, (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (char *) adevs[i]->hba), adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].command); - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); } @@ -542,13 +542,13 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", + grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port, (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (char *) adevs[i]->hba), adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].command); - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command From 3ac342205dc81293bb8e2d91b8c5ebe124b4ad35 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Thu, 21 May 2015 10:28:48 -0600 Subject: [PATCH 0255/1167] arm64/setjmp: Add missing license macro Including the setjmp module in an arm64-efi image will cause it to immediately exit with an "incompatible license" error. The source file includes a GPLv3+ boilerplate, so fix this by declaring a GPLv3+ license using the GRUB_MOD_LICENSE macro. Signed-off-by: dann frazier --- grub-core/lib/arm64/setjmp.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S index adaafe40f..eabfd99b2 100644 --- a/grub-core/lib/arm64/setjmp.S +++ b/grub-core/lib/arm64/setjmp.S @@ -17,8 +17,10 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE "GPLv3+" .text /* From 43d4231432838821cabe4f6aea4f0f50e87af9c4 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 2 Jun 2015 15:41:09 +0100 Subject: [PATCH 0256/1167] configure.ac: clean up arm64 soft-float handling Fix compilation with gcc 5.1 (avoid internal compiler error), by replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only. This also enables the removal of some further conditional build flag setting. --- configure.ac | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 891c14ff3..fd8a62ead 100644 --- a/configure.ac +++ b/configure.ac @@ -686,9 +686,9 @@ if test x"$platform" != xemu ; then AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ grub_cv_target_cc_soft_float=no if test "x$target_cpu" = xarm64; then - CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror" + CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) + [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], []) fi if test "x$target_cpu" = xia64; then CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" @@ -720,15 +720,7 @@ if test x"$platform" != xemu ; then TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" ;; esac - case x"$grub_cv_target_cc_soft_float" in - x"-march=armv8-a+nofp+nosimd") - # +nosimd disables also the cache opcodes that we need in asm. - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp" - ;; - *) - TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" - ;; - esac + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi From 697eceff6a168e8712fb7b784b333e0aeb925958 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 4 Jun 2015 19:41:54 +0300 Subject: [PATCH 0257/1167] multiboot_header_tag_module_align fix to confirm multiboot specification --- include/multiboot2.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/multiboot2.h b/include/multiboot2.h index 3ccff15fc..9d4862759 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -156,9 +156,6 @@ struct multiboot_header_tag_module_align multiboot_uint16_t type; multiboot_uint16_t flags; multiboot_uint32_t size; - multiboot_uint32_t width; - multiboot_uint32_t height; - multiboot_uint32_t depth; }; struct multiboot_color From d3ffeb9a9a54148af610cd122028783217d30699 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 1 Jun 2015 14:28:45 +0200 Subject: [PATCH 0258/1167] xfs: Add helpers for inode size Add helpers to return size of XFS inode on disk and when loaded in memory. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 0d704e9a4..26d8147a9 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -255,6 +255,24 @@ grub_xfs_inode_offset (struct grub_xfs_data *data, data->sblock.log2_inode); } +static inline grub_size_t +grub_xfs_inode_size(struct grub_xfs_data *data) +{ + return 1 << data->sblock.log2_inode; +} + +/* + * Returns size occupied by XFS inode stored in memory - we store struct + * grub_fshelp_node there but on disk inode size may be actually larger than + * struct grub_xfs_inode so we need to account for that so that we can read + * from disk directly into in-memory structure. + */ +static inline grub_size_t +grub_xfs_fshelp_size(struct grub_xfs_data *data) +{ + return sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode) + + grub_xfs_inode_size(data); +} static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, @@ -264,8 +282,8 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, int offset = grub_xfs_inode_offset (data, ino); /* Read the inode. */ - if (grub_disk_read (data->disk, block, offset, - 1 << data->sblock.log2_inode, inode)) + if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), + inode)) return grub_errno; if (grub_strncmp ((char *) inode->magic, "IN", 2)) @@ -297,7 +315,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else - recoffset = ((1 << node->data->sblock.log2_inode) + recoffset = (grub_xfs_inode_size(node->data) - ((char *) &node->inode.data.btree.keys - (char *) &node->inode)) / (2 * sizeof (grub_uint64_t)); @@ -456,9 +474,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, struct grub_fshelp_node *fdiro; grub_err_t err; - fdiro = grub_malloc (sizeof (struct grub_fshelp_node) - - sizeof (struct grub_xfs_inode) - + (1 << ctx->diro->data->sblock.log2_inode) + 1); + fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1); if (!fdiro) { grub_print_error (); @@ -682,7 +698,7 @@ grub_xfs_mount (grub_disk_t disk) data = grub_realloc (data, sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode) + 1); + + grub_xfs_inode_size(data) + 1); if (! data) goto fail; @@ -797,10 +813,7 @@ grub_xfs_open (struct grub_file *file, const char *name) if (fdiro != &data->diropen) { - grub_memcpy (&data->diropen, fdiro, - sizeof (struct grub_fshelp_node) - - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode)); + grub_memcpy (&data->diropen, fdiro, grub_xfs_fshelp_size(data)); grub_free (fdiro); } From b6e80c7778b708c1632d957d00507aad60d9e255 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 1 Jun 2015 14:28:46 +0200 Subject: [PATCH 0259/1167] xfs: V5 filesystem format support Add support for new XFS on disk format. We have to handle optional filetype fields in directory entries, additional CRC, LSN, UUID entries in some structures, etc. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 332 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 252 insertions(+), 80 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 26d8147a9..f00e43e7d 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -34,6 +34,50 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XFS_INODE_FORMAT_EXT 2 #define XFS_INODE_FORMAT_BTREE 3 +/* Superblock version field flags */ +#define XFS_SB_VERSION_NUMBITS 0x000f +#define XFS_SB_VERSION_ATTRBIT 0x0010 +#define XFS_SB_VERSION_NLINKBIT 0x0020 +#define XFS_SB_VERSION_QUOTABIT 0x0040 +#define XFS_SB_VERSION_ALIGNBIT 0x0080 +#define XFS_SB_VERSION_DALIGNBIT 0x0100 +#define XFS_SB_VERSION_LOGV2BIT 0x0400 +#define XFS_SB_VERSION_SECTORBIT 0x0800 +#define XFS_SB_VERSION_EXTFLGBIT 0x1000 +#define XFS_SB_VERSION_DIRV2BIT 0x2000 +#define XFS_SB_VERSION_MOREBITSBIT 0x8000 +#define XFS_SB_VERSION_BITS_SUPPORTED \ + (XFS_SB_VERSION_NUMBITS | \ + XFS_SB_VERSION_ATTRBIT | \ + XFS_SB_VERSION_NLINKBIT | \ + XFS_SB_VERSION_QUOTABIT | \ + XFS_SB_VERSION_ALIGNBIT | \ + XFS_SB_VERSION_DALIGNBIT | \ + XFS_SB_VERSION_LOGV2BIT | \ + XFS_SB_VERSION_SECTORBIT | \ + XFS_SB_VERSION_EXTFLGBIT | \ + XFS_SB_VERSION_DIRV2BIT | \ + XFS_SB_VERSION_MOREBITSBIT) + +/* Recognized xfs format versions */ +#define XFS_SB_VERSION_4 4 /* Good old XFS filesystem */ +#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ + +/* features2 field flags */ +#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ +#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ +#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32-bit project ids */ +#define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ +#define XFS_SB_VERSION2_BITS_SUPPORTED \ + (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ + XFS_SB_VERSION2_ATTR2BIT | \ + XFS_SB_VERSION2_PROJID32BIT | \ + XFS_SB_VERSION2_FTYPE) + +/* incompat feature flags */ +#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ + (XFS_SB_FEAT_INCOMPAT_FTYPE) struct grub_xfs_sblock { @@ -45,7 +89,9 @@ struct grub_xfs_sblock grub_uint64_t rootino; grub_uint8_t unused3[20]; grub_uint32_t agsize; - grub_uint8_t unused4[20]; + grub_uint8_t unused4[12]; + grub_uint16_t version; + grub_uint8_t unused5[6]; grub_uint8_t label[12]; grub_uint8_t log2_bsize; grub_uint8_t log2_sect; @@ -54,12 +100,19 @@ struct grub_xfs_sblock grub_uint8_t log2_agblk; grub_uint8_t unused6[67]; grub_uint8_t log2_dirblk; + grub_uint8_t unused7[7]; + grub_uint32_t features2; + grub_uint8_t unused8[4]; + grub_uint32_t sb_features_compat; + grub_uint32_t sb_features_ro_compat; + grub_uint32_t sb_features_incompat; + grub_uint32_t sb_features_log_incompat; } GRUB_PACKED; struct grub_xfs_dir_header { grub_uint8_t count; - grub_uint8_t smallino; + grub_uint8_t largeino; union { grub_uint32_t i4; @@ -67,14 +120,16 @@ struct grub_xfs_dir_header } GRUB_PACKED parent; } GRUB_PACKED; +/* Structure for directory entry inlined in the inode */ struct grub_xfs_dir_entry { grub_uint8_t len; grub_uint16_t offset; char name[1]; - /* Inode number follows, 32 bits. */ + /* Inode number follows, 32 / 64 bits. */ } GRUB_PACKED; +/* Structure for directory entry in a block */ struct grub_xfs_dir2_entry { grub_uint64_t inode; @@ -90,7 +145,8 @@ struct grub_xfs_btree_node grub_uint16_t numrecs; grub_uint64_t left; grub_uint64_t right; - grub_uint64_t keys[1]; + /* In V5 here follow crc, uuid, etc. */ + /* Then follow keys and block pointers */ } GRUB_PACKED; struct grub_xfs_btree_root @@ -123,19 +179,11 @@ struct grub_xfs_inode grub_uint16_t unused3; grub_uint8_t fork_offset; grub_uint8_t unused4[17]; - union - { - char raw[156]; - struct dir - { - struct grub_xfs_dir_header dirhead; - struct grub_xfs_dir_entry direntry[1]; - } dir; - grub_xfs_extent extents[XFS_INODE_EXTENTS]; - struct grub_xfs_btree_root btree; - } GRUB_PACKED data; } GRUB_PACKED; +#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode) +#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76) + struct grub_xfs_dirblock_tail { grub_uint32_t leaf_count; @@ -157,6 +205,8 @@ struct grub_xfs_data int pos; int bsize; grub_uint32_t agsize; + unsigned int hasftype:1; + unsigned int hascrc:1; struct grub_fshelp_node diropen; }; @@ -164,6 +214,71 @@ static grub_dl_t my_mod; +static int grub_xfs_sb_hascrc(struct grub_xfs_data *data) +{ + return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5); +} + +static int grub_xfs_sb_hasftype(struct grub_xfs_data *data) +{ + if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5) && + data->sblock.sb_features_incompat & grub_cpu_to_be32_compile_time(XFS_SB_FEAT_INCOMPAT_FTYPE)) + return 1; + if (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) && + data->sblock.features2 & grub_cpu_to_be32_compile_time(XFS_SB_VERSION2_FTYPE)) + return 1; + return 0; +} + +static int grub_xfs_sb_valid(struct grub_xfs_data *data) +{ + grub_dprintf("xfs", "Validating superblock\n"); + if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4) + || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS + || ((int) data->sblock.log2_bsize + + (int) data->sblock.log2_dirblk) >= 27) + { + grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem"); + return 0; + } + if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5)) + { + grub_dprintf("xfs", "XFS v5 superblock detected\n"); + if (data->sblock.sb_features_incompat & + grub_cpu_to_be32_compile_time(~XFS_SB_FEAT_INCOMPAT_SUPPORTED)) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported " + "incompatible features"); + return 0; + } + return 1; + } + else if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_4)) + { + grub_dprintf("xfs", "XFS v4 superblock detected\n"); + if (!(data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_DIRV2BIT))) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem without V2 directories " + "is unsupported"); + return 0; + } + if (data->sblock.version & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION_BITS_SUPPORTED) || + (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) && + data->sblock.features2 & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION2_BITS_SUPPORTED))) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported version " + "bits"); + return 0; + } + return 1; + } + return 0; +} + /* Filetype information as used in inodes. */ #define FILETYPE_INO_MASK 0170000 #define FILETYPE_INO_REG 0100000 @@ -219,18 +334,6 @@ GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex) return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1)); } -static inline int -GRUB_XFS_ROUND_TO_DIRENT (int pos) -{ - return ((((pos) + 8 - 1) / 8) * 8); -} - -static inline int -GRUB_XFS_NEXT_DIRENT (int pos, int len) -{ - return (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2); -} - static inline grub_uint64_t grub_xfs_inode_block (struct grub_xfs_data *data, @@ -274,6 +377,85 @@ grub_xfs_fshelp_size(struct grub_xfs_data *data) + grub_xfs_inode_size(data); } +static void * +grub_xfs_inode_data(struct grub_xfs_inode *inode) +{ + if (inode->version <= 2) + return ((char *)inode) + XFS_V2_INODE_SIZE; + return ((char *)inode) + XFS_V3_INODE_SIZE; +} + +static struct grub_xfs_dir_entry * +grub_xfs_inline_de(struct grub_xfs_dir_header *head) +{ + /* + * With small inode numbers the header is 4 bytes smaller because of + * smaller parent pointer + */ + return (void *)(((char *)head) + sizeof(struct grub_xfs_dir_header) - + (head->largeino ? 0 : sizeof(grub_uint32_t))); +} + +static grub_uint8_t * +grub_xfs_inline_de_inopos(struct grub_xfs_data *data, + struct grub_xfs_dir_entry *de) +{ + return ((grub_uint8_t *)(de + 1)) + de->len - 1 + + (data->hasftype ? 1 : 0); +} + +static struct grub_xfs_dir_entry * +grub_xfs_inline_next_de(struct grub_xfs_data *data, + struct grub_xfs_dir_header *head, + struct grub_xfs_dir_entry *de) +{ + char *p = (char *)de + sizeof(struct grub_xfs_dir_entry) - 1 + de->len; + + p += head->largeino ? sizeof(grub_uint64_t) : sizeof(grub_uint32_t); + if (data->hasftype) + p++; + + return (struct grub_xfs_dir_entry *)p; +} + +static struct grub_xfs_dirblock_tail * +grub_xfs_dir_tail(struct grub_xfs_data *data, void *dirblock) +{ + int dirblksize = 1 << (data->sblock.log2_bsize + data->sblock.log2_dirblk); + + return (struct grub_xfs_dirblock_tail *) + ((char *)dirblock + dirblksize - sizeof (struct grub_xfs_dirblock_tail)); +} + +static struct grub_xfs_dir2_entry * +grub_xfs_first_de(struct grub_xfs_data *data, void *dirblock) +{ + if (data->hascrc) + return (struct grub_xfs_dir2_entry *)((char *)dirblock + 64); + return (struct grub_xfs_dir2_entry *)((char *)dirblock + 16); +} + +static struct grub_xfs_dir2_entry * +grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de) +{ + int size = sizeof (struct grub_xfs_dir2_entry) + de->len + 2 /* Tag */; + + if (data->hasftype) + size++; /* File type */ + return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8)); +} + +static grub_uint64_t * +grub_xfs_btree_keys(struct grub_xfs_data *data, + struct grub_xfs_btree_node *leaf) +{ + grub_uint64_t *keys = (grub_uint64_t *)(leaf + 1); + + if (data->hascrc) + keys += 6; /* skip crc, uuid, ... */ + return keys; +} + static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, struct grub_xfs_inode *inode) @@ -281,6 +463,8 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, grub_uint64_t block = grub_xfs_inode_block (data, ino); int offset = grub_xfs_inode_offset (data, ino); + grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n", + ino, block, offset); /* Read the inode. */ if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), inode)) @@ -303,6 +487,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (node->inode.format == XFS_INODE_FORMAT_BTREE) { + struct grub_xfs_btree_root *root; const grub_uint64_t *keys; int recoffset; @@ -310,15 +495,15 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (leaf == 0) return 0; - nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs); - keys = &node->inode.data.btree.keys[0]; + root = grub_xfs_inode_data(&node->inode); + nrec = grub_be_to_cpu16 (root->numrecs); + keys = &root->keys[0]; if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else recoffset = (grub_xfs_inode_size(node->data) - - ((char *) &node->inode.data.btree.keys - - (char *) &node->inode)) - / (2 * sizeof (grub_uint64_t)); + - ((char *) keys - (char *) &node->inode)) + / (2 * sizeof (grub_uint64_t)); do { int i; @@ -340,7 +525,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) 0, node->data->bsize, leaf)) return 0; - if (grub_strncmp ((char *) leaf->magic, "BMAP", 4)) + if ((!node->data->hascrc && + grub_strncmp ((char *) leaf->magic, "BMAP", 4)) || + (node->data->hascrc && + grub_strncmp ((char *) leaf->magic, "BMA3", 4))) { grub_free (leaf); grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node"); @@ -348,8 +536,8 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) } nrec = grub_be_to_cpu16 (leaf->numrecs); - keys = &leaf->keys[0]; - recoffset = ((node->data->bsize - ((char *) &leaf->keys + keys = grub_xfs_btree_keys(node->data, leaf); + recoffset = ((node->data->bsize - ((char *) keys - (char *) leaf)) / (2 * sizeof (grub_uint64_t))); } @@ -359,7 +547,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) else if (node->inode.format == XFS_INODE_FORMAT_EXT) { nrec = grub_be_to_cpu32 (node->inode.nextents); - exts = &node->inode.data.extents[0]; + exts = grub_xfs_inode_data(&node->inode); } else { @@ -417,7 +605,7 @@ grub_xfs_read_symlink (grub_fshelp_node_t node) switch (node->inode.format) { case XFS_INODE_FORMAT_INO: - return grub_strndup (node->inode.data.raw, size); + return grub_strndup (grub_xfs_inode_data(&node->inode), size); case XFS_INODE_FORMAT_EXT: { @@ -512,23 +700,18 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { case XFS_INODE_FORMAT_INO: { - struct grub_xfs_dir_entry *de = &diro->inode.data.dir.direntry[0]; - int smallino = !diro->inode.data.dir.dirhead.smallino; + struct grub_xfs_dir_header *head = grub_xfs_inode_data(&diro->inode); + struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head); + int smallino = !head->largeino; int i; grub_uint64_t parent; /* If small inode numbers are used to pack the direntry, the parent inode number is small too. */ if (smallino) - { - parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4); - /* The header is a bit smaller than usual. */ - de = (struct grub_xfs_dir_entry *) ((char *) de - 4); - } + parent = grub_be_to_cpu32 (head->parent.i4); else - { - parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); - } + parent = grub_be_to_cpu64 (head->parent.i8); /* Synthesize the direntries for `.' and `..'. */ if (iterate_dir_call_hook (diro->ino, ".", &ctx)) @@ -537,12 +720,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, if (iterate_dir_call_hook (parent, "..", &ctx)) return 1; - for (i = 0; i < diro->inode.data.dir.dirhead.count; i++) + for (i = 0; i < head->count; i++) { grub_uint64_t ino; - grub_uint8_t *inopos = (((grub_uint8_t *) de) - + sizeof (struct grub_xfs_dir_entry) - + de->len - 1); + grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de); grub_uint8_t c; /* inopos might be unaligned. */ @@ -567,10 +748,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, return 1; de->name[de->len] = c; - de = ((struct grub_xfs_dir_entry *) - (((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len - + ((smallino ? sizeof (grub_uint32_t) - : sizeof (grub_uint64_t))) - 1)); + de = grub_xfs_inline_next_de(dir->data, head, de); } break; } @@ -597,15 +775,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, >> dirblk_log2); blk++) { - /* The header is skipped, the first direntry is stored - from byte 16. */ - int pos = 16; + struct grub_xfs_dir2_entry *direntry = + grub_xfs_first_de(dir->data, dirblock); int entries; - int tail_start = (dirblk_size - - sizeof (struct grub_xfs_dirblock_tail)); - - struct grub_xfs_dirblock_tail *tail; - tail = (struct grub_xfs_dirblock_tail *) &dirblock[tail_start]; + struct grub_xfs_dirblock_tail *tail = + grub_xfs_dir_tail(dir->data, dirblock); numread = grub_xfs_read_file (dir, 0, 0, blk << dirblk_log2, @@ -617,13 +791,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - grub_be_to_cpu32 (tail->leaf_stale)); /* Iterate over all entries within this block. */ - while (pos < tail_start) + while ((char *)direntry < (char *)tail) { - struct grub_xfs_dir2_entry *direntry; grub_uint8_t *freetag; char *filename; - direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos]; freetag = (grub_uint8_t *) direntry; if (grub_get_unaligned16 (freetag) == 0XFFFF) @@ -631,14 +803,16 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t)); /* This entry is not used, go to the next one. */ - pos += grub_be_to_cpu16 (grub_get_unaligned16 (skip)); + direntry = (struct grub_xfs_dir2_entry *) + (((char *)direntry) + + grub_be_to_cpu16 (grub_get_unaligned16 (skip))); continue; } - filename = &dirblock[pos + sizeof (*direntry)]; - /* The byte after the filename is for the tag, which - is not used by GRUB. So it can be overwritten. */ + filename = (char *)(direntry + 1); + /* The byte after the filename is for the filetype, padding, or + tag, which is not used by GRUB. So it can be overwritten. */ filename[direntry->len] = '\0'; if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), @@ -655,8 +829,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, break; /* Select the next directory entry. */ - pos = GRUB_XFS_NEXT_DIRENT (pos, direntry->len); - pos = GRUB_XFS_ROUND_TO_DIRENT (pos); + direntry = grub_xfs_next_de(dir->data, direntry); } } grub_free (dirblock); @@ -681,19 +854,14 @@ grub_xfs_mount (grub_disk_t disk) if (!data) return 0; + grub_dprintf("xfs", "Reading sb\n"); /* Read the superblock. */ if (grub_disk_read (disk, 0, 0, sizeof (struct grub_xfs_sblock), &data->sblock)) goto fail; - if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4) - || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS - || ((int) data->sblock.log2_bsize - + (int) data->sblock.log2_dirblk) >= 27) - { - grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem"); - goto fail; - } + if (!grub_xfs_sb_valid(data)) + goto fail; data = grub_realloc (data, sizeof (struct grub_xfs_data) @@ -708,9 +876,13 @@ grub_xfs_mount (grub_disk_t disk) data->diropen.inode_read = 1; data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize); + data->hasftype = grub_xfs_sb_hasftype(data); + data->hascrc = grub_xfs_sb_hascrc(data); data->disk = disk; data->pos = 0; + grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n", + grub_cpu_to_be64(data->sblock.rootino)); grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode); From df2aaf94b8d76b1ff7479ad5dc990f3efa30e419 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 12 Jun 2015 09:40:00 +0300 Subject: [PATCH 0260/1167] NEWS: XFS v5 support --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index e417ebad1..ad572ffe1 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ New in 2.02: files. * ZFS features support. * ZFS LZ4 support. + * XFS V5 format support. * New/improved terminal and video support: * Monochrome text (matching `hercules' in GRUB Legacy). From f4b1b48a837a034748a103adc7e9fd719a39ce42 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Thu, 28 May 2015 19:14:19 +0200 Subject: [PATCH 0261/1167] disk/ahci.c: Use defines `GRUB_AHCI_HBA_PORT_CMD_SPIN_UP` and `GRUB_AHCI_HBA_PORT_CMD_POWER_ON` Instead of hard coding `2` and `4` use the macros defined already at the top of the file. As a consequence, wrap the now too long line. --- grub-core/disk/ahci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index da5fead26..f4725e8c1 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -552,7 +552,9 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command - = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4; + = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) + | GRUB_AHCI_HBA_PORT_CMD_SPIN_UP + | GRUB_AHCI_HBA_PORT_CMD_POWER_ON; /* struct grub_disk_ata_pass_through_parms parms2; grub_memset (&parms2, 0, sizeof (parms2)); From c945ca75c3b2b900040b905323b1226cb60a1166 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Fri, 15 Aug 2014 12:22:43 -0400 Subject: [PATCH 0262/1167] Fix exit to EFI firmware The current code for EFI grub_exit() calls grub_efi_fini() before returning to firmware. In the case of ARM, this leaves a timer event running which could lead to a firmware crash. This patch changes this so that grub_machine_fini() is called with a NORETURN flag. This allows machine-specific shutdown to happen as well as the shutdown done by grub_efi_fini(). Signed-off-by: Mark Salter --- grub-core/kern/arm/efi/init.c | 2 +- grub-core/kern/efi/efi.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c index a6ae03475..2572ca8b7 100644 --- a/grub-core/kern/arm/efi/init.c +++ b/grub-core/kern/arm/efi/init.c @@ -67,7 +67,7 @@ grub_machine_fini (int flags) b = grub_efi_system_table->boot_services; - efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 0); + efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_CANCEL, 0); efi_call_1 (b->close_event, tmr_evt); grub_efi_fini (); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 49a150133..2e7783468 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -27,6 +27,7 @@ #include #include #include +#include /* The handle of GRUB itself. Filled in by the startup code. */ grub_efi_handle_t grub_efi_image_handle; @@ -156,7 +157,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) void grub_exit (void) { - grub_efi_fini (); + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); efi_call_4 (grub_efi_system_table->boot_services->exit, grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0); for (;;) ; From afd0f21b2027310fda52b00ac1b964041d39a363 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Mon, 15 Jun 2015 09:10:19 -0300 Subject: [PATCH 0263/1167] Add flag for powerpc ieee1275 to avoid unneeded optimizations --- conf/Makefile.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/Makefile.common b/conf/Makefile.common index 96e58c9a4..fcb8d2e1c 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -17,6 +17,9 @@ endif if COND_arm64 CFLAGS_PLATFORM += -mcmodel=large endif +if COND_powerpc_ieee1275 + CFLAGS_PLATFORM += -mcpu=powerpc +endif #FIXME: discover and check XEN headers CPPFLAGS_XEN = -I/usr/include From b27af387ea56123bfb101f2129490fa2df704d22 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 16 Jun 2015 19:49:32 +0300 Subject: [PATCH 0264/1167] NEWS: mention libgcc removal --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index ad572ffe1..6e33909de 100644 --- a/NEWS +++ b/NEWS @@ -146,6 +146,9 @@ New in 2.02: Python 2.6. * modinfo.sh contains build information now. * Added many new tests to improve robustness. + * Target is built without libgcc now. Necessary builtins are reimplemented + directly. This removes requirement for target-specific runtime on build + system. * Revision control moved to git. From f348aee7b33dd85e7da62b497a96a7319a0bf9dd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 16 Jun 2015 19:52:45 +0300 Subject: [PATCH 0265/1167] efinet: enable hardware filters when opening interface Exclusive open on SNP will close all existing protocol instances which may disable all receive filters on interface. Reinstall them after we opened protocol exclusively. Also follow UEFI specification recommendation and stop interfaces when closing them: Unexpected system errors, reboots and hangs can occur if an OS is loaded and the network devices are not Shutdown() and Stopped(). Also by: Mark Salter Closes: 45204 --- grub-core/net/drivers/efi/efinet.c | 25 +++++++++++++++++++++++++ include/grub/efi/api.h | 20 +++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 5533515fd..70b26af94 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -168,6 +168,29 @@ open_card (struct grub_net_card *dev) return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed", dev->name); + /* Enable hardware receive filters if driver declares support for it. + We need unicast and broadcast and additionaly all nodes and + solicited multicast for IPv6. Solicited multicast is per-IPv6 + address and we currently do not have API to do it so simply + try to enable receive of all multicast packets or evertyhing in + the worst case (i386 PXE driver always enables promiscuous too). + + This does trust firmware to do what it claims to do. + */ + if (net->mode->receive_filter_mask) + { + grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; + + filters &= net->mode->receive_filter_mask; + if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) + filters |= (net->mode->receive_filter_mask & + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); + + efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); + } + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, dev->efi_net, &net_io_guid, grub_efi_image_handle, dev->efi_handle); @@ -181,6 +204,8 @@ open_card (struct grub_net_card *dev) static void close_card (struct grub_net_card *dev) { + efi_call_1 (dev->efi_net->shutdown, dev->efi_net); + efi_call_1 (dev->efi_net->stop, dev->efi_net); efi_call_4 (grub_efi_system_table->boot_services->close_protocol, dev->efi_net, &net_io_guid, grub_efi_image_handle, dev->efi_handle); diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index e5dd543a8..1a5e38c1e 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1501,17 +1501,31 @@ enum GRUB_EFI_NETWORK_INITIALIZED, }; +enum + { + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10, + }; + struct grub_efi_simple_network { grub_uint64_t revision; grub_efi_status_t (*start) (struct grub_efi_simple_network *this); - void (*stop) (void); + grub_efi_status_t (*stop) (struct grub_efi_simple_network *this); grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this, grub_efi_uintn_t extra_rx, grub_efi_uintn_t extra_tx); void (*reset) (void); - void (*shutdown) (void); - void (*receive_filters) (void); + grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this); + grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this, + grub_uint32_t enable, + grub_uint32_t disable, + grub_efi_boolean_t reset_mcast_filter, + grub_efi_uintn_t mcast_filter_count, + grub_efi_mac_address_t *mcast_filter); void (*station_address) (void); void (*statistics) (void); void (*mcastiptomac) (void); From 7af839a108857714b04cfc9384afa0b6d34c10c2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 18 Jun 2015 20:09:47 +0300 Subject: [PATCH 0266/1167] tests: regression tests for "." and ".." directory entries --- tests/util/grub-fs-tester.in | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index e9e85c2a8..5107ca17a 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1121,6 +1121,36 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi fi + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/.");; + *) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/.");; + esac + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/..");; + *) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/..");; + esac + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOTDOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + case x"$fs" in x"zfs"*) LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/////sdir");; @@ -1151,6 +1181,36 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + exit 1 fi + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/.");; + *) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/.");; + esac + if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then + : + else + echo DOT IN SUBDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/sdir" + exit 1 + fi + + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/../sdir");; + *) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/../sdir");; + esac + if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then + : + else + echo DOTDOT IN SUBDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/ssdir" + exit 1 + fi + LSOUT=`run_grubfstest ls -- -l "($GRUBDEVICE)"` if [ x"$NOFSLABEL" = xy ]; then : From 7bb7140df2b6fd5c1fee6c47488724bc256e957a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 18 Jun 2015 20:09:47 +0300 Subject: [PATCH 0267/1167] fat: fix handling of "." and ".." directory entries Emulate dot and dotdot in root directory. For other directories do not add separator between name and extension for these two special entries. Closes: 45335 --- grub-core/fs/fat.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 71537ff44..827708c18 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -829,7 +829,9 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, i--; } - *filep++ = '.'; + /* XXX should we check that dir position is 0 or 1? */ + if (i > 2 || filep[0] != '.' || (i == 2 && filep[1] != '.')) + *filep++ = '.'; for (i = 8; i < 11 && ctxt->dir.name[i]; i++) *filep++ = grub_tolower (ctxt->dir.name[i]); @@ -871,9 +873,31 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, return 0; } - /* Extract a directory name. */ - while (*path == '/') - path++; + do + { + /* Extract a directory name. */ + while (*path == '/') + path++; + + /* Emulate special "." and ".." entries in root directory */ + if (data->file_cluster == data->root_cluster) + { + if (*path != '.') + break; + if (!path[1] || path[1] == '/') + { + path++; + continue; + } + if (path[1] == '.' && (!path[2] || path[2] == '/')) + { + path += 2; + continue; + } + } + break; + } + while (1); dirp = grub_strchr (path, '/'); if (dirp) @@ -935,6 +959,9 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) | grub_le_to_cpu16 (ctxt.dir.first_cluster_low)); + /* If directory points to root, starting cluster is 0 */ + if (!data->file_cluster) + data->file_cluster = data->root_cluster; #endif data->cur_cluster_num = ~0U; From 8067fe28edcedacf2507132baaab65dc3c4bb3d5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 17:35:17 +0300 Subject: [PATCH 0268/1167] syslinux_parse: make print_escaped actually stop before `to' The only current user is mboot.c32 which unfortunately is not covered by regression tests. --- grub-core/lib/syslinux_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 153260b54..ba71a4831 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -772,7 +772,7 @@ print_escaped (struct output_buffer *outbuf, if (err) return err; outbuf->buf[outbuf->ptr++] = '\''; - for (ptr = from; *ptr; ptr++) + for (ptr = from; *ptr && ptr < to; ptr++) { if (*ptr == '\'') { From 48cd9dc104082d4106ccd81fa3feec0d514ddd08 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 0269/1167] syslinux_parse: assorted issues found by Coverity 1. Remove unneeded NULL check CID: 96607 2. Do not allocate storage for initrd, copy it directly from input buffer. Avoids memory leak in failure path. CID: 96604 3. Unchecked error return from print() CID: 96601, 73595 --- grub-core/lib/syslinux_parse.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index ba71a4831..28ba3aef0 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -874,7 +874,9 @@ print_config (struct output_buffer *outbuf, print_string ("#"); print_file (outbuf, menu, filename, NULL); print_string (" "); - print (outbuf, newname, grub_strlen (newname)); + err = print (outbuf, newname, grub_strlen (newname)); + if (err) + return err; print_string (":\n"); for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) @@ -944,8 +946,8 @@ write_entry (struct output_buffer *outbuf, { case KERNEL_LINUX: { - char *ptr; - char *initrd = NULL; + const char *ptr; + const char *initrd = NULL, *initrde= NULL; for (ptr = curentry->append; ptr && *ptr; ptr++) if ((ptr == curentry->append || grub_isspace (ptr[-1])) && grub_strncasecmp (ptr, "initrd=", sizeof ("initrd=") - 1) @@ -953,12 +955,8 @@ write_entry (struct output_buffer *outbuf, break; if (ptr && *ptr) { - char *ptr2; - initrd = grub_strdup(ptr + sizeof ("initrd=") - 1); - if (!initrd) - return grub_errno; - for (ptr2 = initrd; *ptr2 && !grub_isspace (*ptr2); ptr2++); - *ptr2 = 0; + initrd = ptr + sizeof ("initrd=") - 1; + for (initrde = initrd; *initrde && !grub_isspace (*initrde); initrde++); } print_string (" if test x$grub_platform = xpc; then " "linux_suffix=16; else linux_suffix= ; fi\n"); @@ -966,7 +964,11 @@ write_entry (struct output_buffer *outbuf, print_file (outbuf, menu, curentry->kernel_file, NULL); print_string (" "); if (curentry->append) - print (outbuf, curentry->append, grub_strlen (curentry->append)); + { + err = print (outbuf, curentry->append, grub_strlen (curentry->append)); + if (err) + return err; + } print_string ("\n"); if (initrd || curentry->initrds) { @@ -974,7 +976,7 @@ write_entry (struct output_buffer *outbuf, print_string (" initrd$linux_suffix "); if (initrd) { - print_file (outbuf, menu, initrd, NULL); + print_file (outbuf, menu, initrd, initrde); print_string (" "); } for (lst = curentry->initrds; lst; lst = lst->next) @@ -985,7 +987,6 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } - grub_free (initrd); } break; case KERNEL_CHAINLOADER: @@ -1197,8 +1198,7 @@ write_entry (struct output_buffer *outbuf, ptr++; i386e = ptr; } - if (lme) - *lme = '\0'; + *lme = '\0'; if (paee) *paee = '\0'; if (i386e) From 10a6d2d91562231d3b21fb0c64adf88805a6fbec Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 0270/1167] unix/relpath: memory leak Found by Coverity scan. CID: 96606 --- grub-core/osdep/unix/relpath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c index 8fdc3a73a..f719950fd 100644 --- a/grub-core/osdep/unix/relpath.c +++ b/grub-core/osdep/unix/relpath.c @@ -51,7 +51,10 @@ grub_make_system_path_relative_to_its_root (const char *path) #ifdef __linux__ ret = grub_make_system_path_relative_to_its_root_os (p); if (ret) - return ret; + { + free (p); + return ret; + } #endif /* For ZFS sub-pool filesystems. */ From 5d0ee3d7a1a1381cb75111f2992d5d97b301894f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 0271/1167] unix/getroot: memory leak Found by Coverity scan. CID: 96605 --- grub-core/osdep/unix/getroot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index b98b2dfb0..14d483fb1 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -544,6 +544,7 @@ grub_guess_root_devices (const char *dir_in) if (stat (dir, &st) < 0) grub_util_error (_("cannot stat `%s': %s"), dir, strerror (errno)); + free (dir); dev = st.st_dev; From 15ba6a40be2ce73f89d781ffdfc0e19e43a4d80f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 0272/1167] zfs: memory leak Found by Coverity scan. CID: 96603 --- grub-core/fs/zfs/zfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index f9ca0e75e..252cefdc6 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3668,6 +3668,8 @@ zfs_mount (grub_device_t dev) data) != 0) { grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool"); + grub_free (osp); + zfs_unmount (data); return NULL; } From 4db569ca6a471aff9f2669d6e3a2fbb33f563425 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 0273/1167] xfs: silence Coverity overflow warning inode size cannot really overflow integer, but Coverity does not know it. CID: 96602 --- grub-core/fs/xfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index f00e43e7d..724929155 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -361,7 +361,7 @@ grub_xfs_inode_offset (struct grub_xfs_data *data, static inline grub_size_t grub_xfs_inode_size(struct grub_xfs_data *data) { - return 1 << data->sblock.log2_inode; + return (grub_size_t)1 << data->sblock.log2_inode; } /* From fbdd37e7f947ae39208ce0b6f0dd17e958cd5b8e Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:43 +0300 Subject: [PATCH 0274/1167] zfs: fix memory leak Found by: Coverity scan. CID: 73647 --- grub-core/fs/zfs/zfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 252cefdc6..c4ead29fb 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2882,7 +2882,10 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, err = dmu_read (&(dnode_path->dn), block, &t, 0, data); if (err) - return err; + { + grub_free (sym_value); + return err; + } movesize = sym_sz - block * blksz; if (movesize > blksz) From 03f1f24e37d59e79b6c011cb51bab215cc7ec9cd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:43 +0300 Subject: [PATCH 0275/1167] grub-probe: restructure code to make static analysis easier Current code in probe() could not be verified to not contain memory leaks. Restructure code and ensure grub_device_close is always called at the end of loop. Calms down Coverity scan. CID: 73739 --- util/grub-probe.c | 86 ++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 61 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 6075cb3fc..4013229cb 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -485,23 +485,18 @@ probe (const char *path, char **device_names, char delim) printf (" "); else printf ("\n"); - - grub_device_close (dev); - continue; } - if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT + else if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT || print == PRINT_IEEE1275_HINT || print == PRINT_BAREMETAL_HINT || print == PRINT_EFI_HINT || print == PRINT_ARC_HINT) && dev->disk->dev->id != GRUB_DISK_DEVICE_HOSTDISK_ID) { grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev); putchar (delim); - grub_device_close (dev); - continue; } - if (print == PRINT_COMPATIBILITY_HINT) + else if (print == PRINT_COMPATIBILITY_HINT) { const char *map; char *biosname; @@ -519,16 +514,14 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); + /* Compatibility hint is one device only. */ + grub_device_close (dev); + break; } - free (biosname); - grub_device_close (dev); - /* Compatibility hint is one device only. */ - if (biosname) - break; - continue; } - if (print == PRINT_BIOS_HINT) + else if (print == PRINT_BIOS_HINT) { char *biosname; biosname = grub_util_guess_bios_drive (*curdev); @@ -536,12 +529,10 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_IEEE1275_HINT) + else if (print == PRINT_IEEE1275_HINT) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); char *ofpath = grub_util_devname_to_ofpath (osdev); @@ -565,11 +556,8 @@ probe (const char *path, char **device_names, char delim) free (ofpath); putchar (delim); } - - grub_device_close (dev); - continue; } - if (print == PRINT_EFI_HINT) + else if (print == PRINT_EFI_HINT) { char *biosname; const char *map; @@ -585,14 +573,11 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_BAREMETAL_HINT) + else if (print == PRINT_BAREMETAL_HINT) { char *biosname; const char *map; @@ -609,14 +594,11 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_ARC_HINT) + else if (print == PRINT_ARC_HINT) { const char *map; @@ -626,46 +608,28 @@ probe (const char *path, char **device_names, char delim) grub_util_fprint_full_disk_name (stdout, map, dev); putchar (delim); } - - /* FIXME */ - grub_device_close (dev); - continue; } - if (print == PRINT_ABSTRACTION) - { - probe_abstraction (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_ABSTRACTION) + probe_abstraction (dev->disk, delim); - if (print == PRINT_CRYPTODISK_UUID) - { - probe_cryptodisk_uuid (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_CRYPTODISK_UUID) + probe_cryptodisk_uuid (dev->disk, delim); - if (print == PRINT_PARTMAP) - { - /* Check if dev->disk itself is contained in a partmap. */ - probe_partmap (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_PARTMAP) + /* Check if dev->disk itself is contained in a partmap. */ + probe_partmap (dev->disk, delim); - if (print == PRINT_MSDOS_PARTTYPE) + else if (print == PRINT_MSDOS_PARTTYPE) { if (dev->disk->partition && strcmp(dev->disk->partition->partmap->name, "msdos") == 0) printf ("%02x", dev->disk->partition->msdostype); putchar (delim); - grub_device_close (dev); - continue; } - if (print == PRINT_GPT_PARTTYPE) + else if (print == PRINT_GPT_PARTTYPE) { if (dev->disk->partition && strcmp (dev->disk->partition->partmap->name, "gpt") == 0) @@ -694,9 +658,9 @@ probe (const char *path, char **device_names, char delim) dev->disk->partition = p; } putchar (delim); - grub_device_close (dev); - continue; } + + grub_device_close (dev); } end: From 4358e0c81ec506ad9400f053b3f1f41597285833 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:44 +0300 Subject: [PATCH 0276/1167] grub-probe: fix memory leak in probe (ofpath) Found by: Coverity scan. CID: 73772 --- util/grub-probe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 4013229cb..b1f533626 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -429,7 +429,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_HINT_STR) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); - const char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0; + char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0; char *biosname, *bare, *efi; const char *map; @@ -443,6 +443,7 @@ probe (const char *path, char **device_names, char delim) grub_util_fprint_full_disk_name (stdout, tmp, dev); printf ("' "); free (tmp); + free (ofpath); } biosname = grub_util_guess_bios_drive (*curdev); From 72ccf92c3937fda8f101b62e6ec8eb389aa8a915 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 09:23:43 +0300 Subject: [PATCH 0277/1167] NEWS: emu libusb support removed --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 6e33909de..4abd873de 100644 --- a/NEWS +++ b/NEWS @@ -149,6 +149,7 @@ New in 2.02: * Target is built without libgcc now. Necessary builtins are reimplemented directly. This removes requirement for target-specific runtime on build system. + * emu libusb support removed (was broken and unmaintained). * Revision control moved to git. From 0fb886cde97b8b65eceece62440194523530737a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:17 +0300 Subject: [PATCH 0278/1167] search: fix use after free Found by: Coverity scan. CID: 96715 --- grub-core/commands/search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index 16143a34c..440303a4e 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -210,10 +210,10 @@ try (struct search_ctx *ctx) /* Cache entry was outdated. Remove it. */ if (!ctx->count) { + *prev = cache_ent->next; grub_free (cache_ent->key); grub_free (cache_ent->value); grub_free (cache_ent); - *prev = cache_ent->next; } } From c069460259b0a3ed77c4035267250dc2b82f1cb4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:17 +0300 Subject: [PATCH 0279/1167] efi/chainloader: fix use after free Found by: Coverity scan. CID: 96714 --- grub-core/loader/efi/chainloader.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index 233237018..ec23cf4ed 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -351,6 +351,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), loaded_image->device_handle = dev_handle; grub_file_close (file); + file = NULL; if (argc > 1) { From cd816bd23683de5fecc0aeafaed9e2b850b70dd8 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0280/1167] disk/scsi: fix use after free Found by: Coverity scan. CID: 96713 --- grub-core/disk/scsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index 92084d0f8..4c6923f8b 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -615,9 +615,10 @@ grub_scsi_open (const char *name, grub_disk_t disk) if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize) { + grub_error (GRUB_ERR_IO, "invalid sector size %d", + scsi->blocksize); grub_free (scsi); - return grub_error (GRUB_ERR_IO, "invalid sector size %d", - scsi->blocksize); + return grub_errno; } for (disk->log_sector_size = 0; (1U << disk->log_sector_size) < scsi->blocksize; From e261fcf4c6c3381691875e02549c5723ca06da7d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0281/1167] xnu: fix use after free Found by: Coverity scan. CID: 96706 --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index e0506a676..2fe1fdc1f 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -269,9 +269,9 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev, prop->data = grub_malloc (prop->length); if (!prop->data) { - grub_free (prop); grub_free (prop->name); grub_free (prop->name16); + grub_free (prop); return grub_errno; } grub_memcpy (prop->data, data, prop->length); From cf0b0306d818e1b79745420b2bdca449ba881130 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0282/1167] usb: fix use after free Found by: Coverity scan. CID: 96704 --- grub-core/bus/usb/usbtrans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index b614997f2..ee8680853 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -311,8 +311,8 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer) transfer->size + 1); grub_free (transfer->transactions); - grub_free (transfer); grub_dma_free (transfer->data_chunk); + grub_free (transfer); } static grub_usb_err_t From a6f7d1abce848da5593ccc39492ef5c1df11a33c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0283/1167] reed_solomon: fix memory leak Found by: Coverity scan. CID: 96688 --- grub-core/lib/reed_solomon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 7263cbc04..ee9fa7b4f 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -362,7 +362,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, /* Nothing to do. */ if (!rs) - return; + goto exit; init_powx (); @@ -388,6 +388,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, #ifndef TEST assert (grub_memcmp (tmp, buffer, data_size) == 0); #endif +exit: free (tmp); } #endif From 20211c0077a6eb9a0949fe9cb5778c7f69d28894 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0284/1167] loader/bsd: fix memory leak Found by: Coverity scan. CID: 96686 --- grub-core/loader/i386/bsdXX.c | 40 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 9e36cd4b6..cfb44c080 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -417,7 +417,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + { + grub_free (shdr); + return grub_errno; + } for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -426,7 +429,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, break; if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) - return GRUB_ERR_NONE; + { + grub_free (shdr); + return GRUB_ERR_NONE; + } symsize = s->sh_size; symsh = s; s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link); @@ -443,7 +449,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, symtarget, chunk_size); if (err) - return err; + goto out; sym_chunk = get_virtual_current_address (ch); } @@ -482,29 +488,41 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, } if (grub_file_seek (file, symsh->sh_offset) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } curload += ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)); if (grub_file_seek (file, strsh->sh_offset) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } err = grub_bsd_add_meta (NETBSD_BTINFO_SYMTAB, &symtab, sizeof (symtab)); +out: + grub_free (shdr); if (err) return err; From 2a3ebf94283171f919fee5a0e35e497d800816fb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0285/1167] normal: fix memory leak Found by: Coverity scan. CID: 96685 --- grub-core/normal/cmdline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c index 204d15a4b..a36180d75 100644 --- a/grub-core/normal/cmdline.c +++ b/grub-core/normal/cmdline.c @@ -389,6 +389,7 @@ grub_cmdline_get (const char *prompt_translated) if (!unicode_msg) { grub_free (buf); + grub_free (cl_terms); return 0; } msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1, From eb33e61b31902a5493468895aaf83fa0b4f5f59d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0286/1167] multiboot: fix memory leak Found by: Coverity scan. CID: 96684 --- grub-core/loader/multiboot_elfxx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 9dc21a1ba..6a220bdc1 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -169,7 +169,10 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_errno; if (grub_file_seek (file, ehdr->e_shoff) == (grub_off_t) -1) - return grub_errno; + { + grub_free (shdr); + return grub_errno; + } if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize) != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize) From 4a857e63c189a756e7c6099306faa41cf173ad28 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 0287/1167] loader/bsd: free memory leaks Found by: Coverity scan. CID: 96682 --- grub-core/loader/i386/bsdXX.c | 43 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index cfb44c080..53ae37c1e 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -292,13 +292,13 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + goto out; err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ELFHDR, &e, sizeof (e)); if (err) - return err; + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -307,7 +307,10 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, break; if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) - return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table")); + { + err = grub_error (GRUB_ERR_BAD_OS, N_("no symbol table")); + goto out; + } symoff = s->sh_offset; symsize = s->sh_size; symentsize = s->sh_entsize; @@ -325,7 +328,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, symtarget, chunk_size); if (err) - return err; + goto out; sym_chunk = get_virtual_current_address (ch); } @@ -337,28 +340,38 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, curload += sizeof (grub_freebsd_addr_t); if (grub_file_seek (file, symoff) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } sym = (Elf_Sym *) curload; if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } curload += symsize; *((grub_freebsd_addr_t *) curload) = strsize; curload += sizeof (grub_freebsd_addr_t); if (grub_file_seek (file, stroff) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } str = (char *) curload; if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } for (i = 0; @@ -378,18 +391,20 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, FREEBSD_MODINFOMD_DYNAMIC, &dynamic, sizeof (dynamic)); if (err) - return err; + goto out; } err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_SSYM, &symstart, sizeof (symstart)); if (err) - return err; + goto out; err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ESYM, &symend, sizeof (symend)); +out: + grub_free (shdr); if (err) return err; From 47490ada3ddc24a323a654cef7828f604d9b871a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0288/1167] ohci: fix memory leak Found by: Coverity scan. CID: 96679 --- grub-core/bus/usb/ohci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c index d27bfe7fb..f0be533d4 100644 --- a/grub-core/bus/usb/ohci.c +++ b/grub-core/bus/usb/ohci.c @@ -750,7 +750,10 @@ grub_ohci_setup_transfer (grub_usb_controller_t dev, { cdata->td_head_virt = grub_ohci_alloc_td (o); if (!cdata->td_head_virt) - return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */ + { + grub_free (cdata); + return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */ + } /* We can set td_head only when ED is not active, i.e. * when it is newly allocated. */ cdata->ed_virt->td_head From e7e05cae8d4bd48fb3221297fe3b388aeab47f37 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0289/1167] efi/serial: fix memory leak Found by: Coverity scan. CID: 96678 --- grub-core/term/efi/serial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c index c0911ad7b..4c94723c5 100644 --- a/grub-core/term/efi/serial.c +++ b/grub-core/term/efi/serial.c @@ -173,7 +173,10 @@ grub_efiserial_init (void) port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX")); if (!port->name) - return; + { + grub_free (port); + return; + } grub_snprintf (port->name, sizeof ("efiXXXXXXXXXXXXXXXXXXXX"), "efi%d", num_serial++); From 152695d0faefe763b2198048e6f3e905a8c0c786 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0290/1167] normal: fix memory leak Found by: Coverity scan. CID: 96677 --- grub-core/normal/context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 7e0a696f3..ee53d4a68 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -64,7 +64,10 @@ grub_env_new_context (int export_all) return grub_errno; menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (context); + return grub_errno; + } context->prev = grub_current_context; grub_current_context = context; From 2f01f08103aac50878c8ed704df5bfddf7443c5a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0291/1167] password_pbkdf2: fix memory leak Found by: Coverity scan. CID: 96676 --- grub-core/commands/password_pbkdf2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c index 0dd1aef3d..c6a77c8c5 100644 --- a/grub-core/commands/password_pbkdf2.c +++ b/grub-core/commands/password_pbkdf2.c @@ -104,7 +104,10 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), pass->c = grub_strtoul (ptr, &ptr, 0); if (grub_errno) - return grub_errno; + { + grub_free (pass); + return grub_errno; + } if (*ptr != '.') { grub_free (pass); From 5af859bb77c80583d4412a44929b33bb344b05f3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0292/1167] search_wrap: fix memory leak Found by: Coverity scan. CID: 96675 --- grub-core/commands/search_wrap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c index 3f75fecdf..d7fd26b94 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) var = "root"; } else - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); + goto out; + } if (state[SEARCH_LABEL].set) grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, @@ -187,8 +190,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, hints, nhints); else - return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); + grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); +out: + grub_free (hints); return grub_errno; } From 867c9b7bec3446daa6a14a553c404ea26548242b Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 0293/1167] loader/bsd: free memory leaks Found by: Coverity scan. CID: 96671, 96658, 96653 --- grub-core/loader/i386/bsdXX.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 53ae37c1e..051ff06b5 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -563,7 +563,10 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + { + grub_free (shdr); + return err; + } for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -616,7 +619,11 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, } if (grub_file_seek (file, stroff) == (grub_off_t) -1) - return grub_errno; + { + grub_free (syms); + grub_free (strs); + return grub_errno; + } if (grub_file_read (file, strs, strsize) != (grub_ssize_t) strsize) { grub_free (syms); From 806bb7999dab556ffa12db976480a129a43e8a68 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Jun 2015 09:25:30 +0300 Subject: [PATCH 0294/1167] loader/bsd: fix memory leak Found by: Coverity scan. CID: 96662, 96665 --- grub-core/loader/i386/bsdXX.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 051ff06b5..9f57cfa82 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -84,11 +84,11 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, grub_size_t chunk_size = 0; void *chunk_src; + curload = module = ALIGN_PAGE (*kern_end); + err = read_headers (file, argv[0], &e, &shdr); if (err) - return err; - - curload = module = ALIGN_PAGE (*kern_end); + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize); @@ -109,7 +109,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, module, chunk_size); if (err) - return err; + goto out; chunk_src = get_virtual_current_address (ch); } @@ -135,7 +135,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, s->sh_offset, s->sh_size); if (err) - return err; + goto out; break; case SHT_NOBITS: grub_memset ((grub_uint8_t *) chunk_src + curload - *kern_end, 0, @@ -159,6 +159,8 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, | FREEBSD_MODINFOMD_SHDR, shdr, e.e_shnum * e.e_shentsize); +out: + grub_free (shdr); return err; } @@ -177,11 +179,11 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, grub_size_t chunk_size = 0; void *chunk_src; + curload = module = ALIGN_PAGE (*kern_end); + err = read_headers (file, argv[0], &e, &shdr); if (err) - return err; - - curload = module = ALIGN_PAGE (*kern_end); + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize); @@ -207,7 +209,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, module, chunk_size); if (err) - return err; + goto out; chunk_src = get_virtual_current_address (ch); } @@ -235,7 +237,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, + s->sh_addr - *kern_end, s->sh_offset, s->sh_size); if (err) - return err; + goto out; break; case SHT_NOBITS: grub_memset ((grub_uint8_t *) chunk_src + module @@ -265,6 +267,10 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, grub_freebsd_add_meta_module (argv[0], FREEBSD_MODTYPE_ELF_MODULE, argc - 1, argv + 1, module, curload - module); +out: + grub_free (shdr); + if (err) + return err; return SUFFIX (grub_freebsd_load_elf_meta) (relocator, file, argv[0], kern_end); } From c058e85615fde15d9593ff0377cf3de94a906fac Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Jun 2015 09:25:30 +0300 Subject: [PATCH 0295/1167] chainloader: fix resoource leak Found by: Coverity scan. CID: 96651 --- grub-core/loader/efi/chainloader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index ec23cf4ed..522a716e3 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -350,9 +350,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } loaded_image->device_handle = dev_handle; - grub_file_close (file); - file = NULL; - if (argc > 1) { int i, len; @@ -382,6 +379,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), loaded_image->load_options_size = len; } + grub_file_close (file); + grub_device_close (dev); + grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); return 0; From 7a210304ebfd6d704b4fc08fe496a0c417441879 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 22 Jun 2015 16:45:27 +0800 Subject: [PATCH 0296/1167] Fix missing byte order conversion in get_btrfs_fs_prefix function Since btrfs on-disk format uses little-endian, the searched item types (ROOT_REF, INODE_REF) need converting the byte order in order to function properly on big-endian systems. --- grub-core/osdep/linux/getroot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index a2e360f52..3978c7114 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -316,9 +316,9 @@ get_btrfs_fs_prefix (const char *mount_path) tree_id = sargs.buf[2]; br = (struct grub_btrfs_root_backref *) (sargs.buf + 4); - inode_id = br->inode_id; + inode_id = grub_le_to_cpu64 (br->inode_id); name = br->name; - namelen = br->n; + namelen = grub_le_to_cpu16 (br->n); } else { @@ -345,7 +345,7 @@ get_btrfs_fs_prefix (const char *mount_path) ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4); name = ir->name; - namelen = ir->n; + namelen = grub_le_to_cpu16 (ir->n); } old = ret; ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2); From 0d7c7f751dc5a8338497bef8b38f78153c4f0464 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 5 Jul 2015 08:21:38 +0300 Subject: [PATCH 0297/1167] use TARGET_LDFLAGS in grub_PROG_OBJCOPY_ABSOLUTE That's what Makefile will use and it is required if unusual flags must be passed to linker (e.g. to build ppc32 code on ppc64le with clang). --- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 609c4f2f6..526f97a3a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -93,7 +93,7 @@ else fi grub_cv_prog_objcopy_absolute=yes for link_addr in 0x2000 0x8000 0x7C00; do - if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : + if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : else AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) fi From 54e7dbbcb93b913514e3e9f8f29e6372ea34ff32 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 16 Jul 2015 10:59:33 +0200 Subject: [PATCH 0298/1167] grub_ext2_read_block: Fix return type on error. --- grub-core/fs/ext2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 5199cb0c1..cdce63bcc 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -538,8 +538,9 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) shift = 2; goto indirect; } - return grub_error (GRUB_ERR_BAD_FS, - "ext2fs doesn't support quadruple indirect blocks"); + grub_error (GRUB_ERR_BAD_FS, + "ext2fs doesn't support quadruple indirect blocks"); + return -1; indirect: do { @@ -554,7 +555,7 @@ indirect: & ((1 << log_perblock) - 1)) * sizeof (indir), sizeof (indir), &indir)) - return grub_errno; + return -1; } while (shift--); return grub_le_to_cpu32 (indir); From ff3c2007ef22b4385ff189b60aaf1f9de3dff24b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 16 Jul 2015 12:46:02 +0200 Subject: [PATCH 0299/1167] XFS: Fix wrong alignment treatment. --- grub-core/fs/xfs.c | 87 ++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 724929155..46de6aff3 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -136,7 +136,13 @@ struct grub_xfs_dir2_entry grub_uint8_t len; } GRUB_PACKED; -typedef grub_uint32_t grub_xfs_extent[4]; +struct grub_xfs_extent +{ + /* This should be a bitfield but bietfields are unportable, so just have + a raw array and functions extracting useful info from it. + */ + grub_uint32_t raw[4]; +} GRUB_PACKED; struct grub_xfs_btree_node { @@ -147,20 +153,20 @@ struct grub_xfs_btree_node grub_uint64_t right; /* In V5 here follow crc, uuid, etc. */ /* Then follow keys and block pointers */ -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_btree_root { grub_uint16_t level; grub_uint16_t numrecs; grub_uint64_t keys[1]; -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_time { grub_uint32_t sec; grub_uint32_t nanosec; -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_inode { @@ -313,25 +319,25 @@ GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb) } static inline grub_uint64_t -GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex) { - return ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 - | grub_be_to_cpu32 (exts[ex][1]) >> 9); + return ((grub_be_to_cpu32 (exts[ex].raw[0]) & ~(1 << 31)) << 23 + | grub_be_to_cpu32 (exts[ex].raw[1]) >> 9); } static inline grub_uint64_t -GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_BLOCK (struct grub_xfs_extent *exts, int ex) { - return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1]) + return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1]) & (0x1ff)) << 43 - | (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11 - | grub_be_to_cpu32 (exts[ex][3]) >> 21); + | (grub_uint64_t) grub_be_to_cpu32 (exts[ex].raw[2]) << 11 + | grub_be_to_cpu32 (exts[ex].raw[3]) >> 21); } static inline grub_uint64_t -GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex) { - return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1)); + return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1)); } @@ -377,7 +383,10 @@ grub_xfs_fshelp_size(struct grub_xfs_data *data) + grub_xfs_inode_size(data); } -static void * +/* This should return void * but XFS code is error-prone with alignment, so + return char to retain cast-align. + */ +static char * grub_xfs_inode_data(struct grub_xfs_inode *inode) { if (inode->version <= 2) @@ -388,20 +397,20 @@ grub_xfs_inode_data(struct grub_xfs_inode *inode) static struct grub_xfs_dir_entry * grub_xfs_inline_de(struct grub_xfs_dir_header *head) { - /* - * With small inode numbers the header is 4 bytes smaller because of - * smaller parent pointer - */ - return (void *)(((char *)head) + sizeof(struct grub_xfs_dir_header) - - (head->largeino ? 0 : sizeof(grub_uint32_t))); + /* + With small inode numbers the header is 4 bytes smaller because of + smaller parent pointer + */ + return (struct grub_xfs_dir_entry *) + (((char *) head) + sizeof(struct grub_xfs_dir_header) - + (head->largeino ? 0 : sizeof(grub_uint32_t))); } static grub_uint8_t * grub_xfs_inline_de_inopos(struct grub_xfs_data *data, struct grub_xfs_dir_entry *de) { - return ((grub_uint8_t *)(de + 1)) + de->len - 1 + - (data->hasftype ? 1 : 0); + return ((grub_uint8_t *)(de + 1)) + de->len - 1 + (data->hasftype ? 1 : 0); } static struct grub_xfs_dir_entry * @@ -445,14 +454,17 @@ grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de) return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8)); } -static grub_uint64_t * +/* This should return void * but XFS code is error-prone with alignment, so + return char to retain cast-align. + */ +static char * grub_xfs_btree_keys(struct grub_xfs_data *data, struct grub_xfs_btree_node *leaf) { - grub_uint64_t *keys = (grub_uint64_t *)(leaf + 1); + char *keys = (char *)(leaf + 1); if (data->hascrc) - keys += 6; /* skip crc, uuid, ... */ + keys += 48; /* skip crc, uuid, ... */ return keys; } @@ -476,28 +488,34 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, return 0; } +static grub_uint64_t +get_fsb (const void *keys, int idx) +{ + const char *p = (const char *) keys + sizeof(grub_uint64_t) * idx; + return grub_be_to_cpu64 (grub_get_unaligned64 (p)); +} static grub_disk_addr_t grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) { struct grub_xfs_btree_node *leaf = 0; int ex, nrec; - grub_xfs_extent *exts; + struct grub_xfs_extent *exts; grub_uint64_t ret = 0; if (node->inode.format == XFS_INODE_FORMAT_BTREE) { struct grub_xfs_btree_root *root; - const grub_uint64_t *keys; + const char *keys; int recoffset; leaf = grub_malloc (node->data->bsize); if (leaf == 0) return 0; - root = grub_xfs_inode_data(&node->inode); + root = (struct grub_xfs_btree_root *) grub_xfs_inode_data(&node->inode); nrec = grub_be_to_cpu16 (root->numrecs); - keys = &root->keys[0]; + keys = (char *) &root->keys[0]; if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else @@ -510,7 +528,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) for (i = 0; i < nrec; i++) { - if (fileblock < grub_be_to_cpu64 (keys[i])) + if (fileblock < get_fsb(keys, i)) break; } @@ -520,8 +538,9 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) grub_free (leaf); return 0; } + if (grub_disk_read (node->data->disk, - GRUB_XFS_FSB_TO_BLOCK (node->data, grub_be_to_cpu64 (keys[i - 1 + recoffset])) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), + GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), 0, node->data->bsize, leaf)) return 0; @@ -542,12 +561,12 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) / (2 * sizeof (grub_uint64_t))); } while (leaf->level); - exts = (grub_xfs_extent *) keys; + exts = (struct grub_xfs_extent *) keys; } else if (node->inode.format == XFS_INODE_FORMAT_EXT) { nrec = grub_be_to_cpu32 (node->inode.nextents); - exts = grub_xfs_inode_data(&node->inode); + exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode); } else { @@ -700,7 +719,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { case XFS_INODE_FORMAT_INO: { - struct grub_xfs_dir_header *head = grub_xfs_inode_data(&diro->inode); + struct grub_xfs_dir_header *head = (struct grub_xfs_dir_header *) grub_xfs_inode_data(&diro->inode); struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head); int smallino = !head->largeino; int i; From 61c778f6402d540a2da7b2d034de7a920ca38c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Mon, 20 Jul 2015 14:06:45 +0200 Subject: [PATCH 0300/1167] loader/linux: Make trailer initrd entry aligned again. Regression from commit: loader/linux: do not pad initrd with zeroes at the end a8c473288d3f0a5e17a903a5121dea1a695dda3b Wimboot fails since the change above because it expects the "trailer" initrd element on an aligned address. This issue shows only when newc_name is used and the last initrd entry has a not aligned size. --- grub-core/loader/linux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index d2cd591f6..be6fa0f4d 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[], if (newc) { + initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) + sizeof ("TRAILER!!!") - 1, 4); free_dir (root); @@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, ptr += cursize; } if (newc) - ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); + { + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); + ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); + } free_dir (root); root = 0; return GRUB_ERR_NONE; From 5c46165a7cefe8b5319bdc10839a3bc5dee40826 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 01:54:59 +0200 Subject: [PATCH 0301/1167] configure.ac: Handle powerpc64le compiler Also-by: Paulo Flabiano Smorigo --- configure.ac | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/configure.ac b/configure.ac index fd8a62ead..e54b9df12 100644 --- a/configure.ac +++ b/configure.ac @@ -116,6 +116,7 @@ if test "x$with_platform" = x; then x86_64-*) platform=pc ;; powerpc-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;; + powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;; @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; + powerpc64le-ieee1275) target_cpu=powerpc ;; esac # Check if the platform is supported, make final adjustments. @@ -560,6 +562,41 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) +if test x$target_cpu = xpowerpc; then + AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ + grub_cv_target_cc_big_endian=no + for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ + "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ + "-mbig-endian"; do + if test x"$grub_cv_target_cc_big_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) +#error still little endian +#endif +asm (".globl start; start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_big_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_big_endian" = xno ; then + AC_MSG_ERROR([could not force big-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in From 9f27f9f69163bf6b41d8b4dc959f1baefa6f674e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 01:57:40 +0200 Subject: [PATCH 0302/1167] dmraid_nvidia: Set a name to usable value to avoid null dereference. Reported by: Andrei Borzenkov --- grub-core/disk/dmraid_nvidia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index 881508cf2..060279124 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -172,7 +172,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, return grub_diskfilter_make_raid (sizeof (sb.array.signature), uuid, sb.array.total_volumes, - NULL, disk_size, + "nv", disk_size, sb.array.stripe_block_size, GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC, level); From 389d509df0d59445b0efcc7c6138d743ad573765 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:39:14 +0200 Subject: [PATCH 0303/1167] diskfilter: Make name a const char to fix compilation error. --- grub-core/disk/diskfilter.c | 2 +- include/grub/diskfilter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index c4f6678b6..6f901c0ad 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1007,7 +1007,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) struct grub_diskfilter_vg * grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, - char *name, grub_uint64_t disk_size, + const char *name, grub_uint64_t disk_size, grub_uint64_t stripe_size, int layout, int level) { diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h index 1aedcd3df..d89273c1b 100644 --- a/include/grub/diskfilter.h +++ b/include/grub/diskfilter.h @@ -172,7 +172,7 @@ grub_diskfilter_unregister (grub_diskfilter_t diskfilter) struct grub_diskfilter_vg * grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, - char *name, grub_uint64_t disk_size, + const char *name, grub_uint64_t disk_size, grub_uint64_t stripe_size, int layout, int level); From f250c337f1a5ab648709c899d14fcf086f5c3aff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:40:13 +0200 Subject: [PATCH 0304/1167] ARM: provide __aeabi_memclr* and __aeabi_memcpy* symbols Fixes compilation with recent clang. --- grub-core/kern/compiler-rt.c | 15 +++++++++++++++ include/grub/compiler-rt.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index d4cc15513..5cfcb3907 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -381,9 +381,24 @@ __aeabi_idiv (grub_int32_t a, grub_int32_t b) __attribute__ ((alias ("__divsi3"))); void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memcpy4 (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memcpy8 (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); void *__aeabi_memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("memset"))); +void +__aeabi_memclr (void *s, grub_size_t n) +{ + grub_memset (s, 0, n); +} + +void __aeabi_memclr4 (void *s, grub_size_t n) + __attribute__ ((alias ("__aeabi_memclr"))); +void __aeabi_memclr8 (void *s, grub_size_t n) + __attribute__ ((alias ("__aeabi_memclr"))); + int __aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b) { diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index 9265c7e80..dc73649a5 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -88,7 +88,14 @@ EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); void * EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); void * +EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n); +void * EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n); grub_uint64_t EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); From eecdbebc8416467c029ab05d1c457901c4701c26 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:47:56 +0200 Subject: [PATCH 0305/1167] Remove mips_attributes. mips_attributes was introduced to work around clang problems with -msoft-float. Those problems are now fixed and moreover .gnu_attributes itself is unportable and creates problem with clang. Revert "mips: Fix soft-float handling." This partially reverts commit 6a4ecd276ed39f66be0ad6ff0f8ff67598098605. --- grub-core/boot/mips/startup_raw.S | 2 -- grub-core/kern/mips/cache.S | 2 -- grub-core/kern/mips/startup.S | 2 -- grub-core/lib/mips/relocator_asm.S | 2 -- include/grub/mips/kernel.h | 4 ---- 5 files changed, 12 deletions(-) diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index fd95c3134..ca3413bbe 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BASE_ADDR 8 @@ -33,7 +32,6 @@ .globl __start, _start, start .set noreorder .set nomacro - mips_attributes __start: _start: start: diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S index e83960fcc..fa6897e14 100644 --- a/grub-core/kern/mips/cache.S +++ b/grub-core/kern/mips/cache.S @@ -1,10 +1,8 @@ #include -#include .set noreorder .set nomacro - mips_attributes FUNCTION (grub_arch_sync_caches) #include "cache_flush.S" diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 337aca914..339ab337e 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BASE_ADDR 8 @@ -29,7 +28,6 @@ .globl __start, _start, start .set noreorder .set nomacro - mips_attributes __start: _start: start: diff --git a/grub-core/lib/mips/relocator_asm.S b/grub-core/lib/mips/relocator_asm.S index 959893ca9..1d142a4f3 100644 --- a/grub-core/lib/mips/relocator_asm.S +++ b/grub-core/lib/mips/relocator_asm.S @@ -17,13 +17,11 @@ */ #include -#include .p2align 4 /* force 16-byte alignment */ .set noreorder .set nomacro - mips_attributes VARIABLE (grub_relocator_forward_start) move $a0, $9 diff --git a/include/grub/mips/kernel.h b/include/grub/mips/kernel.h index d0e09ddc6..07b08848d 100644 --- a/include/grub/mips/kernel.h +++ b/include/grub/mips/kernel.h @@ -21,8 +21,4 @@ #include -#ifdef ASM_FILE -#define mips_attributes .gnu_attribute 4, 3 -#endif - #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ From 80783ea646b98b263df30cb3c75cef773729a1b2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:40:55 +0200 Subject: [PATCH 0306/1167] fwstart: Replace blt with bltz. blt A, $zero, B and bltz A, B are equivalent but clang recognizes only later, so use it. Resulting binary is unchanged. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 71bab6dc8..c95b38ac0 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -344,7 +344,7 @@ printhex: nop srl $t1, $a0, 28 addiu $t1, $t1, -10 - blt $t1, $zero, 2f + bltz $t1, 2f sll $a0, $a0, 4 addiu $t1, $t1, 'A'-10-'0' 2: addiu $t1, $t1, '0'+10 From 63411b14be3da8d376d9d52a06c08c8ae36761da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:41:58 +0200 Subject: [PATCH 0307/1167] fwstart: Add missing argument to p2align. Resulting binary is unchanged as it happens we were already aligned by chance. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index c95b38ac0..921dbd1f1 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -547,7 +547,7 @@ gpio_dump: #endif gpio_dump_end: - .p2align + .p2align 3 write_dumpreg: ld $t2, 0($t6) From 248bc1d0fcdd7729ee225de9e8a293b61d9a3de0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:42:41 +0200 Subject: [PATCH 0308/1167] fwstart: Fix loading of address of read_spd_fail. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 921dbd1f1..28c634614 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -398,7 +398,7 @@ read_spd: move $t2, $a0 move $t3, $ra lui $a0, %hi(read_spd_fail) - addiu $a0, $a0, %hi(read_spd_fail) + addiu $a0, $a0, %lo(read_spd_fail) /* Send START. */ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) From ca73ae446c426661a8f05196df279e8b973fead9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 02:15:46 +0200 Subject: [PATCH 0309/1167] arm-emu: Add __aeabi_memcpy* and __aeabi_memclr* symbols. Fixes compilation with clang. --- configure.ac | 2 +- include/grub/compiler-rt-emu.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e54b9df12..c864311f7 100644 --- a/configure.ac +++ b/configure.ac @@ -1181,7 +1181,7 @@ fi # Check for libgcc symbols if test x"$platform" = xemu; then -AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) +AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) fi if test "x$TARGET_APPLE_LINKER" = x1 ; then diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h index edc82999e..b21425d9e 100644 --- a/include/grub/compiler-rt-emu.h +++ b/include/grub/compiler-rt-emu.h @@ -115,11 +115,36 @@ void * EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); #endif +#ifdef HAVE___AEABI_MEMCPY4 +void * +EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCPY8 +void * +EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n); +#endif + #ifdef HAVE___AEABI_MEMSET void * EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); #endif +#ifdef HAVE___AEABI_MEMCLR +void * +EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCLR4 +void * +EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCLR8 +void * +EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n); +#endif + #ifdef HAVE___AEABI_LASR grub_uint64_t EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); From f34a42208153e520d5239be1cea2ca1fbfced9e0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 19:01:00 +0200 Subject: [PATCH 0310/1167] archelp: Fix handling of dot and dotdot at the end of the name. Fixes cpio_test and tar_test. --- grub-core/fs/archelp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index c85cbfac2..707f9a658 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -34,12 +34,12 @@ canonicalize (char *name) iptr++; if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0)) { - iptr += 2; + iptr++; continue; } if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0)) { - iptr += 3; + iptr += 2; if (optr == name) continue; for (optr -= 2; optr >= name && *optr != '/'; optr--); From d0d90d78485f9b53c80962faa617c30d55380032 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 19:04:55 +0200 Subject: [PATCH 0311/1167] exclude.pot: Add missing blacklisted strings. --- po/exclude.pot | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/po/exclude.pot b/po/exclude.pot index ab52e9990..0a9b215ea 100644 --- a/po/exclude.pot +++ b/po/exclude.pot @@ -7440,7 +7440,57 @@ msgid "" "\n" msgstr "" -#: util/grub-probe.c:735 +#: grub-core/bus/emu/pci.c:58 #, c-format -msgid "%s\n%s %s %s" +msgid "mapping 0x%llx failed (error %d)" +msgstr "" + +#: grub-core/disk/dmraid_nvidia.c:175 +msgid "nv" +msgstr "" + +#: grub-core/fs/xfs.c:478 +msgid ") - %" +msgstr "" + +#: grub-core/fs/xfs.c:478 +#, c-format +msgid ", %d +" +msgstr "" + +#: grub-core/fs/xfs.c:550 +msgid "BMA3" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:284 +msgid "com.delphix:hole_birth" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:285 +msgid "com.delphix:embedded_data" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:286 +msgid "com.delphix:extensible_dataset" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:287 +msgid "org.open-zfs:large_blocks" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:1877 +msgid "/%" +msgstr "" + +#: grub-core/osdep/linux/platform.c:73 +msgid "/sys/firmware/efi/fw_platform_size" +msgstr "" + +#: util/grub-mkrescue.c:454 +msgid "-output" +msgstr "" + +#: util/grub-mkrescue.c:455 +msgid "--output" msgstr "" From 81ca24a59cdab59503a8f13586da3b62a52d7460 Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Thu, 23 Jul 2015 21:13:09 +0300 Subject: [PATCH 0312/1167] efi: fix memory leak in variable handling --- grub-core/kern/efi/efi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 2e7783468..490edefe5 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -206,6 +206,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS | GRUB_EFI_VARIABLE_RUNTIME_ACCESS), datasize, data); + grub_free (var16); if (status == GRUB_EFI_SUCCESS) return GRUB_ERR_NONE; @@ -237,8 +238,11 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL); - if (!datasize) - return NULL; + if (status != GRUB_EFI_SUCCESS || !datasize) + { + grub_free (var16); + return NULL; + } data = grub_malloc (datasize); if (!data) From 02a249005fe5e53905fd809a74f65d1b1333a0e0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:13:27 +0200 Subject: [PATCH 0313/1167] reiserfs: Fix handling of first entry in the directory. Fixes garbage being added to "." filename. --- grub-core/fs/reiserfs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index b78166554..39736f63c 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -783,12 +783,30 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_reiserfs_key entry_key; enum grub_fshelp_filetype entry_type; char *entry_name; + char *entry_name_end = 0; + char c; if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK)) continue; entry_name = (((char *) directory_headers) + grub_le_to_cpu16 (directory_header->location)); + if (entry_number == 0) + { + entry_name_end = (char *) block_header + + grub_le_to_cpu16 (item_headers[block_position].item_location) + + grub_le_to_cpu16 (item_headers[block_position].item_size); + } + else + { + entry_name_end = (((char *) directory_headers) + + grub_le_to_cpu16 (directory_headers[entry_number - 1].location)); + } + if (entry_name_end < entry_name || entry_name_end > (char *) block_header + block_size) + { + entry_name_end = (char *) block_header + block_size; + } + entry_key.directory_id = directory_header->directory_id; entry_key.object_id = directory_header->object_id; entry_key.u.v2.offset_type = 0; @@ -935,7 +953,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, else { /* Pseudo file ".." never has stat block. */ - if (grub_strcmp (entry_name, "..")) + if (entry_name_end == entry_name + 2 && grub_memcmp (entry_name, "..", 2) != 0) grub_dprintf ("reiserfs", "Warning : %s has no stat block !\n", entry_name); @@ -943,18 +961,21 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, goto next; } } + + c = *entry_name_end; + *entry_name_end = 0; if (hook (entry_name, entry_type, entry_item, hook_data)) { + *entry_name_end = c; grub_dprintf ("reiserfs", "Found : %s, type=%d\n", entry_name, entry_type); ret = 1; goto found; } + *entry_name_end = c; next: - *entry_name = 0; /* Make sure next entry name (which is just - before this one in disk order) stops before - the current one. */ + ; } if (next_offset == 0) From 049dcfa03c2217f3af9f108d3f41229b8155c534 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:15:32 +0200 Subject: [PATCH 0314/1167] xfs: Fix handling of symlink with crc-enabled filesystem. --- grub-core/fs/xfs.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 46de6aff3..a03526b32 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -604,13 +604,13 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) POS. Return the amount of read bytes in READ. */ static grub_ssize_t grub_xfs_read_file (grub_fshelp_node_t node, - grub_disk_read_hook_t read_hook, void *read_hook_data, - grub_off_t pos, grub_size_t len, char *buf) + grub_disk_read_hook_t read_hook, void *read_hook_data, + grub_off_t pos, grub_size_t len, char *buf, grub_uint32_t header_size) { return grub_fshelp_read_file (node->data->disk, node, read_hook, read_hook_data, pos, len, buf, grub_xfs_read_block, - grub_be_to_cpu64 (node->inode.size), + grub_be_to_cpu64 (node->inode.size) + header_size, node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS, 0); } @@ -619,7 +619,13 @@ grub_xfs_read_file (grub_fshelp_node_t node, static char * grub_xfs_read_symlink (grub_fshelp_node_t node) { - int size = grub_be_to_cpu64 (node->inode.size); + grub_ssize_t size = grub_be_to_cpu64 (node->inode.size); + + if (size < 0) + { + grub_error (GRUB_ERR_BAD_FS, "invalid symlink"); + return 0; + } switch (node->inode.format) { @@ -630,12 +636,17 @@ grub_xfs_read_symlink (grub_fshelp_node_t node) { char *symlink; grub_ssize_t numread; + int off = 0; + + if (node->data->hascrc) + off = 56; symlink = grub_malloc (size + 1); if (!symlink) return 0; - numread = grub_xfs_read_file (node, 0, 0, 0, size, symlink); + node->inode.size = grub_be_to_cpu64 (size + off); + numread = grub_xfs_read_file (node, 0, 0, off, size, symlink, off); if (numread != size) { grub_free (symlink); @@ -802,7 +813,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, numread = grub_xfs_read_file (dir, 0, 0, blk << dirblk_log2, - dirblk_size, dirblock); + dirblk_size, dirblock, 0); if (numread != dirblk_size) return 0; @@ -1034,7 +1045,7 @@ grub_xfs_read (grub_file_t file, char *buf, grub_size_t len) return grub_xfs_read_file (&data->diropen, file->read_hook, file->read_hook_data, - file->offset, len, buf); + file->offset, len, buf, 0); } From 900fca88ac7dd8a4767cd1edc71b8ee6737eaa75 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:16:30 +0200 Subject: [PATCH 0315/1167] xfs_test: Test both crc and non-crc filesystems. --- tests/util/grub-fs-tester.in | 17 ++++++++++++++--- tests/xfs_test.in | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 5107ca17a..6fcac31c3 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -40,6 +40,10 @@ case x"$fs" in MINLOGSECSIZE=9 # OS LIMITATION: GNU/Linux doesn't accept > 4096 MAXLOGSECSIZE=12;; + xxfs_crc) + MINLOGSECSIZE=9 + # OS LIMITATION: GNU/Linux doesn't accept > 1024 + MAXLOGSECSIZE=10;; xzfs*) # OS LIMITATION: zfs-fuse hangs when creating zpool with sectors <=256B. MINLOGSECSIZE=9 @@ -142,6 +146,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MINBLKSIZE=$SECSIZE # OS Limitation: GNU/Linux doesn't accept > 4096 MAXBLKSIZE=4096;; + xxfs_crc) + # OS Limitation: GNU/Linux doesn't accept != 1024 + MINBLKSIZE=1024 + MAXBLKSIZE=1024;; xudf) MINBLKSIZE=1024 MAXBLKSIZE=4096;; @@ -287,7 +295,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + x"ufs1" | x"ufs1_sun" | x"ufs2") FSLABEL="grubtest""ieurrucnenreeiurueurewf";; # FS LIMITATION: XFS label is at most 12 UTF-8 characters - x"xfs") + x"xfs"|x"xfs_crc") FSLABEL="géт ðŸ˜Ðº";; # FS LIMITATION: FAT labels limited to 11 characters, no international characters or lowercase x"vfat"* | xmsdos*) @@ -465,7 +473,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x"$fs" in # FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it. # FS LIMITATION: as far as I know those FS don't store their last modification date. - x"jfs_caseins" | x"jfs" | x"xfs"| x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ + x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ | x"bfs" | x"afs" \ | x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \ | x"minix3" | x"ntfs"* | x"udf" | x"sfs"*) @@ -758,7 +766,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + xext*) MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; xxfs) - "mkfs.xfs" -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; + "mkfs.xfs" -m crc=0 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; + xxfs_crc) + MOUNTFS="xfs" + "mkfs.xfs" -m crc=1 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; *) echo "Add appropriate mkfs command here" exit 1 diff --git a/tests/xfs_test.in b/tests/xfs_test.in index 173b1cfe6..3807e2e5c 100644 --- a/tests/xfs_test.in +++ b/tests/xfs_test.in @@ -16,4 +16,5 @@ if ! which mkfs.xfs >/dev/null 2>&1; then fi +"@builddir@/grub-fs-tester" xfs_crc "@builddir@/grub-fs-tester" xfs From 333855c6469d52a7a555ea55834182603981ea0e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:17:04 +0200 Subject: [PATCH 0316/1167] zfs_test: Skip dotdot in volume root test. Given special semantics of ZFS it's far from clear what the expected result is. Just skip it for now --- tests/util/grub-fs-tester.in | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 6fcac31c3..29ae69153 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1149,18 +1149,19 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x"$fs" in x"zfs"*) - LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/..");; + ;; *) - LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/..");; + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/.."); + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOTDOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + ;; esac - if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then - : - else - echo DOTDOT IN ROOTDIR FAIL - echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" - exit 1 - fi case x"$fs" in x"zfs"*) From d5847bf59443ef54c838fe5be1ecd47443c7807b Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Fri, 24 Jul 2015 20:46:02 +0300 Subject: [PATCH 0317/1167] efi: fix GetVariable return status check in 81ca24a GetVariable should return EFI_BUFFER_TOO_SMALL if given buffer of size zero; commit incorrectly checked for EFI_SUCCESS. --- grub-core/kern/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 490edefe5..caf9bcc41 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -238,7 +238,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL); - if (status != GRUB_EFI_SUCCESS || !datasize) + if (status != GRUB_EFI_BUFFER_TOO_SMALL || !datasize) { grub_free (var16); return NULL; From 368ecfc3a031bd3b03bcaae776d6f276f79af157 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:39:41 +0200 Subject: [PATCH 0318/1167] Add transform_data as a variant of data with substitutions. This fixrs name mismatch for grub.chrp with transform_program_name='s,grub,grub2,g' --- gentpl.py | 15 +++++++++++++++ grub-core/Makefile.core.def | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gentpl.py b/gentpl.py index 37b1f45bf..76971d3ce 100644 --- a/gentpl.py +++ b/gentpl.py @@ -834,6 +834,20 @@ def data(defn, platform): var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform)) gvar_add("dist_noinst_DATA", extra_dist(defn)) +def transform_data(defn, platform): + name = defn['name'] + + var_add(installdir(defn) + "_DATA", name) + + rule(name, "$(top_builddir)/config.status " + platform_sources(defn, platform) + platform_dependencies(defn, platform), """ +(for x in """ + platform_sources(defn, platform) + """; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:- +chmod a+x """ + name + """ +""") + + gvar_add("CLEANFILES", name) + gvar_add("EXTRA_DIST", extra_dist(defn)) + gvar_add("dist_noinst_DATA", platform_sources(defn, platform)) + def script(defn, platform): name = defn['name'] @@ -881,6 +895,7 @@ rules("library", library) rules("program", program) rules("script", script) rules("data", data) +rules("transform_data", transform_data) write_output(section='decl') write_output() diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a6101dec7..9764cd235 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1,43 +1,43 @@ AutoGen definitions Makefile.tpl; -script = { +transform_data = { installdir = noinst; name = gensyminfo.sh; common = gensyminfo.sh.in; }; -script = { +transform_data = { installdir = noinst; name = genmod.sh; common = genmod.sh.in; }; -script = { +transform_data = { installdir = noinst; name = modinfo.sh; common = modinfo.sh.in; }; -script = { +transform_data = { installdir = platform; name = gmodule.pl; common = gmodule.pl.in; }; -script = { +transform_data = { installdir = platform; name = gdb_grub; common = gdb_grub.in; }; -script = { +transform_data = { installdir = platform; name = grub.chrp; common = boot/powerpc/grub.chrp.in; enable = powerpc_ieee1275; }; -script = { +transform_data = { installdir = platform; name = bootinfo.txt; common = boot/powerpc/bootinfo.txt.in; From a2721778e5234fc87af7c3bf2b7cfdaca3abfa60 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:42:47 +0200 Subject: [PATCH 0319/1167] grub-install: Use a+ in fopen rather than r+. r+ does not create a file if none exists. --- util/grub-install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index 566272600..df5c7e520 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1727,7 +1727,7 @@ main (int argc, char *argv[]) grub_elf = grub_util_path_concat (2, core_services, "grub.elf"); grub_install_copy_file (imgfile, grub_elf, 1); - f = grub_util_fopen (mach_kernel, "r+"); + f = grub_util_fopen (mach_kernel, "a+"); if (!f) grub_util_error (_("Can't create file: %s"), strerror (errno)); fclose (f); From 4622f4e1ee569d5841bf8bb080430dc28b1c5665 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:44:19 +0200 Subject: [PATCH 0320/1167] Switch procfs to use archelp. This fixes handling of "." and "..". --- Makefile.util.def | 2 +- grub-core/fs/proc.c | 84 ++++++++++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def index 3cb6b21d3..db7e8ec2a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -48,6 +48,7 @@ library = { common = grub-core/partmap/gpt.c; common = grub-core/partmap/msdos.c; common = grub-core/fs/proc.c; + common = grub-core/fs/archelp.c; }; library = { @@ -91,7 +92,6 @@ library = { common = grub-core/fs/bfs.c; common = grub-core/fs/btrfs.c; common = grub-core/fs/cbfs.c; - common = grub-core/fs/archelp.c; common = grub-core/fs/cpio.c; common = grub-core/fs/cpio_be.c; common = grub-core/fs/odc.c; diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c index a03469ec6..31f3aa9a4 100644 --- a/grub-core/fs/proc.c +++ b/grub-core/fs/proc.c @@ -22,6 +22,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -74,6 +75,44 @@ grub_procdev_write (grub_disk_t disk __attribute ((unused)), return GRUB_ERR_OUT_OF_RANGE; } +struct grub_archelp_data +{ + struct grub_procfs_entry *entry, *next_entry; +}; + +static void +grub_procfs_rewind (struct grub_archelp_data *data) +{ + data->entry = NULL; + data->next_entry = grub_procfs_entries; +} + +static grub_err_t +grub_procfs_find_file (struct grub_archelp_data *data, char **name, + grub_int32_t *mtime, + grub_uint32_t *mode) +{ + data->entry = data->next_entry; + if (!data->entry) + { + *mode = GRUB_ARCHELP_ATTR_END; + return GRUB_ERR_NONE; + } + data->next_entry = data->entry->next; + *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; + *name = grub_strdup (data->entry->name); + *mtime = 0; + if (!*name) + return grub_errno; + return GRUB_ERR_NONE; +} + +static struct grub_archelp_ops arcops = + { + .find_file = grub_procfs_find_file, + .rewind = grub_procfs_rewind + }; + static grub_ssize_t grub_procfs_read (grub_file_t file, char *buf, grub_size_t len) { @@ -99,44 +138,35 @@ static grub_err_t grub_procfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, void *hook_data) { - const char *ptr; - struct grub_dirhook_info info; - struct grub_procfs_entry *entry; - - grub_memset (&info, 0, sizeof (info)); + struct grub_archelp_data data; /* Check if the disk is our dummy disk. */ if (grub_strcmp (device->disk->name, "proc")) return grub_error (GRUB_ERR_BAD_FS, "not a procfs"); - for (ptr = path; *ptr == '/'; ptr++); - if (*ptr) - return 0; - FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) - if (hook (entry->name, &info, hook_data)) - return 0; - return 0; + + grub_procfs_rewind (&data); + + return grub_archelp_dir (&data, &arcops, + path, hook, hook_data); } static grub_err_t grub_procfs_open (struct grub_file *file, const char *path) { - const char *pathptr; - struct grub_procfs_entry *entry; + grub_err_t err; + struct grub_archelp_data data; + grub_size_t sz; - for (pathptr = path; *pathptr == '/'; pathptr++); + grub_procfs_rewind (&data); - FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) - if (grub_strcmp (pathptr, entry->name) == 0) - { - grub_size_t sz; - file->data = entry->get_contents (&sz); - if (!file->data) - return grub_errno; - file->size = sz; - return GRUB_ERR_NONE; - } - - return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path); + err = grub_archelp_open (&data, &arcops, path); + if (err) + return err; + file->data = data.entry->get_contents (&sz); + if (!file->data) + return grub_errno; + file->size = sz; + return GRUB_ERR_NONE; } static struct grub_disk_dev grub_procfs_dev = { From fa93b0e4f5dd8d218da1c32c71c2bffd48eab89b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:45:35 +0200 Subject: [PATCH 0321/1167] fshelp: Add handling of "." and ".." and grub_fshelp_find_file_lookup. Recent tests have discovered that many of our filesystems have flawed handling of "." and "..". Rather than attempting to fix it in filesystems themselves, make the common code fshelp aware of "." and ".." and handle them in this layer. Add grub_fshelp_find_file_lookup for easy conversion of BFS, HFS and exFAT which have the same problem and don't use fshelp. --- grub-core/fs/fshelp.c | 324 ++++++++++++++++++++++++++++-------------- include/grub/fshelp.h | 11 ++ 2 files changed, 228 insertions(+), 107 deletions(-) diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c index b899bed04..4c902adf3 100644 --- a/grub-core/fs/fshelp.c +++ b/grub-core/fs/fshelp.c @@ -30,169 +30,287 @@ GRUB_MOD_LICENSE ("GPLv3+"); typedef int (*iterate_dir_func) (grub_fshelp_node_t dir, grub_fshelp_iterate_dir_hook_t hook, void *data); +typedef grub_err_t (*lookup_file_func) (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype); typedef char *(*read_symlink_func) (grub_fshelp_node_t node); +struct stack_element { + struct stack_element *parent; + grub_fshelp_node_t node; + enum grub_fshelp_filetype type; +}; + /* Context for grub_fshelp_find_file. */ struct grub_fshelp_find_file_ctx { + /* Inputs. */ const char *path; - grub_fshelp_node_t rootnode, currroot, currnode, oldnode; - enum grub_fshelp_filetype foundtype; + grub_fshelp_node_t rootnode; + + /* Global options. */ int symlinknest; - const char *name; - const char *next; - enum grub_fshelp_filetype type; + + /* Current file being traversed and its parents. */ + struct stack_element *currnode; }; /* Helper for find_file_iter. */ static void free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx) { - if (node != ctx->rootnode && node != ctx->currroot) + if (node != ctx->rootnode) grub_free (node); } +static void +pop_element (struct grub_fshelp_find_file_ctx *ctx) +{ + struct stack_element *el; + el = ctx->currnode; + ctx->currnode = el->parent; + free_node (el->node, ctx); + grub_free (el); +} + +static void +free_stack (struct grub_fshelp_find_file_ctx *ctx) +{ + while (ctx->currnode) + pop_element (ctx); +} + +static void +go_up_a_level (struct grub_fshelp_find_file_ctx *ctx) +{ + if (!ctx->currnode->parent) + return; + pop_element (ctx); +} + +static grub_err_t +push_node (struct grub_fshelp_find_file_ctx *ctx, grub_fshelp_node_t node, enum grub_fshelp_filetype filetype) +{ + struct stack_element *nst; + nst = grub_malloc (sizeof (*nst)); + if (!nst) + return grub_errno; + nst->node = node; + nst->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE; + nst->parent = ctx->currnode; + ctx->currnode = nst; + return GRUB_ERR_NONE; +} + +static grub_err_t +go_to_root (struct grub_fshelp_find_file_ctx *ctx) +{ + free_stack (ctx); + return push_node (ctx, ctx->rootnode, GRUB_FSHELP_DIR); +} + +struct grub_fshelp_find_file_iter_ctx +{ + const char *name; + grub_fshelp_node_t *foundnode; + enum grub_fshelp_filetype *foundtype; +}; + /* Helper for grub_fshelp_find_file. */ static int find_file_iter (const char *filename, enum grub_fshelp_filetype filetype, grub_fshelp_node_t node, void *data) { - struct grub_fshelp_find_file_ctx *ctx = data; + struct grub_fshelp_find_file_iter_ctx *ctx = data; if (filetype == GRUB_FSHELP_UNKNOWN || ((filetype & GRUB_FSHELP_CASE_INSENSITIVE) - ? grub_strncasecmp (ctx->name, filename, ctx->next - ctx->name) - : grub_strncmp (ctx->name, filename, ctx->next - ctx->name)) - || filename[ctx->next - ctx->name]) + ? grub_strcasecmp (ctx->name, filename) + : grub_strcmp (ctx->name, filename))) { grub_free (node); return 0; } /* The node is found, stop iterating over the nodes. */ - ctx->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE; - ctx->oldnode = ctx->currnode; - ctx->currnode = node; - + *ctx->foundnode = node; + *ctx->foundtype = filetype; return 1; } static grub_err_t -find_file (const char *currpath, grub_fshelp_node_t currroot, - grub_fshelp_node_t *currfound, - iterate_dir_func iterate_dir, read_symlink_func read_symlink, +directory_find_file (grub_fshelp_node_t node, const char *name, grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype, iterate_dir_func iterate_dir) +{ + int found; + struct grub_fshelp_find_file_iter_ctx ctx = { + .foundnode = foundnode, + .foundtype = foundtype, + .name = name + }; + found = iterate_dir (node, find_file_iter, &ctx); + if (! found) + { + if (grub_errno) + return grub_errno; + } + return GRUB_ERR_NONE; +} + +static grub_err_t +find_file (char *currpath, + iterate_dir_func iterate_dir, lookup_file_func lookup_file, + read_symlink_func read_symlink, struct grub_fshelp_find_file_ctx *ctx) { - ctx->currroot = currroot; - ctx->name = currpath; - ctx->type = GRUB_FSHELP_DIR; - ctx->currnode = currroot; - ctx->oldnode = currroot; - - for (;;) + char *name, *next; + grub_err_t err; + for (name = currpath; ; name = next) { - int found; + char c; + grub_fshelp_node_t foundnode = NULL; + enum grub_fshelp_filetype foundtype = 0; /* Remove all leading slashes. */ - while (*ctx->name == '/') - ctx->name++; + while (*name == '/') + name++; /* Found the node! */ - if (! *ctx->name) - { - *currfound = ctx->currnode; - ctx->foundtype = ctx->type; - return 0; - } + if (! *name) + return 0; /* Extract the actual part from the pathname. */ - for (ctx->next = ctx->name; *ctx->next && *ctx->next != '/'; ctx->next++); + for (next = name; *next && *next != '/'; next++); /* At this point it is expected that the current node is a directory, check if this is true. */ - if (ctx->type != GRUB_FSHELP_DIR) + if (ctx->currnode->type != GRUB_FSHELP_DIR) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + + /* Don't rely on fs providing actual . in the listing. */ + if (next - name == 1 && name[0] == '.') + continue; + + /* Don't rely on fs providing actual .. in the listing. */ + if (next - name == 2 && name[0] == '.' && name[1] == '.') { - free_node (ctx->currnode, ctx); - ctx->currnode = 0; - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + go_up_a_level (ctx); + continue; } /* Iterate over the directory. */ - found = iterate_dir (ctx->currnode, find_file_iter, ctx); - if (! found) - { - free_node (ctx->currnode, ctx); - ctx->currnode = 0; - if (grub_errno) - return grub_errno; + c = *next; + *next = '\0'; + if (lookup_file) + err = lookup_file (ctx->currnode->node, name, &foundnode, &foundtype); + else + err = directory_find_file (ctx->currnode->node, name, &foundnode, &foundtype, iterate_dir); + *next = c; - break; - } + if (err) + return err; + if (!foundnode) + break; + + push_node (ctx, foundnode, foundtype); + /* Read in the symlink and follow it. */ - if (ctx->type == GRUB_FSHELP_SYMLINK) + if (ctx->currnode->type == GRUB_FSHELP_SYMLINK) { char *symlink; - const char *next; /* Test if the symlink does not loop. */ if (++ctx->symlinknest == 8) - { - free_node (ctx->currnode, ctx); - free_node (ctx->oldnode, ctx); - ctx->currnode = 0; - ctx->oldnode = 0; - return grub_error (GRUB_ERR_SYMLINK_LOOP, - N_("too deep nesting of symlinks")); - } + return grub_error (GRUB_ERR_SYMLINK_LOOP, + N_("too deep nesting of symlinks")); - symlink = read_symlink (ctx->currnode); - free_node (ctx->currnode, ctx); - ctx->currnode = 0; + symlink = read_symlink (ctx->currnode->node); if (!symlink) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - return grub_errno; - } + return grub_errno; /* The symlink is an absolute path, go back to the root inode. */ if (symlink[0] == '/') { - free_node (ctx->oldnode, ctx); - ctx->oldnode = ctx->rootnode; + err = go_to_root (ctx); + if (err) + return err; + } + else + { + /* Get from symlink to containing directory. */ + go_up_a_level (ctx); } + /* Lookup the node the symlink points to. */ - next = ctx->next; - find_file (symlink, ctx->oldnode, &ctx->currnode, - iterate_dir, read_symlink, ctx); - ctx->next = next; - ctx->type = ctx->foundtype; + find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx); grub_free (symlink); if (grub_errno) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - return grub_errno; - } + return grub_errno; } - - if (ctx->oldnode != ctx->currnode) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - } - - ctx->name = ctx->next; } return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), ctx->path); } +static grub_err_t +grub_fshelp_find_file_real (const char *path, grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + iterate_dir_func iterate_dir, + lookup_file_func lookup_file, + read_symlink_func read_symlink, + enum grub_fshelp_filetype expecttype) +{ + struct grub_fshelp_find_file_ctx ctx = { + .path = path, + .rootnode = rootnode, + .symlinknest = 0, + .currnode = 0 + }; + grub_err_t err; + enum grub_fshelp_filetype foundtype; + char *duppath; + + if (!path || path[0] != '/') + { + return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); + } + + err = go_to_root (&ctx); + if (err) + return err; + + duppath = grub_strdup (path); + if (!duppath) + return grub_errno; + err = find_file (duppath, iterate_dir, lookup_file, read_symlink, &ctx); + grub_free (duppath); + if (err) + { + free_stack (&ctx); + return err; + } + + *foundnode = ctx.currnode->node; + foundtype = ctx.currnode->type; + /* Avoid the node being freed. */ + ctx.currnode->node = 0; + free_stack (&ctx); + + /* Check if the node that was found was of the expected type. */ + if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); + else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + + return 0; +} + /* Lookup the node PATH. The node ROOTNODE describes the root of the directory tree. The node found is returned in FOUNDNODE, which is either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to @@ -207,31 +325,23 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode, read_symlink_func read_symlink, enum grub_fshelp_filetype expecttype) { - struct grub_fshelp_find_file_ctx ctx = { - .path = path, - .rootnode = rootnode, - .foundtype = GRUB_FSHELP_DIR, - .symlinknest = 0 - }; - grub_err_t err; + return grub_fshelp_find_file_real (path, rootnode, foundnode, + iterate_dir, NULL, + read_symlink, expecttype); - if (!path || path[0] != '/') - { - grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); - return grub_errno; - } +} - err = find_file (path, rootnode, foundnode, iterate_dir, read_symlink, &ctx); - if (err) - return err; +grub_err_t +grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + lookup_file_func lookup_file, + read_symlink_func read_symlink, + enum grub_fshelp_filetype expecttype) +{ + return grub_fshelp_find_file_real (path, rootnode, foundnode, + NULL, lookup_file, + read_symlink, expecttype); - /* Check if the node that was found was of the expected type. */ - if (expecttype == GRUB_FSHELP_REG && ctx.foundtype != expecttype) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - else if (expecttype == GRUB_FSHELP_DIR && ctx.foundtype != expecttype) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - - return 0; } /* Read LEN bytes from the file NODE on disk DISK into the buffer BUF, diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h index 38923044c..eb1ba4f6c 100644 --- a/include/grub/fshelp.h +++ b/include/grub/fshelp.h @@ -62,6 +62,17 @@ EXPORT_FUNC(grub_fshelp_find_file) (const char *path, enum grub_fshelp_filetype expect); +grub_err_t +EXPORT_FUNC(grub_fshelp_find_file_lookup) (const char *path, + grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + grub_err_t (*lookup_file) (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype), + char *(*read_symlink) (grub_fshelp_node_t node), + enum grub_fshelp_filetype expect); + /* Read LEN bytes from the file NODE on disk DISK into the buffer BUF, beginning with the block POS. READ_HOOK should be set before reading a block from the file. GET_BLOCK is used to translate file From d1d3a60b713f4075d7ed337a6cd942fad690f004 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:48:38 +0200 Subject: [PATCH 0322/1167] BFS: Convert to fshelp. BFS doesn't handle ".." correctly, so convert it to fshelp to reuse the logic. --- grub-core/fs/bfs.c | 221 +++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 117 deletions(-) diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c index 145e77186..d2b490bce 100644 --- a/grub-core/fs/bfs.c +++ b/grub-core/fs/bfs.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -561,10 +562,10 @@ iterate_in_b_tree (grub_disk_t disk, } static int -bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen) +bfs_strcmp (const char *a, const char *b, grub_size_t alen) { char ac, bc; - while (blen && alen) + while (*b && alen) { if (*a != *b) break; @@ -572,11 +573,10 @@ bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen) a++; b++; alen--; - blen--; } ac = alen ? *a : 0; - bc = blen ? *b : 0; + bc = *b; #ifdef MODE_AFS return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc; @@ -589,7 +589,6 @@ static grub_err_t find_in_b_tree (grub_disk_t disk, const struct grub_bfs_superblock *sb, const struct grub_bfs_inode *ino, const char *name, - grub_size_t name_len, grub_uint64_t * res) { struct grub_bfs_btree_header head; @@ -637,7 +636,7 @@ find_in_b_tree (grub_disk_t disk, end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]); if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) end = grub_bfs_to_cpu_treehead (node->total_key_len); - cmp = bfs_strcmp (key_data + start, name, end - start, name_len); + cmp = bfs_strcmp (key_data + start, name, end - start); if (cmp == 0 && level == 0) { *res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val); @@ -658,7 +657,7 @@ find_in_b_tree (grub_disk_t disk, end = grub_bfs_to_cpu16 (keylen_idx[0]); if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) end = grub_bfs_to_cpu_treehead (node->total_key_len); - cmp = bfs_strcmp (key_data, name, end, name_len); + cmp = bfs_strcmp (key_data, name, end); if (cmp == 0 && level == 0) { *res = grub_bfs_to_cpu64 (key_values[0].val); @@ -707,127 +706,119 @@ find_in_b_tree (grub_disk_t disk, } } +struct grub_fshelp_node +{ + grub_disk_t disk; + const struct grub_bfs_superblock *sb; + struct grub_bfs_inode ino; +}; + static grub_err_t -hop_level (grub_disk_t disk, - const struct grub_bfs_superblock *sb, - struct grub_bfs_inode *ino, const char *name, - const char *name_end) +lookup_file (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) { grub_err_t err; + struct grub_bfs_inode *new_ino; grub_uint64_t res = 0; - if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - - err = find_in_b_tree (disk, sb, ino, name, name_end - name, &res); + err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res); if (err) return err; - return grub_disk_read (disk, res - << (grub_bfs_to_cpu32 (sb->log2_bsize) - - GRUB_DISK_SECTOR_BITS), 0, - sizeof (*ino), (char *) ino); + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + + (*foundnode)->disk = dir->disk; + (*foundnode)->sb = dir->sb; + new_ino = &(*foundnode)->ino; + + if (grub_disk_read (dir->disk, res + << (grub_bfs_to_cpu32 (dir->sb->log2_bsize) + - GRUB_DISK_SECTOR_BITS), 0, + sizeof (*new_ino), (char *) new_ino)) + { + grub_free (*foundnode); + return grub_errno; + } + switch (grub_bfs_to_cpu32 (new_ino->mode) & ATTR_TYPE) + { + default: + case ATTR_REG: + *foundtype = GRUB_FSHELP_REG; + break; + case ATTR_DIR: + *foundtype = GRUB_FSHELP_DIR; + break; + case ATTR_LNK: + *foundtype = GRUB_FSHELP_SYMLINK; + break; + } + return GRUB_ERR_NONE; +} + +static char * +read_symlink (grub_fshelp_node_t node) +{ + char *alloc = NULL; + grub_err_t err; + +#ifndef MODE_AFS + if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK)) + { + alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1); + if (!alloc) + { + return NULL; + } + grub_memcpy (alloc, node->ino.inplace_link, + sizeof (node->ino.inplace_link)); + alloc[sizeof (node->ino.inplace_link)] = 0; + } + else +#endif + { + grub_size_t symsize = grub_bfs_to_cpu64 (node->ino.size); + alloc = grub_malloc (symsize + 1); + if (!alloc) + return NULL; + err = read_bfs_file (node->disk, node->sb, &node->ino, 0, alloc, symsize, 0, 0); + if (err) + { + grub_free (alloc); + return NULL; + } + alloc[symsize] = 0; + } + + return alloc; } static grub_err_t find_file (const char *path, grub_disk_t disk, - const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino) + const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino, + enum grub_fshelp_filetype exptype) { - const char *ptr, *next = path; - char *alloc = NULL; - char *wptr; grub_err_t err; - struct grub_bfs_inode old_ino; - unsigned symlinks_max = 32; + struct grub_fshelp_node root = { + .disk = disk, + .sb = sb, + }; + struct grub_fshelp_node *found; - err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino, - sizeof (*ino)); + err = read_extent (disk, sb, &sb->root_dir, 0, 0, &root.ino, + sizeof (root.ino)); if (err) return err; + err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, read_symlink, exptype); + if (!err) + grub_memcpy (ino, &found->ino, sizeof (*ino)); - while (1) - { - ptr = next; - while (*ptr == '/') - ptr++; - if (*ptr == 0) - { - grub_free (alloc); - return GRUB_ERR_NONE; - } - for (next = ptr; *next && *next != '/'; next++); - grub_memcpy (&old_ino, ino, sizeof (old_ino)); - err = hop_level (disk, sb, ino, ptr, next); - if (err) - return err; - - if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) == ATTR_LNK)) - { - char *old_alloc = alloc; - if (--symlinks_max == 0) - { - grub_free (alloc); - return grub_error (GRUB_ERR_SYMLINK_LOOP, - N_("too deep nesting of symlinks")); - } - -#ifndef MODE_AFS - if (grub_bfs_to_cpu32 (ino->flags) & LONG_SYMLINK) -#endif - { - grub_size_t symsize = grub_bfs_to_cpu64 (ino->size); - alloc = grub_malloc (grub_strlen (next) - + symsize + 1); - if (!alloc) - { - grub_free (alloc); - return grub_errno; - } - grub_free (old_alloc); - err = read_bfs_file (disk, sb, ino, 0, alloc, symsize, 0, 0); - if (err) - { - grub_free (alloc); - return err; - } - alloc[symsize] = 0; - } -#ifndef MODE_AFS - else - { - alloc = grub_malloc (grub_strlen (next) - + sizeof (ino->inplace_link) + 1); - if (!alloc) - { - grub_free (alloc); - return grub_errno; - } - grub_free (old_alloc); - grub_memcpy (alloc, ino->inplace_link, - sizeof (ino->inplace_link)); - alloc[sizeof (ino->inplace_link)] = 0; - } -#endif - if (alloc[0] == '/') - { - err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino, - sizeof (*ino)); - if (err) - { - grub_free (alloc); - return err; - } - } - else - grub_memcpy (ino, &old_ino, sizeof (old_ino)); - wptr = alloc + grub_strlen (alloc); - if (next) - wptr = grub_stpcpy (wptr, next); - *wptr = 0; - next = alloc; - continue; - } - } + if (&root != found) + grub_free (found); + return err; } static grub_err_t @@ -909,11 +900,9 @@ grub_bfs_dir (grub_device_t device, const char *path, { struct grub_bfs_inode ino; - err = find_file (path, device->disk, &ctx.sb, &ino); + err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR); if (err) return err; - if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_DIR)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter, &ctx); } @@ -934,11 +923,9 @@ grub_bfs_open (struct grub_file *file, const char *name) { struct grub_bfs_inode ino; struct grub_bfs_data *data; - err = find_file (name, file->device->disk, &sb, &ino); + err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG); if (err) return err; - if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_REG)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); data = grub_zalloc (sizeof (struct grub_bfs_data)); if (!data) @@ -1034,7 +1021,7 @@ read_bfs_attr (grub_disk_t disk, if (err) return -1; - err = find_in_b_tree (disk, sb, ino, name, grub_strlen (name), &res); + err = find_in_b_tree (disk, sb, ino, name, &res); if (err) return -1; grub_disk_read (disk, res From bfb5b33e968f4bc4bb45d4f4c6724967b8abefdb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:49:26 +0200 Subject: [PATCH 0323/1167] FAT: Convert to fshelp. exFAT doesn't handle "." and ".." correctly, convert it to fshelp to reuse the same logic. --- grub-core/fs/fat.c | 363 +++++++++++++++++++++------------------------ 1 file changed, 170 insertions(+), 193 deletions(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 827708c18..aa2145cf2 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -31,6 +31,7 @@ #else #include #endif +#include #include GRUB_MOD_LICENSE ("GPLv3+"); @@ -173,8 +174,6 @@ struct grub_fat_data #ifndef MODE_EXFAT grub_uint32_t root_sector; grub_uint32_t num_root_sectors; -#else - int is_contiguous; #endif int cluster_bits; @@ -182,13 +181,22 @@ struct grub_fat_data grub_uint32_t cluster_sector; grub_uint32_t num_clusters; + grub_uint32_t uuid; +}; + +struct grub_fshelp_node { + grub_disk_t disk; + struct grub_fat_data *data; + grub_uint8_t attr; grub_ssize_t file_size; grub_uint32_t file_cluster; grub_uint32_t cur_cluster_num; grub_uint32_t cur_cluster; - grub_uint32_t uuid; +#ifdef MODE_EXFAT + int is_contiguous; +#endif }; static grub_dl_t my_mod; @@ -427,13 +435,6 @@ grub_fat_mount (grub_disk_t disk) (void) magic; #endif - /* Start from the root directory. */ - data->file_cluster = data->root_cluster; - data->cur_cluster_num = ~0U; - data->attr = GRUB_FAT_ATTR_DIRECTORY; -#ifdef MODE_EXFAT - data->is_contiguous = 0; -#endif return data; fail: @@ -444,7 +445,7 @@ grub_fat_mount (grub_disk_t disk) } static grub_ssize_t -grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node, grub_disk_read_hook_t read_hook, void *read_hook_data, grub_off_t offset, grub_size_t len, char *buf) { @@ -457,13 +458,13 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #ifndef MODE_EXFAT /* This is a special case. FAT12 and FAT16 doesn't have the root directory in clusters. */ - if (data->file_cluster == ~0U) + if (node->file_cluster == ~0U) { - size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset; + size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset; if (size > len) size = len; - if (grub_disk_read (disk, data->root_sector, offset, size, buf)) + if (grub_disk_read (disk, node->data->root_sector, offset, size, buf)) return -1; return size; @@ -471,12 +472,12 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #endif #ifdef MODE_EXFAT - if (data->is_contiguous) + if (node->is_contiguous) { /* Read the data here. */ - sector = (data->cluster_sector - + ((data->file_cluster - 2) - << data->cluster_bits)); + sector = (node->data->cluster_sector + + ((node->file_cluster - 2) + << node->data->cluster_bits)); disk->read_hook = read_hook; disk->read_hook_data = read_hook_data; @@ -491,53 +492,53 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #endif /* Calculate the logical cluster number and offset. */ - logical_cluster_bits = (data->cluster_bits + logical_cluster_bits = (node->data->cluster_bits + GRUB_DISK_SECTOR_BITS); logical_cluster = offset >> logical_cluster_bits; offset &= (1ULL << logical_cluster_bits) - 1; - if (logical_cluster < data->cur_cluster_num) + if (logical_cluster < node->cur_cluster_num) { - data->cur_cluster_num = 0; - data->cur_cluster = data->file_cluster; + node->cur_cluster_num = 0; + node->cur_cluster = node->file_cluster; } while (len) { - while (logical_cluster > data->cur_cluster_num) + while (logical_cluster > node->cur_cluster_num) { /* Find next cluster. */ grub_uint32_t next_cluster; grub_uint32_t fat_offset; - switch (data->fat_size) + switch (node->data->fat_size) { case 32: - fat_offset = data->cur_cluster << 2; + fat_offset = node->cur_cluster << 2; break; case 16: - fat_offset = data->cur_cluster << 1; + fat_offset = node->cur_cluster << 1; break; default: /* case 12: */ - fat_offset = data->cur_cluster + (data->cur_cluster >> 1); + fat_offset = node->cur_cluster + (node->cur_cluster >> 1); break; } /* Read the FAT. */ - if (grub_disk_read (disk, data->fat_sector, fat_offset, - (data->fat_size + 7) >> 3, + if (grub_disk_read (disk, node->data->fat_sector, fat_offset, + (node->data->fat_size + 7) >> 3, (char *) &next_cluster)) return -1; next_cluster = grub_le_to_cpu32 (next_cluster); - switch (data->fat_size) + switch (node->data->fat_size) { case 16: next_cluster &= 0xFFFF; break; case 12: - if (data->cur_cluster & 1) + if (node->cur_cluster & 1) next_cluster >>= 4; next_cluster &= 0x0FFF; @@ -545,27 +546,27 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, } grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n", - data->fat_size, next_cluster); + node->data->fat_size, next_cluster); /* Check the end. */ - if (next_cluster >= data->cluster_eof_mark) + if (next_cluster >= node->data->cluster_eof_mark) return ret; - if (next_cluster < 2 || next_cluster >= data->num_clusters) + if (next_cluster < 2 || next_cluster >= node->data->num_clusters) { grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u", next_cluster); return -1; } - data->cur_cluster = next_cluster; - data->cur_cluster_num++; + node->cur_cluster = next_cluster; + node->cur_cluster_num++; } /* Read the data here. */ - sector = (data->cluster_sector - + ((data->cur_cluster - 2) - << data->cluster_bits)); + sector = (node->data->cluster_sector + + ((node->cur_cluster - 2) + << node->data->cluster_bits)); size = (1 << logical_cluster_bits) - offset; if (size > len) size = len; @@ -631,7 +632,7 @@ grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt) #ifdef MODE_EXFAT static grub_err_t -grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_iterate_dir_next (grub_fshelp_node_t node, struct grub_fat_iterate_context *ctxt) { grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir)); @@ -641,7 +642,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, ctxt->offset += sizeof (dir); - if (grub_fat_read_data (disk, data, 0, 0, ctxt->offset, sizeof (dir), + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir), (char *) &dir) != sizeof (dir)) break; @@ -663,7 +664,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, { struct grub_fat_dir_entry sec; ctxt->offset += sizeof (sec); - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (sec), (char *) &sec) != sizeof (sec)) break; @@ -727,7 +728,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, #else static grub_err_t -grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_iterate_dir_next (grub_fshelp_node_t node, struct grub_fat_iterate_context *ctxt) { char *filep = 0; @@ -742,7 +743,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, ctxt->offset += sizeof (ctxt->dir); /* Read a directory entry. */ - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (ctxt->dir), (char *) &ctxt->dir) != sizeof (ctxt->dir) || ctxt->dir.name[0] == 0) @@ -853,84 +854,20 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, #endif -/* Find the underlying directory or file in PATH and return the - next path. If there is no next path or an error occurs, return NULL. - If HOOK is specified, call it with each file name. */ -static char * -grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, - const char *path, const char *origpath, - grub_fs_dir_hook_t hook, void *hook_data) +static grub_err_t lookup_file (grub_fshelp_node_t node, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) { - char *dirname, *dirp; - int call_hook; - int found = 0; - struct grub_fat_iterate_context ctxt; grub_err_t err; - - if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - return 0; - } - - do - { - /* Extract a directory name. */ - while (*path == '/') - path++; - - /* Emulate special "." and ".." entries in root directory */ - if (data->file_cluster == data->root_cluster) - { - if (*path != '.') - break; - if (!path[1] || path[1] == '/') - { - path++; - continue; - } - if (path[1] == '.' && (!path[2] || path[2] == '/')) - { - path += 2; - continue; - } - } - break; - } - while (1); - - dirp = grub_strchr (path, '/'); - if (dirp) - { - unsigned len = dirp - path; - - dirname = grub_malloc (len + 1); - if (! dirname) - goto fail; - - grub_memcpy (dirname, path, len); - dirname[len] = '\0'; - } - else - /* This is actually a file. */ - dirname = grub_strdup (path); - - call_hook = (! dirp && hook); + struct grub_fat_iterate_context ctxt; err = grub_fat_iterate_init (&ctxt); if (err) - { - grub_free (dirname); - return 0; - } + return err; - while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) + while (!(err = grub_fat_iterate_dir_next (node, &ctxt))) { - struct grub_dirhook_info info; - grub_memset (&info, 0, sizeof (info)); - - info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY); - info.case_insensitive = 1; #ifdef MODE_EXFAT if (!ctxt.dir.have_stream) @@ -939,36 +876,33 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID) continue; #endif - if (*dirname == '\0' && call_hook) - { - if (hook (ctxt.filename, &info, hook_data)) - break; - else - continue; - } - if (grub_strcasecmp (dirname, ctxt.filename) == 0) + if (grub_strcasecmp (name, ctxt.filename) == 0) { - found = 1; - data->attr = ctxt.dir.attr; + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + (*foundnode)->attr = ctxt.dir.attr; #ifdef MODE_EXFAT - data->file_size = ctxt.dir.file_size; - data->file_cluster = ctxt.dir.first_cluster; - data->is_contiguous = ctxt.dir.is_contiguous; + (*foundnode)->file_size = ctxt.dir.file_size; + (*foundnode)->file_cluster = ctxt.dir.first_cluster; + (*foundnode)->is_contiguous = ctxt.dir.is_contiguous; #else - data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); - data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) + (*foundnode)->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); + (*foundnode)->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) | grub_le_to_cpu16 (ctxt.dir.first_cluster_low)); /* If directory points to root, starting cluster is 0 */ - if (!data->file_cluster) - data->file_cluster = data->root_cluster; + if (!(*foundnode)->file_cluster) + (*foundnode)->file_cluster = node->data->root_cluster; #endif - data->cur_cluster_num = ~0U; + (*foundnode)->cur_cluster_num = ~0U; + (*foundnode)->data = node->data; + (*foundnode)->disk = node->disk; - if (call_hook) - hook (ctxt.filename, &info, hook_data); + *foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG; - break; + grub_fat_iterate_fini (&ctxt); + return GRUB_ERR_NONE; } } @@ -976,13 +910,8 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, if (err == GRUB_ERR_EOF) err = 0; - if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook) - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath); + return err; - fail: - grub_free (dirname); - - return found ? dirp : 0; } static grub_err_t @@ -991,9 +920,9 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, { struct grub_fat_data *data = 0; grub_disk_t disk = device->disk; - grub_size_t len; - char *dirname = 0; - char *p; + grub_fshelp_node_t found = NULL; + grub_err_t err; + struct grub_fat_iterate_context ctxt; grub_dl_ref (my_mod); @@ -1001,27 +930,53 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, if (! data) goto fail; - /* Make sure that DIRNAME terminates with '/'. */ - len = grub_strlen (path); - dirname = grub_malloc (len + 1 + 1); - if (! dirname) - goto fail; - grub_memcpy (dirname, path, len); - p = dirname + len; - if (path[len - 1] != '/') - *p++ = '/'; - *p = '\0'; - p = dirname; + struct grub_fshelp_node root = { + .data = data, + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .file_cluster = data->root_cluster, + .cur_cluster_num = ~0U, + .cur_cluster = 0, +#ifdef MODE_EXFAT + .is_contiguous = 0, +#endif + }; - do + err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, NULL, GRUB_FSHELP_DIR); + if (err) + goto fail; + + err = grub_fat_iterate_init (&ctxt); + if (err) + goto fail; + + while (!(err = grub_fat_iterate_dir_next (found, &ctxt))) { - p = grub_fat_find_dir (disk, data, p, path, hook, hook_data); + struct grub_dirhook_info info; + grub_memset (&info, 0, sizeof (info)); + + info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY); + info.case_insensitive = 1; +#ifdef MODE_EXFAT + if (!ctxt.dir.have_stream) + continue; +#else + if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID) + continue; +#endif + + if (hook (ctxt.filename, &info, hook_data)) + break; } - while (p && grub_errno == GRUB_ERR_NONE); + grub_fat_iterate_fini (&ctxt); + if (err == GRUB_ERR_EOF) + err = 0; fail: + if (found != &root) + grub_free (found); - grub_free (dirname); grub_free (data); grub_dl_unref (my_mod); @@ -1033,35 +988,43 @@ static grub_err_t grub_fat_open (grub_file_t file, const char *name) { struct grub_fat_data *data = 0; - char *p = (char *) name; + grub_fshelp_node_t found = NULL; + grub_err_t err; + grub_disk_t disk = file->device->disk; grub_dl_ref (my_mod); - data = grub_fat_mount (file->device->disk); + data = grub_fat_mount (disk); if (! data) goto fail; - do - { - p = grub_fat_find_dir (file->device->disk, data, p, name, 0, 0); - if (grub_errno != GRUB_ERR_NONE) - goto fail; - } - while (p); + struct grub_fshelp_node root = { + .data = data, + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .file_cluster = data->root_cluster, + .cur_cluster_num = ~0U, + .cur_cluster = 0, +#ifdef MODE_EXFAT + .is_contiguous = 0, +#endif + }; - if (data->attr & GRUB_FAT_ATTR_DIRECTORY) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - goto fail; - } + err = grub_fshelp_find_file_lookup (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG); + if (err) + goto fail; - file->data = data; - file->size = data->file_size; + file->data = found; + file->size = found->file_size; return GRUB_ERR_NONE; fail: + if (found != &root) + grub_free (found); + grub_free (data); grub_dl_unref (my_mod); @@ -1080,7 +1043,10 @@ grub_fat_read (grub_file_t file, char *buf, grub_size_t len) static grub_err_t grub_fat_close (grub_file_t file) { - grub_free (file->data); + grub_fshelp_node_t node = file->data; + + grub_free (node->data); + grub_free (node); grub_dl_unref (my_mod); @@ -1093,20 +1059,29 @@ grub_fat_label (grub_device_t device, char **label) { struct grub_fat_dir_entry dir; grub_ssize_t offset = -sizeof(dir); - struct grub_fat_data *data; grub_disk_t disk = device->disk; + struct grub_fshelp_node root = { + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .cur_cluster_num = ~0U, + .cur_cluster = 0, + .is_contiguous = 0, + }; - data = grub_fat_mount (disk); - if (! data) + root.data = grub_fat_mount (disk); + if (! root.data) return grub_errno; + root.file_cluster = root.data->root_cluster; + *label = NULL; while (1) { offset += sizeof (dir); - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (disk, &root, 0, 0, offset, sizeof (dir), (char *) &dir) != sizeof (dir)) break; @@ -1126,7 +1101,7 @@ grub_fat_label (grub_device_t device, char **label) * GRUB_MAX_UTF8_PER_UTF16 + 1); if (!*label) { - grub_free (data); + grub_free (root.data); return grub_errno; } chc = dir.type_specific.volume_label.character_count; @@ -1138,7 +1113,7 @@ grub_fat_label (grub_device_t device, char **label) } } - grub_free (data); + grub_free (root.data); return grub_errno; } @@ -1147,30 +1122,32 @@ grub_fat_label (grub_device_t device, char **label) static grub_err_t grub_fat_label (grub_device_t device, char **label) { - struct grub_fat_data *data; grub_disk_t disk = device->disk; grub_err_t err; struct grub_fat_iterate_context ctxt; + struct grub_fshelp_node root = { + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .cur_cluster_num = ~0U, + .cur_cluster = 0, + }; *label = 0; grub_dl_ref (my_mod); - data = grub_fat_mount (disk); - if (! data) + root.data = grub_fat_mount (disk); + if (! root.data) goto fail; - if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } + root.file_cluster = root.data->root_cluster; err = grub_fat_iterate_init (&ctxt); if (err) goto fail; - while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) + while (!(err = grub_fat_iterate_dir_next (&root, &ctxt))) if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID) { *label = grub_strdup (ctxt.filename); @@ -1183,7 +1160,7 @@ grub_fat_label (grub_device_t device, char **label) grub_dl_unref (my_mod); - grub_free (data); + grub_free (root.data); return grub_errno; } From 5fb1e859f71c33bec25d7a7f5926e80e0019b37c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:50:22 +0200 Subject: [PATCH 0324/1167] HFS: Convert to fshelp. HFS doesn't handle "." and ".." properly. Convert it to fshelp to reuse the logic. --- grub-core/fs/hfs.c | 177 ++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 99 deletions(-) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 06cf0c7ab..0ebc71b62 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -1125,90 +1126,81 @@ utf8_to_macroman (grub_uint8_t *to, const char *from) return optr - to; } +union grub_hfs_anyrec { + struct grub_hfs_filerec frec; + struct grub_hfs_dirrec dir; +}; + +struct grub_fshelp_node +{ + struct grub_hfs_data *data; + union grub_hfs_anyrec fdrec; + grub_uint32_t inode; +}; + +static grub_err_t +lookup_file (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) +{ + struct grub_hfs_catalog_key key; + grub_ssize_t slen; + union grub_hfs_anyrec fdrec; + + key.parent_dir = grub_cpu_to_be32 (dir->inode); + slen = utf8_to_macroman (key.str, name); + if (slen < 0) + /* Not found */ + return GRUB_ERR_NONE; + key.strlen = slen; + + /* Lookup this node. */ + if (! grub_hfs_find_node (dir->data, (char *) &key, dir->data->cat_root, + 0, (char *) &fdrec.frec, sizeof (fdrec.frec))) + /* Not found */ + return GRUB_ERR_NONE; + + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + + (*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid); + (*foundnode)->fdrec = fdrec; + (*foundnode)->data = dir->data; + *foundtype = (fdrec.frec.type == GRUB_HFS_FILETYPE_DIR) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG; + return GRUB_ERR_NONE; +} /* Find a file or directory with the pathname PATH in the filesystem DATA. Return the file record in RETDATA when it is non-zero. Return the directory number in RETINODE when it is non-zero. */ static grub_err_t grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, - struct grub_hfs_filerec *retdata, int *retinode) + grub_fshelp_node_t *found, + enum grub_fshelp_filetype exptype) { - int inode = data->rootdir; - char *next; - char *origpath; - union { - struct grub_hfs_filerec frec; - struct grub_hfs_dirrec dir; - } fdrec; - - fdrec.frec.type = GRUB_HFS_FILETYPE_DIR; - - if (path[0] != '/') - { - grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); - return 0; + struct grub_fshelp_node root = { + .data = data, + .inode = data->rootdir, + .fdrec = { + .frec = { + .type = GRUB_HFS_FILETYPE_DIR + } } + }; + grub_err_t err; - origpath = grub_strdup (path); - if (!origpath) - return grub_errno; + err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype); - path = origpath; - while (*path == '/') - path++; - - while (path && grub_strlen (path)) + if (&root == *found) { - grub_ssize_t slen; - if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } - - /* Isolate a part of the path. */ - next = grub_strchr (path, '/'); - if (next) - { - while (*next == '/') - *(next++) = '\0'; - } - - struct grub_hfs_catalog_key key; - - key.parent_dir = grub_cpu_to_be32 (inode); - slen = utf8_to_macroman (key.str, path); - if (slen < 0) - { - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path); - goto fail; - } - key.strlen = slen; - - /* Lookup this node. */ - if (! grub_hfs_find_node (data, (char *) &key, data->cat_root, - 0, (char *) &fdrec.frec, sizeof (fdrec.frec))) - { - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath); - goto fail; - } - - if (grub_errno) - goto fail; - - inode = grub_be_to_cpu32 (fdrec.dir.dirid); - path = next; + *found = grub_malloc (sizeof (root)); + if (!*found) + return grub_errno; + grub_memcpy (*found, &root, sizeof (root)); } - - if (retdata) - grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec)); - - if (retinode) - *retinode = inode; - - fail: - grub_free (origpath); - return grub_errno; + return err; } struct grub_hfs_dir_hook_ctx @@ -1266,16 +1258,14 @@ static grub_err_t grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, void *hook_data) { - int inode; - struct grub_hfs_data *data; - struct grub_hfs_filerec frec; struct grub_hfs_dir_hook_ctx ctx = { .hook = hook, .hook_data = hook_data }; - + grub_fshelp_node_t found = NULL; + grub_dl_ref (my_mod); data = grub_hfs_mount (device->disk); @@ -1283,18 +1273,13 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, goto fail; /* First the directory ID for the directory. */ - if (grub_hfs_find_dir (data, path, &frec, &inode)) + if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR)) goto fail; - if (frec.type != GRUB_HFS_FILETYPE_DIR) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } - - grub_hfs_iterate_dir (data, data->cat_root, inode, grub_hfs_dir_hook, &ctx); + grub_hfs_iterate_dir (data, data->cat_root, found->inode, grub_hfs_dir_hook, &ctx); fail: + grub_free (found); grub_free (data); grub_dl_unref (my_mod); @@ -1308,8 +1293,8 @@ static grub_err_t grub_hfs_open (struct grub_file *file, const char *name) { struct grub_hfs_data *data; - struct grub_hfs_filerec frec; - + grub_fshelp_node_t found = NULL; + grub_dl_ref (my_mod); data = grub_hfs_mount (file->device->disk); @@ -1320,29 +1305,23 @@ grub_hfs_open (struct grub_file *file, const char *name) return grub_errno; } - if (grub_hfs_find_dir (data, name, &frec, 0)) + if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG)) { grub_free (data); grub_dl_unref (my_mod); return grub_errno; } - if (frec.type != GRUB_HFS_FILETYPE_FILE) - { - grub_free (data); - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - grub_dl_unref (my_mod); - return grub_errno; - } - - grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t)); - file->size = grub_be_to_cpu32 (frec.size); - data->size = grub_be_to_cpu32 (frec.size); - data->fileid = grub_be_to_cpu32 (frec.fileid); + grub_memcpy (data->extents, found->fdrec.frec.extents, sizeof (grub_hfs_datarecord_t)); + file->size = grub_be_to_cpu32 (found->fdrec.frec.size); + data->size = grub_be_to_cpu32 (found->fdrec.frec.size); + data->fileid = grub_be_to_cpu32 (found->fdrec.frec.fileid); file->offset = 0; file->data = data; + grub_free (found); + return 0; } From d3b464a7c0a9acb7d0f7202a7fa45ac29a014692 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 13:19:02 +0200 Subject: [PATCH 0325/1167] archelp: Never pass NULL as mtime. Moves complexity from fs code (NULL check) to common code (passing non-NULL). --- grub-core/fs/archelp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index 707f9a658..0cf544f6f 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -249,9 +249,10 @@ grub_archelp_open (struct grub_archelp_data *data, while (1) { grub_uint32_t mode; + grub_int32_t mtime; int restart; - if (arcops->find_file (data, &fn, NULL, &mode)) + if (arcops->find_file (data, &fn, &mtime, &mode)) goto fail; if (mode == GRUB_ARCHELP_ATTR_END) From 72fc110d95129410443b898e931ff7a1db75312e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 28 Jul 2015 01:51:14 +0200 Subject: [PATCH 0326/1167] ahci: Ensure that bus mastering is set. Fixes ahci_test failing on several platforms. --- grub-core/disk/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index f4725e8c1..fc640d5d4 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -195,7 +195,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); grub_pci_write_word (addr, grub_pci_read_word (addr) - | GRUB_PCI_COMMAND_MEM_ENABLED); + | GRUB_PCI_COMMAND_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER); hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, sizeof (*hba)); From d7a85e69e0c00a6a2ddb2fca2261e0aed8b1d724 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 9 Aug 2015 16:28:12 +0300 Subject: [PATCH 0327/1167] linguas.sh: fix error when removing non-existing autogenerated files --- linguas.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linguas.sh b/linguas.sh index 1de42ba2d..e57f50dc6 100755 --- a/linguas.sh +++ b/linguas.sh @@ -6,7 +6,7 @@ autogenerated="en@quot en@hebrew de@hebrew en@cyrillic en@greek en@arabic en@pig for x in $autogenerated; do - rm "po/$x.po"; + rm -f "po/$x.po"; done From 4fe8e6d4a1279b1840171d8e797d911cd8443333 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Thu, 6 Aug 2015 10:49:46 -0700 Subject: [PATCH 0328/1167] efinet: handle get_status() on buggy firmware properly The EFI spec indicates that get_status() should return the address of the buffer we passed into transmit to indicate the the buffer was transmitted. However we have boxes where the firmware returns some arbitrary address instead, which makes grub think that we've not sent anything. So since we have the SNP stuff opened in exclusive mode just assume any non-NULL txbuf means that our transmit occurred properly. This makes grub able to do its networking stuff properly on our broken firmware. Thanks, cc: Peter Jones Signed-off-by: Josef Bacik --- grub-core/net/drivers/efi/efinet.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 70b26af94..5388f952b 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -47,19 +47,19 @@ send_card_buffer (struct grub_net_card *dev, if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")); - if (txbuf == dev->txbuf) + /* + Some buggy firmware could return an arbitrary address instead of the + txbuf address we trasmitted, so just check that txbuf is non NULL + for success. This is ok because we open the SNP protocol in + exclusive mode so we know we're the only ones transmitting on this + box and since we only transmit one packet at a time we know our + transmit was successfull. + */ + if (txbuf) { dev->txbusy = 0; break; } - if (txbuf) - { - st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size, - dev->txbuf, NULL, NULL, NULL); - if (st != GRUB_EFI_SUCCESS) - return grub_error (GRUB_ERR_IO, - N_("couldn't send network packet")); - } if (limit_time < grub_get_time_ms ()) return grub_error (GRUB_ERR_TIMEOUT, N_("couldn't send network packet")); @@ -84,8 +84,9 @@ send_card_buffer (struct grub_net_card *dev, we run in the GRUB_ERR_TIMEOUT case above. Perhaps a timeout in the FW has discarded the recycle buffer. */ + txbuf = NULL; st = efi_call_3 (net->get_status, net, 0, &txbuf); - dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf); + dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf); return GRUB_ERR_NONE; } From ba218c1c10833092b14177896c10e48715c836fe Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 13 Aug 2015 20:20:39 +0300 Subject: [PATCH 0329/1167] net: do not try to load protocol module via itself Otherwise we get infinite recursion. Closes: 45729 --- grub-core/net/net.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 21a4e94d1..a0472d5d4 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1341,6 +1341,43 @@ grub_net_open_real (const char *name) } if (try == 0) { + const char *prefix, *root; + char *prefdev, *comma; + int skip = 0; + grub_size_t devlen; + + /* Do not attempt to load module if it requires protocol provided + by this module - it results in infinite recursion. Just continue, + fail and cleanup on next iteration. + */ + prefix = grub_env_get ("prefix"); + if (!prefix) + continue; + + prefdev = grub_file_get_device_name (prefix); + if (!prefdev) + { + root = grub_env_get ("root"); + if (!root) + continue; + prefdev = grub_strdup (root); + if (!prefdev) + continue; + } + + comma = grub_strchr (prefdev, ','); + if (comma) + *comma = '\0'; + devlen = grub_strlen (prefdev); + + if (protnamelen == devlen && grub_memcmp (prefdev, protname, devlen) == 0) + skip = 1; + + grub_free (prefdev); + + if (skip) + continue; + if (sizeof ("http") - 1 == protnamelen && grub_memcmp ("http", protname, protnamelen) == 0) { From 8e3d2c80ed1b9c2d150910cf3611d7ecb7d3dc6f Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Sat, 22 Aug 2015 21:22:41 +0200 Subject: [PATCH 0330/1167] disk/ldm, partmap/msdos.c: fix spelling error --- grub-core/disk/ldm.c | 2 +- grub-core/partmap/msdos.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c index 8075f2a9e..0f978ad05 100644 --- a/grub-core/disk/ldm.c +++ b/grub-core/disk/ldm.c @@ -963,7 +963,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors, if (embed_type != GRUB_EMBED_PCBIOS) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "LDM curently supports only PC-BIOS embedding"); + "LDM currently supports only PC-BIOS embedding"); if (disk->partition) return grub_error (GRUB_ERR_BUG, "disk isn't LDM"); pv = grub_diskfilter_get_pv_from_disk (disk, &vg); diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 46c406bff..6d4b455a1 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -249,7 +249,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (embed_type != GRUB_EMBED_PCBIOS) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "PC-style partitions curently support " + "PC-style partitions currently support " "only PC-BIOS embedding"); if (disk->partition) From c93d3e694713b8230fa2cf88414fabe005b56782 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 13 Sep 2015 20:12:31 +0300 Subject: [PATCH 0331/1167] cryptodisk: strip parenthesis from backing device name Otherwise subsequent disk open fails. Reported-By: Klemens Nanni --- grub-core/disk/cryptodisk.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 82a3dcb63..85d68e3b6 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -964,33 +964,43 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) grub_disk_t disk; grub_cryptodisk_t dev; char *diskname; - char *disklast; + char *disklast = NULL; + grub_size_t len; search_uuid = NULL; check_boot = state[2].set; diskname = args[0]; - if (diskname[0] == '(' && *(disklast = &diskname[grub_strlen (diskname) - 1]) == ')') + len = grub_strlen (diskname); + if (len && diskname[0] == '(' && diskname[len - 1] == ')') { + disklast = &diskname[len - 1]; *disklast = '\0'; - disk = grub_disk_open (diskname + 1); - *disklast = ')'; + diskname++; } - else - disk = grub_disk_open (diskname); + + disk = grub_disk_open (diskname); if (!disk) - return grub_errno; + { + if (disklast) + *disklast = ')'; + return grub_errno; + } dev = grub_cryptodisk_get_by_source_disk (disk); if (dev) { grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id); grub_disk_close (disk); + if (disklast) + *disklast = ')'; return GRUB_ERR_NONE; } - err = grub_cryptodisk_scan_device_real (args[0], disk); + err = grub_cryptodisk_scan_device_real (diskname, disk); grub_disk_close (disk); + if (disklast) + *disklast = ')'; return err; } From 8cb4c4edbe84fe455455dd26d5763541c2824098 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 6 Oct 2015 13:21:43 -0400 Subject: [PATCH 0332/1167] sparc64 - use correct drive name within grub_util_sparc_setup Incorrect drive name was being passed into grub_util_sparc_setup, causing the grub-install to fail. Signed-off-by: Eric Snowberg --- util/grub-install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index df5c7e520..eabd6de4d 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1698,7 +1698,7 @@ main (int argc, char *argv[]) /* Now perform the installation. */ if (install_bootsector) grub_util_sparc_setup (platdir, "boot.img", "core.img", - install_device, force, + install_drive, force, fs_probe, allow_floppy, 0 /* unused */ ); break; From ee67bcf31ec946848b2a186676f18786c45b4035 Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Mon, 7 Sep 2015 14:13:11 +0300 Subject: [PATCH 0333/1167] ofnet: Do not set SUFFIX for sun4v network devices sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail: ok select net:speed=auto,duplex=auto Unknown key 'speed' Unknown key 'duplex' Manual Configuration: Host IP, boot server and filename must be specified WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package Can't open device ok Therefore, let's not set SUFFIX for such devices. Signed-off-by: Stanislav Kholmanskikh --- grub-core/net/drivers/ieee1275/ofnet.c | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index eea8e71d3..eff9085ed 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) grub_uint64_t prop; grub_uint8_t *pprop; char *shortname; + char need_suffix = 1; if (grub_strcmp (alias->type, "network") != 0) return 0; @@ -325,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias *alias) #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512" - if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + need_suffix = 0; + + /* sun4v vnet devices do not support setting duplex/speed */ + { + char *ptr; + + grub_ieee1275_finddevice (alias->path, &devhandle); + + grub_ieee1275_get_property_length (devhandle, "compatible", &prop_size); + if (prop_size > 0) + { + pprop = grub_malloc (prop_size); + if (!pprop) + { + grub_free (card); + grub_free (ofdata); + grub_print_error (); + return 1; + } + + if (!grub_ieee1275_get_property (devhandle, "compatible", + pprop, prop_size, NULL)) + { + for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size; + ptr += grub_strlen (ptr) + 1) + { + if (!grub_strcmp(ptr, "SUNW,sun4v-network")) + need_suffix = 0; + } + } + + grub_free (pprop); + } + } + + if (need_suffix) ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX)); else ofdata->path = grub_malloc (grub_strlen (alias->path) + 1); @@ -335,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) return 0; } ofdata->suffix = grub_stpcpy (ofdata->path, alias->path); - if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + if (need_suffix) grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX)); else *ofdata->suffix = '\0'; From f188a86064c4d58f697c25174ea851429203b414 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Fri, 9 Oct 2015 13:35:40 +0200 Subject: [PATCH 0334/1167] ufs: Fix parameters to grub_memset. len = 0 made simply no sense. Fix parameters to be in line with read. --- grub-core/fs/ufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 0619d6e32..293f027aa 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -394,7 +394,7 @@ grub_ufs_read_file (struct grub_ufs_data *data, return -1; } else - grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0); + grub_memset (buf, 0, blockend); buf += UFS_BLKSZ (sblock) - skipfirst; } From f59b83fce67fffcdc2414081debf50913dc6b010 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 9 Oct 2015 23:30:53 +0200 Subject: [PATCH 0335/1167] gfxmenu/model: Delete empty file. --- grub-core/Makefile.core.def | 1 - grub-core/gfxmenu/model.c | 0 2 files changed, 1 deletion(-) delete mode 100644 grub-core/gfxmenu/model.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 9764cd235..abf5ac1bf 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1448,7 +1448,6 @@ module = { module = { name = gfxmenu; common = gfxmenu/gfxmenu.c; - common = gfxmenu/model.c; common = gfxmenu/view.c; common = gfxmenu/font.c; common = gfxmenu/icon_manager.c; diff --git a/grub-core/gfxmenu/model.c b/grub-core/gfxmenu/model.c deleted file mode 100644 index e69de29bb..000000000 From c2443e49bc2a165744dab596b4a9d1b04f52da83 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 9 Oct 2015 23:32:06 +0200 Subject: [PATCH 0336/1167] mips/dl: Handle addend in RELA entries. --- grub-core/kern/mips/dl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c index 8c057e01d..e320a4ee7 100644 --- a/grub-core/kern/mips/dl.c +++ b/grub-core/kern/mips/dl.c @@ -138,6 +138,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, sym = (Elf_Sym *) ((char *) mod->symtab + mod->symsize * ELF_R_SYM (rel->r_info)); sym_value = sym->st_value; + if (s->sh_type == SHT_RELA) + { + sym_value += ((Elf_Rela *) rel)->r_addend; + } if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy) sym_value = (grub_addr_t) mod->got; else if (sym_value == (grub_addr_t) &_gp_disp_dummy) From d31321835e9e0b2e1c792b8834840eb148cdd29f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 10 Oct 2015 10:02:20 +0300 Subject: [PATCH 0337/1167] file: ignore host disk in blocklist check It cannot work anyway because host disk cannot be read. This fixes hostfs access on native Windows build where filenames start with '\' or do not have initial separator at all (d:\foo). Issue was observed when running grub-fstest on Windows. On UNIX image name is canonicalized to always start with `/' so this was not noticed. This has side effect of allowing relative path names on host, but this already was the case with `ls' command, so it just extends it to all commands. Reported-By: Arch Stack Also-By: Arch Stack --- grub-core/kern/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 24da12bb9..3367485fb 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -89,7 +89,11 @@ grub_file_open (const char *name) file->device = device; - if (device->disk && file_name[0] != '/') + if (device->disk && file_name[0] != '/' +#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU) + && grub_strcmp (device->disk->name, "host") +#endif + ) /* This is a block list. */ file->fs = &grub_fs_blocklist; else From 6e211958901168957f9c2f71041f2871756c5b65 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 10 Oct 2015 11:44:14 +0300 Subject: [PATCH 0338/1167] progress: avoid NULL dereference for net files From original patch by dann frazier : grub_net_fs_open() saves off a copy of the file structure it gets passed and uses it to create a bufio structure. It then overwrites the passed in file structure with this new bufio structure. Since file->name doesn't get set until we return back to grub_file_open(), it means that only the bufio structure gets a valid file->name. The "real" file's name is left uninitialized. This leads to a crash when the progress module hook is called on it. grub_net_fs_open() already saved copy of file name as ->net->name, so change progress module to use it. Also, grub_file_open may leave file->name as NULL if grub_strdup fails. Check for it. Also-By: dann frazier --- grub-core/lib/progress.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c index 63a0767d6..95a4a6281 100644 --- a/grub-core/lib/progress.c +++ b/grub-core/lib/progress.c @@ -23,6 +23,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -70,7 +71,15 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), percent = grub_divmod64 (100 * file->progress_offset, file->size, 0); - partial_file_name = grub_strrchr (file->name, '/'); + /* grub_net_fs_open() saves off partial file structure before name is initialized. + It already saves passed file name in net structure so just use it in this case. + */ + if (file->device->net) + partial_file_name = grub_strrchr (file->device->net->name, '/'); + else if (file->name) /* grub_file_open() may leave it as NULL */ + partial_file_name = grub_strrchr (file->name, '/'); + else + partial_file_name = NULL; if (partial_file_name) partial_file_name++; else From 285540e44869f7d463eb97e56141f6c19c2af67d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 10 Oct 2015 10:34:55 +0200 Subject: [PATCH 0339/1167] mips: Make the assembly-code N32-compatible. There are no $t4 or $t5 in N32 but there are $a4 and $a5. --- asm-tests/mips.S | 4 ++-- grub-core/boot/mips/startup_raw.S | 37 ++++++++++++++++--------------- grub-core/kern/mips/startup.S | 5 +++-- include/grub/mips/asm.h | 11 +++++++++ 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 include/grub/mips/asm.h diff --git a/asm-tests/mips.S b/asm-tests/mips.S index 8233dfcc9..1312d47d5 100644 --- a/asm-tests/mips.S +++ b/asm-tests/mips.S @@ -4,8 +4,8 @@ .set mips3 sync - ld $t2, 0($t6) + ld $t2, 0($t1) a: - addiu $t7, $s0, (b - a) + addiu $t1, $s0, (b - a) b: nop diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index ca3413bbe..6a81b3733 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -118,32 +119,32 @@ parsestr: move $v0, $zero move $t3, $t1 3: - lb $t4, 0($t2) - lb $t5, 0($t3) + lb GRUB_ASM_T4, 0($t2) + lb GRUB_ASM_T5, 0($t3) addiu $t2, $t2, 1 addiu $t3, $t3, 1 - beq $t5, $zero, 1f + beq GRUB_ASM_T5, $zero, 1f nop - beq $t5, $t4, 3b + beq GRUB_ASM_T5, GRUB_ASM_T4, 3b nop - bne $t4, $zero, 1f + bne GRUB_ASM_T4, $zero, 1f nop addiu $t3, $t3, 0xffff digcont: - lb $t5, 0($t3) + lb GRUB_ASM_T5, 0($t3) /* Substract '0' from digit. */ - addiu $t5, $t5, 0xffd0 - bltz $t5, 1f + addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0 + bltz GRUB_ASM_T5, 1f nop - addiu $t4, $t5, 0xfff7 - bgtz $t4, 1f + addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7 + bgtz GRUB_ASM_T4, 1f nop /* Multiply $v0 by 10 with bitshifts. */ sll $v0, $v0, 1 - sll $t4, $v0, 2 - addu $v0, $v0, $t4 - addu $v0, $v0, $t5 + sll GRUB_ASM_T4, $v0, 2 + addu $v0, $v0, GRUB_ASM_T4 + addu $v0, $v0, GRUB_ASM_T5 addiu $t3, $t3, 1 b digcont nop @@ -182,10 +183,10 @@ argdone: b argdone addiu $a1, $a1, 4 do_check: - lb $t4, 0($t7) - beq $t4, $zero, 1f + lb GRUB_ASM_T4, 0($t7) + beq GRUB_ASM_T4, $zero, 1f lb $t3, 0($t6) - bne $t3, $t4, 2f + bne $t3, GRUB_ASM_T4, 2f addiu $t6, $t6, 1 b do_check addiu $t7, $t7, 1 @@ -222,8 +223,8 @@ cmdlinedone: 1: beq $t1, $t3, 2f - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t1, $t1, 1 b 1b addiu $t2, $t2, 1 diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 339ab337e..1fdb58aca 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -95,8 +96,8 @@ cont: modulesmovcont: beq $t3, $0, modulesmovdone nop - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t2, $t2, -1 addiu $t1, $t1, -1 b modulesmovcont diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h new file mode 100644 index 000000000..ad2f71abe --- /dev/null +++ b/include/grub/mips/asm.h @@ -0,0 +1,11 @@ +#ifndef GRUB_MIPS_ASM_HEADER +#define GRUB_MIPS_ASM_HEADER 1 + +#if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 +#define GRUB_ASM_T4 $a4 +#define GRUB_ASM_T5 $a5 +#else +#define GRUB_ASM_T4 $t4 +#define GRUB_ASM_T5 $t5 +#endif +#endif From cfabe05cc6ab88fc7c7a48c9bc0072770b7ad101 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 11 Oct 2015 13:15:50 +0200 Subject: [PATCH 0340/1167] mips: Make setjmp code N32-compliant. --- grub-core/lib/mips/setjmp.S | 51 ++++++++++++++++++++----------------- include/grub/mips/asm.h | 7 +++++ include/grub/mips/setjmp.h | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S index f01294518..895235b78 100644 --- a/grub-core/lib/mips/setjmp.S +++ b/grub-core/lib/mips/setjmp.S @@ -18,6 +18,7 @@ #include #include +#include .file "setjmp.S" @@ -29,40 +30,42 @@ GRUB_MOD_LICENSE "GPLv3+" * int grub_setjmp (grub_jmp_buf env) */ FUNCTION(grub_setjmp) - sw $s0, 0($a0) - sw $s1, 4($a0) - sw $s2, 8($a0) - sw $s3, 12($a0) - sw $s4, 16($a0) - sw $s5, 20($a0) - sw $s6, 24($a0) - sw $s7, 28($a0) - sw $s8, 32($a0) - sw $gp, 36($a0) - sw $sp, 40($a0) - sw $ra, 44($a0) + GRUB_ASM_REG_S $s0, 0($a0) + GRUB_ASM_REG_S $s1, 8($a0) + GRUB_ASM_REG_S $s2, 16($a0) + GRUB_ASM_REG_S $s3, 24($a0) + GRUB_ASM_REG_S $s4, 32($a0) + GRUB_ASM_REG_S $s5, 40($a0) + GRUB_ASM_REG_S $s6, 48($a0) + GRUB_ASM_REG_S $s7, 56($a0) + GRUB_ASM_REG_S $s8, 64($a0) + GRUB_ASM_REG_S $gp, 72($a0) + GRUB_ASM_REG_S $sp, 80($a0) + GRUB_ASM_REG_S $ra, 88($a0) move $v0, $zero move $v1, $zero jr $ra + nop /* * int grub_longjmp (grub_jmp_buf env, int val) */ FUNCTION(grub_longjmp) - lw $s0, 0($a0) - lw $s1, 4($a0) - lw $s2, 8($a0) - lw $s3, 12($a0) - lw $s4, 16($a0) - lw $s5, 20($a0) - lw $s6, 24($a0) - lw $s7, 28($a0) - lw $s8, 32($a0) - lw $gp, 36($a0) - lw $sp, 40($a0) - lw $ra, 44($a0) + GRUB_ASM_REG_L $s0, 0($a0) + GRUB_ASM_REG_L $s1, 8($a0) + GRUB_ASM_REG_L $s2, 16($a0) + GRUB_ASM_REG_L $s3, 24($a0) + GRUB_ASM_REG_L $s4, 32($a0) + GRUB_ASM_REG_L $s5, 40($a0) + GRUB_ASM_REG_L $s6, 48($a0) + GRUB_ASM_REG_L $s7, 56($a0) + GRUB_ASM_REG_L $s8, 64($a0) + GRUB_ASM_REG_L $gp, 72($a0) + GRUB_ASM_REG_L $sp, 80($a0) + GRUB_ASM_REG_L $ra, 88($a0) move $v0, $a1 bne $v0, $zero, 1f addiu $v0, $v0, 1 1: move $v1, $zero jr $ra + nop diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h index ad2f71abe..4c397f4a0 100644 --- a/include/grub/mips/asm.h +++ b/include/grub/mips/asm.h @@ -4,8 +4,15 @@ #if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 #define GRUB_ASM_T4 $a4 #define GRUB_ASM_T5 $a5 +#define GRUB_ASM_SZREG 8 +#define GRUB_ASM_REG_S sd +#define GRUB_ASM_REG_L ld #else #define GRUB_ASM_T4 $t4 #define GRUB_ASM_T5 $t5 +#define GRUB_ASM_SZREG 4 +#define GRUB_ASM_REG_S sw +#define GRUB_ASM_REG_L lw #endif + #endif diff --git a/include/grub/mips/setjmp.h b/include/grub/mips/setjmp.h index a99dde9ef..f8f6517ac 100644 --- a/include/grub/mips/setjmp.h +++ b/include/grub/mips/setjmp.h @@ -19,7 +19,7 @@ #ifndef GRUB_SETJMP_CPU_HEADER #define GRUB_SETJMP_CPU_HEADER 1 -typedef unsigned long grub_jmp_buf[12]; +typedef grub_uint64_t grub_jmp_buf[12]; int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn)); From 76197d9be648adef902a86181493b297b3edce88 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 11 Oct 2015 21:17:37 +0300 Subject: [PATCH 0341/1167] install: --compress argument is not optional Fixes crash if argument is not specified. Also use `|' to separate choices in list of compression methods to align it with --core-compress. --- include/grub/util/install.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/util/install.h b/include/grub/util/install.h index aedcd29f9..5ca4811cd 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -39,7 +39,7 @@ { "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\ 0, N_("install only LOCALES [default=all]"), 1 }, \ { "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \ - "no,xz,gz,lzo", OPTION_ARG_OPTIONAL, \ + "no|xz|gz|lzo", 0, \ N_("compress GRUB files [optional]"), 1 }, \ {"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \ "xz|none|auto", \ From a01ab69848257a3df705e524c4acafe795e05cc9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 12 Oct 2015 23:16:23 +0300 Subject: [PATCH 0342/1167] net: avoid closing NULL socket in DNS lookup Refactor code so that we do not store NULL pointers in array of in-flight DNS servers. Reported-By: Josef Bacik --- grub-core/net/dns.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 9d0c8fcea..953f3bedd 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -437,7 +437,7 @@ grub_net_dns_lookup (const char *name, struct recv_data data = {naddresses, addresses, cache, grub_cpu_to_be16 (id++), 0, 0, name, 0}; grub_uint8_t *nbd; - int have_server = 0; + grub_size_t try_server = 0; if (!servers) { @@ -543,33 +543,31 @@ grub_net_dns_lookup (const char *name, for (i = 0; i < n_servers * 4; i++) { /* Connect to a next server. */ - while (!(i & 1) && send_servers < n_servers) + while (!(i & 1) && try_server < n_servers) { - sockets[send_servers] = grub_net_udp_open (servers[send_servers], + sockets[send_servers] = grub_net_udp_open (servers[try_server++], DNS_PORT, recv_hook, &data); - send_servers++; - if (!sockets[send_servers - 1]) + if (!sockets[send_servers]) { err = grub_errno; grub_errno = GRUB_ERR_NONE; } else { - have_server = 1; + send_servers++; break; } } - if (!have_server) + if (!send_servers) goto out; if (*data.naddresses) goto out; for (j = 0; j < send_servers; j++) { grub_err_t err2; - if (!sockets[j]) - continue; + nb->data = nbd; grub_size_t t = 0; From be25d92196fe31e307ac0b8996ba7f059332ffe3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 14 Oct 2015 00:39:15 +0200 Subject: [PATCH 0343/1167] configure: force o32 ABI on MIPS GRUB code expects O32 or N32. N32 is less tested than O32, so we prefer to compile with O32. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32. For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32". Reported-By: Mark H Weaver Also-By: Mark H Weaver --- configure.ac | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/configure.ac b/configure.ac index c864311f7..7bac86560 100644 --- a/configure.ac +++ b/configure.ac @@ -597,6 +597,40 @@ int main (void); TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" fi +# GRUB code is N32-compliant but it's experimental and we would prefer to +# avoid having too much variety when it doesn't result in any real improvement. +# Moreover N64 isn't supported. +if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then + AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [ + grub_cv_target_cc_mips_o32_abi=no + for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do + if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $arg -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32) +#error not o32 ABI +#endif +asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_mips_o32_abi="$arg"], []) + done + ]) + + if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then + AC_MSG_ERROR([could not force MIPS o32 ABI]) + fi + + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in From a3645c1240a0b89c3b51593bd3efc14fe66d67cf Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 14 Oct 2015 00:42:14 +0200 Subject: [PATCH 0344/1167] configure: find options to force endian on MIPS --- configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7bac86560..21691c15c 100644 --- a/configure.ac +++ b/configure.ac @@ -562,12 +562,12 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) -if test x$target_cpu = xpowerpc; then +if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ grub_cv_target_cc_big_endian=no - for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ - "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ - "-mbig-endian"; do + for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \ + "-EB" "-mbig-endian"; do if test x"$grub_cv_target_cc_big_endian" != xno ; then break fi @@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then #error still little endian #endif asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); void __main (void); void __main (void) {} int main (void); @@ -595,6 +597,41 @@ int main (void); TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +elif test x$target_cpu = xmipsel; then + AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [ + grub_cv_target_cc_little_endian=no + for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \ + "-EL"; do + if test x"$grub_cv_target_cc_little_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__) +#error still big endian +#endif +asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_little_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_little_endian" = xno ; then + AC_MSG_ERROR([could not force little-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian" fi # GRUB code is N32-compliant but it's experimental and we would prefer to From 9e5f70174ec960a0077f20bb74cb9f4da9b57e7b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sun, 25 Oct 2015 16:36:28 +0100 Subject: [PATCH 0345/1167] Use EFI_SIMPLE_TEXT_INPUT_EX to support key combinations. --- grub-core/term/efi/console.c | 120 +++++++++++++++++++++++++++++------ include/grub/efi/api.h | 65 ++++++++++++++++++- 2 files changed, 163 insertions(+), 22 deletions(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index a37eb841c..8b2096f19 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -104,26 +104,12 @@ const unsigned efi_codes[] = GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, - GRUB_TERM_KEY_F10, 0, 0, '\e' + GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, '\e' }; - static int -grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) +grub_efi_translate_key (grub_efi_input_key_t key) { - grub_efi_simple_input_interface_t *i; - grub_efi_input_key_t key; - grub_efi_status_t status; - - if (grub_efi_is_finished) - return 0; - - i = grub_efi_system_table->con_in; - status = efi_call_2 (i->read_key_stroke, i, &key); - - if (status != GRUB_EFI_SUCCESS) - return GRUB_TERM_NO_KEY; - if (key.scan_code == 0) { /* Some firmware implementations use VT100-style codes against the spec. @@ -139,9 +125,100 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) else if (key.scan_code < ARRAY_SIZE (efi_codes)) return efi_codes[key.scan_code]; + if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f + || key.unicode_char == '\t' || key.unicode_char == '\b' + || key.unicode_char == '\n' || key.unicode_char == '\r') + return key.unicode_char; + return GRUB_TERM_NO_KEY; } +static int +grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused))) +{ + grub_efi_simple_input_interface_t *i; + grub_efi_input_key_t key; + grub_efi_status_t status; + + i = grub_efi_system_table->con_in; + status = efi_call_2 (i->read_key_stroke, i, &key); + + if (status != GRUB_EFI_SUCCESS) + return GRUB_TERM_NO_KEY; + + return grub_efi_translate_key(key); +} + +static int +grub_console_getkey_ex(struct grub_term_input *term) +{ + grub_efi_key_data_t key_data; + grub_efi_status_t status; + grub_efi_uint32_t kss; + int key = -1; + + grub_efi_simple_text_input_ex_interface_t *text_input = term->data; + + status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); + + if (status != GRUB_EFI_SUCCESS) + return GRUB_TERM_NO_KEY; + + kss = key_data.key_state.key_shift_state; + key = grub_efi_translate_key(key_data.key); + + if (key == GRUB_TERM_NO_KEY) + return GRUB_TERM_NO_KEY; + + if (kss & GRUB_EFI_SHIFT_STATE_VALID) + { + if ((kss & GRUB_EFI_LEFT_SHIFT_PRESSED + || kss & GRUB_EFI_RIGHT_SHIFT_PRESSED) + && (key & GRUB_TERM_EXTENDED)) + key |= GRUB_TERM_SHIFT; + if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED) + key |= GRUB_TERM_ALT; + if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED + || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED) + key |= GRUB_TERM_CTRL; + } + + return key; +} + +static grub_err_t +grub_efi_console_input_init (struct grub_term_input *term) +{ + grub_efi_guid_t text_input_ex_guid = + GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; + + if (grub_efi_is_finished) + return 0; + + grub_efi_simple_text_input_ex_interface_t *text_input = term->data; + if (text_input) + return 0; + + text_input = grub_efi_open_protocol(grub_efi_system_table->console_in_handler, + &text_input_ex_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + term->data = (void *)text_input; + + return 0; +} + +static int +grub_console_getkey (struct grub_term_input *term) +{ + if (grub_efi_is_finished) + return 0; + + if (term->data) + return grub_console_getkey_ex(term); + else + return grub_console_getkey_con(term); +} + static struct grub_term_coordinate grub_console_getwh (struct grub_term_output *term __attribute__ ((unused))) { @@ -243,7 +320,7 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), } static grub_err_t -grub_efi_console_init (struct grub_term_output *term) +grub_efi_console_output_init (struct grub_term_output *term) { grub_efi_set_text_mode (1); grub_console_setcursor (term, 1); @@ -251,7 +328,7 @@ grub_efi_console_init (struct grub_term_output *term) } static grub_err_t -grub_efi_console_fini (struct grub_term_output *term) +grub_efi_console_output_fini (struct grub_term_output *term) { grub_console_setcursor (term, 0); grub_efi_set_text_mode (0); @@ -262,13 +339,14 @@ static struct grub_term_input grub_console_term_input = { .name = "console", .getkey = grub_console_getkey, + .init = grub_efi_console_input_init, }; static struct grub_term_output grub_console_term_output = { .name = "console", - .init = grub_efi_console_init, - .fini = grub_efi_console_fini, + .init = grub_efi_console_output_init, + .fini = grub_efi_console_output_fini, .putchar = grub_console_putchar, .getwh = grub_console_getwh, .getxy = grub_console_getxy, @@ -291,8 +369,8 @@ grub_console_init (void) return; } - grub_term_register_input ("console", &grub_console_term_input); grub_term_register_output ("console", &grub_console_term_output); + grub_term_register_input ("console", &grub_console_term_input); } void diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 1a5e38c1e..029ee92f5 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -111,7 +111,7 @@ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ } -#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ +#define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ { 0xdd9e7534, 0x7762, 0x4698, \ { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \ } @@ -952,6 +952,32 @@ struct grub_efi_input_key }; typedef struct grub_efi_input_key grub_efi_input_key_t; +typedef grub_efi_uint8_t grub_efi_key_toggle_state_t; +struct grub_efi_key_state +{ + grub_efi_uint32_t key_shift_state; + grub_efi_key_toggle_state_t key_toggle_state; +}; +typedef struct grub_efi_key_state grub_efi_key_state_t; + +#define GRUB_EFI_SHIFT_STATE_VALID 0x80000000 +#define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001 +#define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002 +#define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004 +#define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008 +#define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010 +#define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020 +#define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040 +#define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080 +#define GRUB_EFI_MENU_KEY_PRESSED 0x00000100 +#define GRUB_EFI_SYS_REQ_PRESSED 0x00000200 + +#define GRUB_EFI_TOGGLE_STATE_VALID 0x80 +#define GRUB_EFI_KEY_STATE_EXPOSED 0x40 +#define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01 +#define GRUB_EFI_NUM_LOCK_ACTIVE 0x02 +#define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04 + struct grub_efi_simple_text_output_mode { grub_efi_int32_t max_mode; @@ -1294,6 +1320,43 @@ struct grub_efi_simple_input_interface }; typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t; +struct grub_efi_key_data { + grub_efi_input_key_t key; + grub_efi_key_state_t key_state; +}; +typedef struct grub_efi_key_data grub_efi_key_data_t; + +typedef grub_efi_status_t (*grub_efi_key_notify_function_t) ( + grub_efi_key_data_t *key_data + ); + +struct grub_efi_simple_text_input_ex_interface +{ + grub_efi_status_t + (*reset) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_boolean_t extended_verification); + + grub_efi_status_t + (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_data_t *key_data); + + grub_efi_event_t wait_for_key; + + grub_efi_status_t + (*set_state) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_toggle_state_t *key_toggle_state); + + grub_efi_status_t + (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_data_t *key_data, + grub_efi_key_notify_function_t key_notification_function); + + grub_efi_status_t + (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this, + void *notification_handle); +}; +typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t; + struct grub_efi_simple_text_output_interface { grub_efi_status_t From bf3df4070f4c0530366e9d6f518785f57c5df8b3 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Mon, 26 Oct 2015 22:07:26 +0100 Subject: [PATCH 0346/1167] Implement cross-endian ELF load for powerpc --- grub-core/kern/elf.c | 56 ++++++++++++++++++++++++++++++++++++++++-- grub-core/kern/elfXX.c | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 5f99c43cc..00de36984 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -28,6 +28,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) +#define GRUB_ELF_ENABLE_BI_ENDIAN 1 +#else +#define GRUB_ELF_ENABLE_BI_ENDIAN 0 +#endif + +#if defined(GRUB_CPU_WORDS_BIGENDIAN) +#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2MSB +#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2LSB +#else +#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2LSB +#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2MSB +#endif + +static int grub_elf32_check_endianess_and_bswap_ehdr (grub_elf_t elf); +static int grub_elf64_check_endianess_and_bswap_ehdr (grub_elf_t elf); + /* Check if EHDR is a valid ELF header. */ static grub_err_t grub_elf_check_header (grub_elf_t elf) @@ -38,8 +55,25 @@ grub_elf_check_header (grub_elf_t elf) || e->e_ident[EI_MAG1] != ELFMAG1 || e->e_ident[EI_MAG2] != ELFMAG2 || e->e_ident[EI_MAG3] != ELFMAG3 - || e->e_ident[EI_VERSION] != EV_CURRENT - || e->e_version != EV_CURRENT) + || e->e_ident[EI_VERSION] != EV_CURRENT) + return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic")); + + if (grub_elf_is_elf32 (elf)) + { + if (!grub_elf32_check_endianess_and_bswap_ehdr (elf)) { + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic"); + } + } + else if (grub_elf_is_elf64 (elf)) + { + if (!grub_elf64_check_endianess_and_bswap_ehdr (elf)) { + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic"); + } + } + else + return grub_error (GRUB_ERR_BAD_OS, "unknown ELF class"); + + if (e->e_version != EV_CURRENT) return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic")); return GRUB_ERR_NONE; @@ -117,6 +151,9 @@ grub_elf_open (const char *name) } +#define grub_swap_bytes_halfXX grub_swap_bytes16 +#define grub_swap_bytes_wordXX grub_swap_bytes32 + /* 32-bit */ #define ehdrXX ehdr32 #define ELFCLASSXX ELFCLASS32 @@ -127,7 +164,12 @@ grub_elf_open (const char *name) #define grub_elf_is_elfXX grub_elf_is_elf32 #define grub_elfXX_load_phdrs grub_elf32_load_phdrs #define ElfXX_Phdr Elf32_Phdr +#define ElfXX_Ehdr Elf32_Ehdr #define grub_uintXX_t grub_uint32_t +#define grub_swap_bytes_addrXX grub_swap_bytes32 +#define grub_swap_bytes_offXX grub_swap_bytes32 +#define grub_swap_bytes_XwordXX grub_swap_bytes32 +#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf32_check_endianess_and_bswap_ehdr #include "elfXX.c" @@ -140,7 +182,12 @@ grub_elf_open (const char *name) #undef grub_elf_is_elfXX #undef grub_elfXX_load_phdrs #undef ElfXX_Phdr +#undef ElfXX_Ehdr #undef grub_uintXX_t +#undef grub_swap_bytes_addrXX +#undef grub_swap_bytes_offXX +#undef grub_swap_bytes_XwordXX +#undef grub_elfXX_check_endianess_and_bswap_ehdr /* 64-bit */ @@ -153,6 +200,11 @@ grub_elf_open (const char *name) #define grub_elf_is_elfXX grub_elf_is_elf64 #define grub_elfXX_load_phdrs grub_elf64_load_phdrs #define ElfXX_Phdr Elf64_Phdr +#define ElfXX_Ehdr Elf64_Ehdr #define grub_uintXX_t grub_uint64_t +#define grub_swap_bytes_addrXX grub_swap_bytes64 +#define grub_swap_bytes_offXX grub_swap_bytes64 +#define grub_swap_bytes_XwordXX grub_swap_bytes64 +#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf64_check_endianess_and_bswap_ehdr #include "elfXX.c" diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c index 1d0997186..b91c39d9e 100644 --- a/grub-core/kern/elfXX.c +++ b/grub-core/kern/elfXX.c @@ -31,6 +31,25 @@ grub_elfXX_load_phdrs (grub_elf_t elf) return grub_errno; } +#if GRUB_ELF_ENABLE_BI_ENDIAN + if (elf->ehdr.ehdrXX.e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS) + { + ElfXX_Phdr *phdr; + for (phdr = elf->phdrs; (char *) phdr < (char *) elf->phdrs + phdrs_size; + phdr = (ElfXX_Phdr *) ((char *) phdr + elf->ehdr.ehdrXX.e_phentsize)) + { + phdr->p_type = grub_swap_bytes_wordXX (phdr->p_type); + phdr->p_flags = grub_swap_bytes_wordXX (phdr->p_flags); + phdr->p_offset = grub_swap_bytes_offXX (phdr->p_offset); + phdr->p_vaddr = grub_swap_bytes_addrXX (phdr->p_vaddr); + phdr->p_paddr = grub_swap_bytes_addrXX (phdr->p_paddr); + phdr->p_filesz = grub_swap_bytes_XwordXX (phdr->p_filesz); + phdr->p_memsz = grub_swap_bytes_XwordXX (phdr->p_memsz); + phdr->p_align = grub_swap_bytes_XwordXX (phdr->p_align); + } + } +#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */ + return GRUB_ERR_NONE; } @@ -154,3 +173,35 @@ grub_elfXX_load (grub_elf_t elf, const char *filename, return grub_errno; } + +static int +grub_elfXX_check_endianess_and_bswap_ehdr (grub_elf_t elf) +{ + ElfXX_Ehdr *e = &(elf->ehdr.ehdrXX); + if (e->e_ident[EI_DATA] == GRUB_ELF_NATIVE_ENDIANNESS) + { + return 1; + } + +#if GRUB_ELF_ENABLE_BI_ENDIAN + if (e->e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS) + { + e->e_type = grub_swap_bytes_halfXX (e->e_type); + e->e_machine = grub_swap_bytes_halfXX (e->e_machine); + e->e_version = grub_swap_bytes_wordXX (e->e_version); + e->e_entry = grub_swap_bytes_addrXX (e->e_entry); + e->e_phoff = grub_swap_bytes_offXX (e->e_phoff); + e->e_shoff = grub_swap_bytes_offXX (e->e_shoff); + e->e_flags = grub_swap_bytes_wordXX (e->e_flags); + e->e_ehsize = grub_swap_bytes_halfXX (e->e_ehsize); + e->e_phentsize = grub_swap_bytes_halfXX (e->e_phentsize); + e->e_phnum = grub_swap_bytes_halfXX (e->e_phnum); + e->e_shentsize = grub_swap_bytes_halfXX (e->e_shentsize); + e->e_shnum = grub_swap_bytes_halfXX (e->e_shnum); + e->e_shstrndx = grub_swap_bytes_halfXX (e->e_shstrndx); + return 1; + } +#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */ + + return 0; +} From 0b72543afdfee193597911c8a427f88adacb3fbe Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Oct 2015 23:03:06 +0100 Subject: [PATCH 0347/1167] ofdisk: Fix devpath freeing logic. --- grub-core/disk/ieee1275/ofdisk.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 331769b12..297f058ee 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -422,16 +422,20 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) op = ofdisk_hash_find (devpath); if (!op) op = ofdisk_hash_add (devpath, NULL); - else - grub_free (devpath); if (!op) - return grub_errno; + { + grub_free (devpath); + return grub_errno; + } disk->id = (unsigned long) op; disk->data = op->open_path; err = grub_ofdisk_get_block_size (devpath, &block_size, op); if (err) - return err; + { + grub_free (devpath); + return err; + } if (block_size != 0) { for (disk->log_sector_size = 0; @@ -442,6 +446,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) disk->log_sector_size = 9; } + grub_free (devpath); return 0; } From 5fcde03bf1e8cf74c186bcef6d705734f2d002c5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Oct 2015 23:30:54 +0300 Subject: [PATCH 0348/1167] efi: fix warnings with recent GCC ../../grub-core/term/efi/console.c:128:32: error: suggest parentheses around '&&' within '||' [-Werror=parentheses] if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f --- grub-core/term/efi/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 8b2096f19..7d31095b1 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -125,7 +125,7 @@ grub_efi_translate_key (grub_efi_input_key_t key) else if (key.scan_code < ARRAY_SIZE (efi_codes)) return efi_codes[key.scan_code]; - if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f + if ((key.unicode_char >= 0x20 && key.unicode_char <= 0x7f) || key.unicode_char == '\t' || key.unicode_char == '\b' || key.unicode_char == '\n' || key.unicode_char == '\r') return key.unicode_char; From 4d0cb755387d6f109b901386ed4d3d475df239fe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 29 Oct 2015 13:31:30 +0100 Subject: [PATCH 0349/1167] arm64: Move FDT functions to separate module --- grub-core/Makefile.core.def | 6 ++ grub-core/loader/arm64/fdt.c | 185 +++++++++++++++++++++++++++++++++ grub-core/loader/arm64/linux.c | 170 ++++-------------------------- include/grub/arm64/fdtload.h | 35 +++++++ include/grub/arm64/linux.h | 4 - 5 files changed, 244 insertions(+), 156 deletions(-) create mode 100644 grub-core/loader/arm64/fdt.c create mode 100644 include/grub/arm64/fdtload.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index abf5ac1bf..19ed47362 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1664,6 +1664,12 @@ module = { enable = noemu; }; +module = { + name = fdt; + arm64 = loader/arm64/fdt.c; + enable = arm64; +}; + module = { name = xnu; x86 = loader/xnu_resume.c; diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c new file mode 100644 index 000000000..5202c14e0 --- /dev/null +++ b/grub-core/loader/arm64/fdt.c @@ -0,0 +1,185 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013-2015 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void *loaded_fdt; +static void *fdt; + +static void * +get_firmware_fdt (void) +{ + grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + void *firmware_fdt = NULL; + unsigned int i; + + /* Look for FDT in UEFI config tables. */ + tables = grub_efi_system_table->configuration_table; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) + { + firmware_fdt = tables[i].vendor_table; + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); + break; + } + + return firmware_fdt; +} + +void * +grub_fdt_load (grub_size_t additional_size) +{ + void *raw_fdt; + grub_size_t size; + + if (fdt) + { + size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); + grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); + } + + if (loaded_fdt) + raw_fdt = loaded_fdt; + else + raw_fdt = get_firmware_fdt(); + + size = + raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; + size += additional_size; + + grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); + fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); + if (!fdt) + return NULL; + + if (raw_fdt) + { + grub_memmove (fdt, raw_fdt, size); + grub_fdt_set_totalsize (fdt, size); + } + else + { + grub_fdt_create_empty_tree (fdt, size); + } + return fdt; +} + +grub_err_t +grub_fdt_install (void) +{ + grub_efi_boot_services_t *b; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, fdt); + if (status != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_IO, "failed to install FDT"); + + grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n", + fdt); + return GRUB_ERR_NONE; +} + +void +grub_fdt_unload (void) { + if (!fdt) { + return; + } + grub_efi_free_pages ((grub_efi_physical_address_t) fdt, + GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); + fdt = NULL; +} + +static grub_err_t +grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + grub_file_t dtb; + void *blob = NULL; + int size; + + if (loaded_fdt) + grub_free (loaded_fdt); + loaded_fdt = NULL; + + /* No arguments means "use firmware FDT". */ + if (argc == 0) + { + return GRUB_ERR_NONE; + } + + dtb = grub_file_open (argv[0]); + if (!dtb) + goto out; + + size = grub_file_size (dtb); + blob = grub_malloc (size); + if (!blob) + goto out; + + if (grub_file_read (dtb, blob, size) < size) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); + goto out; + } + + if (grub_fdt_check_header (blob, size) != 0) + { + grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); + goto out; + } + +out: + if (dtb) + grub_file_close (dtb); + + if (blob) + { + if (grub_errno == GRUB_ERR_NONE) + loaded_fdt = blob; + else + grub_free (blob); + } + + return grub_errno; +} + +static grub_command_t cmd_devicetree; + +GRUB_MOD_INIT (fdt) +{ + cmd_devicetree = + grub_register_command ("devicetree", grub_cmd_devicetree, 0, + N_("Load DTB file.")); +} + +GRUB_MOD_FINI (fdt) +{ + grub_unregister_command (cmd_devicetree); +} diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 987f5b9ee..9519d2e4d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -45,69 +46,6 @@ static grub_uint32_t cmdline_size; static grub_addr_t initrd_start; static grub_addr_t initrd_end; -static void *loaded_fdt; -static void *fdt; - -static void * -get_firmware_fdt (void) -{ - grub_efi_configuration_table_t *tables; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - void *firmware_fdt = NULL; - unsigned int i; - - /* Look for FDT in UEFI config tables. */ - tables = grub_efi_system_table->configuration_table; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) - { - firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); - break; - } - - return firmware_fdt; -} - -void * -grub_linux_get_fdt (void) -{ - void *raw_fdt; - grub_size_t size; - - if (fdt) - { - size = BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); - } - - if (loaded_fdt) - raw_fdt = loaded_fdt; - else - raw_fdt = get_firmware_fdt(); - - size = - raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; - size += 0x400; - - grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); - fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size)); - if (!fdt) - return NULL; - - if (raw_fdt) - { - grub_memmove (fdt, raw_fdt, size); - grub_fdt_set_totalsize (fdt, size); - } - else - { - grub_fdt_create_empty_tree (fdt, size); - } - return fdt; -} - grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) { @@ -129,12 +67,13 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) static grub_err_t finalize_params_linux (void) { - grub_efi_boot_services_t *b; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - grub_efi_status_t status; int node, retval; - if (!grub_linux_get_fdt ()) + void *fdt; + + fdt = grub_fdt_load (0x400); + + if (!fdt) goto failure; node = grub_fdt_find_subnode (fdt, 0, "chosen"); @@ -160,82 +99,16 @@ finalize_params_linux (void) goto failure; } - b = grub_efi_system_table->boot_services; - status = b->install_configuration_table (&fdt_guid, fdt); - if (status != GRUB_EFI_SUCCESS) + if (grub_fdt_install() != GRUB_ERR_NONE) goto failure; - grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", - fdt); - return GRUB_ERR_NONE; failure: - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, - BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); - fdt = NULL; + grub_fdt_unload(); return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); } -static grub_err_t -grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) -{ - grub_file_t dtb; - void *blob = NULL; - int size; - - if (!loaded) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("you need to load the kernel first")); - return GRUB_ERR_BAD_OS; - } - - if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - - if (loaded_fdt) - grub_free (loaded_fdt); - loaded_fdt = NULL; - - dtb = grub_file_open (argv[0]); - if (!dtb) - goto out; - - size = grub_file_size (dtb); - blob = grub_malloc (size); - if (!blob) - goto out; - - if (grub_file_read (dtb, blob, size) < size) - { - if (!grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); - goto out; - } - - if (grub_fdt_check_header (blob, size) != 0) - { - grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); - goto out; - } - -out: - if (dtb) - grub_file_close (dtb); - - if (blob) - { - if (grub_errno == GRUB_ERR_NONE) - loaded_fdt = blob; - else - grub_free (blob); - } - - return grub_errno; -} - grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) { @@ -276,7 +149,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = grub_efi_allocate_pages (0, - BYTES_TO_PAGES (loaded_image->load_options_size)); + GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); if (!loaded_image->load_options) return grub_errno; @@ -290,7 +163,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) /* When successful, not reached */ b->unload_image (image_handle); grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, - BYTES_TO_PAGES (loaded_image->load_options_size)); + GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); return grub_errno; } @@ -312,16 +185,13 @@ grub_linux_unload (void) loaded = 0; if (initrd_start) grub_efi_free_pages ((grub_efi_physical_address_t) initrd_start, - BYTES_TO_PAGES (initrd_end - initrd_start)); + GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start)); initrd_start = initrd_end = 0; grub_free (linux_args); if (kernel_addr) grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, - BYTES_TO_PAGES (kernel_size)); - if (fdt) - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, - BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); - + GRUB_EFI_BYTES_TO_PAGES (kernel_size)); + grub_fdt_unload (); return GRUB_ERR_NONE; } @@ -352,7 +222,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), initrd_size = grub_get_initrd_size (&initrd_ctx); grub_dprintf ("linux", "Loading initrd\n"); - initrd_pages = (BYTES_TO_PAGES (initrd_size)); + initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); initrd_mem = grub_efi_allocate_pages (0, initrd_pages); if (!initrd_mem) { @@ -407,9 +277,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset(); grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size); - kernel_addr = grub_efi_allocate_pages (0, BYTES_TO_PAGES (kernel_size)); + kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_dprintf ("linux", "kernel numpages: %lld\n", - (long long) BYTES_TO_PAGES (kernel_size)); + (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size)); if (!kernel_addr) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); @@ -460,13 +330,13 @@ fail: if (kernel_addr && !loaded) grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, - BYTES_TO_PAGES (kernel_size)); + GRUB_EFI_BYTES_TO_PAGES (kernel_size)); return grub_errno; } -static grub_command_t cmd_linux, cmd_initrd, cmd_devicetree; +static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT (linux) { @@ -474,9 +344,6 @@ GRUB_MOD_INIT (linux) N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, N_("Load initrd.")); - cmd_devicetree = - grub_register_command ("devicetree", grub_cmd_devicetree, 0, - N_("Load DTB file.")); my_mod = mod; } @@ -484,5 +351,4 @@ GRUB_MOD_FINI (linux) { grub_unregister_command (cmd_linux); grub_unregister_command (cmd_initrd); - grub_unregister_command (cmd_devicetree); } diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h new file mode 100644 index 000000000..7b9ddba91 --- /dev/null +++ b/include/grub/arm64/fdtload.h @@ -0,0 +1,35 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013-2015 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 . + */ + +#ifndef GRUB_FDTLOAD_CPU_HEADER +#define GRUB_FDTLOAD_CPU_HEADER 1 + +#include +#include + +void * +grub_fdt_load (grub_size_t additional_size); +void +grub_fdt_unload (void); +grub_err_t +grub_fdt_install (void); + +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + +#endif diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 65796d907..1ea23696e 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,8 +23,6 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ -#define GRUB_EFI_PAGE_SHIFT 12 -#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) #define GRUB_EFI_PE_MAGIC 0x5A4D /* From linux/Documentation/arm64/booting.txt */ @@ -42,8 +40,6 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -/* Declare the functions for getting dtb and checking/booting image */ -void *grub_linux_get_fdt (void); grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header *lh); grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, From 83cb45e98261a2159e20a430f761c533b1cf3b05 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 29 Oct 2015 15:24:20 +0100 Subject: [PATCH 0350/1167] arm64: Add support for xen boot protocol. --- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 596 ++++++++++++++++++++++++++++++ 2 files changed, 603 insertions(+) create mode 100644 grub-core/loader/arm64/xen_boot.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 19ed47362..2ef10d1af 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1646,6 +1646,13 @@ module = { enable = x86; }; +module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + module = { name = linux; x86 = loader/i386/linux.c; diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c new file mode 100644 index 000000000..fc5bb0c86 --- /dev/null +++ b/grub-core/loader/arm64/xen_boot.c @@ -0,0 +1,596 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2014 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* required by struct xen_hypervisor_header */ +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" +#define MODULE_CUSTOM_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 + * https://www.power.org/documentation/epapr-version-1-1/ + * 2.2.1.1 Node Name Requirements + * node-name@unit-address + * 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 + */ +#define FDT_NODE_NAME_MAX_SIZE (49) + +struct compat_string_struct +{ + grub_size_t size; + const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t; +#define FDT_COMPATIBLE(x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ + MODULE_IMAGE, + MODULE_INITRD, + MODULE_XSM, + MODULE_CUSTOM +}; +typedef enum module_type module_type_t; + +struct fdt_node_info +{ + module_type_t type; + + const char *compat_string; + grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ + struct grub_arm64_linux_kernel_header efi_head; + + /* This is always PE\0\0. */ + grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; + /* The COFF file header. */ + struct grub_pe32_coff_header coff_header; + /* The Optional header. */ + struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ + struct xen_boot_binary *next; + struct xen_boot_binary **prev; + const char *name; + + grub_addr_t start; + grub_size_t size; + grub_size_t align; + + char *cmdline; + int cmdline_size; + + struct fdt_node_info node_info; +}; + +static grub_dl_t my_mod; + +static int loaded; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { + MODULE_IMAGE_MIN_ALIGN, + MODULE_INITRD_MIN_ALIGN, + MODULE_XSM_MIN_ALIGN, + MODULE_CUSTOM_MIN_ALIGN +}; + +static const compat_string_struct_t default_compat_string[] = { + FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE), + FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE), + FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE), + FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE) +}; + +static __inline grub_addr_t +xen_boot_address_align (grub_addr_t start, grub_size_t align) +{ + return (align ? (ALIGN_UP (start, align)) : start); +} + +/* Parse the option of xen_module command. For now, we support + (1) --type + We also set up the type of module in this function. + If there are some "--type" options in the command line, + we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (grub_command_t cmd, struct xen_boot_binary *module, int *file_name_index) +{ + *file_name_index = 0; + + if (!grub_strcmp (cmd->name, "xen_linux")) + module->node_info.type = MODULE_IMAGE; + else if (!grub_strcmp (cmd->name, "xen_initrd")) + module->node_info.type = MODULE_INITRD; + else if (!grub_strcmp (cmd->name, "xen_xsm")) + module->node_info.type = MODULE_XSM; + + return GRUB_ERR_NONE; +} + +static grub_err_t +prepare_xen_hypervisor_params (void *xen_boot_fdt) +{ + int chosen_node = 0; + int retval; + + chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 0) + chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 1) + return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); + + grub_dprintf ("xen_loader", + "Xen Hypervisor cmdline : %s @ %p size:%d\n", + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + + retval = grub_fdt_set_prop (xen_boot_fdt, chosen_node, "bootargs", + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to install/update FDT"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) +{ + int retval, chosen_node = 0, module_node = 0; + char module_name[FDT_NODE_NAME_MAX_SIZE]; + + retval = grub_snprintf (module_name, FDT_NODE_NAME_MAX_SIZE, "module@%lx", + xen_boot_address_align (module->start, + module->align)); + grub_dprintf ("xen_loader", "Module node name %s \n", module_name); + + if (retval < (int) sizeof ("module@")) + return grub_error (GRUB_ERR_IO, N_("failed to get FDT")); + + chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 0) + chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 1) + return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); + + module_node = + grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); + if (module_node < 0) + module_node = + grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", + module->node_info.compat_string, + (grub_uint32_t) module-> + node_info.compat_string_size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + + grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n", + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node, + xen_boot_address_align (module->start, + module->align), + module->size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + + if (module->cmdline && module->cmdline_size > 0) + { + grub_dprintf ("xen_loader", + "Module %s cmdline : %s @ %p size:%d\n", module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs", + module->cmdline, module->cmdline_size + 1); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + } + else + { + grub_dprintf ("xen_loader", "Module %s has not bootargs!\n", + module->name); + } + + return GRUB_ERR_NONE; +} + +static grub_err_t +finalize_params_xen_boot (void) +{ + struct xen_boot_binary *module; + void *xen_boot_fdt; + grub_size_t additional_size = 0x1000; + + /* Hypervisor. */ + additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size; + FOR_LIST_ELEMENTS (module, module_head) + { + additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module-> + node_info.compat_string_size + module->cmdline_size; + } + + xen_boot_fdt = grub_fdt_load (additional_size); + if (!xen_boot_fdt) + return grub_error (GRUB_ERR_IO, "failed to get FDT"); + + if (xen_hypervisor) + { + if (prepare_xen_hypervisor_params (xen_boot_fdt) != GRUB_ERR_NONE) + goto fail; + } + else + { + grub_dprintf ("xen_loader", "Failed to get Xen Hypervisor info!\n"); + goto fail; + } + + /* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { + if (module->start && module->size > 0) + { + grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n", + module->name, + xen_boot_address_align (module->start, module->align), + module->size); + if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE) + goto fail; + } + else + { + grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name); + goto fail; + } + } + + if (grub_fdt_install() == GRUB_ERR_NONE) + return GRUB_ERR_NONE; + +fail: + grub_fdt_unload (); + + return grub_error (GRUB_ERR_IO, "failed to install/update FDT"); +} + + +static grub_err_t +xen_boot (void) +{ + grub_err_t err = finalize_params_xen_boot (); + if (err) + return err; + + return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{ + if (!binary) + return; + + if (binary->start && binary->size > 0) + { + grub_efi_free_pages ((grub_efi_physical_address_t) binary->start, + GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + } + + if (binary->cmdline && binary->cmdline_size > 0) + { + grub_free (binary->cmdline); + grub_dprintf ("xen_loader", + "Module %s cmdline memory free @ %p size: %d\n", + binary->name, binary->cmdline, binary->cmdline_size); + } + + if (binary->node_info.type == MODULE_CUSTOM) + grub_free ((void *) binary->node_info.compat_string); + + if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME)) + grub_list_remove (GRUB_AS_LIST (binary)); + + grub_dprintf ("xen_loader", + "Module %s struct memory free @ %p size: 0x%lx\n", + binary->name, binary, sizeof (binary)); + grub_free (binary); + + return; +} + +static void +all_binaries_unload (void) +{ + struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { + single_binary_unload (binary); + } + + if (xen_hypervisor) + single_binary_unload (xen_hypervisor); + + return; +} + +static grub_err_t +xen_unload (void) +{ + loaded = 0; + all_binaries_unload (); + grub_fdt_unload (); + grub_dl_unref (my_mod); + + return GRUB_ERR_NONE; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, + int argc, char *argv[]) +{ + binary->size = grub_file_size (file); + grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", + binary->name, binary->size); + + binary->start + = (grub_addr_t) grub_efi_allocate_pages (0, + GRUB_EFI_BYTES_TO_PAGES + (binary->size + + binary->align)); + if (!binary->start) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return; + } + + grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", + binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + + if (grub_file_read (file, (void *) xen_boot_address_align (binary->start, + binary->align), + binary->size) != (grub_ssize_t) binary->size) + { + single_binary_unload (binary); + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); + return; + } + + if (argc > 1) + { + binary->cmdline_size = grub_loader_cmdline_size (argc - 1, argv + 1); + binary->cmdline = grub_zalloc (binary->cmdline_size); + if (!binary->cmdline) + { + single_binary_unload (binary); + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return; + } + grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, + binary->cmdline_size); + grub_dprintf ("xen_loader", + "Xen_boot %s cmdline @ %p %s, size: %d\n", binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } + else + { + binary->cmdline_size = 0; + binary->cmdline = NULL; + } + + grub_errno = GRUB_ERR_NONE; + return; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) +{ + + struct xen_boot_binary *module = NULL; + int file_name_index = 0; + grub_file_t file = 0; + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + if (!loaded) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the Xen Hypervisor first")); + goto fail; + } + + module = + (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary)); + if (!module) + return grub_errno; + + /* process all the options and get module type */ + if (set_module_type (cmd, module, &file_name_index) != + GRUB_ERR_NONE) + goto fail; + switch (module->node_info.type) + { + case MODULE_IMAGE: + case MODULE_INITRD: + case MODULE_XSM: + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; + break; + + case MODULE_CUSTOM: + /* we have set the node_info in set_module_type */ + break; + + default: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + + grub_dprintf ("xen_loader", "Init %s module and node info:\n" + "compatible %s\ncompat_string_size 0x%lx\n", + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file = grub_file_open (argv[file_name_index]); + if (!file) + goto fail; + + xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); + if (grub_errno == GRUB_ERR_NONE) + grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); + +fail: + if (file) + grub_file_close (file); + if (grub_errno != GRUB_ERR_NONE) + single_binary_unload (module); + + return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + struct xen_hypervisor_header sh; + grub_file_t file = NULL; + + grub_dl_ref (my_mod); + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + file = grub_file_open (argv[0]); + if (!file) + goto fail; + + if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) + goto fail; + if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) + goto fail; + grub_file_seek (file, 0); + + /* if another module has called grub_loader_set, + we need to make sure that another module is unloaded properly */ + grub_loader_unset (); + + xen_hypervisor = + (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary)); + if (!xen_hypervisor) + return grub_errno; + + xen_hypervisor->name = XEN_HYPERVISOR_NAME; + xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment; + + xen_boot_binary_load (xen_hypervisor, file, argc, argv); + if (grub_errno == GRUB_ERR_NONE) + { + grub_loader_set (xen_boot, xen_unload, 0); + loaded = 1; + } + +fail: + if (file) + grub_file_close (file); + if (grub_errno != GRUB_ERR_NONE) + { + loaded = 0; + all_binaries_unload (); + grub_dl_unref (my_mod); + } + + return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor; +static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; + +GRUB_MOD_INIT (xen_boot) +{ + cmd_xen_hypervisor = + grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0, + N_("Load a xen hypervisor.")); + cmd_xen_linux = + grub_register_command ("xen_linux", grub_cmd_xen_module, 0, + N_("Load a xen linux kernel for dom0.")); + cmd_xen_initrd = + grub_register_command ("xen_initrd", grub_cmd_xen_module, 0, + N_("Load a xen initrd for dom0.")); + cmd_xen_xsm = + grub_register_command ("xen_xsm", grub_cmd_xen_module, 0, + N_("Load a xen security module.")); + my_mod = mod; +} + +GRUB_MOD_FINI (xen_boot) +{ + grub_unregister_command (cmd_xen_hypervisor); + grub_unregister_command (cmd_xen_linux); + grub_unregister_command (cmd_xen_initrd); + grub_unregister_command (cmd_xen_xsm); +} From 43c83102440f193847005598c6f51b6c95642a90 Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Thu, 29 Oct 2015 16:30:28 +0100 Subject: [PATCH 0351/1167] tcp: Fix uninited mac address when accepting connection. --- grub-core/net/tcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 1d90f1ec5..9e81a0a85 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -498,11 +498,22 @@ grub_net_tcp_accept (grub_net_tcp_socket_t sock, struct grub_net_buff *nb_ack; struct tcphdr *tcph; grub_err_t err; + grub_net_network_level_address_t gateway; + struct grub_net_network_level_interface *inf; sock->recv_hook = recv_hook; sock->error_hook = error_hook; sock->fin_hook = fin_hook; sock->hook_data = hook_data; + + err = grub_net_route_address (sock->out_nla, &gateway, &inf); + if (err) + return err; + + err = grub_net_link_layer_resolve (sock->inf, &gateway, &(sock->ll_target_addr)); + if (err) + return err; + nb_ack = grub_netbuff_alloc (sizeof (*tcph) + GRUB_NET_OUR_MAX_IP_HEADER_SIZE + GRUB_NET_MAX_LINK_HEADER_SIZE); From 33b1103e303a6112315257ddad9d771088ba813f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 29 Oct 2015 21:29:12 +0300 Subject: [PATCH 0352/1167] NEWS: mention powerpc64le support --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 4abd873de..2db2f87a9 100644 --- a/NEWS +++ b/NEWS @@ -88,6 +88,7 @@ New in 2.02: * Support *-emu on Windows. * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. + * Support for booting little-endian Linux kernel on powerpc. * Security: * Add optional facility to enforce that all files read by the core image @@ -150,6 +151,7 @@ New in 2.02: directly. This removes requirement for target-specific runtime on build system. * emu libusb support removed (was broken and unmaintained). + * powerpc64le compile support. * Revision control moved to git. From 5b7b4d97812e9f539265f3f98bf5cfb83dfeb3d0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Nov 2015 04:31:23 +0100 Subject: [PATCH 0353/1167] README: Remove dead link to the wiki --- README | 2 -- 1 file changed, 2 deletions(-) diff --git a/README b/README index b30a4b68b..685b01657 100644 --- a/README +++ b/README @@ -12,8 +12,6 @@ The URL is . More extensive documentation is available in the Info manual, accessible using 'info grub' after building and installing GRUB 2. -Please look at the GRUB Wiki for testing -procedures. There are a number of important user-visible differences from the first version of GRUB, now known as GRUB Legacy. For a summary, please From cd6d79cda2487b3cc1a2955116a65746b669878b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Nov 2015 04:32:34 +0100 Subject: [PATCH 0354/1167] configure.ac: Explicitly add -mno-sse3 on x86. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 21691c15c..9e8a606a6 100644 --- a/configure.ac +++ b/configure.ac @@ -783,7 +783,7 @@ fi if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then # Some toolchains enable these features by default, but they need # registers that aren't set up properly in GRUB. - TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" + TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" fi # GRUB doesn't use float or doubles at all. Yet some toolchains may decide From 1018e91dce8bd5c60c073c16209b979b033460a7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 6 Nov 2015 21:33:28 +0300 Subject: [PATCH 0355/1167] mkimage: zero fill alignment space This did not cause real problem but is good for reproducible builds. I hit it with recent bootinfoscript that displays embedded config; I was puzzled by random garbage at the end. Prezero memory buffer used to assemble core.img. This makes individual memset redundant. Also ensure buffer is filled with zeroes in several other places. Also remove redundant zeroing code where we fill in the whole memory block anyway. --- util/grub-mkimagexx.c | 3 ++- util/mkimage.c | 30 +++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 3c76d0708..a1ddc6269 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -101,7 +101,7 @@ SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target program_size = ALIGN_ADDR (*core_size); elf_img = xmalloc (program_size + header_size + footer_size); - memset (elf_img, 0, program_size + header_size); + memset (elf_img, 0, program_size + header_size + footer_size); memcpy (elf_img + header_size, *core_img, *core_size); ehdr = (void *) elf_img; phdr = (void *) (elf_img + sizeof (*ehdr)); @@ -1587,6 +1587,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, } out_img = xmalloc (*kernel_sz + total_module_size); + memset (out_img, 0, *kernel_sz + total_module_size); if (image_target->id == IMAGE_EFI) { diff --git a/util/mkimage.c b/util/mkimage.c index 35df99871..dc4046185 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -992,7 +992,7 @@ grub_install_generate_image (const char *dir, const char *prefix, { char *kernel_img, *core_img; size_t kernel_size, total_module_size, core_size, exec_size; - size_t memdisk_size = 0, config_size = 0, config_size_pure = 0; + size_t memdisk_size = 0, config_size = 0; size_t prefix_size = 0; char *kernel_path; size_t offset; @@ -1043,8 +1043,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (config_path) { - config_size_pure = grub_util_get_image_size (config_path) + 1; - config_size = ALIGN_ADDR (config_size_pure); + config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1); grub_util_info ("the size of config file is 0x%" GRUB_HOST_PRIxLONG_LONG, (unsigned long long) config_size); total_module_size += config_size + sizeof (struct grub_module_header); @@ -1080,7 +1079,10 @@ grub_install_generate_image (const char *dir, const char *prefix, = grub_host_to_target32 (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) - memmove (kernel_img + total_module_size, kernel_img, kernel_size); + { + memmove (kernel_img + total_module_size, kernel_img, kernel_size); + memset (kernel_img, 0, total_module_size); + } if (image_target->voidp_sizeof == 8) { @@ -1090,7 +1092,6 @@ grub_install_generate_image (const char *dir, const char *prefix, modinfo = (struct grub_module_info64 *) kernel_img; else modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size); - memset (modinfo, 0, sizeof (struct grub_module_info64)); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64)); modinfo->size = grub_host_to_target_addr (total_module_size); @@ -1107,7 +1108,6 @@ grub_install_generate_image (const char *dir, const char *prefix, modinfo = (struct grub_module_info32 *) kernel_img; else modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size); - memset (modinfo, 0, sizeof (struct grub_module_info32)); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32)); modinfo->size = grub_host_to_target_addr (total_module_size); @@ -1120,17 +1120,14 @@ grub_install_generate_image (const char *dir, const char *prefix, for (p = path_list; p; p = p->next) { struct grub_module_header *header; - size_t mod_size, orig_size; + size_t mod_size; - orig_size = grub_util_get_image_size (p->name); - mod_size = ALIGN_ADDR (orig_size); + mod_size = ALIGN_ADDR (grub_util_get_image_size (p->name)); header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_ELF); header->size = grub_host_to_target32 (mod_size + sizeof (*header)); offset += sizeof (*header); - memset (kernel_img + offset + orig_size, 0, mod_size - orig_size); grub_util_load_image (p->name, kernel_img + offset); offset += mod_size; @@ -1146,7 +1143,6 @@ grub_install_generate_image (const char *dir, const char *prefix, curs = grub_util_get_image_size (pubkey_paths[i]); header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_PUBKEY); header->size = grub_host_to_target32 (curs + sizeof (*header)); offset += sizeof (*header); @@ -1161,7 +1157,6 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK); header->size = grub_host_to_target32 (memdisk_size + sizeof (*header)); offset += sizeof (*header); @@ -1175,13 +1170,11 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG); header->size = grub_host_to_target32 (config_size + sizeof (*header)); offset += sizeof (*header); grub_util_load_image (config_path, kernel_img + offset); - *(kernel_img + offset + config_size_pure - 1) = 0; offset += config_size; } @@ -1190,12 +1183,10 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX); header->size = grub_host_to_target32 (prefix_size + sizeof (*header)); offset += sizeof (*header); - grub_memset (kernel_img + offset, 0, prefix_size); grub_strcpy (kernel_img + offset, prefix); offset += prefix_size; } @@ -1269,15 +1260,11 @@ grub_install_generate_image (const char *dir, const char *prefix, full_size = core_size + decompress_size; full_img = xmalloc (full_size); - memset (full_img, 0, full_size); memcpy (full_img, decompress_img, decompress_size); memcpy (full_img + decompress_size, core_img, core_size); - memset (full_img + decompress_size + core_size, 0, - full_size - (decompress_size + core_size)); - free (core_img); core_img = full_img; core_size = full_size; @@ -1428,6 +1415,7 @@ grub_install_generate_image (const char *dir, const char *prefix, pe_img = xmalloc (reloc_addr + reloc_size); memset (pe_img, 0, header_size); memcpy ((char *) pe_img + header_size, core_img, core_size); + memset ((char *) pe_img + header_size + core_size, 0, reloc_addr - (header_size + core_size)); memcpy ((char *) pe_img + reloc_addr, rel_section, reloc_size); header = pe_img; From 349a381df0ce2e809506f7b166bf952f97407330 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 09:46:46 +0300 Subject: [PATCH 0356/1167] devmapper/getroot: use makedev instead of direct shift Fixes device detection with large number of devices. Reported by Tim Wallberg --- grub-core/osdep/devmapper/getroot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 0a77a04b9..64419f678 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -208,8 +208,7 @@ grub_util_devmapper_part_to_disk (struct stat *st, &major, &minor, 0)) { *is_part = 1; - return grub_find_device ("/dev", - (major << 8) | minor); + return grub_find_device ("/dev", makedev (major, minor)); } *is_part = 0; return xstrdup (path); From c1fbc262032ede5d59d0db8fa7ff24dd1fcd062a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 13:01:23 +0300 Subject: [PATCH 0357/1167] Add comments to code for commit d313218 --- grub-core/kern/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 3367485fb..668f8930b 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -89,6 +89,11 @@ grub_file_open (const char *name) file->device = device; + /* In case of relative pathnames and non-Unix systems (like Windows) + * name of host files may not start with `/'. Blocklists for host files + * are meaningless as well (for a start, host disk does not allow any direct + * access - it is just a marker). So skip host disk in this case. + */ if (device->disk && file_name[0] != '/' #if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU) && grub_strcmp (device->disk->name, "host") From dff8d0e3f59c1f1888527078c3a04f863ce33e64 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 17:02:21 +0300 Subject: [PATCH 0358/1167] unix/getroot: remove unused MAJOR definition We use major() everywhere, these definitions just add to confusion. --- grub-core/osdep/unix/getroot.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 14d483fb1..1079a919d 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -45,12 +45,6 @@ #ifdef __linux__ #include /* ioctl */ #include -#ifndef MAJOR -# ifndef MINORBITS -# define MINORBITS 8 -# endif /* ! MINORBITS */ -# define MAJOR(dev) ((unsigned) ((dev) >> MINORBITS)) -#endif /* ! MAJOR */ #ifndef FLOPPY_MAJOR # define FLOPPY_MAJOR 2 #endif /* ! FLOPPY_MAJOR */ @@ -73,7 +67,6 @@ #include #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# define MAJOR(dev) major(dev) # define FLOPPY_MAJOR 2 #endif @@ -90,7 +83,6 @@ #endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */ #if defined(__NetBSD__) || defined(__OpenBSD__) -# define MAJOR(dev) major(dev) # ifdef HAVE_GETRAWPARTITION # include /* getrawpartition */ # endif /* HAVE_GETRAWPARTITION */ From bcf8c5814d8499bebe913ddc1f9c6a85bc45a02e Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 7 Nov 2015 17:03:38 +0300 Subject: [PATCH 0359/1167] doc: document config_directory and config_file variables --- docs/grub.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index b9f41a73e..db765a3b5 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3038,6 +3038,8 @@ These variables have special meaning to GRUB. * cmdpath:: * color_highlight:: * color_normal:: +* config_directory:: +* config_file:: * debug:: * default:: * fallback:: @@ -3180,6 +3182,22 @@ matching colors of first half. to support whole rgb24 palette but currently there is no compelling reason to go beyond the current 16 colors. + +@node config_directory +@subsection config_directory + +This variable is automatically set by GRUB to the directory part of +current configuration file name (@pxref{config_file}). + + +@node config_file +@subsection config_file + +This variable is automatically set by GRUB to the name of configuration file that is being +processed by commands @command{configfile} (@pxref{configfile}) or @command{normal} +(@pxref{normal}). It is restored to the previous value when command completes. + + @node debug @subsection debug From c7f93a20c47f712d45cd97fdfd43e0715ae855e3 Mon Sep 17 00:00:00 2001 From: "grub-devel@iam.tj" Date: Sat, 7 Nov 2015 18:52:59 +0300 Subject: [PATCH 0360/1167] cryptodisk: teach grub_cryptodisk_insert() about partitions (bug #45889) It is not possible to configure encrypted containers on multiple partitions of the same disk; after the first one all subsequent fail with disk/cryptodisk.c:978: already mounted as crypto0 Store partition offset in cryptomount descriptor to distinguish between them. --- grub-core/disk/cryptodisk.c | 7 ++++++- include/grub/cryptodisk.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 85d68e3b6..1e03a091c 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef GRUB_UTIL #include @@ -718,6 +719,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name, newdev->id = last_cryptodisk_id++; newdev->source_id = source->id; newdev->source_dev_id = source->dev->id; + newdev->partition_start = grub_partition_get_start (source->partition); newdev->next = cryptodisk_list; cryptodisk_list = newdev; @@ -740,7 +742,9 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk) grub_cryptodisk_t dev; for (dev = cryptodisk_list; dev != NULL; dev = dev->next) if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id) - return dev; + if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) || + (!disk->partition && dev->partition_start == 0)) + return dev; return NULL; } @@ -761,6 +765,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, newdev->cheat_fd = GRUB_UTIL_FD_INVALID; newdev->source_id = source->id; newdev->source_dev_id = source->dev->id; + newdev->partition_start = grub_partition_get_start (source->partition); newdev->id = last_cryptodisk_id++; newdev->next = cryptodisk_list; cryptodisk_list = newdev; diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index f2ad2a79a..32f564ae0 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -97,6 +97,7 @@ struct grub_cryptodisk grub_uint8_t rekey_key[64]; grub_uint64_t last_rekey; int rekey_derived_size; + grub_disk_addr_t partition_start; }; typedef struct grub_cryptodisk *grub_cryptodisk_t; From c054020581c3cf998930cc021cd7a569691bcf9f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 23:42:35 +0300 Subject: [PATCH 0361/1167] partmap_test: check that parted is available Skip test if parted is unavailable instead of returning false failure. --- tests/partmap_test.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/partmap_test.in b/tests/partmap_test.in index 7786ccfbc..4230ba228 100644 --- a/tests/partmap_test.in +++ b/tests/partmap_test.in @@ -92,6 +92,12 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk=hd0 ;; esac + +if ! which parted >/dev/null 2>&1; then + echo "parted not installed; cannot test partmap" + exit 77 +fi + imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 From ae66efc63b4ec8d536aaf1da667db71e72f1556b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 18:45:57 +0100 Subject: [PATCH 0362/1167] autogen: Use cp instead of ln -s. libgcrypt-grub shouldn't be modified directly anyway. With this patch tarball without contrib can be unpacked on FAT and stay usable for out-of-tree compile on full POSIX FS (compile on FAT not tested). --- autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 5020456bc..7537561ad 100755 --- a/autogen.sh +++ b/autogen.sh @@ -23,14 +23,14 @@ fi if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then rm -rf grub-core/lib/libgcrypt-grub/mpi/generic fi -ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h +cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c mpih-lshift.c mpih-rshift.c; do if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then rm grub-core/lib/libgcrypt-grub/mpi/"$x" fi - ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x" + cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x" done echo "Generating Automake input..." From 7cc27aeda92846f7c3587f2b465730ccf38c08cb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 18:47:53 +0100 Subject: [PATCH 0363/1167] Makefile.core.def: Break circular dependency on arm64. --- grub-core/Makefile.core.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2ef10d1af..03e04ab39 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1665,7 +1665,6 @@ module = { ia64_efi = loader/ia64/efi/linux.c; arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; - fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c; enable = noemu; @@ -1674,7 +1673,8 @@ module = { module = { name = fdt; arm64 = loader/arm64/fdt.c; - enable = arm64; + common = lib/fdt.c; + enable = fdt; }; module = { From db97faec91e63678cb1e9fa57af18948c33cce38 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:00:27 +0100 Subject: [PATCH 0364/1167] genmoddep.awk: Add a test that we have no circular dependencies --- grub-core/genmoddep.awk | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk index 2f32465c4..bd98d84cd 100644 --- a/grub-core/genmoddep.awk +++ b/grub-core/genmoddep.awk @@ -29,7 +29,7 @@ BEGIN { } } else { - printf "error: %u: unrecognized input format\n", NR; + printf "error: %u: unrecognized input format\n", NR >"/dev/stderr"; error++; } } @@ -39,6 +39,8 @@ END { if (error >= 1) exit 1; + total_depcount = 0 + for (mod in modtab) { # Remove duplications. split(modtab[mod], depmods, " "); @@ -52,14 +54,42 @@ END { uniqmods[depmod] = 1; } modlist = "" + depcount[mod] = 0 for (depmod in uniqmods) { modlist = modlist " " depmod; + inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod + depcount[mod]++ + total_depcount++ } if (mod == "all_video") { continue; } printf "%s:%s\n", mod, modlist; } + + # Check that we have no dependency circles + while (total_depcount != 0) { + something_done = 0 + for (mod in depcount) { + if (depcount[mod] == 0) { + delete depcount[mod] + split(inverse_dependencies[mod], inv_depmods, " "); + for (ctr in inv_depmods) { + depcount[inv_depmods[ctr]]-- + total_depcount-- + } + delete inverse_dependencies[mod] + something_done = 1 + } + } + if (something_done == 0) { + for (mod in depcount) { + circle = circle " " mod + } + printf "error: modules %s form a dependency circle\n", circle >"/dev/stderr"; + exit 1 + } + } modlist = "" while (getline <"video.lst") { modlist = modlist " " $1; From a39137aefeaec4a6510b166d0ac8c1663627bfdb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:23:15 +0100 Subject: [PATCH 0365/1167] Remove reliance C.UTF-8 --- po/Rules-translit | 10 +++--- po/cyrillic.sed | 80 +++++++++++++++++++++++++++++++++++++++++++++-- po/greek.sed | 80 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 161 insertions(+), 9 deletions(-) diff --git a/po/Rules-translit b/po/Rules-translit index 4f9176d30..ab84a5f1f 100644 --- a/po/Rules-translit +++ b/po/Rules-translit @@ -1,16 +1,16 @@ DISTFILES.common.extra4 = hebrew.sed cyrillic.sed greek.sed arabic.sed Rules-translit de@hebrew.po-create: de.po hebrew.sed - LC_ALL=C.UTF-8 $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed + LC_ALL=C $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed en@hebrew.po-create: $(DOMAIN).pot hebrew.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed en@cyrillic.po-create: $(DOMAIN).pot cyrillic.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed en@greek.po-create: $(DOMAIN).pot greek.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed en@arabic.po-create: $(DOMAIN).pot arabic.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed diff --git a/po/cyrillic.sed b/po/cyrillic.sed index 46ddaec6e..ffad0ed8c 100644 --- a/po/cyrillic.sed +++ b/po/cyrillic.sed @@ -10,8 +10,84 @@ /^Content-Transfer-Encoding:/ b /^Plural-Forms:/ b -y,abcdefghijklmnopqrstuvwxyz,абцдефгхийклмнопќрÑтувўѯÑз, -y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,ÐБЦДЕФГХИЙКЛМÐОПЌРСТУВЎѮÐЗ, +s,a,а,g +s,b,б,g +s,c,ц,g +s,d,д,g +s,e,е,g +s,f,Ñ„,g +s,g,г,g +s,h,Ñ…,g +s,i,и,g +s,j,й,g +s,k,к,g +s,l,л,g +s,m,м,g +s,n,н,g +s,o,о,g +s,p,п,g +s,q,Ñœ,g +s,r,Ñ€,g +s,s,Ñ,g +s,t,Ñ‚,g +s,u,у,g +s,v,в,g +s,w,Ñž,g +s,x,ѯ,g +s,y,Ñ,g +s,z,з,g +s,A,Ð,g +s,B,Б,g +s,C,Ц,g +s,D,Д,g +s,E,Е,g +s,F,Ф,g +s,G,Г,g +s,H,Ð¥,g +s,I,И,g +s,J,Й,g +s,K,К,g +s,L,Л,g +s,M,М,g +s,N,Ð,g +s,O,О,g +s,P,П,g +s,Q,ÐŒ,g +s,R,Р,g +s,S,С,g +s,T,Т,g +s,U,У,g +s,V,Ð’,g +s,W,ÐŽ,g +s,X,Ñ®,g +s,Y,Ð,g +s,Z,З,g +s,Ð,Ð,g +s,Б,Б,g +s,Ц,Ц,g +s,Д,Д,g +s,Е,Е,g +s,Ф,Ф,g +s,Г,Г,g +s,Ð¥,Ð¥,g +s,И,И,g +s,Й,Й,g +s,К,К,g +s,Л,Л,g +s,М,М,g +s,Ð,Ð,g +s,О,О,g +s,П,П,g +s,ÐŒ,ÐŒ,g +s,Р,Р,g +s,С,С,g +s,Т,Т,g +s,У,У,g +s,Ð’,Ð’,g +s,ÐŽ,ÐŽ,g +s,Ñ®,Ñ®,g +s,Ð,Ð,g +s,З,З,g s,%\([0-9]*\)Ц,%\1C,g s,%\([0-9]*\)ц,%\1c,g diff --git a/po/greek.sed b/po/greek.sed index 17e4b0468..93556c386 100644 --- a/po/greek.sed +++ b/po/greek.sed @@ -12,8 +12,84 @@ s,%\([0-9]*\)C,%\1#,g -y,abcdefghijklmnopqrstuvwxyz,αϭϲδεφγχιϊκλμνοπϗÏστυβωξϋζ, -y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,ΑϬϲΔΕΦΓΧΙΪΚΛΜÎΟΠÏΡΣΤΥΒΩΞΫΖ, +s,a,α,g +s,b,Ï­,g +s,c,ϲ,g +s,d,δ,g +s,e,ε,g +s,f,φ,g +s,g,γ,g +s,h,χ,g +s,i,ι,g +s,j,ÏŠ,g +s,k,κ,g +s,l,λ,g +s,m,μ,g +s,n,ν,g +s,o,ο,g +s,p,Ï€,g +s,q,Ï—,g +s,r,Ï,g +s,s,σ,g +s,t,Ï„,g +s,u,Ï…,g +s,v,β,g +s,w,ω,g +s,x,ξ,g +s,y,Ï‹,g +s,z,ζ,g +s,A,Α,g +s,B,Ϭ,g +s,C,ϲ,g +s,D,Δ,g +s,E,Ε,g +s,F,Φ,g +s,G,Γ,g +s,H,Χ,g +s,I,Ι,g +s,J,Ϊ,g +s,K,Κ,g +s,L,Λ,g +s,M,Μ,g +s,N,Î,g +s,O,Ο,g +s,P,Π,g +s,Q,Ï,g +s,R,Ρ,g +s,S,Σ,g +s,T,Τ,g +s,U,Î¥,g +s,V,Î’,g +s,W,Ω,g +s,X,Ξ,g +s,Y,Ϋ,g +s,Z,Ζ,g +s,Ð,Ð,g +s,Б,Б,g +s,Ц,Ц,g +s,Д,Д,g +s,Е,Е,g +s,Ф,Ф,g +s,Г,Г,g +s,Ð¥,Ð¥,g +s,И,И,g +s,Й,Й,g +s,К,К,g +s,Л,Л,g +s,М,М,g +s,Ð,Ð,g +s,О,О,g +s,П,П,g +s,ÐŒ,ÐŒ,g +s,Р,Р,g +s,С,С,g +s,Т,Т,g +s,У,У,g +s,Ð’,Ð’,g +s,ÐŽ,ÐŽ,g +s,Ñ®,Ñ®,g +s,Ð,Ð,g +s,З,З,g s,%\([0-9]*\)#,%\1C,g s,%\([0-9]*\)ϲ,%\1c,g From 855fe6869cc4407569513a231f2a01cb8215e77f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:34:30 +0100 Subject: [PATCH 0366/1167] cbfs: Check for ptr range sanity. Triaged by Andrei and enhanced with suggestions by Aaron Durbin Also-By: Andrei Borzenkov --- grub-core/fs/cbfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index a34eb88cb..5fc9c0147 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -344,8 +344,16 @@ init_cbfsdisk (void) ptr = *(grub_uint32_t *) 0xfffffffc; head = (struct cbfs_header *) (grub_addr_t) ptr; + grub_dprintf ("cbfs", "head=%p\n", head); - if (!validate_head (head)) + /* coreboot current supports only ROMs <= 16 MiB. Bigger ROMs will + have problems as RCBA is 18 MiB below end of 32-bit typically, + so either memory map would have to be rearranged or we'd need to support + reading ROMs through controller directly. + */ + if (ptr < 0xff000000 + || 0xffffffff - ptr < sizeof (*head) + 0x10 + || !validate_head (head)) return; cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize), From e07badcc31babb24ace4f96444bc484502427d3a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 21:23:52 +0100 Subject: [PATCH 0367/1167] Import xen headers directly into GRUB --- include/xen/arch-x86/xen-x86_32.h | 171 ++++++ include/xen/arch-x86/xen-x86_64.h | 202 +++++++ include/xen/arch-x86/xen.h | 273 +++++++++ include/xen/event_channel.h | 381 +++++++++++++ include/xen/grant_table.h | 662 ++++++++++++++++++++++ include/xen/io/blkif.h | 608 ++++++++++++++++++++ include/xen/io/console.h | 51 ++ include/xen/io/protocols.h | 40 ++ include/xen/io/ring.h | 312 +++++++++++ include/xen/io/xenbus.h | 80 +++ include/xen/io/xs_wire.h | 138 +++++ include/xen/sched.h | 174 ++++++ include/xen/xen-compat.h | 44 ++ include/xen/xen.h | 899 ++++++++++++++++++++++++++++++ 14 files changed, 4035 insertions(+) create mode 100644 include/xen/arch-x86/xen-x86_32.h create mode 100644 include/xen/arch-x86/xen-x86_64.h create mode 100644 include/xen/arch-x86/xen.h create mode 100644 include/xen/event_channel.h create mode 100644 include/xen/grant_table.h create mode 100644 include/xen/io/blkif.h create mode 100644 include/xen/io/console.h create mode 100644 include/xen/io/protocols.h create mode 100644 include/xen/io/ring.h create mode 100644 include/xen/io/xenbus.h create mode 100644 include/xen/io/xs_wire.h create mode 100644 include/xen/sched.h create mode 100644 include/xen/xen-compat.h create mode 100644 include/xen/xen.h diff --git a/include/xen/arch-x86/xen-x86_32.h b/include/xen/arch-x86/xen-x86_32.h new file mode 100644 index 000000000..15041911e --- /dev/null +++ b/include/xen/arch-x86/xen-x86_32.h @@ -0,0 +1,171 @@ +/****************************************************************************** + * xen-x86_32.h + * + * Guest OS interface to x86 32-bit Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2007, K A Fraser + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ + +/* + * Hypercall interface: + * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6) + * Output: %eax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx) + */ + +/* + * These flat segments are in the Xen-private section of every GDT. Since these + * are also present in the initial GDT, many OSes will be able to avoid + * installing their own GDT. + */ +#define FLAT_RING1_CS 0xe019 /* GDT index 259 */ +#define FLAT_RING1_DS 0xe021 /* GDT index 260 */ +#define FLAT_RING1_SS 0xe021 /* GDT index 260 */ +#define FLAT_RING3_CS 0xe02b /* GDT index 261 */ +#define FLAT_RING3_DS 0xe033 /* GDT index 262 */ +#define FLAT_RING3_SS 0xe033 /* GDT index 262 */ + +#define FLAT_KERNEL_CS FLAT_RING1_CS +#define FLAT_KERNEL_DS FLAT_RING1_DS +#define FLAT_KERNEL_SS FLAT_RING1_SS +#define FLAT_USER_CS FLAT_RING3_CS +#define FLAT_USER_DS FLAT_RING3_DS +#define FLAT_USER_SS FLAT_RING3_SS + +#define __HYPERVISOR_VIRT_START_PAE 0xF5800000 +#define __MACH2PHYS_VIRT_START_PAE 0xF5800000 +#define __MACH2PHYS_VIRT_END_PAE 0xF6800000 +#define HYPERVISOR_VIRT_START_PAE \ + mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE) +#define MACH2PHYS_VIRT_START_PAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE) +#define MACH2PHYS_VIRT_END_PAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE) + +/* Non-PAE bounds are obsolete. */ +#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000 +#define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000 +#define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000 +#define HYPERVISOR_VIRT_START_NONPAE \ + mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE) +#define MACH2PHYS_VIRT_START_NONPAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE) +#define MACH2PHYS_VIRT_END_NONPAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE) + +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE +#define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE +#define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE + +#ifndef HYPERVISOR_VIRT_START +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) +#endif + +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2) +#ifndef machine_to_phys_mapping +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START) +#endif + +/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) +#undef ___DEFINE_XEN_GUEST_HANDLE +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef struct { type *p; } \ + __guest_handle_ ## name; \ + typedef struct { union { type *p; uint64_aligned_t q; }; } \ + __guest_handle_64_ ## name +#undef set_xen_guest_handle_raw +#define set_xen_guest_handle_raw(hnd, val) \ + do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \ + (hnd).p = val; \ + } while ( 0 ) +#define uint64_aligned_t uint64_t __attribute__((aligned(8))) +#define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name +#define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name) +#endif + +#ifndef __ASSEMBLY__ + +struct cpu_user_regs { + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + uint32_t esi; + uint32_t edi; + uint32_t ebp; + uint32_t eax; + uint16_t error_code; /* private */ + uint16_t entry_vector; /* private */ + uint32_t eip; + uint16_t cs; + uint8_t saved_upcall_mask; + uint8_t _pad0; + uint32_t eflags; /* eflags.IF == !saved_upcall_mask */ + uint32_t esp; + uint16_t ss, _pad1; + uint16_t es, _pad2; + uint16_t ds, _pad3; + uint16_t fs, _pad4; + uint16_t gs, _pad5; +}; +typedef struct cpu_user_regs cpu_user_regs_t; +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t); + +/* + * Page-directory addresses above 4GB do not fit into architectural %cr3. + * When accessing %cr3, or equivalent field in vcpu_guest_context, guests + * must use the following accessor macros to pack/unpack valid MFNs. + */ +#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20)) +#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20)) + +struct arch_vcpu_info { + unsigned long cr2; + unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */ +}; +typedef struct arch_vcpu_info arch_vcpu_info_t; + +struct xen_callback { + unsigned long cs; + unsigned long eip; +}; +typedef struct xen_callback xen_callback_t; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/arch-x86/xen-x86_64.h b/include/xen/arch-x86/xen-x86_64.h new file mode 100644 index 000000000..1c4e1590f --- /dev/null +++ b/include/xen/arch-x86/xen-x86_64.h @@ -0,0 +1,202 @@ +/****************************************************************************** + * xen-x86_64.h + * + * Guest OS interface to x86 64-bit Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2006, K A Fraser + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ + +/* + * Hypercall interface: + * Input: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6) + * Output: %rax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi) + */ + +/* + * 64-bit segment selectors + * These flat segments are in the Xen-private section of every GDT. Since these + * are also present in the initial GDT, many OSes will be able to avoid + * installing their own GDT. + */ + +#define FLAT_RING3_CS32 0xe023 /* GDT index 260 */ +#define FLAT_RING3_CS64 0xe033 /* GDT index 261 */ +#define FLAT_RING3_DS32 0xe02b /* GDT index 262 */ +#define FLAT_RING3_DS64 0x0000 /* NULL selector */ +#define FLAT_RING3_SS32 0xe02b /* GDT index 262 */ +#define FLAT_RING3_SS64 0xe02b /* GDT index 262 */ + +#define FLAT_KERNEL_DS64 FLAT_RING3_DS64 +#define FLAT_KERNEL_DS32 FLAT_RING3_DS32 +#define FLAT_KERNEL_DS FLAT_KERNEL_DS64 +#define FLAT_KERNEL_CS64 FLAT_RING3_CS64 +#define FLAT_KERNEL_CS32 FLAT_RING3_CS32 +#define FLAT_KERNEL_CS FLAT_KERNEL_CS64 +#define FLAT_KERNEL_SS64 FLAT_RING3_SS64 +#define FLAT_KERNEL_SS32 FLAT_RING3_SS32 +#define FLAT_KERNEL_SS FLAT_KERNEL_SS64 + +#define FLAT_USER_DS64 FLAT_RING3_DS64 +#define FLAT_USER_DS32 FLAT_RING3_DS32 +#define FLAT_USER_DS FLAT_USER_DS64 +#define FLAT_USER_CS64 FLAT_RING3_CS64 +#define FLAT_USER_CS32 FLAT_RING3_CS32 +#define FLAT_USER_CS FLAT_USER_CS64 +#define FLAT_USER_SS64 FLAT_RING3_SS64 +#define FLAT_USER_SS32 FLAT_RING3_SS32 +#define FLAT_USER_SS FLAT_USER_SS64 + +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000 +#define __HYPERVISOR_VIRT_END 0xFFFF880000000000 +#define __MACH2PHYS_VIRT_START 0xFFFF800000000000 +#define __MACH2PHYS_VIRT_END 0xFFFF804000000000 + +#ifndef HYPERVISOR_VIRT_START +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) +#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END) +#endif + +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3) +#ifndef machine_to_phys_mapping +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) +#endif + +/* + * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) + * @which == SEGBASE_* ; @base == 64-bit base address + * Returns 0 on success. + */ +#define SEGBASE_FS 0 +#define SEGBASE_GS_USER 1 +#define SEGBASE_GS_KERNEL 2 +#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */ + +/* + * int HYPERVISOR_iret(void) + * All arguments are on the kernel stack, in the following format. + * Never returns if successful. Current kernel context is lost. + * The saved CS is mapped as follows: + * RING0 -> RING3 kernel mode. + * RING1 -> RING3 kernel mode. + * RING2 -> RING3 kernel mode. + * RING3 -> RING3 user mode. + * However RING0 indicates that the guest kernel should return to iteself + * directly with + * orb $3,1*8(%rsp) + * iretq + * If flags contains VGCF_in_syscall: + * Restore RAX, RIP, RFLAGS, RSP. + * Discard R11, RCX, CS, SS. + * Otherwise: + * Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP. + * All other registers are saved on hypercall entry and restored to user. + */ +/* Guest exited in SYSCALL context? Return to guest with SYSRET? */ +#define _VGCF_in_syscall 8 +#define VGCF_in_syscall (1<<_VGCF_in_syscall) +#define VGCF_IN_SYSCALL VGCF_in_syscall + +#ifndef __ASSEMBLY__ + +struct iret_context { + /* Top of stack (%rsp at point of hypercall). */ + uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss; + /* Bottom of iret stack frame. */ +}; + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */ +#define __DECL_REG(name) union { \ + uint64_t r ## name, e ## name; \ + uint32_t _e ## name; \ +} +#else +/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */ +#define __DECL_REG(name) uint64_t r ## name +#endif + +struct cpu_user_regs { + uint64_t r15; + uint64_t r14; + uint64_t r13; + uint64_t r12; + __DECL_REG(bp); + __DECL_REG(bx); + uint64_t r11; + uint64_t r10; + uint64_t r9; + uint64_t r8; + __DECL_REG(ax); + __DECL_REG(cx); + __DECL_REG(dx); + __DECL_REG(si); + __DECL_REG(di); + uint32_t error_code; /* private */ + uint32_t entry_vector; /* private */ + __DECL_REG(ip); + uint16_t cs, _pad0[1]; + uint8_t saved_upcall_mask; + uint8_t _pad1[3]; + __DECL_REG(flags); /* rflags.IF == !saved_upcall_mask */ + __DECL_REG(sp); + uint16_t ss, _pad2[3]; + uint16_t es, _pad3[3]; + uint16_t ds, _pad4[3]; + uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base. */ + uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */ +}; +typedef struct cpu_user_regs cpu_user_regs_t; +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t); + +#undef __DECL_REG + +#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12) +#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12) + +struct arch_vcpu_info { + unsigned long cr2; + unsigned long pad; /* sizeof(vcpu_info_t) == 64 */ +}; +typedef struct arch_vcpu_info arch_vcpu_info_t; + +typedef unsigned long xen_callback_t; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h new file mode 100644 index 000000000..f35804b88 --- /dev/null +++ b/include/xen/arch-x86/xen.h @@ -0,0 +1,273 @@ +/****************************************************************************** + * arch-x86/xen.h + * + * Guest OS interface to x86 Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2006, K A Fraser + */ + +#include "../xen.h" + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_H__ + +/* Structural guest handles introduced in 0x00030201. */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef struct { type *p; } __guest_handle_ ## name +#else +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef type * __guest_handle_ ## name +#endif + +/* + * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field + * in a struct in memory. + * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an + * hypercall argument. + * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but + * they might not be on other architectures. + */ +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ + ___DEFINE_XEN_GUEST_HANDLE(name, type); \ + ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) +#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) +#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name +#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) +#define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) +#ifdef __XEN_TOOLS__ +#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) +#endif +#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) + +#if defined(__i386__) +#include "xen-x86_32.h" +#elif defined(__x86_64__) +#include "xen-x86_64.h" +#endif + +#ifndef __ASSEMBLY__ +typedef unsigned long xen_pfn_t; +#define PRI_xen_pfn "lx" +#endif + +#define XEN_HAVE_PV_GUEST_ENTRY 1 + +#define XEN_HAVE_PV_UPCALL_MASK 1 + +/* + * `incontents 200 segdesc Segment Descriptor Tables + */ +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_gdt(const xen_pfn_t frames[], unsigned int entries); + * ` + */ +/* + * A number of GDT entries are reserved by Xen. These are not situated at the + * start of the GDT because some stupid OSes export hard-coded selector values + * in their ABI. These hard-coded values are always near the start of the GDT, + * so Xen places itself out of the way, at the far end of the GDT. + * + * NB The LDT is set using the MMUEXT_SET_LDT op of HYPERVISOR_mmuext_op + */ +#define FIRST_RESERVED_GDT_PAGE 14 +#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096) +#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8) + + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_update_descriptor(u64 pa, u64 desc); + * ` + * ` @pa The machine physical address of the descriptor to + * ` update. Must be either a descriptor page or writable. + * ` @desc The descriptor value to update, in the same format as a + * ` native descriptor table entry. + */ + +/* Maximum number of virtual CPUs in legacy multi-processor guests. */ +#define XEN_LEGACY_MAX_VCPUS 32 + +#ifndef __ASSEMBLY__ + +typedef unsigned long xen_ulong_t; +#define PRI_xen_ulong "lx" + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp); + * ` + * Sets the stack segment and pointer for the current vcpu. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_trap_table(const struct trap_info traps[]); + * ` + */ +/* + * Send an array of these to HYPERVISOR_set_trap_table(). + * Terminate the array with a sentinel entry, with traps[].address==0. + * The privilege level specifies which modes may enter a trap via a software + * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate + * privilege levels as follows: + * Level == 0: Noone may enter + * Level == 1: Kernel may enter + * Level == 2: Kernel may enter + * Level == 3: Everyone may enter + */ +#define TI_GET_DPL(_ti) ((_ti)->flags & 3) +#define TI_GET_IF(_ti) ((_ti)->flags & 4) +#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl)) +#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2)) +struct trap_info { + uint8_t vector; /* exception vector */ + uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */ + uint16_t cs; /* code selector */ + unsigned long address; /* code offset */ +}; +typedef struct trap_info trap_info_t; +DEFINE_XEN_GUEST_HANDLE(trap_info_t); + +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ + +/* + * The following is all CPU context. Note that the fpu_ctxt block is filled + * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. + * + * Also note that when calling DOMCTL_setvcpucontext and VCPU_initialise + * for HVM and PVH guests, not all information in this structure is updated: + * + * - For HVM guests, the structures read include: fpu_ctxt (if + * VGCT_I387_VALID is set), flags, user_regs, debugreg[*] + * + * - PVH guests are the same as HVM guests, but additionally use ctrlreg[3] to + * set cr3. All other fields not used should be set to 0. + */ +struct vcpu_guest_context { + /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */ + struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */ +#define VGCF_I387_VALID (1<<0) +#define VGCF_IN_KERNEL (1<<2) +#define _VGCF_i387_valid 0 +#define VGCF_i387_valid (1<<_VGCF_i387_valid) +#define _VGCF_in_kernel 2 +#define VGCF_in_kernel (1<<_VGCF_in_kernel) +#define _VGCF_failsafe_disables_events 3 +#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events) +#define _VGCF_syscall_disables_events 4 +#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events) +#define _VGCF_online 5 +#define VGCF_online (1<<_VGCF_online) + unsigned long flags; /* VGCF_* flags */ + struct cpu_user_regs user_regs; /* User-level CPU registers */ + struct trap_info trap_ctxt[256]; /* Virtual IDT */ + unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */ + unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */ + unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */ + /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ + unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */ + unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */ +#ifdef __i386__ + unsigned long event_callback_cs; /* CS:EIP of event callback */ + unsigned long event_callback_eip; + unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ + unsigned long failsafe_callback_eip; +#else + unsigned long event_callback_eip; + unsigned long failsafe_callback_eip; +#ifdef __XEN__ + union { + unsigned long syscall_callback_eip; + struct { + unsigned int event_callback_cs; /* compat CS of event cb */ + unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */ + }; + }; +#else + unsigned long syscall_callback_eip; +#endif +#endif + unsigned long vm_assist; /* VMASST_TYPE_* bitmap */ +#ifdef __x86_64__ + /* Segment base addresses. */ + uint64_t fs_base; + uint64_t gs_base_kernel; + uint64_t gs_base_user; +#endif +}; +typedef struct vcpu_guest_context vcpu_guest_context_t; +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); + +struct arch_shared_info { + unsigned long max_pfn; /* max pfn that appears in table */ + /* Frame containing list of mfns containing list of mfns containing p2m. */ + xen_pfn_t pfn_to_mfn_frame_list_list; + unsigned long nmi_reason; + uint64_t pad[32]; +}; +typedef struct arch_shared_info arch_shared_info_t; + +#endif /* !__ASSEMBLY__ */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_fpu_taskswitch(int set); + * ` + * Sets (if set!=0) or clears (if set==0) CR0.TS. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_debugreg(int regno, unsigned long value); + * + * ` unsigned long + * ` HYPERVISOR_get_debugreg(int regno); + * For 0<=reg<=7, returns the debug register value. + * For other values of reg, returns ((unsigned long)-EINVAL). + * (Unfortunately, this interface is defective.) + */ + +/* + * Prefix forces emulation of some non-trapping instructions. + * Currently only CPUID. + */ +#ifdef __ASSEMBLY__ +#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; +#define XEN_CPUID XEN_EMULATE_PREFIX cpuid +#else +#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " +#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" +#endif + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/event_channel.h b/include/xen/event_channel.h new file mode 100644 index 000000000..49ac8cca5 --- /dev/null +++ b/include/xen/event_channel.h @@ -0,0 +1,381 @@ +/****************************************************************************** + * event_channel.h + * + * Event channels between domains. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2003-2004, K A Fraser. + */ + +#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__ +#define __XEN_PUBLIC_EVENT_CHANNEL_H__ + +#include "xen.h" + +/* + * `incontents 150 evtchn Event Channels + * + * Event channels are the basic primitive provided by Xen for event + * notifications. An event is the Xen equivalent of a hardware + * interrupt. They essentially store one bit of information, the event + * of interest is signalled by transitioning this bit from 0 to 1. + * + * Notifications are received by a guest via an upcall from Xen, + * indicating when an event arrives (setting the bit). Further + * notifications are masked until the bit is cleared again (therefore, + * guests must check the value of the bit after re-enabling event + * delivery to ensure no missed notifications). + * + * Event notifications can be masked by setting a flag; this is + * equivalent to disabling interrupts and can be used to ensure + * atomicity of certain operations in the guest kernel. + * + * Event channels are represented by the evtchn_* fields in + * struct shared_info and struct vcpu_info. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args) + * ` + * @cmd == EVTCHNOP_* (event-channel operation). + * @args == struct evtchn_* Operation-specific extra arguments (NULL if none). + */ + +/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */ +#define EVTCHNOP_bind_interdomain 0 +#define EVTCHNOP_bind_virq 1 +#define EVTCHNOP_bind_pirq 2 +#define EVTCHNOP_close 3 +#define EVTCHNOP_send 4 +#define EVTCHNOP_status 5 +#define EVTCHNOP_alloc_unbound 6 +#define EVTCHNOP_bind_ipi 7 +#define EVTCHNOP_bind_vcpu 8 +#define EVTCHNOP_unmask 9 +#define EVTCHNOP_reset 10 +#define EVTCHNOP_init_control 11 +#define EVTCHNOP_expand_array 12 +#define EVTCHNOP_set_priority 13 +/* ` } */ + +typedef uint32_t evtchn_port_t; +DEFINE_XEN_GUEST_HANDLE(evtchn_port_t); + +/* + * EVTCHNOP_alloc_unbound: Allocate a port in domain and mark as + * accepting interdomain bindings from domain . A fresh port + * is allocated in and returned as . + * NOTES: + * 1. If the caller is unprivileged then must be DOMID_SELF. + * 2. may be DOMID_SELF, allowing loopback connections. + */ +struct evtchn_alloc_unbound { + /* IN parameters */ + domid_t dom, remote_dom; + /* OUT parameters */ + evtchn_port_t port; +}; +typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t; + +/* + * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between + * the calling domain and . must identify + * a port that is unbound and marked as accepting bindings from the calling + * domain. A fresh port is allocated in the calling domain and returned as + * . + * + * In case the peer domain has already tried to set our event channel + * pending, before it was bound, EVTCHNOP_bind_interdomain always sets + * the local event channel pending. + * + * The usual pattern of use, in the guest's upcall (or subsequent + * handler) is as follows: (Re-enable the event channel for subsequent + * signalling and then) check for the existence of whatever condition + * is being waited for by other means, and take whatever action is + * needed (if any). + * + * NOTES: + * 1. may be DOMID_SELF, allowing loopback connections. + */ +struct evtchn_bind_interdomain { + /* IN parameters. */ + domid_t remote_dom; + evtchn_port_t remote_port; + /* OUT parameters. */ + evtchn_port_t local_port; +}; +typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t; + +/* + * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ on specified + * vcpu. + * NOTES: + * 1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list + * in xen.h for the classification of each VIRQ. + * 2. Global VIRQs must be allocated on VCPU0 but can subsequently be + * re-bound via EVTCHNOP_bind_vcpu. + * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu. + * The allocated event channel is bound to the specified vcpu and the + * binding cannot be changed. + */ +struct evtchn_bind_virq { + /* IN parameters. */ + uint32_t virq; /* enum virq */ + uint32_t vcpu; + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_virq evtchn_bind_virq_t; + +/* + * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ ). + * NOTES: + * 1. A physical IRQ may be bound to at most one event channel per domain. + * 2. Only a sufficiently-privileged domain may bind to a physical IRQ. + */ +struct evtchn_bind_pirq { + /* IN parameters. */ + uint32_t pirq; +#define BIND_PIRQ__WILL_SHARE 1 + uint32_t flags; /* BIND_PIRQ__* */ + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_pirq evtchn_bind_pirq_t; + +/* + * EVTCHNOP_bind_ipi: Bind a local event channel to receive events. + * NOTES: + * 1. The allocated event channel is bound to the specified vcpu. The binding + * may not be changed. + */ +struct evtchn_bind_ipi { + uint32_t vcpu; + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_ipi evtchn_bind_ipi_t; + +/* + * EVTCHNOP_close: Close a local event channel . If the channel is + * interdomain then the remote end is placed in the unbound state + * (EVTCHNSTAT_unbound), awaiting a new connection. + */ +struct evtchn_close { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_close evtchn_close_t; + +/* + * EVTCHNOP_send: Send an event to the remote end of the channel whose local + * endpoint is . + */ +struct evtchn_send { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_send evtchn_send_t; + +/* + * EVTCHNOP_status: Get the current status of the communication channel which + * has an endpoint at . + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may obtain the status of an event + * channel for which is not DOMID_SELF. + */ +struct evtchn_status { + /* IN parameters */ + domid_t dom; + evtchn_port_t port; + /* OUT parameters */ +#define EVTCHNSTAT_closed 0 /* Channel is not in use. */ +#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/ +#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */ +#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */ +#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */ +#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */ + uint32_t status; + uint32_t vcpu; /* VCPU to which this channel is bound. */ + union { + struct { + domid_t dom; + } unbound; /* EVTCHNSTAT_unbound */ + struct { + domid_t dom; + evtchn_port_t port; + } interdomain; /* EVTCHNSTAT_interdomain */ + uint32_t pirq; /* EVTCHNSTAT_pirq */ + uint32_t virq; /* EVTCHNSTAT_virq */ + } u; +}; +typedef struct evtchn_status evtchn_status_t; + +/* + * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an + * event is pending. + * NOTES: + * 1. IPI-bound channels always notify the vcpu specified at bind time. + * This binding cannot be changed. + * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time. + * This binding cannot be changed. + * 3. All other channels notify vcpu0 by default. This default is set when + * the channel is allocated (a port that is freed and subsequently reused + * has its binding reset to vcpu0). + */ +struct evtchn_bind_vcpu { + /* IN parameters. */ + evtchn_port_t port; + uint32_t vcpu; +}; +typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t; + +/* + * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver + * a notification to the appropriate VCPU if an event is pending. + */ +struct evtchn_unmask { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_unmask evtchn_unmask_t; + +/* + * EVTCHNOP_reset: Close all event channels associated with specified domain. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF. + */ +struct evtchn_reset { + /* IN parameters. */ + domid_t dom; +}; +typedef struct evtchn_reset evtchn_reset_t; + +/* + * EVTCHNOP_init_control: initialize the control block for the FIFO ABI. + * + * Note: any events that are currently pending will not be resent and + * will be lost. Guests should call this before binding any event to + * avoid losing any events. + */ +struct evtchn_init_control { + /* IN parameters. */ + uint64_t control_gfn; + uint32_t offset; + uint32_t vcpu; + /* OUT parameters. */ + uint8_t link_bits; + uint8_t _pad[7]; +}; +typedef struct evtchn_init_control evtchn_init_control_t; + +/* + * EVTCHNOP_expand_array: add an additional page to the event array. + */ +struct evtchn_expand_array { + /* IN parameters. */ + uint64_t array_gfn; +}; +typedef struct evtchn_expand_array evtchn_expand_array_t; + +/* + * EVTCHNOP_set_priority: set the priority for an event channel. + */ +struct evtchn_set_priority { + /* IN parameters. */ + uint32_t port; + uint32_t priority; +}; +typedef struct evtchn_set_priority evtchn_set_priority_t; + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op) + * ` + * Superceded by new event_channel_op() hypercall since 0x00030202. + */ +struct evtchn_op { + uint32_t cmd; /* enum event_channel_op */ + union { + struct evtchn_alloc_unbound alloc_unbound; + struct evtchn_bind_interdomain bind_interdomain; + struct evtchn_bind_virq bind_virq; + struct evtchn_bind_pirq bind_pirq; + struct evtchn_bind_ipi bind_ipi; + struct evtchn_close close; + struct evtchn_send send; + struct evtchn_status status; + struct evtchn_bind_vcpu bind_vcpu; + struct evtchn_unmask unmask; + } u; +}; +typedef struct evtchn_op evtchn_op_t; +DEFINE_XEN_GUEST_HANDLE(evtchn_op_t); + +/* + * 2-level ABI + */ + +#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64) + +/* + * FIFO ABI + */ + +/* Events may have priorities from 0 (highest) to 15 (lowest). */ +#define EVTCHN_FIFO_PRIORITY_MAX 0 +#define EVTCHN_FIFO_PRIORITY_DEFAULT 7 +#define EVTCHN_FIFO_PRIORITY_MIN 15 + +#define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1) + +typedef uint32_t event_word_t; + +#define EVTCHN_FIFO_PENDING 31 +#define EVTCHN_FIFO_MASKED 30 +#define EVTCHN_FIFO_LINKED 29 +#define EVTCHN_FIFO_BUSY 28 + +#define EVTCHN_FIFO_LINK_BITS 17 +#define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1) + +#define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS) + +struct evtchn_fifo_control_block { + uint32_t ready; + uint32_t _rsvd; + uint32_t head[EVTCHN_FIFO_MAX_QUEUES]; +}; +typedef struct evtchn_fifo_control_block evtchn_fifo_control_block_t; + +#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h new file mode 100644 index 000000000..b8a3d6ceb --- /dev/null +++ b/include/xen/grant_table.h @@ -0,0 +1,662 @@ +/****************************************************************************** + * grant_table.h + * + * Interface for granting foreign access to page frames, and receiving + * page-ownership transfers. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004, K A Fraser + */ + +#ifndef __XEN_PUBLIC_GRANT_TABLE_H__ +#define __XEN_PUBLIC_GRANT_TABLE_H__ + +#include "xen.h" + +/* + * `incontents 150 gnttab Grant Tables + * + * Xen's grant tables provide a generic mechanism to memory sharing + * between domains. This shared memory interface underpins the split + * device drivers for block and network IO. + * + * Each domain has its own grant table. This is a data structure that + * is shared with Xen; it allows the domain to tell Xen what kind of + * permissions other domains have on its pages. Entries in the grant + * table are identified by grant references. A grant reference is an + * integer, which indexes into the grant table. It acts as a + * capability which the grantee can use to perform operations on the + * granter’s memory. + * + * This capability-based system allows shared-memory communications + * between unprivileged domains. A grant reference also encapsulates + * the details of a shared page, removing the need for a domain to + * know the real machine address of a page it is sharing. This makes + * it possible to share memory correctly with domains running in + * fully virtualised memory. + */ + +/*********************************** + * GRANT TABLE REPRESENTATION + */ + +/* Some rough guidelines on accessing and updating grant-table entries + * in a concurrency-safe manner. For more information, Linux contains a + * reference implementation for guest OSes (drivers/xen/grant_table.c, see + * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD + * + * NB. WMB is a no-op on current-generation x86 processors. However, a + * compiler barrier will still be required. + * + * Introducing a valid entry into the grant table: + * 1. Write ent->domid. + * 2. Write ent->frame: + * GTF_permit_access: Frame to which access is permitted. + * GTF_accept_transfer: Pseudo-phys frame slot being filled by new + * frame, or zero if none. + * 3. Write memory barrier (WMB). + * 4. Write ent->flags, inc. valid type. + * + * Invalidating an unused GTF_permit_access entry: + * 1. flags = ent->flags. + * 2. Observe that !(flags & (GTF_reading|GTF_writing)). + * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). + * NB. No need for WMB as reuse of entry is control-dependent on success of + * step 3, and all architectures guarantee ordering of ctrl-dep writes. + * + * Invalidating an in-use GTF_permit_access entry: + * This cannot be done directly. Request assistance from the domain controller + * which can set a timeout on the use of a grant entry and take necessary + * action. (NB. This is not yet implemented!). + * + * Invalidating an unused GTF_accept_transfer entry: + * 1. flags = ent->flags. + * 2. Observe that !(flags & GTF_transfer_committed). [*] + * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). + * NB. No need for WMB as reuse of entry is control-dependent on success of + * step 3, and all architectures guarantee ordering of ctrl-dep writes. + * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. + * The guest must /not/ modify the grant entry until the address of the + * transferred frame is written. It is safe for the guest to spin waiting + * for this to occur (detect by observing GTF_transfer_completed in + * ent->flags). + * + * Invalidating a committed GTF_accept_transfer entry: + * 1. Wait for (ent->flags & GTF_transfer_completed). + * + * Changing a GTF_permit_access from writable to read-only: + * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. + * + * Changing a GTF_permit_access from read-only to writable: + * Use SMP-safe bit-setting instruction. + */ + +/* + * Reference to a grant entry in a specified domain's grant table. + */ +typedef uint32_t grant_ref_t; + +/* + * A grant table comprises a packed array of grant entries in one or more + * page frames shared between Xen and a guest. + * [XEN]: This field is written by Xen and read by the sharing guest. + * [GST]: This field is written by the guest and read by Xen. + */ + +/* + * Version 1 of the grant table entry structure is maintained purely + * for backwards compatibility. New guests should use version 2. + */ +#if __XEN_INTERFACE_VERSION__ < 0x0003020a +#define grant_entry_v1 grant_entry +#define grant_entry_v1_t grant_entry_t +#endif +struct grant_entry_v1 { + /* GTF_xxx: various type and flag information. [XEN,GST] */ + uint16_t flags; + /* The domain being granted foreign privileges. [GST] */ + domid_t domid; + /* + * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] + * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] + */ + uint32_t frame; +}; +typedef struct grant_entry_v1 grant_entry_v1_t; + +/* The first few grant table entries will be preserved across grant table + * version changes and may be pre-populated at domain creation by tools. + */ +#define GNTTAB_NR_RESERVED_ENTRIES 8 +#define GNTTAB_RESERVED_CONSOLE 0 +#define GNTTAB_RESERVED_XENSTORE 1 + +/* + * Type of grant entry. + * GTF_invalid: This grant entry grants no privileges. + * GTF_permit_access: Allow @domid to map/access @frame. + * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame + * to this guest. Xen writes the page number to @frame. + * GTF_transitive: Allow @domid to transitively access a subrange of + * @trans_grant in @trans_domid. No mappings are allowed. + */ +#define GTF_invalid (0U<<0) +#define GTF_permit_access (1U<<0) +#define GTF_accept_transfer (2U<<0) +#define GTF_transitive (3U<<0) +#define GTF_type_mask (3U<<0) + +/* + * Subflags for GTF_permit_access. + * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] + * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] + * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] + * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST] + * GTF_sub_page: Grant access to only a subrange of the page. @domid + * will only be allowed to copy from the grant, and not + * map it. [GST] + */ +#define _GTF_readonly (2) +#define GTF_readonly (1U<<_GTF_readonly) +#define _GTF_reading (3) +#define GTF_reading (1U<<_GTF_reading) +#define _GTF_writing (4) +#define GTF_writing (1U<<_GTF_writing) +#define _GTF_PWT (5) +#define GTF_PWT (1U<<_GTF_PWT) +#define _GTF_PCD (6) +#define GTF_PCD (1U<<_GTF_PCD) +#define _GTF_PAT (7) +#define GTF_PAT (1U<<_GTF_PAT) +#define _GTF_sub_page (8) +#define GTF_sub_page (1U<<_GTF_sub_page) + +/* + * Subflags for GTF_accept_transfer: + * GTF_transfer_committed: Xen sets this flag to indicate that it is committed + * to transferring ownership of a page frame. When a guest sees this flag + * it must /not/ modify the grant entry until GTF_transfer_completed is + * set by Xen. + * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag + * after reading GTF_transfer_committed. Xen will always write the frame + * address, followed by ORing this flag, in a timely manner. + */ +#define _GTF_transfer_committed (2) +#define GTF_transfer_committed (1U<<_GTF_transfer_committed) +#define _GTF_transfer_completed (3) +#define GTF_transfer_completed (1U<<_GTF_transfer_completed) + +/* + * Version 2 grant table entries. These fulfil the same role as + * version 1 entries, but can represent more complicated operations. + * Any given domain will have either a version 1 or a version 2 table, + * and every entry in the table will be the same version. + * + * The interface by which domains use grant references does not depend + * on the grant table version in use by the other domain. + */ +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +/* + * Version 1 and version 2 grant entries share a common prefix. The + * fields of the prefix are documented as part of struct + * grant_entry_v1. + */ +struct grant_entry_header { + uint16_t flags; + domid_t domid; +}; +typedef struct grant_entry_header grant_entry_header_t; + +/* + * Version 2 of the grant entry structure. + */ +union grant_entry_v2 { + grant_entry_header_t hdr; + + /* + * This member is used for V1-style full page grants, where either: + * + * -- hdr.type is GTF_accept_transfer, or + * -- hdr.type is GTF_permit_access and GTF_sub_page is not set. + * + * In that case, the frame field has the same semantics as the + * field of the same name in the V1 entry structure. + */ + struct { + grant_entry_header_t hdr; + uint32_t pad0; + uint64_t frame; + } full_page; + + /* + * If the grant type is GTF_grant_access and GTF_sub_page is set, + * @domid is allowed to access bytes [@page_off,@page_off+@length) + * in frame @frame. + */ + struct { + grant_entry_header_t hdr; + uint16_t page_off; + uint16_t length; + uint64_t frame; + } sub_page; + + /* + * If the grant is GTF_transitive, @domid is allowed to use the + * grant @gref in domain @trans_domid, as if it was the local + * domain. Obviously, the transitive access must be compatible + * with the original grant. + * + * The current version of Xen does not allow transitive grants + * to be mapped. + */ + struct { + grant_entry_header_t hdr; + domid_t trans_domid; + uint16_t pad0; + grant_ref_t gref; + } transitive; + + uint32_t __spacer[4]; /* Pad to a power of two */ +}; +typedef union grant_entry_v2 grant_entry_v2_t; + +typedef uint16_t grant_status_t; + +#endif /* __XEN_INTERFACE_VERSION__ */ + +/*********************************** + * GRANT TABLE QUERIES AND USES + */ + +/* ` enum neg_errnoval + * ` HYPERVISOR_grant_table_op(enum grant_table_op cmd, + * ` void *args, + * ` unsigned int count) + * ` + * + * @args points to an array of a per-command data structure. The array + * has @count members + */ + +/* ` enum grant_table_op { // GNTTABOP_* => struct gnttab_* */ +#define GNTTABOP_map_grant_ref 0 +#define GNTTABOP_unmap_grant_ref 1 +#define GNTTABOP_setup_table 2 +#define GNTTABOP_dump_table 3 +#define GNTTABOP_transfer 4 +#define GNTTABOP_copy 5 +#define GNTTABOP_query_size 6 +#define GNTTABOP_unmap_and_replace 7 +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +#define GNTTABOP_set_version 8 +#define GNTTABOP_get_status_frames 9 +#define GNTTABOP_get_version 10 +#define GNTTABOP_swap_grant_ref 11 +#endif /* __XEN_INTERFACE_VERSION__ */ +/* ` } */ + +/* + * Handle to track a mapping created via a grant reference. + */ +typedef uint32_t grant_handle_t; + +/* + * GNTTABOP_map_grant_ref: Map the grant entry (,) for access + * by devices and/or host CPUs. If successful, is a tracking number + * that must be presented later to destroy the mapping(s). On error, + * is a negative status code. + * NOTES: + * 1. If GNTMAP_device_map is specified then is the address + * via which I/O devices may access the granted frame. + * 2. If GNTMAP_host_map is specified then a mapping will be added at + * either a host virtual address in the current address space, or at + * a PTE at the specified machine address. The type of mapping to + * perform is selected through the GNTMAP_contains_pte flag, and the + * address is specified in . + * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a + * host mapping is destroyed by other means then it is *NOT* guaranteed + * to be accounted to the correct grant reference! + */ +struct gnttab_map_grant_ref { + /* IN parameters. */ + uint64_t host_addr; + uint32_t flags; /* GNTMAP_* */ + grant_ref_t ref; + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ + grant_handle_t handle; + uint64_t dev_bus_addr; +}; +typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); + +/* + * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings + * tracked by . If or is zero, that + * field is ignored. If non-zero, they must refer to a device/host mapping + * that is tracked by + * NOTES: + * 1. The call may fail in an undefined manner if either mapping is not + * tracked by . + * 3. After executing a batch of unmaps, it is guaranteed that no stale + * mappings will remain in the device or host TLBs. + */ +struct gnttab_unmap_grant_ref { + /* IN parameters. */ + uint64_t host_addr; + uint64_t dev_bus_addr; + grant_handle_t handle; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); + +/* + * GNTTABOP_setup_table: Set up a grant table for comprising at least + * pages. The frame addresses are written to the . + * Only addresses are written, even if the table is larger. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + * 3. Xen may not support more than a single grant-table page per domain. + */ +struct gnttab_setup_table { + /* IN parameters. */ + domid_t dom; + uint32_t nr_frames; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +#if __XEN_INTERFACE_VERSION__ < 0x00040300 + XEN_GUEST_HANDLE(ulong) frame_list; +#else + XEN_GUEST_HANDLE(xen_pfn_t) frame_list; +#endif +}; +typedef struct gnttab_setup_table gnttab_setup_table_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t); + +/* + * GNTTABOP_dump_table: Dump the contents of the grant table to the + * xen console. Debugging use only. + */ +struct gnttab_dump_table { + /* IN parameters. */ + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_dump_table gnttab_dump_table_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t); + +/* + * GNTTABOP_transfer_grant_ref: Transfer to a foreign domain. The + * foreign domain has previously registered its interest in the transfer via + * . + * + * Note that, even if the transfer fails, the specified page no longer belongs + * to the calling domain *unless* the error is GNTST_bad_page. + */ +struct gnttab_transfer { + /* IN parameters. */ + xen_pfn_t mfn; + domid_t domid; + grant_ref_t ref; + /* OUT parameters. */ + int16_t status; +}; +typedef struct gnttab_transfer gnttab_transfer_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t); + + +/* + * GNTTABOP_copy: Hypervisor based copy + * source and destinations can be eithers MFNs or, for foreign domains, + * grant references. the foreign domain has to grant read/write access + * in its grant table. + * + * The flags specify what type source and destinations are (either MFN + * or grant reference). + * + * Note that this can also be used to copy data between two domains + * via a third party if the source and destination domains had previously + * grant appropriate access to their pages to the third party. + * + * source_offset specifies an offset in the source frame, dest_offset + * the offset in the target frame and len specifies the number of + * bytes to be copied. + */ + +#define _GNTCOPY_source_gref (0) +#define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref) +#define _GNTCOPY_dest_gref (1) +#define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) + +struct gnttab_copy { + /* IN parameters. */ + struct { + union { + grant_ref_t ref; + xen_pfn_t gmfn; + } u; + domid_t domid; + uint16_t offset; + } source, dest; + uint16_t len; + uint16_t flags; /* GNTCOPY_* */ + /* OUT parameters. */ + int16_t status; +}; +typedef struct gnttab_copy gnttab_copy_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t); + +/* + * GNTTABOP_query_size: Query the current and maximum sizes of the shared + * grant table. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + */ +struct gnttab_query_size { + /* IN parameters. */ + domid_t dom; + /* OUT parameters. */ + uint32_t nr_frames; + uint32_t max_nr_frames; + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_query_size gnttab_query_size_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t); + +/* + * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings + * tracked by but atomically replace the page table entry with one + * pointing to the machine address under . will be + * redirected to the null entry. + * NOTES: + * 1. The call may fail in an undefined manner if either mapping is not + * tracked by . + * 2. After executing a batch of unmaps, it is guaranteed that no stale + * mappings will remain in the device or host TLBs. + */ +struct gnttab_unmap_and_replace { + /* IN parameters. */ + uint64_t host_addr; + uint64_t new_addr; + grant_handle_t handle; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_unmap_and_replace gnttab_unmap_and_replace_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t); + +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +/* + * GNTTABOP_set_version: Request a particular version of the grant + * table shared table structure. This operation can only be performed + * once in any given domain. It must be performed before any grants + * are activated; otherwise, the domain will be stuck with version 1. + * The only defined versions are 1 and 2. + */ +struct gnttab_set_version { + /* IN/OUT parameters */ + uint32_t version; +}; +typedef struct gnttab_set_version gnttab_set_version_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_set_version_t); + + +/* + * GNTTABOP_get_status_frames: Get the list of frames used to store grant + * status for . In grant format version 2, the status is separated + * from the other shared grant fields to allow more efficient synchronization + * using barriers instead of atomic cmpexch operations. + * specify the size of vector . + * The frame addresses are returned in the . + * Only addresses are returned, even if the table is larger. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + */ +struct gnttab_get_status_frames { + /* IN parameters. */ + uint32_t nr_frames; + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ + XEN_GUEST_HANDLE(uint64_t) frame_list; +}; +typedef struct gnttab_get_status_frames gnttab_get_status_frames_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_get_status_frames_t); + +/* + * GNTTABOP_get_version: Get the grant table version which is in + * effect for domain . + */ +struct gnttab_get_version { + /* IN parameters */ + domid_t dom; + uint16_t pad; + /* OUT parameters */ + uint32_t version; +}; +typedef struct gnttab_get_version gnttab_get_version_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_get_version_t); + +/* + * GNTTABOP_swap_grant_ref: Swap the contents of two grant entries. + */ +struct gnttab_swap_grant_ref { + /* IN parameters */ + grant_ref_t ref_a; + grant_ref_t ref_b; + /* OUT parameters */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_swap_grant_ref gnttab_swap_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_swap_grant_ref_t); + +#endif /* __XEN_INTERFACE_VERSION__ */ + +/* + * Bitfield values for gnttab_map_grant_ref.flags. + */ + /* Map the grant entry for access by I/O devices. */ +#define _GNTMAP_device_map (0) +#define GNTMAP_device_map (1<<_GNTMAP_device_map) + /* Map the grant entry for access by host CPUs. */ +#define _GNTMAP_host_map (1) +#define GNTMAP_host_map (1<<_GNTMAP_host_map) + /* Accesses to the granted frame will be restricted to read-only access. */ +#define _GNTMAP_readonly (2) +#define GNTMAP_readonly (1<<_GNTMAP_readonly) + /* + * GNTMAP_host_map subflag: + * 0 => The host mapping is usable only by the guest OS. + * 1 => The host mapping is usable by guest OS + current application. + */ +#define _GNTMAP_application_map (3) +#define GNTMAP_application_map (1<<_GNTMAP_application_map) + + /* + * GNTMAP_contains_pte subflag: + * 0 => This map request contains a host virtual address. + * 1 => This map request contains the machine addess of the PTE to update. + */ +#define _GNTMAP_contains_pte (4) +#define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) + +#define _GNTMAP_can_fail (5) +#define GNTMAP_can_fail (1<<_GNTMAP_can_fail) + +/* + * Bits to be placed in guest kernel available PTE bits (architecture + * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). + */ +#define _GNTMAP_guest_avail0 (16) +#define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0) + +/* + * Values for error status returns. All errors are -ve. + */ +/* ` enum grant_status { */ +#define GNTST_okay (0) /* Normal return. */ +#define GNTST_general_error (-1) /* General undefined error. */ +#define GNTST_bad_domain (-2) /* Unrecognsed domain id. */ +#define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */ +#define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */ +#define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */ +#define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/ +#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ +#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ +#define GNTST_bad_page (-9) /* Specified page was invalid for op. */ +#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ +#define GNTST_address_too_big (-11) /* transfer page address too large. */ +#define GNTST_eagain (-12) /* Operation not done; try again. */ +/* ` } */ + +#define GNTTABOP_error_msgs { \ + "okay", \ + "undefined error", \ + "unrecognised domain id", \ + "invalid grant reference", \ + "invalid mapping handle", \ + "invalid virtual address", \ + "invalid device address", \ + "no spare translation slot in the I/O MMU", \ + "permission denied", \ + "bad page", \ + "copy arguments cross page boundary", \ + "page address size too large", \ + "operation not done; try again" \ +} + +#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/blkif.h b/include/xen/io/blkif.h new file mode 100644 index 000000000..c3e169ce2 --- /dev/null +++ b/include/xen/io/blkif.h @@ -0,0 +1,608 @@ +/****************************************************************************** + * blkif.h + * + * Unified block-device I/O interface for Xen guest OSes. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2003-2004, Keir Fraser + * Copyright (c) 2012, Spectra Logic Corporation + */ + +#ifndef __XEN_PUBLIC_IO_BLKIF_H__ +#define __XEN_PUBLIC_IO_BLKIF_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* + * Front->back notifications: When enqueuing a new request, sending a + * notification can be made conditional on req_event (i.e., the generic + * hold-off mechanism provided by the ring macros). Backends must set + * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). + * + * Back->front notifications: When enqueuing a new response, sending a + * notification can be made conditional on rsp_event (i.e., the generic + * hold-off mechanism provided by the ring macros). Frontends must set + * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). + */ + +#ifndef blkif_vdev_t +#define blkif_vdev_t uint16_t +#endif +#define blkif_sector_t uint64_t + +/* + * Feature and Parameter Negotiation + * ================================= + * The two halves of a Xen block driver utilize nodes within the XenStore to + * communicate capabilities and to negotiate operating parameters. This + * section enumerates these nodes which reside in the respective front and + * backend portions of the XenStore, following the XenBus convention. + * + * All data in the XenStore is stored as strings. Nodes specifying numeric + * values are encoded in decimal. Integer value ranges listed below are + * expressed as fixed sized integer types capable of storing the conversion + * of a properly formated node string, without loss of information. + * + * Any specified default value is in effect if the corresponding XenBus node + * is not present in the XenStore. + * + * XenStore nodes in sections marked "PRIVATE" are solely for use by the + * driver side whose XenBus tree contains them. + * + * XenStore nodes marked "DEPRECATED" in their notes section should only be + * used to provide interoperability with legacy implementations. + * + * See the XenBus state transition diagram below for details on when XenBus + * nodes must be published and when they can be queried. + * + ***************************************************************************** + * Backend XenBus Nodes + ***************************************************************************** + * + *------------------ Backend Device Identification (PRIVATE) ------------------ + * + * mode + * Values: "r" (read only), "w" (writable) + * + * The read or write access permissions to the backing store to be + * granted to the frontend. + * + * params + * Values: string + * + * A free formatted string providing sufficient information for the + * backend driver to open the backing device. (e.g. the path to the + * file or block device representing the backing store.) + * + * type + * Values: "file", "phy", "tap" + * + * The type of the backing device/object. + * + *--------------------------------- Features --------------------------------- + * + * feature-barrier + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_WRITE_BARRIER request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-flush-cache + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_FLUSH_DISKCACHE request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-discard + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_DISCARD request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-persistent + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 7 + * + * A value of "1" indicates that the backend can keep the grants used + * by the frontend driver mapped, so the same set of grants should be + * used in all transactions. The maximum number of grants the backend + * can map persistently depends on the implementation, but ideally it + * should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this + * feature the backend doesn't need to unmap each grant, preventing + * costly TLB flushes. The backend driver should only map grants + * persistently if the frontend supports it. If a backend driver chooses + * to use the persistent protocol when the frontend doesn't support it, + * it will probably hit the maximum number of persistently mapped grants + * (due to the fact that the frontend won't be reusing the same grants), + * and fall back to non-persistent mode. Backend implementations may + * shrink or expand the number of persistently mapped grants without + * notifying the frontend depending on memory constraints (this might + * cause a performance degradation). + * + * If a backend driver wants to limit the maximum number of persistently + * mapped grants to a value less than RING_SIZE * + * BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to + * discard the grants that are less commonly used. Using a LRU in the + * backend driver paired with a LIFO queue in the frontend will + * allow us to have better performance in this scenario. + * + *----------------------- Request Transport Parameters ------------------------ + * + * max-ring-page-order + * Values: + * Default Value: 0 + * Notes: 1, 3 + * + * The maximum supported size of the request ring buffer in units of + * lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, + * etc.). + * + * max-ring-pages + * Values: + * Default Value: 1 + * Notes: DEPRECATED, 2, 3 + * + * The maximum supported size of the request ring buffer in units of + * machine pages. The value must be a power of 2. + * + *------------------------- Backend Device Properties ------------------------- + * + * discard-alignment + * Values: + * Default Value: 0 + * Notes: 4, 5 + * + * The offset, in bytes from the beginning of the virtual block device, + * to the first, addressable, discard extent on the underlying device. + * + * discard-granularity + * Values: + * Default Value: <"sector-size"> + * Notes: 4 + * + * The size, in bytes, of the individually addressable discard extents + * of the underlying device. + * + * discard-secure + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 10 + * + * A value of "1" indicates that the backend can process BLKIF_OP_DISCARD + * requests with the BLKIF_DISCARD_SECURE flag set. + * + * info + * Values: (bitmap) + * + * A collection of bit flags describing attributes of the backing + * device. The VDISK_* macros define the meaning of each bit + * location. + * + * sector-size + * Values: + * + * The logical sector size, in bytes, of the backend device. + * + * physical-sector-size + * Values: + * + * The physical sector size, in bytes, of the backend device. + * + * sectors + * Values: + * + * The size of the backend device, expressed in units of its logical + * sector size ("sector-size"). + * + ***************************************************************************** + * Frontend XenBus Nodes + ***************************************************************************** + * + *----------------------- Request Transport Parameters ----------------------- + * + * event-channel + * Values: + * + * The identifier of the Xen event channel used to signal activity + * in the ring buffer. + * + * ring-ref + * Values: + * Notes: 6 + * + * The Xen grant reference granting permission for the backend to map + * the sole page in a single page sized ring buffer. + * + * ring-ref%u + * Values: + * Notes: 6 + * + * For a frontend providing a multi-page ring, a "number of ring pages" + * sized list of nodes, each containing a Xen grant reference granting + * permission for the backend to map the page of the ring located + * at page index "%u". Page indexes are zero based. + * + * protocol + * Values: string (XEN_IO_PROTO_ABI_*) + * Default Value: XEN_IO_PROTO_ABI_NATIVE + * + * The machine ABI rules governing the format of all ring request and + * response structures. + * + * ring-page-order + * Values: + * Default Value: 0 + * Maximum Value: MAX(ffs(max-ring-pages) - 1, max-ring-page-order) + * Notes: 1, 3 + * + * The size of the frontend allocated request ring buffer in units + * of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, + * etc.). + * + * num-ring-pages + * Values: + * Default Value: 1 + * Maximum Value: MAX(max-ring-pages,(0x1 << max-ring-page-order)) + * Notes: DEPRECATED, 2, 3 + * + * The size of the frontend allocated request ring buffer in units of + * machine pages. The value must be a power of 2. + * + * feature-persistent + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 7, 8, 9 + * + * A value of "1" indicates that the frontend will reuse the same grants + * for all transactions, allowing the backend to map them with write + * access (even when it should be read-only). If the frontend hits the + * maximum number of allowed persistently mapped grants, it can fallback + * to non persistent mode. This will cause a performance degradation, + * since the the backend driver will still try to map those grants + * persistently. Since the persistent grants protocol is compatible with + * the previous protocol, a frontend driver can choose to work in + * persistent mode even when the backend doesn't support it. + * + * It is recommended that the frontend driver stores the persistently + * mapped grants in a LIFO queue, so a subset of all persistently mapped + * grants gets used commonly. This is done in case the backend driver + * decides to limit the maximum number of persistently mapped grants + * to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. + * + *------------------------- Virtual Device Properties ------------------------- + * + * device-type + * Values: "disk", "cdrom", "floppy", etc. + * + * virtual-device + * Values: + * + * A value indicating the physical device to virtualize within the + * frontend's domain. (e.g. "The first ATA disk", "The third SCSI + * disk", etc.) + * + * See docs/misc/vbd-interface.txt for details on the format of this + * value. + * + * Notes + * ----- + * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer + * PV drivers. + * (2) Multi-page ring buffer scheme first used in some RedHat distributions + * including a distribution deployed on certain nodes of the Amazon + * EC2 cluster. + * (3) Support for multi-page ring buffers was implemented independently, + * in slightly different forms, by both Citrix and RedHat/Amazon. + * For full interoperability, block front and backends should publish + * identical ring parameters, adjusted for unit differences, to the + * XenStore nodes used in both schemes. + * (4) Devices that support discard functionality may internally allocate space + * (discardable extents) in units that are larger than the exported logical + * block size. If the backing device has such discardable extents the + * backend should provide both discard-granularity and discard-alignment. + * Providing just one of the two may be considered an error by the frontend. + * Backends supporting discard should include discard-granularity and + * discard-alignment even if it supports discarding individual sectors. + * Frontends should assume discard-alignment == 0 and discard-granularity + * == sector size if these keys are missing. + * (5) The discard-alignment parameter allows a physical device to be + * partitioned into virtual devices that do not necessarily begin or + * end on a discardable extent boundary. + * (6) When there is only a single page allocated to the request ring, + * 'ring-ref' is used to communicate the grant reference for this + * page to the backend. When using a multi-page ring, the 'ring-ref' + * node is not created. Instead 'ring-ref0' - 'ring-refN' are used. + * (7) When using persistent grants data has to be copied from/to the page + * where the grant is currently mapped. The overhead of doing this copy + * however doesn't suppress the speed improvement of not having to unmap + * the grants. + * (8) The frontend driver has to allow the backend driver to map all grants + * with write access, even when they should be mapped read-only, since + * further requests may reuse these grants and require write permissions. + * (9) Linux implementation doesn't have a limit on the maximum number of + * grants that can be persistently mapped in the frontend driver, but + * due to the frontent driver implementation it should never be bigger + * than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. + *(10) The discard-secure property may be present and will be set to 1 if the + * backing device supports secure discard. + */ + +/* + * STATE DIAGRAMS + * + ***************************************************************************** + * Startup * + ***************************************************************************** + * + * Tool stack creates front and back nodes with state XenbusStateInitialising. + * + * Front Back + * ================================= ===================================== + * XenbusStateInitialising XenbusStateInitialising + * o Query virtual device o Query backend device identification + * properties. data. + * o Setup OS device instance. o Open and validate backend device. + * o Publish backend features and + * transport parameters. + * | + * | + * V + * XenbusStateInitWait + * + * o Query backend features and + * transport parameters. + * o Allocate and initialize the + * request ring. + * o Publish transport parameters + * that will be in effect during + * this connection. + * | + * | + * V + * XenbusStateInitialised + * + * o Query frontend transport parameters. + * o Connect to the request ring and + * event channel. + * o Publish backend device properties. + * | + * | + * V + * XenbusStateConnected + * + * o Query backend device properties. + * o Finalize OS virtual device + * instance. + * | + * | + * V + * XenbusStateConnected + * + * Note: Drivers that do not support any optional features, or the negotiation + * of transport parameters, can skip certain states in the state machine: + * + * o A frontend may transition to XenbusStateInitialised without + * waiting for the backend to enter XenbusStateInitWait. In this + * case, default transport parameters are in effect and any + * transport parameters published by the frontend must contain + * their default values. + * + * o A backend may transition to XenbusStateInitialised, bypassing + * XenbusStateInitWait, without waiting for the frontend to first + * enter the XenbusStateInitialised state. In this case, default + * transport parameters are in effect and any transport parameters + * published by the backend must contain their default values. + * + * Drivers that support optional features and/or transport parameter + * negotiation must tolerate these additional state transition paths. + * In general this means performing the work of any skipped state + * transition, if it has not already been performed, in addition to the + * work associated with entry into the current state. + */ + +/* + * REQUEST CODES. + */ +#define BLKIF_OP_READ 0 +#define BLKIF_OP_WRITE 1 +/* + * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER + * operation code ("barrier request") must be completed prior to the + * execution of the barrier request. All writes issued after the barrier + * request must not execute until after the completion of the barrier request. + * + * Optional. See "feature-barrier" XenBus node documentation above. + */ +#define BLKIF_OP_WRITE_BARRIER 2 +/* + * Commit any uncommitted contents of the backing device's volatile cache + * to stable storage. + * + * Optional. See "feature-flush-cache" XenBus node documentation above. + */ +#define BLKIF_OP_FLUSH_DISKCACHE 3 +/* + * Used in SLES sources for device specific command packet + * contained within the request. Reserved for that purpose. + */ +#define BLKIF_OP_RESERVED_1 4 +/* + * Indicate to the backend device that a region of storage is no longer in + * use, and may be discarded at any time without impact to the client. If + * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the + * discarded region on the device must be rendered unrecoverable before the + * command returns. + * + * This operation is analogous to performing a trim (ATA) or unamp (SCSI), + * command on a native device. + * + * More information about trim/unmap operations can be found at: + * http://t13.org/Documents/UploadedDocuments/docs2008/ + * e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc + * http://www.seagate.com/staticfiles/support/disc/manuals/ + * Interface%20manuals/100293068c.pdf + * + * Optional. See "feature-discard", "discard-alignment", + * "discard-granularity", and "discard-secure" in the XenBus node + * documentation above. + */ +#define BLKIF_OP_DISCARD 5 + +/* + * Recognized if "feature-max-indirect-segments" in present in the backend + * xenbus info. The "feature-max-indirect-segments" node contains the maximum + * number of segments allowed by the backend per request. If the node is + * present, the frontend might use blkif_request_indirect structs in order to + * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The + * maximum number of indirect segments is fixed by the backend, but the + * frontend can issue requests with any number of indirect segments as long as + * it's less than the number provided by the backend. The indirect_grefs field + * in blkif_request_indirect should be filled by the frontend with the + * grant references of the pages that are holding the indirect segments. + * These pages are filled with an array of blkif_request_segment that hold the + * information about the segments. The number of indirect pages to use is + * determined by the number of segments an indirect request contains. Every + * indirect page can contain a maximum of + * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to + * calculate the number of indirect pages to use we have to do + * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))). + * + * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not* + * create the "feature-max-indirect-segments" node! + */ +#define BLKIF_OP_INDIRECT 6 + +/* + * Maximum scatter/gather segments per request. + * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE. + * NB. This could be 12 if the ring indexes weren't stored in the same page. + */ +#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 + +/* + * Maximum number of indirect pages to use per request. + */ +#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8 + +/* + * NB. first_sect and last_sect in blkif_request_segment, as well as + * sector_number in blkif_request, are always expressed in 512-byte units. + * However they must be properly aligned to the real sector size of the + * physical disk, which is reported in the "physical-sector-size" node in + * the backend xenbus info. Also the xenbus "sectors" node is expressed in + * 512-byte units. + */ +struct blkif_request_segment { + grant_ref_t gref; /* reference to I/O buffer frame */ + /* @first_sect: first sector in frame to transfer (inclusive). */ + /* @last_sect: last sector in frame to transfer (inclusive). */ + uint8_t first_sect, last_sect; +}; + +/* + * Starting ring element for any I/O request. + */ +struct blkif_request { + uint8_t operation; /* BLKIF_OP_??? */ + uint8_t nr_segments; /* number of segments */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; +}; +typedef struct blkif_request blkif_request_t; + +/* + * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD + * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request) + */ +struct blkif_request_discard { + uint8_t operation; /* BLKIF_OP_DISCARD */ + uint8_t flag; /* BLKIF_DISCARD_SECURE or zero */ +#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ + blkif_vdev_t handle; /* same as for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk */ + uint64_t nr_sectors; /* number of contiguous sectors to discard*/ +}; +typedef struct blkif_request_discard blkif_request_discard_t; + +struct blkif_request_indirect { + uint8_t operation; /* BLKIF_OP_INDIRECT */ + uint8_t indirect_op; /* BLKIF_OP_{READ/WRITE} */ + uint16_t nr_segments; /* number of segments */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + blkif_vdev_t handle; /* same as for read/write requests */ + grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; +#ifdef __i386__ + uint64_t pad; /* Make it 64 byte aligned on i386 */ +#endif +}; +typedef struct blkif_request_indirect blkif_request_indirect_t; + +struct blkif_response { + uint64_t id; /* copied from request */ + uint8_t operation; /* copied from request */ + int16_t status; /* BLKIF_RSP_??? */ +}; +typedef struct blkif_response blkif_response_t; + +/* + * STATUS RETURN CODES. + */ + /* Operation not supported (only happens on barrier writes). */ +#define BLKIF_RSP_EOPNOTSUPP -2 + /* Operation failed for some unspecified reason (-EIO). */ +#define BLKIF_RSP_ERROR -1 + /* Operation completed successfully. */ +#define BLKIF_RSP_OKAY 0 + +/* + * Generate blkif ring structures and types. + */ +DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); + +#define VDISK_CDROM 0x1 +#define VDISK_REMOVABLE 0x2 +#define VDISK_READONLY 0x4 + +#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/console.h b/include/xen/io/console.h new file mode 100644 index 000000000..e2cd97f77 --- /dev/null +++ b/include/xen/io/console.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * console.h + * + * Console I/O interface for Xen guest OSes. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2005, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ +#define __XEN_PUBLIC_IO_CONSOLE_H__ + +typedef uint32_t XENCONS_RING_IDX; + +#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) + +struct xencons_interface { + char in[1024]; + char out[2048]; + XENCONS_RING_IDX in_cons, in_prod; + XENCONS_RING_IDX out_cons, out_prod; +}; + +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/protocols.h b/include/xen/io/protocols.h new file mode 100644 index 000000000..80b196bc3 --- /dev/null +++ b/include/xen/io/protocols.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * protocols.h + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PROTOCOLS_H__ +#define __XEN_PROTOCOLS_H__ + +#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" +#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" +#define XEN_IO_PROTO_ABI_ARM "arm-abi" + +#if defined(__i386__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 +#elif defined(__x86_64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 +#elif defined(__arm__) || defined(__aarch64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM +#else +# error arch fixup needed here +#endif + +#endif diff --git a/include/xen/io/ring.h b/include/xen/io/ring.h new file mode 100644 index 000000000..73e13d7ae --- /dev/null +++ b/include/xen/io/ring.h @@ -0,0 +1,312 @@ +/****************************************************************************** + * ring.h + * + * Shared producer-consumer ring macros. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Tim Deegan and Andrew Warfield November 2004. + */ + +#ifndef __XEN_PUBLIC_IO_RING_H__ +#define __XEN_PUBLIC_IO_RING_H__ + +#include "../xen-compat.h" + +#if __XEN_INTERFACE_VERSION__ < 0x00030208 +#define xen_mb() mb() +#define xen_rmb() rmb() +#define xen_wmb() wmb() +#endif + +typedef unsigned int RING_IDX; + +/* Round a 32-bit unsigned constant down to the nearest power of two. */ +#define __RD2(_x) (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1)) +#define __RD4(_x) (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x)) +#define __RD8(_x) (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x)) +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x)) +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x)) + +/* + * Calculate size of a shared ring, given the total available space for the + * ring and indexes (_sz), and the name tag of the request/response structure. + * A ring contains as many entries as will fit, rounded down to the nearest + * power of two (so we can mask with (size-1) to loop around). + */ +#define __CONST_RING_SIZE(_s, _sz) \ + (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ + sizeof(((struct _s##_sring *)0)->ring[0]))) +/* + * The same for passing in an actual pointer instead of a name tag. + */ +#define __RING_SIZE(_s, _sz) \ + (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) + +/* + * Macros to make the correct C datatypes for a new kind of ring. + * + * To make a new ring datatype, you need to have two message structures, + * let's say request_t, and response_t already defined. + * + * In a header where you want the ring datatype declared, you then do: + * + * DEFINE_RING_TYPES(mytag, request_t, response_t); + * + * These expand out to give you a set of types, as you can see below. + * The most important of these are: + * + * mytag_sring_t - The shared ring. + * mytag_front_ring_t - The 'front' half of the ring. + * mytag_back_ring_t - The 'back' half of the ring. + * + * To initialize a ring in your code you need to know the location and size + * of the shared memory area (PAGE_SIZE, for instance). To initialise + * the front half: + * + * mytag_front_ring_t front_ring; + * SHARED_RING_INIT((mytag_sring_t *)shared_page); + * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); + * + * Initializing the back follows similarly (note that only the front + * initializes the shared ring): + * + * mytag_back_ring_t back_ring; + * BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); + */ + +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t) \ + \ +/* Shared ring entry */ \ +union __name##_sring_entry { \ + __req_t req; \ + __rsp_t rsp; \ +}; \ + \ +/* Shared ring page */ \ +struct __name##_sring { \ + RING_IDX req_prod, req_event; \ + RING_IDX rsp_prod, rsp_event; \ + union { \ + struct { \ + uint8_t smartpoll_active; \ + } netif; \ + struct { \ + uint8_t msg; \ + } tapif_user; \ + uint8_t pvt_pad[4]; \ + } private; \ + uint8_t __pad[44]; \ + union __name##_sring_entry ring[1]; /* variable-length */ \ +}; \ + \ +/* "Front" end's private variables */ \ +struct __name##_front_ring { \ + RING_IDX req_prod_pvt; \ + RING_IDX rsp_cons; \ + unsigned int nr_ents; \ + struct __name##_sring *sring; \ +}; \ + \ +/* "Back" end's private variables */ \ +struct __name##_back_ring { \ + RING_IDX rsp_prod_pvt; \ + RING_IDX req_cons; \ + unsigned int nr_ents; \ + struct __name##_sring *sring; \ +}; \ + \ +/* Syntactic sugar */ \ +typedef struct __name##_sring __name##_sring_t; \ +typedef struct __name##_front_ring __name##_front_ring_t; \ +typedef struct __name##_back_ring __name##_back_ring_t + +/* + * Macros for manipulating rings. + * + * FRONT_RING_whatever works on the "front end" of a ring: here + * requests are pushed on to the ring and responses taken off it. + * + * BACK_RING_whatever works on the "back end" of a ring: here + * requests are taken off the ring and responses put on. + * + * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. + * This is OK in 1-for-1 request-response situations where the + * requestor (front end) never has more than RING_SIZE()-1 + * outstanding requests. + */ + +/* Initialising empty rings */ +#define SHARED_RING_INIT(_s) do { \ + (_s)->req_prod = (_s)->rsp_prod = 0; \ + (_s)->req_event = (_s)->rsp_event = 1; \ + (void)memset((_s)->private.pvt_pad, 0, sizeof((_s)->private.pvt_pad)); \ + (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \ +} while(0) + +#define FRONT_RING_INIT(_r, _s, __size) do { \ + (_r)->req_prod_pvt = 0; \ + (_r)->rsp_cons = 0; \ + (_r)->nr_ents = __RING_SIZE(_s, __size); \ + (_r)->sring = (_s); \ +} while (0) + +#define BACK_RING_INIT(_r, _s, __size) do { \ + (_r)->rsp_prod_pvt = 0; \ + (_r)->req_cons = 0; \ + (_r)->nr_ents = __RING_SIZE(_s, __size); \ + (_r)->sring = (_s); \ +} while (0) + +/* How big is this ring? */ +#define RING_SIZE(_r) \ + ((_r)->nr_ents) + +/* Number of free requests (for use on front side only). */ +#define RING_FREE_REQUESTS(_r) \ + (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons)) + +/* Test if there is an empty slot available on the front ring. + * (This is only meaningful from the front. ) + */ +#define RING_FULL(_r) \ + (RING_FREE_REQUESTS(_r) == 0) + +/* Test if there are outstanding messages to be processed on a ring. */ +#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ + ((_r)->sring->rsp_prod - (_r)->rsp_cons) + +#ifdef __GNUC__ +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ + unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ + unsigned int rsp = RING_SIZE(_r) - \ + ((_r)->req_cons - (_r)->rsp_prod_pvt); \ + req < rsp ? req : rsp; \ +}) +#else +/* Same as above, but without the nice GCC ({ ... }) syntax. */ +#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ + ((((_r)->sring->req_prod - (_r)->req_cons) < \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ + ((_r)->sring->req_prod - (_r)->req_cons) : \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) +#endif + +/* Direct access to individual ring elements, by index. */ +#define RING_GET_REQUEST(_r, _idx) \ + (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) + +#define RING_GET_RESPONSE(_r, _idx) \ + (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) + +/* Loop termination condition: Would the specified index overflow the ring? */ +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ + (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) + +/* Ill-behaved frontend determination: Can there be this many requests? */ +#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ + (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) + +#define RING_PUSH_REQUESTS(_r) do { \ + xen_wmb(); /* back sees requests /before/ updated producer index */ \ + (_r)->sring->req_prod = (_r)->req_prod_pvt; \ +} while (0) + +#define RING_PUSH_RESPONSES(_r) do { \ + xen_wmb(); /* front sees resps /before/ updated producer index */ \ + (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \ +} while (0) + +/* + * Notification hold-off (req_event and rsp_event): + * + * When queueing requests or responses on a shared ring, it may not always be + * necessary to notify the remote end. For example, if requests are in flight + * in a backend, the front may be able to queue further requests without + * notifying the back (if the back checks for new requests when it queues + * responses). + * + * When enqueuing requests or responses: + * + * Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument + * is a boolean return value. True indicates that the receiver requires an + * asynchronous notification. + * + * After dequeuing requests or responses (before sleeping the connection): + * + * Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES(). + * The second argument is a boolean return value. True indicates that there + * are pending messages on the ring (i.e., the connection should not be put + * to sleep). + * + * These macros will set the req_event/rsp_event field to trigger a + * notification on the very next message that is enqueued. If you want to + * create batches of work (i.e., only receive a notification after several + * messages have been enqueued) then you will need to create a customised + * version of the FINAL_CHECK macro in your own code, which sets the event + * field appropriately. + */ + +#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \ + RING_IDX __old = (_r)->sring->req_prod; \ + RING_IDX __new = (_r)->req_prod_pvt; \ + xen_wmb(); /* back sees requests /before/ updated producer index */ \ + (_r)->sring->req_prod = __new; \ + xen_mb(); /* back sees new requests /before/ we check req_event */ \ + (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \ + (RING_IDX)(__new - __old)); \ +} while (0) + +#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \ + RING_IDX __old = (_r)->sring->rsp_prod; \ + RING_IDX __new = (_r)->rsp_prod_pvt; \ + xen_wmb(); /* front sees resps /before/ updated producer index */ \ + (_r)->sring->rsp_prod = __new; \ + xen_mb(); /* front sees new resps /before/ we check rsp_event */ \ + (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \ + (RING_IDX)(__new - __old)); \ +} while (0) + +#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do { \ + (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ + if (_work_to_do) break; \ + (_r)->sring->req_event = (_r)->req_cons + 1; \ + xen_mb(); \ + (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ +} while (0) + +#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do { \ + (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ + if (_work_to_do) break; \ + (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \ + xen_mb(); \ + (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ +} while (0) + +#endif /* __XEN_PUBLIC_IO_RING_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/xenbus.h b/include/xen/io/xenbus.h new file mode 100644 index 000000000..927f9db55 --- /dev/null +++ b/include/xen/io/xenbus.h @@ -0,0 +1,80 @@ +/***************************************************************************** + * xenbus.h + * + * Xenbus protocol details. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (C) 2005 XenSource Ltd. + */ + +#ifndef _XEN_PUBLIC_IO_XENBUS_H +#define _XEN_PUBLIC_IO_XENBUS_H + +/* + * The state of either end of the Xenbus, i.e. the current communication + * status of initialisation across the bus. States here imply nothing about + * the state of the connection between the driver and the kernel's device + * layers. + */ +enum xenbus_state { + XenbusStateUnknown = 0, + + XenbusStateInitialising = 1, + + /* + * InitWait: Finished early initialisation but waiting for information + * from the peer or hotplug scripts. + */ + XenbusStateInitWait = 2, + + /* + * Initialised: Waiting for a connection from the peer. + */ + XenbusStateInitialised = 3, + + XenbusStateConnected = 4, + + /* + * Closing: The device is being closed due to an error or an unplug event. + */ + XenbusStateClosing = 5, + + XenbusStateClosed = 6, + + /* + * Reconfiguring: The device is being reconfigured. + */ + XenbusStateReconfiguring = 7, + + XenbusStateReconfigured = 8 +}; +typedef enum xenbus_state XenbusState; + +#endif /* _XEN_PUBLIC_IO_XENBUS_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/xs_wire.h b/include/xen/io/xs_wire.h new file mode 100644 index 000000000..585f0c8f5 --- /dev/null +++ b/include/xen/io/xs_wire.h @@ -0,0 +1,138 @@ +/* + * Details of the "wire" protocol between Xen Store Daemon and client + * library or guest kernel. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (C) 2005 Rusty Russell IBM Corporation + */ + +#ifndef _XS_WIRE_H +#define _XS_WIRE_H + +enum xsd_sockmsg_type +{ + XS_DEBUG, + XS_DIRECTORY, + XS_READ, + XS_GET_PERMS, + XS_WATCH, + XS_UNWATCH, + XS_TRANSACTION_START, + XS_TRANSACTION_END, + XS_INTRODUCE, + XS_RELEASE, + XS_GET_DOMAIN_PATH, + XS_WRITE, + XS_MKDIR, + XS_RM, + XS_SET_PERMS, + XS_WATCH_EVENT, + XS_ERROR, + XS_IS_DOMAIN_INTRODUCED, + XS_RESUME, + XS_SET_TARGET, + XS_RESTRICT, + XS_RESET_WATCHES +}; + +#define XS_WRITE_NONE "NONE" +#define XS_WRITE_CREATE "CREATE" +#define XS_WRITE_CREATE_EXCL "CREATE|EXCL" + +/* We hand errors as strings, for portability. */ +struct xsd_errors +{ + int errnum; + const char *errstring; +}; +#ifdef EINVAL +#define XSD_ERROR(x) { x, #x } +/* LINTED: static unused */ +static struct xsd_errors xsd_errors[] +#if defined(__GNUC__) +__attribute__((unused)) +#endif + = { + XSD_ERROR(EINVAL), + XSD_ERROR(EACCES), + XSD_ERROR(EEXIST), + XSD_ERROR(EISDIR), + XSD_ERROR(ENOENT), + XSD_ERROR(ENOMEM), + XSD_ERROR(ENOSPC), + XSD_ERROR(EIO), + XSD_ERROR(ENOTEMPTY), + XSD_ERROR(ENOSYS), + XSD_ERROR(EROFS), + XSD_ERROR(EBUSY), + XSD_ERROR(EAGAIN), + XSD_ERROR(EISCONN), + XSD_ERROR(E2BIG) +}; +#endif + +struct xsd_sockmsg +{ + uint32_t type; /* XS_??? */ + uint32_t req_id;/* Request identifier, echoed in daemon's response. */ + uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */ + uint32_t len; /* Length of data following this. */ + + /* Generally followed by nul-terminated string(s). */ +}; + +enum xs_watch_type +{ + XS_WATCH_PATH = 0, + XS_WATCH_TOKEN +}; + +/* + * `incontents 150 xenstore_struct XenStore wire protocol. + * + * Inter-domain shared memory communications. */ +#define XENSTORE_RING_SIZE 1024 +typedef uint32_t XENSTORE_RING_IDX; +#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1)) +struct xenstore_domain_interface { + char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */ + char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */ + XENSTORE_RING_IDX req_cons, req_prod; + XENSTORE_RING_IDX rsp_cons, rsp_prod; +}; + +/* Violating this is very bad. See docs/misc/xenstore.txt. */ +#define XENSTORE_PAYLOAD_MAX 4096 + +/* Violating these just gets you an error back */ +#define XENSTORE_ABS_PATH_MAX 3072 +#define XENSTORE_REL_PATH_MAX 2048 + +#endif /* _XS_WIRE_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/sched.h b/include/xen/sched.h new file mode 100644 index 000000000..a30b11d96 --- /dev/null +++ b/include/xen/sched.h @@ -0,0 +1,174 @@ +/****************************************************************************** + * sched.h + * + * Scheduler state interactions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2005, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_SCHED_H__ +#define __XEN_PUBLIC_SCHED_H__ + +#include "event_channel.h" + +/* + * `incontents 150 sched Guest Scheduler Operations + * + * The SCHEDOP interface provides mechanisms for a guest to interact + * with the scheduler, including yield, blocking and shutting itself + * down. + */ + +/* + * The prototype for this hypercall is: + * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...) + * + * @cmd == SCHEDOP_??? (scheduler operation). + * @arg == Operation-specific extra argument(s), as described below. + * ... == Additional Operation-specific extra arguments, described below. + * + * Versions of Xen prior to 3.0.2 provided only the following legacy version + * of this hypercall, supporting only the commands yield, block and shutdown: + * long sched_op(int cmd, unsigned long arg) + * @cmd == SCHEDOP_??? (scheduler operation). + * @arg == 0 (SCHEDOP_yield and SCHEDOP_block) + * == SHUTDOWN_* code (SCHEDOP_shutdown) + * + * This legacy version is available to new guests as: + * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg) + */ + +/* ` enum sched_op { // SCHEDOP_* => struct sched_* */ +/* + * Voluntarily yield the CPU. + * @arg == NULL. + */ +#define SCHEDOP_yield 0 + +/* + * Block execution of this VCPU until an event is received for processing. + * If called with event upcalls masked, this operation will atomically + * reenable event delivery and check for pending events before blocking the + * VCPU. This avoids a "wakeup waiting" race. + * @arg == NULL. + */ +#define SCHEDOP_block 1 + +/* + * Halt execution of this domain (all VCPUs) and notify the system controller. + * @arg == pointer to sched_shutdown_t structure. + * + * If the sched_shutdown_t reason is SHUTDOWN_suspend then this + * hypercall takes an additional extra argument which should be the + * MFN of the guest's start_info_t. + * + * In addition, which reason is SHUTDOWN_suspend this hypercall + * returns 1 if suspend was cancelled or the domain was merely + * checkpointed, and 0 if it is resuming in a new domain. + */ +#define SCHEDOP_shutdown 2 + +/* + * Poll a set of event-channel ports. Return when one or more are pending. An + * optional timeout may be specified. + * @arg == pointer to sched_poll_t structure. + */ +#define SCHEDOP_poll 3 + +/* + * Declare a shutdown for another domain. The main use of this function is + * in interpreting shutdown requests and reasons for fully-virtualized + * domains. A para-virtualized domain may use SCHEDOP_shutdown directly. + * @arg == pointer to sched_remote_shutdown_t structure. + */ +#define SCHEDOP_remote_shutdown 4 + +/* + * Latch a shutdown code, so that when the domain later shuts down it + * reports this code to the control tools. + * @arg == sched_shutdown_t, as for SCHEDOP_shutdown. + */ +#define SCHEDOP_shutdown_code 5 + +/* + * Setup, poke and destroy a domain watchdog timer. + * @arg == pointer to sched_watchdog_t structure. + * With id == 0, setup a domain watchdog timer to cause domain shutdown + * after timeout, returns watchdog id. + * With id != 0 and timeout == 0, destroy domain watchdog timer. + * With id != 0 and timeout != 0, poke watchdog timer and set new timeout. + */ +#define SCHEDOP_watchdog 6 +/* ` } */ + +struct sched_shutdown { + unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ +}; +typedef struct sched_shutdown sched_shutdown_t; +DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t); + +struct sched_poll { + XEN_GUEST_HANDLE(evtchn_port_t) ports; + unsigned int nr_ports; + uint64_t timeout; +}; +typedef struct sched_poll sched_poll_t; +DEFINE_XEN_GUEST_HANDLE(sched_poll_t); + +struct sched_remote_shutdown { + domid_t domain_id; /* Remote domain ID */ + unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ +}; +typedef struct sched_remote_shutdown sched_remote_shutdown_t; +DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t); + +struct sched_watchdog { + uint32_t id; /* watchdog ID */ + uint32_t timeout; /* timeout */ +}; +typedef struct sched_watchdog sched_watchdog_t; +DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t); + +/* + * Reason codes for SCHEDOP_shutdown. These may be interpreted by control + * software to determine the appropriate action. For the most part, Xen does + * not care about the shutdown code. + */ +/* ` enum sched_shutdown_reason { */ +#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */ +#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ +#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ +#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */ +#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */ +#define SHUTDOWN_MAX 4 /* Maximum valid shutdown reason. */ +/* ` } */ + +#endif /* __XEN_PUBLIC_SCHED_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/xen-compat.h b/include/xen/xen-compat.h new file mode 100644 index 000000000..3eb80a02d --- /dev/null +++ b/include/xen/xen-compat.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * xen-compat.h + * + * Guest OS interface to Xen. Compatibility layer. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2006, Christian Limpach + */ + +#ifndef __XEN_PUBLIC_XEN_COMPAT_H__ +#define __XEN_PUBLIC_XEN_COMPAT_H__ + +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040400 + +#if defined(__XEN__) || defined(__XEN_TOOLS__) +/* Xen is built with matching headers and implements the latest interface. */ +#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__ +#elif !defined(__XEN_INTERFACE_VERSION__) +/* Guests which do not specify a version get the legacy interface. */ +#define __XEN_INTERFACE_VERSION__ 0x00000000 +#endif + +#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__ +#error "These header files do not support the requested interface version." +#endif + +#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */ diff --git a/include/xen/xen.h b/include/xen/xen.h new file mode 100644 index 000000000..a6a20926a --- /dev/null +++ b/include/xen/xen.h @@ -0,0 +1,899 @@ +/****************************************************************************** + * xen.h + * + * Guest OS interface to Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004, K A Fraser + */ + +#ifndef __XEN_PUBLIC_XEN_H__ +#define __XEN_PUBLIC_XEN_H__ + +#include "xen-compat.h" + +#if defined(__i386__) || defined(__x86_64__) +#include "arch-x86/xen.h" +#elif defined(__arm__) || defined (__aarch64__) +#include "arch-arm.h" +#else +#error "Unsupported architecture" +#endif + +#ifndef __ASSEMBLY__ +/* Guest handles for primitive C types. */ +DEFINE_XEN_GUEST_HANDLE(char); +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); +DEFINE_XEN_GUEST_HANDLE(int); +__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); +#if __XEN_INTERFACE_VERSION__ < 0x00040300 +DEFINE_XEN_GUEST_HANDLE(long); +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); +#endif +DEFINE_XEN_GUEST_HANDLE(void); + +DEFINE_XEN_GUEST_HANDLE(uint64_t); +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); +DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); +#endif + +/* + * HYPERCALLS + */ + +/* `incontents 100 hcalls List of hypercalls + * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*() + */ + +#define __HYPERVISOR_set_trap_table 0 +#define __HYPERVISOR_mmu_update 1 +#define __HYPERVISOR_set_gdt 2 +#define __HYPERVISOR_stack_switch 3 +#define __HYPERVISOR_set_callbacks 4 +#define __HYPERVISOR_fpu_taskswitch 5 +#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */ +#define __HYPERVISOR_platform_op 7 +#define __HYPERVISOR_set_debugreg 8 +#define __HYPERVISOR_get_debugreg 9 +#define __HYPERVISOR_update_descriptor 10 +#define __HYPERVISOR_memory_op 12 +#define __HYPERVISOR_multicall 13 +#define __HYPERVISOR_update_va_mapping 14 +#define __HYPERVISOR_set_timer_op 15 +#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */ +#define __HYPERVISOR_xen_version 17 +#define __HYPERVISOR_console_io 18 +#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */ +#define __HYPERVISOR_grant_table_op 20 +#define __HYPERVISOR_vm_assist 21 +#define __HYPERVISOR_update_va_mapping_otherdomain 22 +#define __HYPERVISOR_iret 23 /* x86 only */ +#define __HYPERVISOR_vcpu_op 24 +#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */ +#define __HYPERVISOR_mmuext_op 26 +#define __HYPERVISOR_xsm_op 27 +#define __HYPERVISOR_nmi_op 28 +#define __HYPERVISOR_sched_op 29 +#define __HYPERVISOR_callback_op 30 +#define __HYPERVISOR_xenoprof_op 31 +#define __HYPERVISOR_event_channel_op 32 +#define __HYPERVISOR_physdev_op 33 +#define __HYPERVISOR_hvm_op 34 +#define __HYPERVISOR_sysctl 35 +#define __HYPERVISOR_domctl 36 +#define __HYPERVISOR_kexec_op 37 +#define __HYPERVISOR_tmem_op 38 +#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ + +/* Architecture-specific hypercall definitions. */ +#define __HYPERVISOR_arch_0 48 +#define __HYPERVISOR_arch_1 49 +#define __HYPERVISOR_arch_2 50 +#define __HYPERVISOR_arch_3 51 +#define __HYPERVISOR_arch_4 52 +#define __HYPERVISOR_arch_5 53 +#define __HYPERVISOR_arch_6 54 +#define __HYPERVISOR_arch_7 55 + +/* ` } */ + +/* + * HYPERCALL COMPATIBILITY. + */ + +/* New sched_op hypercall introduced in 0x00030101. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030101 +#undef __HYPERVISOR_sched_op +#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat +#endif + +/* New event-channel and physdev hypercalls introduced in 0x00030202. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030202 +#undef __HYPERVISOR_event_channel_op +#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat +#undef __HYPERVISOR_physdev_op +#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat +#endif + +/* New platform_op hypercall introduced in 0x00030204. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030204 +#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op +#endif + +/* + * VIRTUAL INTERRUPTS + * + * Virtual interrupts that a guest OS may receive from Xen. + * + * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a + * global VIRQ. The former can be bound once per VCPU and cannot be re-bound. + * The latter can be allocated only once per guest: they must initially be + * allocated to VCPU0 but can subsequently be re-bound. + */ +/* ` enum virq { */ +#define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */ +#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */ +#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */ +#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */ +#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */ +#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */ +#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */ +#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */ +#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */ +#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */ +#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */ +#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */ + +/* Architecture-specific VIRQ definitions. */ +#define VIRQ_ARCH_0 16 +#define VIRQ_ARCH_1 17 +#define VIRQ_ARCH_2 18 +#define VIRQ_ARCH_3 19 +#define VIRQ_ARCH_4 20 +#define VIRQ_ARCH_5 21 +#define VIRQ_ARCH_6 22 +#define VIRQ_ARCH_7 23 +/* ` } */ + +#define NR_VIRQS 24 + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_mmu_update(const struct mmu_update reqs[], + * ` unsigned count, unsigned *done_out, + * ` unsigned foreigndom) + * ` + * @reqs is an array of mmu_update_t structures ((ptr, val) pairs). + * @count is the length of the above array. + * @pdone is an output parameter indicating number of completed operations + * @foreigndom[15:0]: FD, the expected owner of data pages referenced in this + * hypercall invocation. Can be DOMID_SELF. + * @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced + * in this hypercall invocation. The value of this field + * (x) encodes the PFD as follows: + * x == 0 => PFD == DOMID_SELF + * x != 0 => PFD == x - 1 + * + * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command. + * ------------- + * ptr[1:0] == MMU_NORMAL_PT_UPDATE: + * Updates an entry in a page table belonging to PFD. If updating an L1 table, + * and the new table entry is valid/present, the mapped frame must belong to + * FD. If attempting to map an I/O page then the caller assumes the privilege + * of the FD. + * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller. + * FD == DOMID_XEN: Map restricted areas of Xen's heap space. + * ptr[:2] -- Machine address of the page-table entry to modify. + * val -- Value to write. + * + * There also certain implicit requirements when using this hypercall. The + * pages that make up a pagetable must be mapped read-only in the guest. + * This prevents uncontrolled guest updates to the pagetable. Xen strictly + * enforces this, and will disallow any pagetable update which will end up + * mapping pagetable page RW, and will disallow using any writable page as a + * pagetable. In practice it means that when constructing a page table for a + * process, thread, etc, we MUST be very dilligient in following these rules: + * 1). Start with top-level page (PGD or in Xen language: L4). Fill out + * the entries. + * 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD + * or L2). + * 3). Start filling out the PTE table (L1) with the PTE entries. Once + * done, make sure to set each of those entries to RO (so writeable bit + * is unset). Once that has been completed, set the PMD (L2) for this + * PTE table as RO. + * 4). When completed with all of the PMD (L2) entries, and all of them have + * been set to RO, make sure to set RO the PUD (L3). Do the same + * operation on PGD (L4) pagetable entries that have a PUD (L3) entry. + * 5). Now before you can use those pages (so setting the cr3), you MUST also + * pin them so that the hypervisor can verify the entries. This is done + * via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame + * number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op( + * MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be + * issued. + * For 32-bit guests, the L4 is not used (as there is less pagetables), so + * instead use L3. + * At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE + * hypercall. Also if so desired the OS can also try to write to the PTE + * and be trapped by the hypervisor (as the PTE entry is RO). + * + * To deallocate the pages, the operations are the reverse of the steps + * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the + * pagetable MUST not be in use (meaning that the cr3 is not set to it). + * + * ptr[1:0] == MMU_MACHPHYS_UPDATE: + * Updates an entry in the machine->pseudo-physical mapping table. + * ptr[:2] -- Machine address within the frame whose mapping to modify. + * The frame must belong to the FD, if one is specified. + * val -- Value to write into the mapping entry. + * + * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD: + * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed + * with those in @val. + * + * @val is usually the machine frame number along with some attributes. + * The attributes by default follow the architecture defined bits. Meaning that + * if this is a X86_64 machine and four page table layout is used, the layout + * of val is: + * - 63 if set means No execute (NX) + * - 46-13 the machine frame number + * - 12 available for guest + * - 11 available for guest + * - 10 available for guest + * - 9 available for guest + * - 8 global + * - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages) + * - 6 dirty + * - 5 accessed + * - 4 page cached disabled + * - 3 page write through + * - 2 userspace accessible + * - 1 writeable + * - 0 present + * + * The one bits that does not fit with the default layout is the PAGE_PSE + * also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the + * HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB + * (or 2MB) instead of using the PAGE_PSE bit. + * + * The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen + * using it as the Page Attribute Table (PAT) bit - for details on it please + * refer to Intel SDM 10.12. The PAT allows to set the caching attributes of + * pages instead of using MTRRs. + * + * The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits): + * PAT4 PAT0 + * +-----+-----+----+----+----+-----+----+----+ + * | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux + * +-----+-----+----+----+----+-----+----+----+ + * | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots) + * +-----+-----+----+----+----+-----+----+----+ + * | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen + * +-----+-----+----+----+----+-----+----+----+ + * + * The lookup of this index table translates to looking up + * Bit 7, Bit 4, and Bit 3 of val entry: + * + * PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3). + * + * If all bits are off, then we are using PAT0. If bit 3 turned on, + * then we are using PAT1, if bit 3 and bit 4, then PAT2.. + * + * As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means + * that if a guest that follows Linux's PAT setup and would like to set Write + * Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is + * set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the + * caching as: + * + * WB = none (so PAT0) + * WC = PWT (bit 3 on) + * UC = PWT | PCD (bit 3 and 4 are on). + * + * To make it work with Xen, it needs to translate the WC bit as so: + * + * PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3 + * + * And to translate back it would: + * + * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7. + */ +#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */ +#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */ +#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */ + +/* + * MMU EXTENDED OPERATIONS + * + * ` enum neg_errnoval + * ` HYPERVISOR_mmuext_op(mmuext_op_t uops[], + * ` unsigned int count, + * ` unsigned int *pdone, + * ` unsigned int foreigndom) + */ +/* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures. + * A foreigndom (FD) can be specified (or DOMID_SELF for none). + * Where the FD has some effect, it is described below. + * + * cmd: MMUEXT_(UN)PIN_*_TABLE + * mfn: Machine frame number to be (un)pinned as a p.t. page. + * The frame must belong to the FD, if one is specified. + * + * cmd: MMUEXT_NEW_BASEPTR + * mfn: Machine frame number of new page-table base to install in MMU. + * + * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only] + * mfn: Machine frame number of new page-table base to install in MMU + * when in user space. + * + * cmd: MMUEXT_TLB_FLUSH_LOCAL + * No additional arguments. Flushes local TLB. + * + * cmd: MMUEXT_INVLPG_LOCAL + * linear_addr: Linear address to be flushed from the local TLB. + * + * cmd: MMUEXT_TLB_FLUSH_MULTI + * vcpumask: Pointer to bitmap of VCPUs to be flushed. + * + * cmd: MMUEXT_INVLPG_MULTI + * linear_addr: Linear address to be flushed. + * vcpumask: Pointer to bitmap of VCPUs to be flushed. + * + * cmd: MMUEXT_TLB_FLUSH_ALL + * No additional arguments. Flushes all VCPUs' TLBs. + * + * cmd: MMUEXT_INVLPG_ALL + * linear_addr: Linear address to be flushed from all VCPUs' TLBs. + * + * cmd: MMUEXT_FLUSH_CACHE + * No additional arguments. Writes back and flushes cache contents. + * + * cmd: MMUEXT_FLUSH_CACHE_GLOBAL + * No additional arguments. Writes back and flushes cache contents + * on all CPUs in the system. + * + * cmd: MMUEXT_SET_LDT + * linear_addr: Linear address of LDT base (NB. must be page-aligned). + * nr_ents: Number of entries in LDT. + * + * cmd: MMUEXT_CLEAR_PAGE + * mfn: Machine frame number to be cleared. + * + * cmd: MMUEXT_COPY_PAGE + * mfn: Machine frame number of the destination page. + * src_mfn: Machine frame number of the source page. + * + * cmd: MMUEXT_[UN]MARK_SUPER + * mfn: Machine frame number of head of superpage to be [un]marked. + */ +/* ` enum mmuext_cmd { */ +#define MMUEXT_PIN_L1_TABLE 0 +#define MMUEXT_PIN_L2_TABLE 1 +#define MMUEXT_PIN_L3_TABLE 2 +#define MMUEXT_PIN_L4_TABLE 3 +#define MMUEXT_UNPIN_TABLE 4 +#define MMUEXT_NEW_BASEPTR 5 +#define MMUEXT_TLB_FLUSH_LOCAL 6 +#define MMUEXT_INVLPG_LOCAL 7 +#define MMUEXT_TLB_FLUSH_MULTI 8 +#define MMUEXT_INVLPG_MULTI 9 +#define MMUEXT_TLB_FLUSH_ALL 10 +#define MMUEXT_INVLPG_ALL 11 +#define MMUEXT_FLUSH_CACHE 12 +#define MMUEXT_SET_LDT 13 +#define MMUEXT_NEW_USER_BASEPTR 15 +#define MMUEXT_CLEAR_PAGE 16 +#define MMUEXT_COPY_PAGE 17 +#define MMUEXT_FLUSH_CACHE_GLOBAL 18 +#define MMUEXT_MARK_SUPER 19 +#define MMUEXT_UNMARK_SUPER 20 +/* ` } */ + +#ifndef __ASSEMBLY__ +struct mmuext_op { + unsigned int cmd; /* => enum mmuext_cmd */ + union { + /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR + * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */ + xen_pfn_t mfn; + /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */ + unsigned long linear_addr; + } arg1; + union { + /* SET_LDT */ + unsigned int nr_ents; + /* TLB_FLUSH_MULTI, INVLPG_MULTI */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030205 + XEN_GUEST_HANDLE(const_void) vcpumask; +#else + const void *vcpumask; +#endif + /* COPY_PAGE */ + xen_pfn_t src_mfn; + } arg2; +}; +typedef struct mmuext_op mmuext_op_t; +DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); +#endif + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_update_va_mapping(unsigned long va, u64 val, + * ` enum uvm_flags flags) + * ` + * ` enum neg_errnoval + * ` HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, u64 val, + * ` enum uvm_flags flags, + * ` domid_t domid) + * ` + * ` @va: The virtual address whose mapping we want to change + * ` @val: The new page table entry, must contain a machine address + * ` @flags: Control TLB flushes + */ +/* These are passed as 'flags' to update_va_mapping. They can be ORed. */ +/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */ +/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */ +/* ` enum uvm_flags { */ +#define UVMF_NONE (0UL<<0) /* No flushing at all. */ +#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */ +#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */ +#define UVMF_FLUSHTYPE_MASK (3UL<<0) +#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */ +#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */ +#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */ +/* ` } */ + +/* + * Commands to HYPERVISOR_console_io(). + */ +#define CONSOLEIO_write 0 +#define CONSOLEIO_read 1 + +/* + * Commands to HYPERVISOR_vm_assist(). + */ +#define VMASST_CMD_enable 0 +#define VMASST_CMD_disable 1 + +/* x86/32 guests: simulate full 4GB segment limits. */ +#define VMASST_TYPE_4gb_segments 0 + +/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */ +#define VMASST_TYPE_4gb_segments_notify 1 + +/* + * x86 guests: support writes to bottom-level PTEs. + * NB1. Page-directory entries cannot be written. + * NB2. Guest must continue to remove all writable mappings of PTEs. + */ +#define VMASST_TYPE_writable_pagetables 2 + +/* x86/PAE guests: support PDPTs above 4GB. */ +#define VMASST_TYPE_pae_extended_cr3 3 + +#define MAX_VMASST_TYPE 3 + +#ifndef __ASSEMBLY__ + +typedef uint16_t domid_t; + +/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ +#define DOMID_FIRST_RESERVED (0x7FF0U) + +/* DOMID_SELF is used in certain contexts to refer to oneself. */ +#define DOMID_SELF (0x7FF0U) + +/* + * DOMID_IO is used to restrict page-table updates to mapping I/O memory. + * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO + * is useful to ensure that no mappings to the OS's own heap are accidentally + * installed. (e.g., in Linux this could cause havoc as reference counts + * aren't adjusted on the I/O-mapping code path). + * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can + * be specified by any calling domain. + */ +#define DOMID_IO (0x7FF1U) + +/* + * DOMID_XEN is used to allow privileged domains to map restricted parts of + * Xen's heap space (e.g., the machine_to_phys table). + * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if + * the caller is privileged. + */ +#define DOMID_XEN (0x7FF2U) + +/* + * DOMID_COW is used as the owner of sharable pages */ +#define DOMID_COW (0x7FF3U) + +/* DOMID_INVALID is used to identify pages with unknown owner. */ +#define DOMID_INVALID (0x7FF4U) + +/* Idle domain. */ +#define DOMID_IDLE (0x7FFFU) + +/* + * Send an array of these to HYPERVISOR_mmu_update(). + * NB. The fields are natural pointer/address size for this architecture. + */ +struct mmu_update { + uint64_t ptr; /* Machine address of PTE. */ + uint64_t val; /* New contents of PTE. */ +}; +typedef struct mmu_update mmu_update_t; +DEFINE_XEN_GUEST_HANDLE(mmu_update_t); + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_multicall(multicall_entry_t call_list[], + * ` uint32_t nr_calls); + * + * NB. The fields are logically the natural register size for this + * architecture. In cases where xen_ulong_t is larger than this then + * any unused bits in the upper portion must be zero. + */ +struct multicall_entry { + xen_ulong_t op, result; + xen_ulong_t args[6]; +}; +typedef struct multicall_entry multicall_entry_t; +DEFINE_XEN_GUEST_HANDLE(multicall_entry_t); + +#if __XEN_INTERFACE_VERSION__ < 0x00040400 +/* + * Event channel endpoints per domain (when using the 2-level ABI): + * 1024 if a long is 32 bits; 4096 if a long is 64 bits. + */ +#define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS +#endif + +struct vcpu_time_info { + /* + * Updates to the following values are preceded and followed by an + * increment of 'version'. The guest can therefore detect updates by + * looking for changes to 'version'. If the least-significant bit of + * the version number is set then an update is in progress and the guest + * must wait to read a consistent set of values. + * The correct way to interact with the version number is similar to + * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry. + */ + uint32_t version; + uint32_t pad0; + uint64_t tsc_timestamp; /* TSC at last update of time vals. */ + uint64_t system_time; /* Time, in nanosecs, since boot. */ + /* + * Current system time: + * system_time + + * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32) + * CPU frequency (Hz): + * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift + */ + uint32_t tsc_to_system_mul; + int8_t tsc_shift; + int8_t pad1[3]; +}; /* 32 bytes */ +typedef struct vcpu_time_info vcpu_time_info_t; + +struct vcpu_info { + /* + * 'evtchn_upcall_pending' is written non-zero by Xen to indicate + * a pending notification for a particular VCPU. It is then cleared + * by the guest OS /before/ checking for pending work, thus avoiding + * a set-and-check race. Note that the mask is only accessed by Xen + * on the CPU that is currently hosting the VCPU. This means that the + * pending and mask flags can be updated by the guest without special + * synchronisation (i.e., no need for the x86 LOCK prefix). + * This may seem suboptimal because if the pending flag is set by + * a different CPU then an IPI may be scheduled even when the mask + * is set. However, note: + * 1. The task of 'interrupt holdoff' is covered by the per-event- + * channel mask bits. A 'noisy' event that is continually being + * triggered can be masked at source at this very precise + * granularity. + * 2. The main purpose of the per-VCPU mask is therefore to restrict + * reentrant execution: whether for concurrency control, or to + * prevent unbounded stack usage. Whatever the purpose, we expect + * that the mask will be asserted only for short periods at a time, + * and so the likelihood of a 'spurious' IPI is suitably small. + * The mask is read before making an event upcall to the guest: a + * non-zero mask therefore guarantees that the VCPU will not receive + * an upcall activation. The mask is cleared when the VCPU requests + * to block: this avoids wakeup-waiting races. + */ + uint8_t evtchn_upcall_pending; +#ifdef XEN_HAVE_PV_UPCALL_MASK + uint8_t evtchn_upcall_mask; +#else /* XEN_HAVE_PV_UPCALL_MASK */ + uint8_t pad0; +#endif /* XEN_HAVE_PV_UPCALL_MASK */ + xen_ulong_t evtchn_pending_sel; + struct arch_vcpu_info arch; + struct vcpu_time_info time; +}; /* 64 bytes (x86) */ +#ifndef __XEN__ +typedef struct vcpu_info vcpu_info_t; +#endif + +/* + * `incontents 200 startofday_shared Start-of-day shared data structure + * Xen/kernel shared data -- pointer provided in start_info. + * + * This structure is defined to be both smaller than a page, and the + * only data on the shared page, but may vary in actual size even within + * compatible Xen versions; guests should not rely on the size + * of this structure remaining constant. + */ +struct shared_info { + struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS]; + + /* + * A domain can create "event channels" on which it can send and receive + * asynchronous event notifications. There are three classes of event that + * are delivered by this mechanism: + * 1. Bi-directional inter- and intra-domain connections. Domains must + * arrange out-of-band to set up a connection (usually by allocating + * an unbound 'listener' port and avertising that via a storage service + * such as xenstore). + * 2. Physical interrupts. A domain with suitable hardware-access + * privileges can bind an event-channel port to a physical interrupt + * source. + * 3. Virtual interrupts ('events'). A domain can bind an event-channel + * port to a virtual interrupt source, such as the virtual-timer + * device or the emergency console. + * + * Event channels are addressed by a "port index". Each channel is + * associated with two bits of information: + * 1. PENDING -- notifies the domain that there is a pending notification + * to be processed. This bit is cleared by the guest. + * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING + * will cause an asynchronous upcall to be scheduled. This bit is only + * updated by the guest. It is read-only within Xen. If a channel + * becomes pending while the channel is masked then the 'edge' is lost + * (i.e., when the channel is unmasked, the guest must manually handle + * pending notifications as no upcall will be scheduled by Xen). + * + * To expedite scanning of pending notifications, any 0->1 pending + * transition on an unmasked channel causes a corresponding bit in a + * per-vcpu selector word to be set. Each bit in the selector covers a + * 'C long' in the PENDING bitfield array. + */ + xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; + xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8]; + + /* + * Wallclock time: updated only by control software. Guests should base + * their gettimeofday() syscall on this wallclock-base value. + */ + uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */ + uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ + uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */ + + struct arch_shared_info arch; + +}; +#ifndef __XEN__ +typedef struct shared_info shared_info_t; +#endif + +/* + * `incontents 200 startofday Start-of-day memory layout + * + * 1. The domain is started within contiguous virtual-memory region. + * 2. The contiguous region ends on an aligned 4MB boundary. + * 3. This the order of bootstrap elements in the initial virtual region: + * a. relocated kernel image + * b. initial ram disk [mod_start, mod_len] + * c. list of allocated page frames [mfn_list, nr_pages] + * (unless relocated due to XEN_ELFNOTE_INIT_P2M) + * d. start_info_t structure [register ESI (x86)] + * e. bootstrap page tables [pt_base and CR3 (x86)] + * f. bootstrap stack [register ESP (x86)] + * 4. Bootstrap elements are packed together, but each is 4kB-aligned. + * 5. The initial ram disk may be omitted. + * 6. The list of page frames forms a contiguous 'pseudo-physical' memory + * layout for the domain. In particular, the bootstrap virtual-memory + * region is a 1:1 mapping to the first section of the pseudo-physical map. + * 7. All bootstrap elements are mapped read-writable for the guest OS. The + * only exception is the bootstrap page table, which is mapped read-only. + * 8. There is guaranteed to be at least 512kB padding after the final + * bootstrap element. If necessary, the bootstrap virtual region is + * extended by an extra 4MB to ensure this. + * + * Note: Prior to 25833:bb85bbccb1c9. ("x86/32-on-64 adjust Dom0 initial page + * table layout") a bug caused the pt_base (3.e above) and cr3 to not point + * to the start of the guest page tables (it was offset by two pages). + * This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU + * or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got + * allocated in the order: 'first L1','first L2', 'first L3', so the offset + * to the page table base is by two pages back. The initial domain if it is + * 32-bit and runs under a 64-bit hypervisor should _NOT_ use two of the + * pages preceding pt_base and mark them as reserved/unused. + */ +#ifdef XEN_HAVE_PV_GUEST_ENTRY +struct start_info { + /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ + char magic[32]; /* "xen--". */ + unsigned long nr_pages; /* Total pages allocated to this domain. */ + unsigned long shared_info; /* MACHINE address of shared info struct. */ + uint32_t flags; /* SIF_xxx flags. */ + xen_pfn_t store_mfn; /* MACHINE page number of shared page. */ + uint32_t store_evtchn; /* Event channel for store communication. */ + union { + struct { + xen_pfn_t mfn; /* MACHINE page number of console page. */ + uint32_t evtchn; /* Event channel for console page. */ + } domU; + struct { + uint32_t info_off; /* Offset of console_info struct. */ + uint32_t info_size; /* Size of console_info struct from start.*/ + } dom0; + } console; + /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */ + unsigned long pt_base; /* VIRTUAL address of page directory. */ + unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */ + unsigned long mfn_list; /* VIRTUAL address of page-frame list. */ + unsigned long mod_start; /* VIRTUAL address of pre-loaded module */ + /* (PFN of pre-loaded module if */ + /* SIF_MOD_START_PFN set in flags). */ + unsigned long mod_len; /* Size (bytes) of pre-loaded module. */ +#define MAX_GUEST_CMDLINE 1024 + int8_t cmd_line[MAX_GUEST_CMDLINE]; + /* The pfn range here covers both page table and p->m table frames. */ + unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */ + unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */ +}; +typedef struct start_info start_info_t; + +/* New console union for dom0 introduced in 0x00030203. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030203 +#define console_mfn console.domU.mfn +#define console_evtchn console.domU.evtchn +#endif +#endif /* XEN_HAVE_PV_GUEST_ENTRY */ + +/* These flags are passed in the 'flags' field of start_info_t. */ +#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */ +#define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */ +#define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */ +#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */ +#define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */ + +/* + * A multiboot module is a package containing modules very similar to a + * multiboot module array. The only differences are: + * - the array of module descriptors is by convention simply at the beginning + * of the multiboot module, + * - addresses in the module descriptors are based on the beginning of the + * multiboot module, + * - the number of modules is determined by a termination descriptor that has + * mod_start == 0. + * + * This permits to both build it statically and reference it in a configuration + * file, and let the PV guest easily rebase the addresses to virtual addresses + * and at the same time count the number of modules. + */ +struct xen_multiboot_mod_list +{ + /* Address of first byte of the module */ + uint32_t mod_start; + /* Address of last byte of the module (inclusive) */ + uint32_t mod_end; + /* Address of zero-terminated command line */ + uint32_t cmdline; + /* Unused, must be zero */ + uint32_t pad; +}; +/* + * `incontents 200 startofday_dom0_console Dom0_console + * + * The console structure in start_info.console.dom0 + * + * This structure includes a variety of information required to + * have a working VGA/VESA console. + */ +typedef struct dom0_vga_console_info { + uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */ +#define XEN_VGATYPE_TEXT_MODE_3 0x03 +#define XEN_VGATYPE_VESA_LFB 0x23 +#define XEN_VGATYPE_EFI_LFB 0x70 + + union { + struct { + /* Font height, in pixels. */ + uint16_t font_height; + /* Cursor location (column, row). */ + uint16_t cursor_x, cursor_y; + /* Number of rows and columns (dimensions in characters). */ + uint16_t rows, columns; + } text_mode_3; + + struct { + /* Width and height, in pixels. */ + uint16_t width, height; + /* Bytes per scan line. */ + uint16_t bytes_per_line; + /* Bits per pixel. */ + uint16_t bits_per_pixel; + /* LFB physical address, and size (in units of 64kB). */ + uint32_t lfb_base; + uint32_t lfb_size; + /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ + uint8_t red_pos, red_size; + uint8_t green_pos, green_size; + uint8_t blue_pos, blue_size; + uint8_t rsvd_pos, rsvd_size; +#if __XEN_INTERFACE_VERSION__ >= 0x00030206 + /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ + uint32_t gbl_caps; + /* Mode attributes (offset 0x0, VESA command 0x4f01). */ + uint16_t mode_attrs; +#endif + } vesa_lfb; + } u; +} dom0_vga_console_info_t; +#define xen_vga_console_info dom0_vga_console_info +#define xen_vga_console_info_t dom0_vga_console_info_t + +typedef uint8_t xen_domain_handle_t[16]; + +/* Turn a plain number into a C unsigned long constant. */ +#define __mk_unsigned_long(x) x ## UL +#define mk_unsigned_long(x) __mk_unsigned_long(x) + +__DEFINE_XEN_GUEST_HANDLE(uint8, uint8_t); +__DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t); +__DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t); +__DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); + +#else /* __ASSEMBLY__ */ + +/* In assembly code we cannot use C numeric constant suffixes. */ +#define mk_unsigned_long(x) x + +#endif /* !__ASSEMBLY__ */ + +/* Default definitions for macros used by domctl/sysctl. */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +#ifndef uint64_aligned_t +#define uint64_aligned_t uint64_t +#endif +#ifndef XEN_GUEST_HANDLE_64 +#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name) +#endif + +#ifndef __ASSEMBLY__ +struct xenctl_bitmap { + XEN_GUEST_HANDLE_64(uint8) bitmap; + uint32_t nr_bits; +}; +#endif + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +#endif /* __XEN_PUBLIC_XEN_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From b2fc9acdc9674de2b930ee92229917881843ba92 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 21:24:18 +0100 Subject: [PATCH 0368/1167] Adapt build-system to use imported xen headers. --- conf/Makefile.common | 3 --- grub-core/Makefile.core.def | 9 --------- include/grub/xen.h | 7 ++++++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index fcb8d2e1c..5083d5f1e 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -21,9 +21,6 @@ if COND_powerpc_ieee1275 CFLAGS_PLATFORM += -mcpu=powerpc endif -#FIXME: discover and check XEN headers -CPPFLAGS_XEN = -I/usr/include - # Other options CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\" diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 03e04ab39..d9fa0e339 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -59,9 +59,6 @@ kernel = { ia64_efi_ldflags = '-Wl,-r,-d'; ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - x86_64_xen_cppflags = '$(CPPFLAGS_XEN)'; - i386_xen_cppflags = '$(CPPFLAGS_XEN)'; - arm_efi_ldflags = '-Wl,-r,-d'; arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; @@ -604,7 +601,6 @@ module = { module = { name = lsxen; common = commands/xen/lsxen.c; - cppflags = '$(CPPFLAGS_XEN)'; enable = xen; }; @@ -825,7 +821,6 @@ module = { i386_coreboot = lib/i386/halt.c; i386_qemu = lib/i386/halt.c; xen = lib/xen/halt.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; efi = lib/efi/halt.c; ieee1275 = lib/ieee1275/halt.c; emu = lib/emu/halt.c; @@ -846,7 +841,6 @@ module = { mips_loongson = lib/mips/loongson/reboot.c; mips_qemu_mips = lib/mips/qemu_mips/reboot.c; xen = lib/xen/reboot.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; uboot = lib/uboot/reboot.c; common = commands/reboot.c; }; @@ -1526,7 +1520,6 @@ module = { i386_xen = lib/i386/xen/relocator.S; x86_64_xen = lib/x86_64/xen/relocator.S; xen = lib/i386/relocator_common_c.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; extra_dist = lib/i386/relocator_common.S; extra_dist = kern/powerpc/cache_flush.S; @@ -1547,7 +1540,6 @@ module = { sparc64_ieee1275 = lib/ieee1275/cmos.c; powerpc_ieee1275 = lib/ieee1275/cmos.c; xen = lib/xen/datetime.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; mips_arc = lib/arc/datetime.c; enable = noemu; @@ -1657,7 +1649,6 @@ module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; i386_pc = lib/i386/pc/vesa_modes_table.c; mips = loader/mips/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; diff --git a/include/grub/xen.h b/include/grub/xen.h index 9ba3b8e6b..c31cc10c7 100644 --- a/include/grub/xen.h +++ b/include/grub/xen.h @@ -33,7 +33,12 @@ #include #ifndef GRUB_SYMBOL_GENERATOR -#include +typedef grub_int8_t int8_t; +typedef grub_int16_t int16_t; +typedef grub_uint8_t uint8_t; +typedef grub_uint16_t uint16_t; +typedef grub_uint32_t uint32_t; +typedef grub_uint64_t uint64_t; #include #include From 4656ced41c8fa61d462b92d28878d9cdb8493120 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 22:39:36 +0100 Subject: [PATCH 0369/1167] fstester: Enforce LC_ALL=C --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 29ae69153..424de2267 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -10,7 +10,7 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 # This wrapper is to ease insertion of valgrind or time statistics run_it () { - "$GRUBFSTEST" "$@" + LC_ALL=C "$GRUBFSTEST" "$@" } run_grubfstest () { From cb28250cfce1da059d94b57eee54cb250bb786fe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 03:24:04 +0100 Subject: [PATCH 0370/1167] cbfs: Fix corner case and compilation with recdent gcc Accept the header to touch the jump address at 0xfffffff0. Fix compilation for 64-bit EFI with recent GCC. --- grub-core/fs/cbfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 5fc9c0147..0842701a6 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -352,7 +352,7 @@ init_cbfsdisk (void) reading ROMs through controller directly. */ if (ptr < 0xff000000 - || 0xffffffff - ptr < sizeof (*head) + 0x10 + || 0xffffffff - ptr < (grub_uint32_t) sizeof (*head) + 0xf || !validate_head (head)) return; From 254f92815b6e4a862ce6d91afe542f0abefd27e7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 11:39:30 +0100 Subject: [PATCH 0371/1167] kern/elf: Ignore cast-align warnings --- grub-core/kern/elf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 00de36984..4f282c9cf 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -28,6 +28,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#pragma GCC diagnostic ignored "-Wcast-align" + #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) #define GRUB_ELF_ENABLE_BI_ENDIAN 1 #else From 372400b4199228c9db15b914c1614fa3ec869722 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Mon, 9 Nov 2015 15:27:59 +0100 Subject: [PATCH 0372/1167] fdt.mod: Add missing license tag. --- grub-core/loader/arm64/fdt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index 5202c14e0..901bd7b68 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static void *loaded_fdt; static void *fdt; From 25a9b8f208653ee288c74d2cdccfc33446a0d30f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 16:15:30 +0100 Subject: [PATCH 0373/1167] fdt.mod: Move license tag to the right file. --- grub-core/lib/fdt.c | 3 +++ grub-core/loader/arm64/fdt.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 7e76dc06b..b5d520f20 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -19,6 +19,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); #define FDT_SUPPORTED_VERSION 17 diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index 901bd7b68..5202c14e0 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -25,8 +25,6 @@ #include #include -GRUB_MOD_LICENSE ("GPLv3+"); - static void *loaded_fdt; static void *fdt; From a50dbb743e53e5e643f27daa84261e6e9d7747c1 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 10 Nov 2015 21:20:20 -0200 Subject: [PATCH 0374/1167] ofdisk: add a comment about vscsi method --- grub-core/disk/ieee1275/ofdisk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 297f058ee..0efe59a66 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -227,7 +227,10 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) if (grub_ieee1275_open (alias->path, &ihandle)) return; - + + /* This method doesn't need memory allocation for the table. Open + firmware takes care of all memory management and the result table + stays in memory and is never freed. */ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); args.method = (grub_ieee1275_cell_t) "vscsi-report-luns"; args.ihandle = ihandle; From 323ef2bdc358b90f0894223a6424df036c6dfe02 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 11 Nov 2015 18:58:57 +0100 Subject: [PATCH 0375/1167] asm-tests/i386-pc: Check that near jumps are 2 bytes. We already check that jump over 300 bytes gap is 3 bytes in code16-mode. Some clang versions generate 3-byte opcode for short jumps which makes boot.img blow over 512-byte limit. Enforce -no-integrated-as in such cases --- asm-tests/i386-pc.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S index 97cd32ae8..f6f9a88be 100644 --- a/asm-tests/i386-pc.S +++ b/asm-tests/i386-pc.S @@ -5,6 +5,10 @@ .code16 jmp far .org 4 - .space 300 + jmp nearer + .org 6 + .space 100 +nearer: + .space 200 far: .byte 0 From fb94736fe87353de1b99fe6c88887171559eca50 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 12 Nov 2015 11:32:01 +0100 Subject: [PATCH 0376/1167] Document ARM64 xen commands --- docs/grub.texi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index db765a3b5..1df3db260 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3857,6 +3857,11 @@ you forget a command, you can run the command @command{help} @comment * vbeinfo:: List available video modes * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes +@comment * xen_*:: Xen boot commands +* xen_hypervisor:: Load xen hypervisor binary +* xen_linux:: Load dom0 kernel for xen hypervisor +* xen_initrd:: Load dom0 initrd for dom0 kernel +* xen_xsm:: Load xen security module for xen hypervisor @end menu @@ -5120,6 +5125,39 @@ successfully. If validation fails, it is set to a non-zero value. List available video modes. If resolution is given, show only matching modes. @end deffn +@node xen_hypervisor +@subsection xen_hypervisor + +@deffn Command xen_hypervisor file [arguments] @dots{} +Load a Xen hypervisor binary from @var{file}. The rest of the line is passed +verbatim as the @dfn{kernel command-line}. Any other binaries must be +reloaded after using this command. +@end deffn + +@node xen_linux +@subsection xen_linux + +@deffn Command xen_linux file [arguments] +Load a dom0 kernel image for xen hypervisor at the booting process of xen. +The rest of the line is passed verbatim as the module command line. +@end deffn + +@node xen_initrd +@subsection xen_initrd + +@deffn Command xen_initrd file +Load a initrd image for dom0 kernel at the booting process of xen. +@end deffn + +@node xen_xsm +@subsection xen_xsm + +@deffn Command xen_xsm file +Load a xen security module for xen hypervisor at the booting process of xen. +See @uref{http://wiki.xen.org/wiki/XSM} for more detail. +@end deffn + + @node Networking commands @section The list of networking commands From a771a7b9f61653dbcff684e8ab62bc8e0daf5844 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 12 Nov 2015 11:33:55 +0100 Subject: [PATCH 0377/1167] xen_boot: Remove useless file_name_index variable. --- grub-core/loader/arm64/xen_boot.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index fc5bb0c86..d1a218929 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -136,16 +136,10 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align) return (align ? (ALIGN_UP (start, align)) : start); } -/* Parse the option of xen_module command. For now, we support - (1) --type - We also set up the type of module in this function. - If there are some "--type" options in the command line, - we make a custom compatible stream in this function. */ +/* set module type according to command name. */ static grub_err_t -set_module_type (grub_command_t cmd, struct xen_boot_binary *module, int *file_name_index) +set_module_type (grub_command_t cmd, struct xen_boot_binary *module) { - *file_name_index = 0; - if (!grub_strcmp (cmd->name, "xen_linux")) module->node_info.type = MODULE_IMAGE; else if (!grub_strcmp (cmd->name, "xen_initrd")) @@ -440,7 +434,6 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) { struct xen_boot_binary *module = NULL; - int file_name_index = 0; grub_file_t file = 0; if (!argc) @@ -462,8 +455,7 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) return grub_errno; /* process all the options and get module type */ - if (set_module_type (cmd, module, &file_name_index) != - GRUB_ERR_NONE) + if (set_module_type (cmd, module) != GRUB_ERR_NONE) goto fail; switch (module->node_info.type) { @@ -491,12 +483,11 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) module->name, module->node_info.compat_string, module->node_info.compat_string_size); - file = grub_file_open (argv[file_name_index]); + file = grub_file_open (argv[0]); if (!file) goto fail; - xen_boot_binary_load (module, file, argc - file_name_index, - argv + file_name_index); + xen_boot_binary_load (module, file, argc, argv); if (grub_errno == GRUB_ERR_NONE) grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); From 95ba04606f940d17b51c74175ae874b192c44b9f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 12 Nov 2015 11:54:13 +0100 Subject: [PATCH 0378/1167] multiboot_mbi: Fix handling of --quirk-bad-kludge. --- grub-core/loader/i386/multiboot_mbi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 956d0e37b..f60b70234 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -73,6 +73,9 @@ load_kernel (grub_file_t file, const char *filename, if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE) { err = grub_multiboot_load_elf (file, filename, buffer); + if (err == GRUB_ERR_NONE) { + return GRUB_ERR_NONE; + } if (err == GRUB_ERR_UNKNOWN_OS && (header->flags & MULTIBOOT_AOUT_KLUDGE)) grub_errno = err = GRUB_ERR_NONE; } From e0bd66c3141f61749c599a190ecae17903a1d7ec Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 12 Nov 2015 11:54:38 +0100 Subject: [PATCH 0379/1167] multiboot: Don't rely on particular ordering of options. --- grub-core/loader/multiboot.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index fd8f28e21..73aa0aa12 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -240,20 +240,27 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), #ifndef GRUB_USE_MULTIBOOT2 grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE; + int option_found = 0; - if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0) + do { - argc--; - argv++; - grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE; - } + option_found = 0; + if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0) + { + argc--; + argv++; + option_found = 1; + grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE; + } - if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0) - { - argc--; - argv++; - grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL; - } + if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0) + { + argc--; + argv++; + option_found = 1; + grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL; + } + } while (option_found); #endif if (argc == 0) From c899d9f42c543939abc92d79c9729d429740492e Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Sun, 8 Nov 2015 21:52:22 -0200 Subject: [PATCH 0380/1167] ofdisk: add sas disks to the device list --- grub-core/disk/ieee1275/ofdisk.c | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 0efe59a66..235c0fe2c 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -263,6 +263,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) grub_free (buf); return; } + else if (grub_strcmp (alias->type, "sas_ioa") == 0) + { + /* The method returns the number of disks and a table where + * each ID is 64-bit long. Example of sas paths: + * /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800 + * /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800 + * /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */ + + struct sas_children + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t max; + grub_ieee1275_cell_t table; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t nentries; + } + args; + char *buf, *bufptr; + unsigned i; + grub_uint64_t *table; + grub_uint16_t table_size; + grub_ieee1275_ihandle_t ihandle; + + buf = grub_malloc (grub_strlen (alias->path) + + sizeof ("/disk@7766554433221100")); + if (!buf) + return; + bufptr = grub_stpcpy (buf, alias->path); + + /* Power machines documentation specify 672 as maximum SAS disks in + one system. Using a slightly larger value to be safe. */ + table_size = 768; + table = grub_malloc (table_size * sizeof (grub_uint64_t)); + + if (!table) + { + grub_free (buf); + return; + } + + if (grub_ieee1275_open (alias->path, &ihandle)) + { + grub_free (buf); + grub_free (table); + return; + } + + INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2); + args.method = (grub_ieee1275_cell_t) "get-sas-children"; + args.ihandle = ihandle; + args.max = table_size; + args.table = (grub_ieee1275_cell_t) table; + args.catch_result = 0; + args.nentries = 0; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + { + grub_ieee1275_close (ihandle); + grub_free (table); + grub_free (buf); + return; + } + + for (i = 0; i < args.nentries; i++) + { + grub_snprintf (bufptr, sizeof ("/disk@7766554433221100"), + "/disk@%" PRIxGRUB_UINT64_T, table[i]); + dev_iterate_real (buf, buf); + } + + grub_ieee1275_close (ihandle); + grub_free (table); + grub_free (buf); + } if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS) && grub_strcmp (alias->type, "block") == 0) From 5646e03dbaa63f38488cc76b642458ff696ee687 Mon Sep 17 00:00:00 2001 From: Konstantin Vlasov Date: Fri, 13 Nov 2015 21:54:19 +0300 Subject: [PATCH 0381/1167] gfxterm: fix calculation of terminal-top and terminal-height They used screen width, not height. --- grub-core/gfxmenu/theme_loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c index 1a6ed1d25..02978392c 100644 --- a/grub-core/gfxmenu/theme_loader.c +++ b/grub-core/gfxmenu/theme_loader.c @@ -255,7 +255,7 @@ theme_set_string (grub_gfxmenu_view_t view, { unsigned int tmp; int err = theme_get_unsigned_int_from_proportional (value, - view->screen.width, + view->screen.height, &tmp); if (err != GRUB_ERR_NONE) return err; @@ -275,7 +275,7 @@ theme_set_string (grub_gfxmenu_view_t view, { unsigned int tmp; int err = theme_get_unsigned_int_from_proportional (value, - view->screen.width, + view->screen.height, &tmp); if (err != GRUB_ERR_NONE) return err; From 7994077ab9da775a11df8a79aa766c400ac8ef28 Mon Sep 17 00:00:00 2001 From: Pavel Bludov Date: Wed, 11 Nov 2015 15:21:52 +0800 Subject: [PATCH 0382/1167] Add some UUIDs found in the hardware --- grub-core/commands/efi/lsefisystab.c | 14 +++++++-- include/grub/efi/api.h | 45 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index 8717db91e..c84cea613 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -37,10 +37,20 @@ static const struct guid_mapping guid_mappings[] = { { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"}, { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"}, + { GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID, + "CRC32 GUIDED SECTION EXTRACTION"}, + { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"}, + { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"}, + { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"}, + { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"}, + { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"}, + { GRUB_EFI_MPS_TABLE_GUID, "MPS"}, { GRUB_EFI_SAL_TABLE_GUID, "SAL"}, { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"}, - { GRUB_EFI_MPS_TABLE_GUID, "MPS"}, - { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"}, + { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"}, + { GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"}, }; static grub_err_t diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 029ee92f5..24a05c5f6 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -246,6 +246,51 @@ { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \ } +#define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \ + { 0xa31280ad, 0x481e, 0x41b6, \ + { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \ + } + +#define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \ + { 0xfc1bcdb0, 0x7d31, 0x49aa, \ + { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \ + } + +#define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \ + { 0xee4e5898, 0x3914, 0x4259, \ + { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \ + } + +#define GRUB_EFI_TSC_FREQUENCY_GUID \ + { 0xdba6a7e3, 0xbb57, 0x4be7, \ + { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \ + } + +#define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \ + { 0xb122a263, 0x3661, 0x4f68, \ + { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \ + } + +#define GRUB_EFI_DXE_SERVICES_TABLE_GUID \ + { 0x05ad34ba, 0x6f02, 0x4214, \ + { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \ + } + +#define GRUB_EFI_HOB_LIST_GUID \ + { 0x7739f24c, 0x93d7, 0x11d4, \ + { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \ + { 0x4c19049f, 0x4137, 0x4dd3, \ + { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \ + } + +#define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + { 0x49152e77, 0x1ada, 0x4764, \ + { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \ + } + #define GRUB_EFI_MPS_TABLE_GUID \ { 0xeb9d2d2f, 0x2d88, 0x11d3, \ { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ From 50d6f38febe80d4d3088dae1ee639b341787ab71 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 17 Nov 2015 06:27:17 +0300 Subject: [PATCH 0383/1167] lsefisystab: add missing comma after 7994077 --- grub-core/commands/efi/lsefisystab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index c84cea613..df1030221 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -41,7 +41,7 @@ static const struct guid_mapping guid_mappings[] = "CRC32 GUIDED SECTION EXTRACTION"}, { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"}, { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"}, - { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}, { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"}, { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"}, { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"}, From 6a46cbcc5c1c746562fd7181bf0f2337db065201 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 18 Nov 2015 22:23:58 +0300 Subject: [PATCH 0384/1167] unix: do not close stdin in grub_passwd_get This makes it impossible to read from stdin without controlling tty: 10:/mnt # echo -e passwd\\npasswd | setsid ./grub-mkpasswd-pbkdf2 Enter password: Reenter password: ./grub-mkpasswd-pbkdf2: error: failure to read password. 10:/mnt --- grub-core/osdep/unix/password.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 4b9507bce..9996b244b 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -54,7 +54,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_memset (buf, 0, buf_size); if (!fgets (buf, buf_size, stdin)) { - fclose (in); + if (in != stdin) + fclose (in); return 0; } ptr = buf + strlen (buf) - 1; @@ -67,7 +68,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); - fclose (in); + if (in != stdin) + fclose (in); return 1; } From f9d1b4422efb2c06e5472fb2c304712e2029796b Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 24 Nov 2015 12:41:35 -0500 Subject: [PATCH 0385/1167] net: reset nb->data per dns record lookup loop We were resetting nb->data every time we tried a new server, but we need to do it every time we try for a different record, otherwise we don't end up falling back to the A record properly. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/dns.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 953f3bedd..89741dd7d 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -568,11 +568,10 @@ grub_net_dns_lookup (const char *name, { grub_err_t err2; - nb->data = nbd; - grub_size_t t = 0; do { + nb->data = nbd; if (servers[j].option == DNS_OPTION_IPV4 || ((servers[j].option == DNS_OPTION_PREFER_IPV4) && (t++ == 0)) || ((servers[j].option == DNS_OPTION_PREFER_IPV6) && (t++ == 1))) From 3d2c8048da7db334fd6d57b27304ac765fd4cd67 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 26 Nov 2015 19:50:42 +0300 Subject: [PATCH 0386/1167] efi: really mark memory of unknown type as reserved 9be4c45dbe3c877d1f4856e99ee15133c6cd2261 added switch case between fall through cases, causing all memory regions of unknown type to be marked as available. Move default case into its own block and add explicit FALLTHROUGH annotation. Reported by Elliott, Robert (Persistent Memory) --- grub-core/mmap/efi/mmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c index a77efe81d..900a4d659 100644 --- a/grub-core/mmap/efi/mmap.c +++ b/grub-core/mmap/efi/mmap.c @@ -73,6 +73,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_AVAILABLE, hook_data); break; } + /* FALLTHROUGH */ case GRUB_EFI_RUNTIME_SERVICES_CODE: hook (desc->physical_start, desc->num_pages * 4096, GRUB_MEMORY_CODE, hook_data); @@ -83,10 +84,6 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_BADRAM, hook_data); break; - default: - grub_printf ("Unknown memory type %d, considering reserved\n", - desc->type); - case GRUB_EFI_BOOT_SERVICES_DATA: if (!avoid_efi_boot_services) { @@ -94,6 +91,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_AVAILABLE, hook_data); break; } + /* FALLTHROUGH */ case GRUB_EFI_RESERVED_MEMORY_TYPE: case GRUB_EFI_RUNTIME_SERVICES_DATA: case GRUB_EFI_MEMORY_MAPPED_IO: @@ -119,6 +117,13 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, hook (desc->physical_start, desc->num_pages * 4096, GRUB_MEMORY_NVS, hook_data); break; + + default: + grub_printf ("Unknown memory type %d, considering reserved\n", + desc->type); + hook (desc->physical_start, desc->num_pages * 4096, + GRUB_MEMORY_RESERVED, hook_data); + break; } } From d43a5ee65143f384357fbfdcace4258e3537c214 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 13 Nov 2015 16:14:53 +0100 Subject: [PATCH 0387/1167] tsc: Use alternative delay sources whenever appropriate. PIT isn't available on some of new hardware including Hyper-V. So use pmtimer for calibration. Moreover pmtimer calibration is faster, so use it on coreboor where booting time is important. Based on patch by Michael Chang. --- grub-core/Makefile.am | 7 + grub-core/Makefile.core.def | 19 ++- grub-core/commands/acpi.c | 12 -- grub-core/kern/acpi.c | 34 +++++ grub-core/{commands => kern}/efi/acpi.c | 0 grub-core/kern/i386/efi/tsc.c | 40 +++++ grub-core/{commands => kern}/i386/pc/acpi.c | 0 grub-core/kern/i386/tsc.c | 133 ++++------------ grub-core/kern/i386/tsc_pit.c | 84 ++++++++++ grub-core/kern/i386/tsc_pmtimer.c | 160 ++++++++++++++++++++ grub-core/kern/i386/xen/tsc.c | 40 +++++ include/grub/acpi.h | 17 ++- include/grub/i386/tsc.h | 26 ++++ 13 files changed, 451 insertions(+), 121 deletions(-) create mode 100644 grub-core/kern/acpi.c rename grub-core/{commands => kern}/efi/acpi.c (100%) create mode 100644 grub-core/kern/i386/efi/tsc.c rename grub-core/{commands => kern}/i386/pc/acpi.c (100%) create mode 100644 grub-core/kern/i386/tsc_pit.c create mode 100644 grub-core/kern/i386/tsc_pmtimer.c create mode 100644 grub-core/kern/i386/xen/tsc.c diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index af0c7f47c..c671aed4b 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -101,6 +101,7 @@ if COND_i386_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h endif @@ -112,10 +113,12 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_multiboot KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_qemu @@ -154,11 +157,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_ia64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_mips @@ -233,11 +238,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_arm64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_emu diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d9fa0e339..0cc40bb2b 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -171,8 +171,20 @@ kernel = { efi = kern/efi/init.c; efi = kern/efi/mm.c; efi = term/efi/console.c; + efi = kern/acpi.c; + efi = kern/efi/acpi.c; + i386_coreboot = kern/i386/pc/acpi.c; + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; + i386_multiboot = kern/acpi.c; x86 = kern/i386/tsc.c; + x86 = kern/i386/tsc_pit.c; + i386_efi = kern/i386/efi/tsc.c; + x86_64_efi = kern/i386/efi/tsc.c; + i386_efi = kern/i386/tsc_pmtimer.c; + i386_coreboot = kern/i386/tsc_pmtimer.c; + x86_64_efi = kern/i386/tsc_pmtimer.c; i386_efi = kern/i386/efi/init.c; i386_efi = bus/pci.c; @@ -184,6 +196,7 @@ kernel = { x86_64_efi = bus/pci.c; xen = kern/i386/tsc.c; + xen = kern/i386/xen/tsc.c; x86_64_xen = kern/x86_64/xen/hypercall.S; i386_xen = kern/i386/xen/hypercall.S; xen = kern/xen/init.c; @@ -665,10 +678,8 @@ module = { name = acpi; common = commands/acpi.c; - efi = commands/efi/acpi.c; - i386_pc = commands/i386/pc/acpi.c; - i386_coreboot = commands/i386/pc/acpi.c; - i386_multiboot = commands/i386/pc/acpi.c; + i386_pc = kern/acpi.c; + i386_pc = kern/i386/pc/acpi.c; enable = efi; enable = i386_pc; diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index c3861f594..ece49b4a9 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -61,18 +61,6 @@ static const struct grub_arg_option options[] = { {0, 0, 0, 0, 0, 0} }; -/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ -grub_uint8_t -grub_byte_checksum (void *base, grub_size_t size) -{ - grub_uint8_t *ptr; - grub_uint8_t ret = 0; - for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; - ptr++) - ret += *ptr; - return ret; -} - /* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise. rev2 contains the revision of ACPIv2+ to generate or 0 if none. */ static int rev1, rev2; diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c new file mode 100644 index 000000000..02c1f4f6f --- /dev/null +++ b/grub-core/kern/acpi.c @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2012 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 . + */ + +#include +#include +#include +#include + +/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ +grub_uint8_t +grub_byte_checksum (void *base, grub_size_t size) +{ + grub_uint8_t *ptr; + grub_uint8_t ret = 0; + for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; + ptr++) + ret += *ptr; + return ret; +} diff --git a/grub-core/commands/efi/acpi.c b/grub-core/kern/efi/acpi.c similarity index 100% rename from grub-core/commands/efi/acpi.c rename to grub-core/kern/efi/acpi.c diff --git a/grub-core/kern/i386/efi/tsc.c b/grub-core/kern/i386/efi/tsc.c new file mode 100644 index 000000000..4b93ba8e1 --- /dev/null +++ b/grub-core/kern/i386/efi/tsc.c @@ -0,0 +1,40 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 . + */ + +#include +#include +#include +#include +#include +#include + +int +grub_tsc_calibrate_from_efi (void) +{ + grub_uint64_t start_tsc, end_tsc; + /* Use EFI Time Service to calibrate TSC */ + start_tsc = grub_get_tsc (); + efi_call_1 (grub_efi_system_table->boot_services->stall, 1000); + end_tsc = grub_get_tsc (); + grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); + return 1; +} diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/kern/i386/pc/acpi.c similarity index 100% rename from grub-core/commands/i386/pc/acpi.c rename to grub-core/kern/i386/pc/acpi.c diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index bc441d0d3..82cdea491 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -1,7 +1,6 @@ /* kern/i386/tsc.c - x86 TSC time source implementation * Requires Pentium or better x86 CPU that supports the RDTSC instruction. - * This module uses the RTC (via grub_get_rtc()) to calibrate the TSC to - * real time. + * This module calibrates the TSC to real time. * * GRUB -- GRand Unified Bootloader * Copyright (C) 2008 Free Software Foundation, Inc. @@ -25,12 +24,6 @@ #include #include #include -#ifdef GRUB_MACHINE_XEN -#include -#else -#include -#endif -#include /* This defines the value TSC had at the epoch (that is, when we calibrated it). */ static grub_uint64_t tsc_boot_time; @@ -40,66 +33,6 @@ static grub_uint64_t tsc_boot_time; in 32-bit. */ grub_uint32_t grub_tsc_rate; -/* Read the TSC value, which increments with each CPU clock cycle. */ -static __inline grub_uint64_t -grub_get_tsc (void) -{ - grub_uint32_t lo, hi; - grub_uint32_t a,b,c,d; - - /* The CPUID instruction is a 'serializing' instruction, and - avoids out-of-order execution of the RDTSC instruction. */ - grub_cpuid (0,a,b,c,d); - /* Read TSC value. We cannot use "=A", since this would use - %rax on x86_64. */ - __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); - - return (((grub_uint64_t) hi) << 32) | lo; -} - -#ifndef GRUB_MACHINE_XEN - -static __inline int -grub_cpu_is_tsc_supported (void) -{ - grub_uint32_t a,b,c,d; - if (! grub_cpu_is_cpuid_supported ()) - return 0; - - grub_cpuid(1,a,b,c,d); - - return (d & (1 << 4)) != 0; -} - -static void -grub_pit_wait (grub_uint16_t tics) -{ - /* Disable timer2 gate and speaker. */ - grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) - & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), - GRUB_PIT_SPEAKER_PORT); - - /* Set tics. */ - grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD, - GRUB_PIT_CTRL); - grub_outb (tics & 0xff, GRUB_PIT_COUNTER_2); - grub_outb (tics >> 8, GRUB_PIT_COUNTER_2); - - /* Enable timer2 gate, keep speaker disabled. */ - grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA) - | GRUB_PIT_SPK_TMR2, - GRUB_PIT_SPEAKER_PORT); - - /* Wait. */ - while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); - - /* Disable timer2 gate and speaker. */ - grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) - & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), - GRUB_PIT_SPEAKER_PORT); -} -#endif - static grub_uint64_t grub_tsc_get_time_ms (void) { @@ -110,52 +43,52 @@ grub_tsc_get_time_ms (void) return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; } -#ifndef GRUB_MACHINE_XEN -/* Calibrate the TSC based on the RTC. */ -static void -calibrate_tsc (void) +static __inline int +grub_cpu_is_tsc_supported (void) { - /* First calibrate the TSC rate (relative, not absolute time). */ - grub_uint64_t end_tsc; +#ifndef GRUB_MACHINE_XEN + grub_uint32_t a,b,c,d; + if (! grub_cpu_is_cpuid_supported ()) + return 0; - tsc_boot_time = grub_get_tsc (); - grub_pit_wait (0xffff); - end_tsc = grub_get_tsc (); + grub_cpuid(1,a,b,c,d); - grub_tsc_rate = 0; - if (end_tsc > tsc_boot_time) - grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); - if (grub_tsc_rate == 0) - grub_tsc_rate = 5368;/* 800 MHz */ -} + return (d & (1 << 4)) != 0; +#else + return 1; #endif +} + +static int +calibrate_tsc_hardcode (void) +{ + grub_tsc_rate = 5368;/* 800 MHz */ + return 1; +} void grub_tsc_init (void) { -#ifdef GRUB_MACHINE_XEN - grub_uint64_t t; - tsc_boot_time = grub_get_tsc (); - t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul; - if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0) - t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift; - else - t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift; - grub_tsc_rate = grub_divmod64 (t, 1000000, 0); - grub_install_get_time_ms (grub_tsc_get_time_ms); -#else - if (grub_cpu_is_tsc_supported ()) - { - calibrate_tsc (); - grub_install_get_time_ms (grub_tsc_get_time_ms); - } - else + if (!grub_cpu_is_tsc_supported ()) { #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275) grub_install_get_time_ms (grub_rtc_get_time_ms); #else grub_fatal ("no TSC found"); #endif + return; } + + tsc_boot_time = grub_get_tsc (); + +#ifdef GRUB_MACHINE_XEN + (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); +#elif defined (GRUB_MACHINE_EFI) + (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); +#elif defined (GRUB_MACHINE_COREBOOT) + (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); +#else + (void) (grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); #endif + grub_install_get_time_ms (grub_tsc_get_time_ms); } diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c new file mode 100644 index 000000000..0c0488c1b --- /dev/null +++ b/grub-core/kern/i386/tsc_pit.c @@ -0,0 +1,84 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 . + */ + +#include +#include +#include +#include +#include +#include + +static int +grub_pit_wait (void) +{ + int ret = 0; + + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) + & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), + GRUB_PIT_SPEAKER_PORT); + + /* Set tics. */ + grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD, + GRUB_PIT_CTRL); + /* 0xffff ticks: 55ms. */ + grub_outb (0xff, GRUB_PIT_COUNTER_2); + grub_outb (0xff, GRUB_PIT_COUNTER_2); + + /* Enable timer2 gate, keep speaker disabled. */ + grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA) + | GRUB_PIT_SPK_TMR2, + GRUB_PIT_SPEAKER_PORT); + + if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) { + ret = 1; + /* Wait. */ + while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); + } + + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) + & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), + GRUB_PIT_SPEAKER_PORT); + + return ret; +} + +/* Calibrate the TSC based on the RTC. */ +int +grub_tsc_calibrate_from_pit (void) +{ + /* First calibrate the TSC rate (relative, not absolute time). */ + grub_uint64_t start_tsc, end_tsc; + + start_tsc = grub_get_tsc (); + if (!grub_pit_wait ()) + return 0; + end_tsc = grub_get_tsc (); + + grub_tsc_rate = 0; + if (end_tsc > start_tsc) + grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - start_tsc, 0); + if (grub_tsc_rate == 0) + return 0; + return 1; +} diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c new file mode 100644 index 000000000..6a47ab7be --- /dev/null +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -0,0 +1,160 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 . + */ + +#include +#include +#include +#include +#include +#include + +static void * +grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) +{ + grub_size_t s; + grub_uint32_t *ptr; + + if (!rsdt) + return 0; + + if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) + return 0; + + ptr = (grub_uint32_t *) (rsdt + 1); + s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; + tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +static void * +grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) +{ + grub_size_t s; + grub_uint64_t *ptr; + + if (!xsdt) + return 0; + + if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) + return 0; + + ptr = (grub_uint64_t *) (xsdt + 1); + s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; +#if GRUB_CPU_SIZEOF_VOID_P != 8 + if (*ptr >> 32) + continue; +#endif + tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +struct grub_acpi_fadt * +grub_acpi_find_fadt (void) +{ + struct grub_acpi_fadt *fadt = 0; + struct grub_acpi_rsdp_v10 *rsdpv1; + struct grub_acpi_rsdp_v20 *rsdpv2; + rsdpv1 = grub_machine_acpi_get_rsdpv1 (); + if (rsdpv1) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv1->rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + rsdpv2 = grub_machine_acpi_get_rsdpv2 (); + if (rsdpv2) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + if (rsdpv2 +#if GRUB_CPU_SIZEOF_VOID_P != 8 + && !(rsdpv2->xsdt_addr >> 32) +#endif + ) + fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->xsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + return 0; +} + +int +grub_tsc_calibrate_from_pmtimer (void) +{ + grub_uint32_t start; + grub_uint32_t last; + grub_uint32_t cur, end; + struct grub_acpi_fadt *fadt; + grub_port_t p; + grub_uint64_t start_tsc; + grub_uint64_t end_tsc; + int num_iter = 0; + + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + p = fadt->pmtimer; + if (!p) + return 0; + + start = grub_inl (p) & 0xffffff; + last = start; + /* It's 3.579545 MHz clock. Wait 1 ms. */ + end = start + 3580; + start_tsc = grub_get_tsc (); + while (1) + { + cur = grub_inl (p) & 0xffffff; + if (cur < last) + cur |= 0x1000000; + num_iter++; + if (cur >= end) + { + end_tsc = grub_get_tsc (); + grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); + return 1; + } + /* Check for broken PM timer. + 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) + if after this time we still don't have 1 ms on pmtimer, then + pmtimer is broken. + */ + if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) { + return 0; + } + } +} diff --git a/grub-core/kern/i386/xen/tsc.c b/grub-core/kern/i386/xen/tsc.c new file mode 100644 index 000000000..8792b308d --- /dev/null +++ b/grub-core/kern/i386/xen/tsc.c @@ -0,0 +1,40 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 . + */ + +#include +#include +#include +#include +#include + +int +grub_tsc_calibrate_from_xen (void) +{ + grub_uint64_t t; + t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul; + if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0) + t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift; + else + t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift; + grub_tsc_rate = grub_divmod64 (t, 1000000, 0); + return 1; +} diff --git a/include/grub/acpi.h b/include/grub/acpi.h index f6e6a11c5..8a8110241 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -67,10 +67,14 @@ struct grub_acpi_fadt grub_uint32_t dsdt_addr; grub_uint8_t somefields1[20]; grub_uint32_t pm1a; - grub_uint8_t somefields2[64]; + grub_uint8_t somefields2[8]; + grub_uint32_t pmtimer; + grub_uint8_t somefields3[32]; + grub_uint32_t flags; + grub_uint8_t somefields4[16]; grub_uint64_t facs_xaddr; grub_uint64_t dsdt_xaddr; - grub_uint8_t somefields3[96]; + grub_uint8_t somefields5[96]; } GRUB_PACKED; #define GRUB_ACPI_MADT_SIGNATURE "APIC" @@ -176,9 +180,9 @@ enum #ifndef GRUB_DSDT_TEST struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void); struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void); -struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void); -struct grub_acpi_rsdp_v20 *grub_machine_acpi_get_rsdpv2 (void); -grub_uint8_t grub_byte_checksum (void *base, grub_size_t size); +struct grub_acpi_rsdp_v10 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv1) (void); +struct grub_acpi_rsdp_v20 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv2) (void); +grub_uint8_t EXPORT_FUNC(grub_byte_checksum) (void *base, grub_size_t size); grub_err_t grub_acpi_create_ebda (void); @@ -234,4 +238,7 @@ enum GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87, }; +struct grub_acpi_fadt * +grub_acpi_find_fadt (void); + #endif /* ! GRUB_ACPI_HEADER */ diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 71b32e6b8..71fa7ca2f 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -20,9 +20,35 @@ #define KERNEL_CPU_TSC_HEADER 1 #include +#include void grub_tsc_init (void); /* In ms per 2^32 ticks. */ extern grub_uint32_t EXPORT_VAR(grub_tsc_rate); +int +grub_tsc_calibrate_from_xen (void); +int +grub_tsc_calibrate_from_efi (void); +int +grub_tsc_calibrate_from_pmtimer (void); +int +grub_tsc_calibrate_from_pit (void); + +/* Read the TSC value, which increments with each CPU clock cycle. */ +static __inline grub_uint64_t +grub_get_tsc (void) +{ + grub_uint32_t lo, hi; + grub_uint32_t a,b,c,d; + + /* The CPUID instruction is a 'serializing' instruction, and + avoids out-of-order execution of the RDTSC instruction. */ + grub_cpuid (0,a,b,c,d); + /* Read TSC value. We cannot use "=A", since this would use + %rax on x86_64. */ + __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); + + return (((grub_uint64_t) hi) << 32) | lo; +} #endif /* ! KERNEL_CPU_TSC_HEADER */ From a2618427857c7013a6d3107eb3b9be2d526a69ed Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Nov 2015 19:42:23 +0300 Subject: [PATCH 0388/1167] configure: fix macports flex version detection Macports add extra information after version itself: $flex --version flex 2.5.35 Apple(flex-31) We require at least felx 2.5.35 so do not need to care about prehistoric "flex version n.n.n"; just use second field always. Reported by Peter Cheung --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9e8a606a6..3300545e0 100644 --- a/configure.ac +++ b/configure.ac @@ -315,7 +315,7 @@ AC_PROG_LN_S if test "x$LEX" = "x:"; then AC_MSG_ERROR([flex is not found]) else - version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` + version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` if test -n "$version" -a "$version" -ge 20535; then : else From f4c143789afaf54b4afaf67eef91c7550282da36 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Nov 2015 19:52:16 +0300 Subject: [PATCH 0389/1167] Replace numbers with grub_memory_type_t enums --- grub-core/kern/ieee1275/init.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index d5bd74d35..4303509f2 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -166,7 +166,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, { unsigned long *total = data; - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM)) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 63d6a1f33..346d9538e 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -196,7 +196,7 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, struct alloc_phys_ctx *ctx = data; grub_addr_t end = addr + len; - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; addr = ALIGN_UP (addr, FOUR_MB); @@ -430,7 +430,7 @@ static int get_physbase (grub_uint64_t addr, grub_uint64_t len __attribute__ ((unused)), grub_memory_type_t type, void *data __attribute__ ((unused))) { - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; if (addr < phys_base) phys_base = addr; From 346a494d7c92fe7c2a89f01be84a7be67bcfbfe7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Nov 2015 21:11:34 +0300 Subject: [PATCH 0390/1167] Do not include generated gnulib headers in tarball gnulib files are already handled by recursive make distdir invocation. Including all generated headers (after make completed) causes build failure if target system is different (different compile version etc). --- conf/Makefile.extra-dist | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index ea6b9df3a..9dd64fdca 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -37,7 +37,6 @@ EXTRA_DIST += grub-core/lib/libgcrypt EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h') EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h') -EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h') EXTRA_DIST += grub-core/efiemu/runtime/config.h EXTRA_DIST += grub-core/lib/LzmaDec.c From a03c1034f6062e69075056c8f31b90e159ce5244 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 1 Dec 2015 18:49:38 +0300 Subject: [PATCH 0391/1167] i386: fix TSC calibration using PIT Condition was accidentally reversed, so PIT calibration always failed when PIT was present and always succeeded when PIT was missing, but in the latter case resulted in absurdly fast clock. Reported and tested by Vitaly Kuznetsov --- grub-core/kern/i386/tsc_pit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c index 0c0488c1b..67990bfa6 100644 --- a/grub-core/kern/i386/tsc_pit.c +++ b/grub-core/kern/i386/tsc_pit.c @@ -49,7 +49,7 @@ grub_pit_wait (void) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); - if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) { + if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00) { ret = 1; /* Wait. */ while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); From fb478079182f3b21603834eaeb9026e051f88c33 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 12 Aug 2015 08:16:22 -0700 Subject: [PATCH 0392/1167] tcp: ack when we get an OOO/lost packet While adding tcp window scaling support I was finding that I'd get some packet loss or reordering when transferring from large distances and grub would just timeout. This is because we weren't ack'ing when we got our OOO packet, so the sender didn't know it needed to retransmit anything, so eventually it would fill the window and stop transmitting, and we'd time out. Fix this by ACK'ing when we don't find our next sequence numbered packet. With this fix I no longer time out. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/tcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 9e81a0a85..576f68498 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -893,7 +893,10 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb, grub_priority_queue_pop (sock->pq); } if (grub_be_to_cpu32 (tcph->seqnr) != sock->their_cur_seq) - return GRUB_ERR_NONE; + { + ack (sock); + return GRUB_ERR_NONE; + } while (1) { nb_top_p = grub_priority_queue_top (sock->pq); From 4803db51ff031890f7fc81ee2667e88422817f31 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Dec 2015 16:21:24 +0100 Subject: [PATCH 0393/1167] Document bootlocation discovery limitations and xen platform limitations --- docs/grub.texi | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 1df3db260..9a25a0bdb 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5669,6 +5669,16 @@ BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol limitations mips-loongson (with Linux protocol) and mips-qemu_mips can use only memory up to first hole. +Bootlocation is ability of GRUB to automatically detect where it boots from. +``disk'' means the detection is limited to detecting the disk with partition +being discovered on install time. ``partition'' means that disk and partiton +can be automatically discovered. ``file'' means that boot image file name as +well as disk and partition can be discovered. For consistency default install ignores +partition and relies solely on disk detection. If no bootlocation discovery is available +or boot and grub-root disks are different, UUID is used instead. On ARC if no device +to install to is specified, UUID is used instead as well. + + @multitable @columnfractions .20 .20 .20 .20 .20 @item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu @item video @tab yes @tab yes @tab yes @tab yes @@ -5685,6 +5695,7 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes @tab yes @tab yes @tab yes @item compression @tab always @tab pointless @tab no @tab no @item exit @tab yes @tab no @tab no @tab no +@item bootlocation @tab disk @tab no @tab no @tab no @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 @@ -5703,6 +5714,7 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes @tab yes @tab no @tab yes @item compression @tab no @tab no @tab no @tab no @item exit @tab yes @tab yes @tab yes @tab yes +@item bootlocation @tab file @tab file @tab file, ignored @tab file @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 @@ -5721,24 +5733,26 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes (*) @tab no @tab no @tab no @item compression @tab configurable @tab no @tab no @tab configurable @item exit @tab no @tab yes @tab yes @tab yes +@item bootlocation @tab no @tab partition @tab file @tab file (*) @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 -@item @tab MIPS qemu @tab emu -@item video @tab no @tab yes -@item console charset @tab CP437 @tab Unicode (*) -@item network @tab no @tab yes -@item ATA/AHCI @tab yes @tab no -@item AT keyboard @tab yes @tab no -@item Speaker @tab no @tab no -@item USB @tab N/A @tab yes -@item chainloader @tab yes @tab no -@item cpuid @tab no @tab no -@item hints @tab guess @tab no -@item PCI @tab no @tab no -@item badram @tab yes (*) @tab no -@item compression @tab configurable @tab no -@item exit @tab no @tab yes +@item @tab MIPS qemu @tab emu @tab xen +@item video @tab no @tab yes @tab no +@item console charset @tab CP437 @tab Unicode (*) @tab ASCII +@item network @tab no @tab yes @tab no +@item ATA/AHCI @tab yes @tab no @tab no +@item AT keyboard @tab yes @tab no @tab no +@item Speaker @tab no @tab no @tab no +@item USB @tab N/A @tab yes @tab no +@item chainloader @tab yes @tab no @tab yes +@item cpuid @tab no @tab no @tab yes +@item hints @tab guess @tab no @tab no +@item PCI @tab no @tab no @tab no +@item badram @tab yes (*) @tab no @tab no +@item compression @tab configurable @tab no @tab no +@item exit @tab no @tab yes @tab no +@item bootlocation @tab no @tab file @tab no @end multitable @node Platform-specific operations From 76ce1de740f202985ffd7b2e980cf34c75a2dac3 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Thu, 3 Dec 2015 11:38:36 -0600 Subject: [PATCH 0394/1167] Translate UEFI persistent memory type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define * GRUB_EFI_PERSISTENT_MEMORY (UEFI memory map type 14) per UEFI 2.5 * GRUB_MEMORY_PERSISTENT (E820 type 7) per ACPI 3.0 * GRUB_MEMORY_PERSISTENT_LEGACY (E820 unofficial type 12) per ACPI 3.0 and translate GRUB_EFI_PERSISTENT_MEMORY to GRUB_MEMORY_PERSISTENT in grub_efi_mmap_iterate(). Includes * adding the E820 names to lsmmap * handling the E820 types in make_efi_memtype() Suggested-by: Vladimir 'φ-coder/phcoder' Serbinenko Suggested-by: Andrei Borzenkov --- grub-core/commands/lsmmap.c | 2 ++ grub-core/mmap/efi/mmap.c | 12 ++++++++++++ include/grub/efi/api.h | 1 + include/grub/memory.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c index 4b504fd28..816ee47d1 100644 --- a/grub-core/commands/lsmmap.c +++ b/grub-core/commands/lsmmap.c @@ -37,6 +37,8 @@ static const char *names[] = is required to save accross hibernations. */ [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"), [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"), + [GRUB_MEMORY_PERSISTENT] = N_("persistent RAM"), + [GRUB_MEMORY_PERSISTENT_LEGACY] = N_("persistent RAM (legacy)"), [GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"), [GRUB_MEMORY_CODE] = N_("RAM holding firmware code") }; diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c index 900a4d659..bd495a184 100644 --- a/grub-core/mmap/efi/mmap.c +++ b/grub-core/mmap/efi/mmap.c @@ -118,6 +118,11 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_NVS, hook_data); break; + case GRUB_EFI_PERSISTENT_MEMORY: + hook (desc->physical_start, desc->num_pages * 4096, + GRUB_MEMORY_PERSISTENT, hook_data); + break; + default: grub_printf ("Unknown memory type %d, considering reserved\n", desc->type); @@ -147,6 +152,13 @@ make_efi_memtype (int type) /* No way to remove a chunk of memory from EFI mmap. So mark it as unusable. */ case GRUB_MEMORY_HOLE: + /* + * AllocatePages() does not support GRUB_EFI_PERSISTENT_MEMORY, + * so no translation for GRUB_MEMORY_PERSISTENT or + * GRUB_MEMORY_PERSISTENT_LEGACY. + */ + case GRUB_MEMORY_PERSISTENT: + case GRUB_MEMORY_PERSISTENT_LEGACY: case GRUB_MEMORY_RESERVED: return GRUB_EFI_UNUSABLE_MEMORY; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 24a05c5f6..2bbfe344c 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -476,6 +476,7 @@ enum grub_efi_memory_type GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_PAL_CODE, + GRUB_EFI_PERSISTENT_MEMORY, GRUB_EFI_MAX_MEMORY_TYPE }; typedef enum grub_efi_memory_type grub_efi_memory_type_t; diff --git a/include/grub/memory.h b/include/grub/memory.h index 083cfb680..6da114a1b 100644 --- a/include/grub/memory.h +++ b/include/grub/memory.h @@ -30,6 +30,8 @@ typedef enum grub_memory_type GRUB_MEMORY_ACPI = 3, GRUB_MEMORY_NVS = 4, GRUB_MEMORY_BADRAM = 5, + GRUB_MEMORY_PERSISTENT = 7, + GRUB_MEMORY_PERSISTENT_LEGACY = 12, GRUB_MEMORY_COREBOOT_TABLES = 16, GRUB_MEMORY_CODE = 20, /* This one is special: it's used internally but is never reported From ff5726b878a485d36bab43898ee528b5a63d38b0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 15 Dec 2015 10:41:01 +0300 Subject: [PATCH 0395/1167] NEWS: more additions Also-By: Robert Elliott --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 2db2f87a9..c9a975219 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,7 @@ New in 2.02: * Command for inspecting coreboot tables (`lscoreboot'). * New target default_payload.elf. * Increased maximal core size. + * Prefer pmtimer for TSC calibration. * New/improved platform support: * New `efifwsetup' and `lsefi' commands on EFI platforms. @@ -89,6 +90,12 @@ New in 2.02: * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. * Support for booting little-endian Linux kernel on powerpc. + * Support network boot with Oracle sun4v vnet devices. + * Added SAS disks to the IEEE 1275 Open Firmware device list. + * Try multiple methods for TSC (timestamp counter) calibration - PIT, pmtimer, + EFI Stall. If everything fails, use hardcoded frequency 800MHz. + * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration. + * Map UEFI Persistent Memory to E820 persistent memory. * Security: * Add optional facility to enforce that all files read by the core image @@ -152,6 +159,7 @@ New in 2.02: system. * emu libusb support removed (was broken and unmaintained). * powerpc64le compile support. + * Use fixed timestamp when generating GRUB image for reproducible builds. * Revision control moved to git. From 451d80e52d851432e109771bb8febafca7a5f1f2 Mon Sep 17 00:00:00 2001 From: Hector Marco-Gisbert Date: Wed, 16 Dec 2015 07:57:18 +0300 Subject: [PATCH 0396/1167] Fix security issue when reading username and password This patch fixes two integer underflows at: * grub-core/lib/crypto.c * grub-core/normal/auth.c CVE-2015-8370 Signed-off-by: Hector Marco-Gisbert Signed-off-by: Ismael Ripoll-Ripoll Also-By: Andrey Borzenkov --- grub-core/lib/crypto.c | 3 ++- grub-core/normal/auth.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 010e550d1..683a8aaa7 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -470,7 +470,8 @@ grub_password_get (char buf[], unsigned buf_size) if (key == '\b') { - cur_len--; + if (cur_len) + cur_len--; continue; } diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index c6bd96e28..8615c48c3 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -174,8 +174,11 @@ grub_username_get (char buf[], unsigned buf_size) if (key == '\b') { - cur_len--; - grub_printf ("\b"); + if (cur_len) + { + cur_len--; + grub_printf ("\b"); + } continue; } From 7136b545c1f3a471766b34a38afd370d4b0915d8 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 16 Dec 2015 19:20:10 +0300 Subject: [PATCH 0397/1167] Erase backspaced character in grub_username_get It probably does not work across linefeed, but hopefully user names are not that long (and nobody is using terminal that small). --- grub-core/normal/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index 8615c48c3..7338f8245 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -177,7 +177,7 @@ grub_username_get (char buf[], unsigned buf_size) if (cur_len) { cur_len--; - grub_printf ("\b"); + grub_printf ("\b \b"); } continue; } From 609c049dcc318fae3af1ba29f0ceb348172769f0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 16 Dec 2015 21:20:30 +0300 Subject: [PATCH 0398/1167] kernel: print and reset grub_errno after each embedded config line Otherwise it causes subsequent file open to fail, because grub_file_open misinterprets set grub_errno for grub_file_get_device_name failure. Closes: 46540 --- grub-core/kern/parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c index b9bd12352..78175aac2 100644 --- a/grub-core/kern/parser.c +++ b/grub-core/kern/parser.c @@ -268,6 +268,7 @@ grub_parser_execute (char *source) grub_parser_execute_getline (&line, 0, &source); grub_rescue_parse_line (line, grub_parser_execute_getline, &source); grub_free (line); + grub_print_error (); } return grub_errno; From c79c59f1295df8ea660f8a858f9532d76a5f67b7 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Thu, 17 Dec 2015 10:53:32 -0600 Subject: [PATCH 0399/1167] lsefimmap: support persistent memory and other UEFI 2.5 features This should accompany 76ce1de740 Translate UEFI persistent memory type 1. Add a string for the EfiPersistentMemory type 14 that was added in UEFI 2.5. 2. Decode the memory attributes that were added in UEFI 2.5: * NV (non-volatile) * MORE_RELIABLE (higher reliable, e.g., mirrored memory in a system with partial memory mirroring) * RO (read-only) 3. Use proper IEC binary units (KiB, MiB, etc.) for power-of-two values rather than misusing SI power-of-ten units (KB, MB, etc.) 4. The lsmmap command only decodes memory ranges sizes up to GiB scale units. Persistent memory ranges will reach into the TiB scale. Since 64-bit size field supports TiB, PiB, and EiB, decode all of them for completeness. 5. In the lsefimmap command, rewrite the print statements to * avoid rounding * avoid a big nested if/else tree. For example: In the sixth entry below, the value of 309MB implies 316416KB but is really reporting 316436KB. Widen the size column to 6 digits to accommodate typical cases. The worst case value would require 14 digits; if that happens, let the columns get out of sync. Old format: Type Physical start - end #Pages Size Attributes conv-mem 0000000000000000-0000000000092fff 00000093 588KB UC WC WT WB reserved 0000000000093000-0000000000093fff 00000001 4KB UC WC WT WB conv-mem 0000000000094000-000000000009ffff 0000000c 48KB UC WC WT WB conv-mem 0000000000100000-000000000fffffff 0000ff00 255MB UC WC WT WB BS-code 0000000010000000-0000000010048fff 00000049 292KB UC WC WT WB conv-mem 0000000010049000-000000002354dfff 00013505 309MB UC WC WT WB ldr-data 000000002354e000-000000003ecfffff 0001b7b2 439MB UC WC WT WB BS-data 000000003ed00000-000000003ed7ffff 00000080 512KB UC WC WT WB conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 705MB UC WC WT WB reserved 000000006af60000-000000006b55ffff 00000600 6MB UC WC WT WB BS-data 000000006b560000-000000006b560fff 00000001 4KB UC WC WT WB RT-data 000000006b561000-000000006b5e1fff 00000081 516KB RT UC WC WT WB BS-data 000000006b5e2000-000000006ecfafff 00003719 55MB UC WC WT WB BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KB UC WC WT WB conv-mem 000000006ecfc000-00000000711fafff 000024ff 36MB UC WC WT WB BS-data 00000000711fb000-000000007128dfff 00000093 588KB UC WC WT WB Unk 0d 0000000880000000-0000000e7fffffff 00600000 24GB UC WC WT WB NV reserved 0000001680000000-0000001c7fffffff 00600000 24GB UC WC WT WB NV New format: Type Physical start - end #Pages Size Attributes conv-mem 0000000000000000-0000000000092fff 00000093 588KiB UC WC WT WB reserved 0000000000093000-0000000000093fff 00000001 4KiB UC WC WT WB conv-mem 0000000000094000-000000000009ffff 0000000c 48KiB UC WC WT WB conv-mem 0000000000100000-000000000fffffff 0000ff00 255MiB UC WC WT WB BS-code 0000000010000000-0000000010048fff 00000049 292KiB UC WC WT WB conv-mem 0000000010049000-000000002354dfff 00013505 316436KiB UC WC WT WB ldr-data 000000002354e000-000000003ecfffff 0001b7b2 450248KiB UC WC WT WB BS-data 000000003ed00000-000000003ed7ffff 00000080 512KiB UC WC WT WB conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 722816KiB UC WC WT WB reserved 000000006af60000-000000006b55ffff 00000600 6MiB UC WC WT WB BS-data 000000006b560000-000000006b560fff 00000001 4KiB UC WC WT WB RT-data 000000006b561000-000000006b5e1fff 00000081 516KiB RT UC WC WT WB BS-data 000000006b5e2000-000000006ecfafff 00003719 56420KiB UC WC WT WB BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KiB UC WC WT WB conv-mem 000000006ecfc000-0000000071222fff 00002527 38044KiB UC WC WT WB BS-data 0000000071223000-00000000712ddfff 000000bb 748KiB UC WC WT WB persist 0000000880000000-0000000e7fffffff 00600000 24GiB UC WC WT WB NV reserved 0000001680000000-0000001c7fffffff 00600000 24GiB UC WC WT WB NV --- grub-core/commands/efi/lsefimmap.c | 47 ++++++++++++++++++++---------- include/grub/efi/api.h | 3 ++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c index 215b45bff..c85ff7f36 100644 --- a/grub-core/commands/efi/lsefimmap.c +++ b/grub-core/commands/efi/lsefimmap.c @@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), grub_printf ("Type Physical start - end #Pages " - " Size Attributes\n"); + " Size Attributes\n"); memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size); for (desc = memory_map; desc < memory_map_end; @@ -74,7 +74,8 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), "ACPI-nvs", "MMIO ", "IO-ports", - "PAL-code" + "PAL-code", + "persist ", }; if (desc->type < ARRAY_SIZE (types_str)) grub_printf ("%s ", types_str[desc->type]); @@ -87,21 +88,29 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), desc->physical_start + (desc->num_pages << 12) - 1, desc->num_pages); - size = desc->num_pages; - size <<= (12 - 10); - if (size < 1024) - grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size); + size = desc->num_pages << 12; /* 4 KiB page size */ + /* + * Since size is a multiple of 4 KiB, no need to handle units + * of just Bytes (which would use a mask of 0x3ff). + * + * 14 characters would support the largest possible number of 4 KiB + * pages that are not a multiple of larger units (e.g., MiB): + * 17592186044415 (0xffffff_fffff000), but that uses a lot of + * whitespace for a rare case. 6 characters usually suffices; + * columns will be off if not, but this is preferable to rounding. + */ + if (size & 0xfffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "KiB", size >> 10); + else if (size & 0x3fffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "MiB", size >> 20); + else if (size & 0xffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "GiB", size >> 30); + else if (size & 0x3ffffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "TiB", size >> 40); + else if (size & 0xfffffffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "PiB", size >> 50); else - { - size /= 1024; - if (size < 1024) - grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size); - else - { - size /= 1024; - grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size); - } - } + grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60); attr = desc->attribute; if (attr & GRUB_EFI_MEMORY_RUNTIME) @@ -122,6 +131,12 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), grub_printf (" RP"); if (attr & GRUB_EFI_MEMORY_XP) grub_printf (" XP"); + if (attr & GRUB_EFI_MEMORY_NV) + grub_printf (" NV"); + if (attr & GRUB_EFI_MEMORY_MORE_RELIABLE) + grub_printf (" MR"); + if (attr & GRUB_EFI_MEMORY_RO) + grub_printf (" RO"); grub_printf ("\n"); } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 2bbfe344c..c7c9f0e1d 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -49,6 +49,9 @@ #define GRUB_EFI_MEMORY_WP 0x0000000000001000LL #define GRUB_EFI_MEMORY_RP 0x0000000000002000LL #define GRUB_EFI_MEMORY_XP 0x0000000000004000LL +#define GRUB_EFI_MEMORY_NV 0x0000000000008000LL +#define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL +#define GRUB_EFI_MEMORY_RO 0x0000000000020000LL #define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL #define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 From a9399f2e1e5819fdd9bd2a4d35d32420dd6cc679 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 19 Dec 2015 11:32:26 +0300 Subject: [PATCH 0400/1167] windows: correct LBA in generated EFI HDD media paths GRUB keeps partition offset and size in units of 512B sectors. Media paths are defined in terms of LBA which are presumed to match HDD sector size. This is probably cosmetic (EFI requires that partition is searched by GUID) and still incorrect if GPT was created using different logical block size. But current code is obviously wrong and new has better chances to be correct. --- grub-core/osdep/windows/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index d217efe17..912269191 100644 --- a/grub-core/osdep/windows/platform.c +++ b/grub-core/osdep/windows/platform.c @@ -370,9 +370,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, } hddp->partition_start = grub_partition_get_start (efidir_grub_dev->disk->partition) - << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); + >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); hddp->partition_size = grub_disk_get_size (efidir_grub_dev->disk) - << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); + >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); pathptr = hddp + 1; filep = pathptr; From 3bca85b4184f74995a7cc2791e432173fde26d34 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 26 Dec 2015 21:45:22 +0300 Subject: [PATCH 0401/1167] devmapper: check for valid device abstraction in get_grub_dev This was lost when code was refactored. Patch restores previous behavior. It is still not clear whether this is the right one. Due to the way we detect DM abstraction, partitions on DM are skipped, we fall through to generic detection which ends up in assuming parent device is BIOS disk. It is useful to install GRUB on VM disk from the host. But it also means that GRUB will mistakenly allow install on real system as well. For now let's fix regression; future behavior needs to be discussed. Closes: 45163 --- grub-core/osdep/devmapper/getroot.c | 33 +++++++++++++++++------------ grub-core/osdep/linux/getroot.c | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 64419f678..05eda500a 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -223,11 +223,14 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) uuid = get_dm_uuid (os_dev); if (!uuid) return NULL; - - if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) == 0) + + switch (grub_util_get_dev_abstraction (os_dev)) { + case GRUB_DEV_ABSTRACTION_LVM: + { unsigned i; int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58}; + grub_dev = xmalloc (grub_strlen (uuid) + 40); optr = grub_stpcpy (grub_dev, "lvmid/"); for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++) @@ -245,19 +248,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) return grub_dev; } - if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0) - { - char *dash; - dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); - if (dash) - *dash = 0; - grub_dev = grub_xasprintf ("cryptouuid/%s", - uuid + sizeof ("CRYPT-LUKS1-") - 1); + case GRUB_DEV_ABSTRACTION_LUKS: + { + char *dash; + + dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); + if (dash) + *dash = 0; + grub_dev = grub_xasprintf ("cryptouuid/%s", + uuid + sizeof ("CRYPT-LUKS1-") - 1); + grub_free (uuid); + return grub_dev; + } + + default: grub_free (uuid); - return grub_dev; + return NULL; } - grub_free (uuid); - return NULL; } char * diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 3978c7114..10480b646 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -1075,7 +1075,7 @@ grub_util_get_grub_dev_os (const char *os_dev) switch (grub_util_get_dev_abstraction (os_dev)) { /* Fallback for non-devmapper build. In devmapper-builds LVM is handled - in rub_util_get_devmapper_grub_dev and this point isn't reached. + in grub_util_get_devmapper_grub_dev and this point isn't reached. */ case GRUB_DEV_ABSTRACTION_LVM: { From ca7bb46d5c3b8c3db6577f1f7d5cdc8d0e104264 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:42:25 +0100 Subject: [PATCH 0402/1167] exfat: Fix stream extension flag parsing. --- grub-core/fs/fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index aa2145cf2..635c2c425 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -681,7 +681,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, ctxt->dir.file_size = grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size); ctxt->dir.have_stream = 1; - ctxt->dir.is_contiguous = !!(dir.type_specific.stream_extension.flags + ctxt->dir.is_contiguous = !!(sec.type_specific.stream_extension.flags & grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS)); break; case 0xc1: From 4111882828597cbf68ae6f9429b68d0210dc2d41 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:43:05 +0100 Subject: [PATCH 0403/1167] grub-mount: Fix oath parsing. Brackets detection was copied from somewhere else and makes no sense in case of grub-mount and prevents user from accessing and files with ) in them. --- util/grub-mount.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/util/grub-mount.c b/util/grub-mount.c index 0d0fea5f2..aca5f82e3 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -151,7 +151,6 @@ fuse_getattr (const char *path, struct stat *st) { struct fuse_getattr_ctx ctx; char *pathname, *path2; - const char *pathname_t; if (path[0] == '/' && path[1] == 0) { @@ -170,12 +169,7 @@ fuse_getattr (const char *path, struct stat *st) ctx.file_exists = 0; - pathname_t = grub_strchr (path, ')'); - if (! pathname_t) - pathname_t = path; - else - pathname_t++; - pathname = xstrdup (pathname_t); + pathname = xstrdup (path); /* Remove trailing '/'. */ while (*pathname && pathname[grub_strlen (pathname) - 1] == '/') From dbab354157fed01841317ae0927cbccc622c3c03 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:48:34 +0100 Subject: [PATCH 0404/1167] grub-mkrescue: Delete temporary file Reported by: Thomas Schmitt --- util/grub-mkrescue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 451182647..da0dc021a 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -310,6 +310,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat, grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output, 0, load_cfg, mkimage_target, 0); grub_install_pop_module (); + grub_util_unlink (load_cfg); } static int @@ -647,6 +648,7 @@ main (int argc, char *argv[]) } grub_install_pop_module (); grub_install_pop_module (); + grub_util_unlink (load_cfg); } /** build multiboot core.img */ From 93ecc3f1f8372e43101301866eea87aa9257a9e0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 30 Dec 2015 06:20:51 +0300 Subject: [PATCH 0405/1167] menu: fix line count calculation for long lines It gave one extra screen line if length was exactly equal to screen width. Reported by Michael Chang. Also-By: Michael Chang --- grub-core/normal/menu_entry.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 62c7e1627..2b732250d 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -126,9 +126,13 @@ ensure_space (struct line *linep, int extra) static int get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen) { - return (grub_getstringwidth (linep->buf, linep->buf + linep->len, - term_screen->term) - / (unsigned) term_screen->geo.entry_width) + 1; + grub_size_t width = grub_getstringwidth (linep->buf, linep->buf + linep->len, + term_screen->term); + + /* Empty line still consumes space on screen */ + return width ? (width + (unsigned) term_screen->geo.entry_width - 1) / + (unsigned) term_screen->geo.entry_width + : 1; } static void From 79cfad6fbeafcfa9b8a664643024e897123927c7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Dec 2015 18:19:44 +0100 Subject: [PATCH 0406/1167] backtrace: Remove assembly assumption that grub_backtrace_pointer is under 4G --- grub-core/lib/i386/backtrace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c index 7a7796a12..d76a46a23 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -56,11 +56,11 @@ void grub_backtrace (void) { #ifdef __x86_64__ - asm volatile ("movq %rbp, %rdi\n" - "call " EXT_C("grub_backtrace_pointer")); + asm volatile ("movq %%rbp, %%rdi\n" + "call %%rax": :"a"(grub_backtrace_pointer)); #else - asm volatile ("movl %ebp, %eax\n" - "call " EXT_C("grub_backtrace_pointer")); + asm volatile ("movl %%ebp, %%eax\n" + "call %%ecx": :"c"(grub_backtrace_pointer)); #endif } From 2333a83baa3caf7efb0c6b94f0d9f9914682cf87 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Wed, 30 Dec 2015 22:30:16 +0300 Subject: [PATCH 0407/1167] 30_os-prober: derive --class from os-prober generated label Currently only Windows gets distinguished icons, everything else is displayed using the same generic one. Add additional --class based on os-prober returned label, which usually is expected to match primary distribution name. Also use it for Windows as well - chainloader prober may actually return different strings (Windows, MS-DOS, Windows9xME). --- util/grub.d/30_os-prober.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 5fc4f0c83..5604ce2b6 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -135,6 +135,9 @@ for OS in ${OSPROBED} ; do LONGNAME="${LABEL}" fi + # os-prober returns text string followed by optional counter + CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')" + gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 case ${BOOT} in @@ -142,7 +145,7 @@ for OS in ${OSPROBED} ; do onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | grub_add_tab prepare_grub_to_access_device ${DEVICE} | grub_add_tab @@ -174,7 +177,7 @@ EOF DEVICE=${DEVICE%@*} onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" @@ -230,7 +233,7 @@ EOF if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then cat << EOF -menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { +menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { EOF save_default_entry | grub_add_tab printf '%s\n' "${prepare_boot_cache}" From 5919626c907a2d141bfeffa4ec04d71e521fbbaa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 13:07:16 +0100 Subject: [PATCH 0408/1167] sparc64: Fix assembly to let compiler to fill in memory references. This fixes the use of not fully relocatable (they assume that variables are under 4G limit in virtual memory) references. --- grub-core/loader/sparc64/ieee1275/linux.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 346d9538e..d44d7a113 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -140,17 +140,17 @@ grub_linux_boot (void) grub_dprintf ("loader", "Jumping to Linux...\n"); /* Boot the kernel. */ - asm volatile ("sethi %hi(grub_ieee1275_entry_fn), %o1\n" - "ldx [%o1 + %lo(grub_ieee1275_entry_fn)], %o4\n" - "sethi %hi(grub_ieee1275_original_stack), %o1\n" - "ldx [%o1 + %lo(grub_ieee1275_original_stack)], %o6\n" - "sethi %hi(linux_addr), %o1\n" - "ldx [%o1 + %lo(linux_addr)], %o5\n" - "mov %g0, %o0\n" - "mov %g0, %o2\n" - "mov %g0, %o3\n" - "jmp %o5\n" - "mov %g0, %o1\n"); + asm volatile ("ldx %0, %%o4\n" + "ldx %1, %%o6\n" + "ldx %2, %%o5\n" + "mov %%g0, %%o0\n" + "mov %%g0, %%o2\n" + "mov %%g0, %%o3\n" + "jmp %%o5\n" + "mov %%g0, %%o1\n": : + "m"(grub_ieee1275_entry_fn), + "m"(grub_ieee1275_original_stack), + "m"(linux_addr)); return GRUB_ERR_NONE; } From a7cf8b1e235fbbc8a460510615c7ff85f21c2d05 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 13:09:15 +0100 Subject: [PATCH 0409/1167] Verify modules on build-time rather than failing in runtime. --- grub-core/Makefile.am | 6 +- grub-core/genmod.sh.in | 5 +- include/grub/module_verifier.h | 19 ++ util/grub-module-verifier.c | 122 +++++++++++++ util/grub-module-verifier32.c | 2 + util/grub-module-verifier64.c | 2 + util/grub-module-verifierXX.c | 315 +++++++++++++++++++++++++++++++++ 7 files changed, 468 insertions(+), 3 deletions(-) create mode 100644 include/grub/module_verifier.h create mode 100644 util/grub-module-verifier.c create mode 100644 util/grub-module-verifier32.c create mode 100644 util/grub-module-verifier64.c create mode 100644 util/grub-module-verifierXX.c diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index c671aed4b..508e86bcd 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -39,6 +39,10 @@ gentrigtables$(BUILD_EXEEXT): gentrigtables.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM) CLEANFILES += gentrigtables$(BUILD_EXEEXT) +build-grub-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/grub-module-verifier.c $(top_srcdir)/util/grub-module-verifier32.c $(top_srcdir)/util/grub-module-verifier64.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\" $^ +CLEANFILES += build-grub-module-verifier$(BUILD_EXEEXT) + # trigtables.c trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac ./gentrigtables$(BUILD_EXEEXT) > $@ @@ -390,7 +394,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst -$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) +$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) platform_DATA += modinfo.sh diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 789732b10..7dcafd9d3 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -15,12 +15,12 @@ set -e # # Example: # -# genmod.sh moddep.lst normal.module normal.mod +# genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod # moddep=$1 infile=$2 -outfile=$3 +outfile=$4 tmpfile=${outfile}.tmp modname=`echo $infile | sed -e 's@\.module.*$@@'` @@ -93,4 +93,5 @@ else -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 rm -f $name.bin fi +./build-grub-module-verifier $tmpfile @target_cpu@ mv $tmpfile $outfile diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h new file mode 100644 index 000000000..9e3a2ba72 --- /dev/null +++ b/include/grub/module_verifier.h @@ -0,0 +1,19 @@ +#include +#include + +#include + +#define GRUB_MODULE_VERIFY_SUPPORTS_REL 1 +#define GRUB_MODULE_VERIFY_SUPPORTS_RELA 2 + +struct grub_module_verifier_arch { + const char *name; + int voidp_sizeof; + int bigendian; + int machine; + int flags; + const int *supported_relocations; +}; + +void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); +void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c new file mode 100644 index 000000000..d2d698403 --- /dev/null +++ b/util/grub-module-verifier.c @@ -0,0 +1,122 @@ +#include +#include + +#include +#include +#include +#include + +struct grub_module_verifier_arch archs[] = { + { "i386", 4, 0, EM_386, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){ + R_386_32, + R_386_PC32, + -1 + } }, + { "x86_64", 8, 0, EM_X86_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_X86_64_64, + R_X86_64_PC64, + /* R_X86_64_32, R_X86_64_32S, R_X86_64_PC32 are supported but shouldn't be used because of their limited range. */ + -1 + } }, + { "powerpc", 4, 1, EM_PPC, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + GRUB_ELF_R_PPC_ADDR16_LO, + GRUB_ELF_R_PPC_REL24, /* It has limited range but GRUB adds trampolines when necessarry. */ + GRUB_ELF_R_PPC_ADDR16_HA, + GRUB_ELF_R_PPC_ADDR32, + GRUB_ELF_R_PPC_REL32, + -1 + } }, + { "sparc64", 8, 1, EM_SPARCV9, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_SPARC_WDISP30, /* It has limited range but GRUB adds trampolines when necessarry. */ + R_SPARC_HH22, + R_SPARC_HM10, + R_SPARC_LM22, + R_SPARC_LO10, + R_SPARC_64, + R_SPARC_OLO10, + /* R_SPARC_32, R_SPARC_HI22 are supported but shouldn't be used because of their limited range. */ + -1 + } }, + { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_IA64_PCREL21B, /* We should verify that it's pointing either + to a function or to a section in the same module. */ + R_IA64_SEGREL64LSB, + R_IA64_FPTR64LSB, + R_IA64_DIR64LSB, + R_IA64_PCREL64LSB, + R_IA64_GPREL22, /* We should verify that it's pointing to a section in the same module. */ + R_IA64_LTOFF22X, + R_IA64_LTOFF22, + R_IA64_LTOFF_FPTR22, + R_IA64_LDXMOV, + -1 + } }, + { "mipsel", 4, 0, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_MIPS_HI16, + R_MIPS_LO16, + R_MIPS_32, + R_MIPS_GPREL32, + R_MIPS_26, + R_MIPS_GOT16, + R_MIPS_CALL16, + R_MIPS_JALR, + -1 + } }, + { "mips", 4, 1, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_MIPS_HI16, + R_MIPS_LO16, + R_MIPS_32, + R_MIPS_GPREL32, + R_MIPS_26, + R_MIPS_GOT16, + R_MIPS_CALL16, + R_MIPS_JALR, + -1 + } }, + { "arm", 4, 0, EM_ARM, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){ + /* Some relocations are range-limited but trampolines are added when necessarry. */ + R_ARM_ABS32, + R_ARM_CALL, + R_ARM_JUMP24, + R_ARM_THM_CALL, + R_ARM_THM_JUMP24, + R_ARM_V4BX, + R_ARM_THM_MOVW_ABS_NC, + R_ARM_THM_MOVT_ABS, + R_ARM_THM_JUMP19, + -1 + } }, + { "arm64", 8, 0, EM_AARCH64, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_AARCH64_ABS64, + R_AARCH64_CALL26, + R_AARCH64_JUMP26, + -1 + } }, +}; + + +int +main (int argc, char **argv) +{ + size_t module_size; + unsigned arch; + char *module_img; + if (argc != 3) { + fprintf (stderr, "usage: %s FILE ARCH\n", argv[0]); + return 1; + } + + for (arch = 0; arch < ARRAY_SIZE(archs); arch++) + if (strcmp(archs[arch].name, argv[2]) == 0) + break; + if (arch == ARRAY_SIZE(archs)) + grub_util_error("unknown arch: %s", argv[2]); + + module_size = grub_util_get_image_size (argv[1]); + module_img = grub_util_read_image (argv[1]); + if (archs[arch].voidp_sizeof == 8) + grub_module_verify64(module_img, module_size, &archs[arch]); + else + grub_module_verify32(module_img, module_size, &archs[arch]); + return 0; +} diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c new file mode 100644 index 000000000..257229f8f --- /dev/null +++ b/util/grub-module-verifier32.c @@ -0,0 +1,2 @@ +#define MODULEVERIFIER_ELF32 1 +#include "grub-module-verifierXX.c" diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c new file mode 100644 index 000000000..4db6b4bed --- /dev/null +++ b/util/grub-module-verifier64.c @@ -0,0 +1,2 @@ +#define MODULEVERIFIER_ELF64 1 +#include "grub-module-verifierXX.c" diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c new file mode 100644 index 000000000..904be27d3 --- /dev/null +++ b/util/grub-module-verifierXX.c @@ -0,0 +1,315 @@ +#include + +#include +#include +#include + +#if defined(MODULEVERIFIER_ELF32) +# define SUFFIX(x) x ## 32 +# define ELFCLASSXX ELFCLASS32 +# define Elf_Ehdr Elf32_Ehdr +# define Elf_Phdr Elf32_Phdr +# define Elf_Nhdr Elf32_Nhdr +# define Elf_Addr Elf32_Addr +# define Elf_Sym Elf32_Sym +# define Elf_Off Elf32_Off +# define Elf_Shdr Elf32_Shdr +# define Elf_Rela Elf32_Rela +# define Elf_Rel Elf32_Rel +# define Elf_Word Elf32_Word +# define Elf_Half Elf32_Half +# define Elf_Section Elf32_Section +# define ELF_R_SYM(val) ELF32_R_SYM(val) +# define ELF_R_TYPE(val) ELF32_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) +#elif defined(MODULEVERIFIER_ELF64) +# define SUFFIX(x) x ## 64 +# define ELFCLASSXX ELFCLASS64 +# define Elf_Ehdr Elf64_Ehdr +# define Elf_Phdr Elf64_Phdr +# define Elf_Nhdr Elf64_Nhdr +# define Elf_Addr Elf64_Addr +# define Elf_Sym Elf64_Sym +# define Elf_Off Elf64_Off +# define Elf_Shdr Elf64_Shdr +# define Elf_Rela Elf64_Rela +# define Elf_Rel Elf64_Rel +# define Elf_Word Elf64_Word +# define Elf_Half Elf64_Half +# define Elf_Section Elf64_Section +# define ELF_R_SYM(val) ELF64_R_SYM(val) +# define ELF_R_TYPE(val) ELF64_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) +#else +#error "I'm confused" +#endif + +#define grub_target_to_host32(x) (grub_target_to_host32_real (arch, (x))) +#define grub_host_to_target32(x) (grub_host_to_target32_real (arch, (x))) +#define grub_target_to_host64(x) (grub_target_to_host64_real (arch, (x))) +#define grub_host_to_target64(x) (grub_host_to_target64_real (arch, (x))) +#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (arch, (x))) +#define grub_target_to_host16(x) (grub_target_to_host16_real (arch, (x))) +#define grub_host_to_target16(x) (grub_host_to_target16_real (arch, (x))) +#define grub_target_to_host(val) grub_target_to_host_real(arch, (val)) + +static inline grub_uint32_t +grub_target_to_host32_real (const struct grub_module_verifier_arch *arch, + grub_uint32_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu32 (in); + else + return grub_le_to_cpu32 (in); +} + +static inline grub_uint64_t +grub_target_to_host64_real (const struct grub_module_verifier_arch *arch, + grub_uint64_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu64 (in); + else + return grub_le_to_cpu64 (in); +} + +static inline grub_uint64_t +grub_host_to_target64_real (const struct grub_module_verifier_arch *arch, + grub_uint64_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be64 (in); + else + return grub_cpu_to_le64 (in); +} + +static inline grub_uint32_t +grub_host_to_target32_real (const struct grub_module_verifier_arch *arch, + grub_uint32_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be32 (in); + else + return grub_cpu_to_le32 (in); +} + +static inline grub_uint16_t +grub_target_to_host16_real (const struct grub_module_verifier_arch *arch, + grub_uint16_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu16 (in); + else + return grub_le_to_cpu16 (in); +} + +static inline grub_uint16_t +grub_host_to_target16_real (const struct grub_module_verifier_arch *arch, + grub_uint16_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be16 (in); + else + return grub_cpu_to_le16 (in); +} + +static inline grub_uint64_t +grub_host_to_target_addr_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in) +{ + if (arch->voidp_sizeof == 8) + return grub_host_to_target64_real (arch, in); + else + return grub_host_to_target32_real (arch, in); +} + +static inline grub_uint64_t +grub_target_to_host_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in) +{ + if (arch->voidp_sizeof == 8) + return grub_target_to_host64_real (arch, in); + else + return grub_target_to_host32_real (arch, in); +} + + +static Elf_Shdr * +find_section (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, const char *name) +{ + Elf_Shdr *s; + const char *str; + unsigned i; + + s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host16 (e->e_shstrndx) * grub_target_to_host16 (e->e_shentsize)); + str = (char *) e + grub_target_to_host (s->sh_offset); + + for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (strcmp (str + grub_target_to_host32 (s->sh_name), name) == 0) + return s; + return NULL; +} + +static void +check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Shdr *s = find_section (arch, e, ".module_license"); + if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0 + || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0 + || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0)) + return; + grub_util_error ("incompatible license"); +} + +static void +check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + unsigned i; + Elf_Shdr *s, *sections; + Elf_Sym *sym; + const char *str; + Elf_Word size, entsize; + + sections = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + for (i = 0, s = sections; + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (grub_target_to_host32 (s->sh_type) == SHT_SYMTAB) + break; + + if (i == grub_target_to_host16 (e->e_shnum)) + grub_util_error ("no symbol table"); + + sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); + size = grub_target_to_host (s->sh_size); + entsize = grub_target_to_host (s->sh_entsize); + + s = (Elf_Shdr *) ((char *) sections + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host32 (s->sh_link)); + str = (char *) e + grub_target_to_host (s->sh_offset); + + for (i = 0; + i < size / entsize; + i++, sym = (Elf_Sym *) ((char *) sym + entsize)) + { + unsigned char type = ELF_ST_TYPE (sym->st_info); + + switch (type) + { + case STT_NOTYPE: + case STT_OBJECT: + case STT_FUNC: + case STT_SECTION: + case STT_FILE: + break; + + default: + return grub_util_error ("unknown symbol type `%d'", (int) type); + } + } +} + +/* Relocate symbols. */ +static void +section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, + Elf_Shdr *s, size_t target_seg_size) +{ + Elf_Rel *rel, *max; + + for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), + max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); + rel < max; + rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize))) + { + Elf_Word *addr; + Elf_Sym *sym; + unsigned i; + + if (target_seg_size < grub_target_to_host (rel->r_offset)) + grub_util_error ("reloc offset is out of the segment"); + + grub_uint32_t type = ELF_R_TYPE (grub_target_to_host (rel->r_info)); + + if (arch->machine == EM_SPARCV9) + type &= 0xff; + + for (i = 0; arch->supported_relocations[i] != -1; i++) + if (type == arch->supported_relocations[i]) + break; + if (arch->supported_relocations[i] == -1) + grub_util_error ("unsupported relocation 0x%x", type); + } +} + +static void +check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Shdr *s; + unsigned i; + + for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (grub_target_to_host32 (s->sh_type) == SHT_REL || grub_target_to_host32 (s->sh_type) == SHT_RELA) + { + Elf_Shdr *ts; + + if (grub_target_to_host32 (s->sh_type) == SHT_REL && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_REL)) + grub_util_error ("unsupported SHT_REL"); + if (grub_target_to_host32 (s->sh_type) == SHT_RELA && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_RELA)) + grub_util_error ("unsupported SHT_RELA"); + + /* Find the target segment. */ + if (grub_target_to_host32 (s->sh_info) >= grub_target_to_host16 (e->e_shnum)) + grub_util_error ("orphaned reloc section"); + ts = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host32 (s->sh_info) * grub_target_to_host16 (e->e_shentsize)); + + section_check_relocations (arch, e, s, grub_target_to_host (ts->sh_size)); + } +} + +void +SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_module_verifier_arch *arch) +{ + Elf_Ehdr *e = module_img; + + /* Check the header size. */ + if (size < sizeof (Elf_Ehdr)) + grub_util_error ("ELF header smaller than expected"); + + /* Check the magic numbers. */ + if (e->e_ident[EI_MAG0] != ELFMAG0 + || e->e_ident[EI_MAG1] != ELFMAG1 + || e->e_ident[EI_MAG2] != ELFMAG2 + || e->e_ident[EI_MAG3] != ELFMAG3 + || e->e_ident[EI_VERSION] != EV_CURRENT + || grub_target_to_host32 (e->e_version) != EV_CURRENT) + grub_util_error ("invalid arch-independent ELF magic"); + + if (e->e_ident[EI_CLASS] != ELFCLASSXX + || e->e_ident[EI_DATA] != (arch->bigendian ? ELFDATA2MSB : ELFDATA2LSB) + || grub_target_to_host16 (e->e_machine) != arch->machine) + grub_util_error ("invalid arch-dependent ELF magic"); + + if (grub_target_to_host16 (e->e_type) != ET_REL) + { + grub_util_error ("this ELF file is not of the right type"); + } + + /* Make sure that every section is within the core. */ + if (size < grub_target_to_host (e->e_shoff) + + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) + { + grub_util_error ("ELF sections outside core"); + } + + check_license (arch, e); + + Elf_Shdr *s; + + s = find_section (arch, e, ".modname"); + if (!s) + grub_util_error ("no module name found"); + + check_symbols(arch, e); + check_relocations(arch, e); +} From 60ae5821428433945b62a79f6a1f71f14f8dfb19 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 14:54:48 +0100 Subject: [PATCH 0410/1167] backtrace: Fix register call syntax --- grub-core/lib/i386/backtrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c index d76a46a23..c3e03c727 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -57,10 +57,10 @@ grub_backtrace (void) { #ifdef __x86_64__ asm volatile ("movq %%rbp, %%rdi\n" - "call %%rax": :"a"(grub_backtrace_pointer)); + "callq *%%rax": :"a"(grub_backtrace_pointer)); #else asm volatile ("movl %%ebp, %%eax\n" - "call %%ecx": :"c"(grub_backtrace_pointer)); + "calll *%%ecx": :"c"(grub_backtrace_pointer)); #endif } From 76588d1319cccde6c3e68279db2a4dcdf2ce7562 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 14:54:56 +0100 Subject: [PATCH 0411/1167] xen/relocator: Use local symbol to ensure that code is relocation-free. --- grub-core/lib/x86_64/xen/relocator.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/x86_64/xen/relocator.S b/grub-core/lib/x86_64/xen/relocator.S index 78c123350..92e9e72a9 100644 --- a/grub-core/lib/x86_64/xen/relocator.S +++ b/grub-core/lib/x86_64/xen/relocator.S @@ -89,7 +89,7 @@ VARIABLE(grub_relocator_xen_mfn_list) loop 1b - leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi + leaq LOCAL(mmu_op) (%rip), %rdi movq $3, %rsi movq $0, %rdx movq $0x7FF0, %r10 @@ -104,6 +104,7 @@ VARIABLE(grub_relocator_xen_remap_continue) jmp *%rax +LOCAL(mmu_op): VARIABLE(grub_relocator_xen_mmu_op) .space 256 From e1b2b9bf1d1cb3b411b5ae45046e4002091f6f5f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 15:29:28 +0100 Subject: [PATCH 0412/1167] module-verifier: Check range-limited relative relocations. Check that they point to the same module, so will end up in the same chunk of memory. --- include/grub/module_verifier.h | 1 + util/grub-module-verifier.c | 19 ++++++++--- util/grub-module-verifierXX.c | 62 ++++++++++++++++++++++++++++------ 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h index 9e3a2ba72..6cddff30f 100644 --- a/include/grub/module_verifier.h +++ b/include/grub/module_verifier.h @@ -13,6 +13,7 @@ struct grub_module_verifier_arch { int machine; int flags; const int *supported_relocations; + const int *short_relocations; }; void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index d2d698403..c027f0a0f 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -15,9 +15,13 @@ struct grub_module_verifier_arch archs[] = { { "x86_64", 8, 0, EM_X86_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_X86_64_64, R_X86_64_PC64, - /* R_X86_64_32, R_X86_64_32S, R_X86_64_PC32 are supported but shouldn't be used because of their limited range. */ + /* R_X86_64_32, R_X86_64_32S are supported but shouldn't be used because of their limited range. */ -1 - } }, + }, (int[]){ + R_X86_64_PC32, + -1 + } + }, { "powerpc", 4, 1, EM_PPC, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ GRUB_ELF_R_PPC_ADDR16_LO, GRUB_ELF_R_PPC_REL24, /* It has limited range but GRUB adds trampolines when necessarry. */ @@ -39,17 +43,24 @@ struct grub_module_verifier_arch archs[] = { } }, { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_IA64_PCREL21B, /* We should verify that it's pointing either - to a function or to a section in the same module. */ + to a function or to a section in the same module. + Checking that external symbol is a function is + non-trivial and I have never seen this relocation used + for anything else, so assume that it always points to a + function. + */ R_IA64_SEGREL64LSB, R_IA64_FPTR64LSB, R_IA64_DIR64LSB, R_IA64_PCREL64LSB, - R_IA64_GPREL22, /* We should verify that it's pointing to a section in the same module. */ R_IA64_LTOFF22X, R_IA64_LTOFF22, R_IA64_LTOFF_FPTR22, R_IA64_LDXMOV, -1 + }, (int[]){ + R_IA64_GPREL22, + -1 } }, { "mipsel", 4, 0, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_MIPS_HI16, diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 904be27d3..25988ebc2 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -161,14 +161,12 @@ check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) grub_util_error ("incompatible license"); } -static void -check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +static Elf_Sym * +get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word *size, Elf_Word *entsize) { unsigned i; Elf_Shdr *s, *sections; Elf_Sym *sym; - const char *str; - Elf_Word size, entsize; sections = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); for (i = 0, s = sections; @@ -181,11 +179,19 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) grub_util_error ("no symbol table"); sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); - size = grub_target_to_host (s->sh_size); - entsize = grub_target_to_host (s->sh_entsize); + *size = grub_target_to_host (s->sh_size); + *entsize = grub_target_to_host (s->sh_entsize); + return sym; +} - s = (Elf_Shdr *) ((char *) sections + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host32 (s->sh_link)); - str = (char *) e + grub_target_to_host (s->sh_offset); +static void +check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Sym *sym; + Elf_Word size, entsize; + unsigned i; + + sym = get_symtab (arch, e, &size, &entsize); for (i = 0; i < size / entsize; @@ -208,19 +214,41 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) } } -/* Relocate symbols. */ +static int +is_symbol_local(Elf_Sym *sym) +{ + switch (ELF_ST_TYPE (sym->st_info)) + { + case STT_NOTYPE: + case STT_OBJECT: + if (sym->st_name != 0 && sym->st_shndx == 0) + return 0; + return 1; + + case STT_FUNC: + case STT_SECTION: + return 1; + + default: + return 0; + } +} + static void section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, Elf_Shdr *s, size_t target_seg_size) { Elf_Rel *rel, *max; + Elf_Sym *symtab; + Elf_Word symtabsize, symtabentsize; + + symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); rel < max; rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize))) { - Elf_Word *addr; Elf_Sym *sym; unsigned i; @@ -235,8 +263,20 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e for (i = 0; arch->supported_relocations[i] != -1; i++) if (type == arch->supported_relocations[i]) break; - if (arch->supported_relocations[i] == -1) + if (arch->supported_relocations[i] != -1) + continue; + if (!arch->short_relocations) grub_util_error ("unsupported relocation 0x%x", type); + for (i = 0; arch->short_relocations[i] != -1; i++) + if (type == arch->short_relocations[i]) + break; + if (arch->short_relocations[i] == -1) + grub_util_error ("unsupported relocation 0x%x", type); + sym = (Elf_Sym *) ((char *) symtab + symtabentsize * ELF_R_SYM (grub_target_to_host (rel->r_info))); + + if (is_symbol_local (sym)) + continue; + grub_util_error ("relocation 0x%x is not module-local", type); } } From 68e158dffde328d5b961518fe23504cc534744ce Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:13:59 +0100 Subject: [PATCH 0413/1167] Strip .ARM.exidx This section is generated by clang and is useful only for debugging. It contains exotic relocations, so strip them to avoid them interferring with module loading. --- conf/Makefile.common | 2 +- gentpl.py | 2 +- grub-core/genmod.sh.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 5083d5f1e..11296b550 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags +STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d diff --git a/gentpl.py b/gentpl.py index 76971d3ce..0782e447d 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \ fi """) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 7dcafd9d3..005cb1985 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -58,7 +58,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then -K grub_mod_init -K grub_mod_fini \ -K _grub_mod_init -K _grub_mod_fini \ -R .note.gnu.gold-version -R .note.GNU-stack \ - -R .note -R .comment $tmpfile || exit 1 + -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1 fi if ! test -z "${TARGET_OBJ2ELF}"; then "${TARGET_OBJ2ELF}" $tmpfile || exit 1 From f1b352538556711dc3f9e8b9bf5bf2e4abea8e25 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:15:49 +0100 Subject: [PATCH 0414/1167] Add -mno-stack-arg-probe on mingw. This argument disables generation of calls to __chkstk_ms. Those calls are useless on GRUB as function is dummy. Yet they increase module size and use limited-range relocations which may not work under some memory layouts. We currently don't use such layouts on concerned platforms but lt's correct this. --- configure.ac | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 3300545e0..f662e200e 100644 --- a/configure.ac +++ b/configure.ac @@ -910,6 +910,18 @@ if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xy TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" fi +AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [ + CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_mno_stack_arg_probe=yes], + [grub_cv_cc_mno_stack_arg_probe=no]) +]) + +if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" +fi + + # By default, GCC 4.6 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler From 5ae590b32d2fa535050399193d21a2305bd008a7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:19:15 +0100 Subject: [PATCH 0415/1167] configure: Fix grub_cv_cc_fno_unwind_tables check. Check tries -fno-dwarf2-cfi-asm but adds -fno-asynchronous-unwind-tables to TARGET_CFLAGS. Fix this. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f662e200e..ada6068d9 100644 --- a/configure.ac +++ b/configure.ac @@ -927,7 +927,7 @@ fi # these and they just use up vital space. Restore the old compiler # behaviour. AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [ - CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" + CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_fno_asynchronous_unwind_tables=yes], [grub_cv_cc_fno_asynchronous_unwind_tables=no]) From 3b21499506b633494cccb1cdb3fc757594ef0ef0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:20:11 +0100 Subject: [PATCH 0416/1167] Disable build-time module check on emu. On emu some checks can be laxer like check for relocation range. Additionally module loading in emu is rarely used. So skip this check rather than making it laxer for all platforms. In ideal we may want to have slightly different check for emu but for now this is good enough. --- grub-core/genmod.sh.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 005cb1985..f74edd551 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -93,5 +93,7 @@ else -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 rm -f $name.bin fi -./build-grub-module-verifier $tmpfile @target_cpu@ +if test x@platform@ != xemu; then + ./build-grub-module-verifier $tmpfile @target_cpu@ +fi mv $tmpfile $outfile From dcc499aaf034a5ee2f1ae11c7ec6f990ab9aea3c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:30:39 +0100 Subject: [PATCH 0417/1167] module-verifier: allow limited-range relocations on sparc64. clang as incomplete mcmodel=large support. As we don't currently need full mcmodel=large support for sparc64, relax those checks. --- util/grub-module-verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index c027f0a0f..e217dcddc 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -38,7 +38,12 @@ struct grub_module_verifier_arch archs[] = { R_SPARC_LO10, R_SPARC_64, R_SPARC_OLO10, - /* R_SPARC_32, R_SPARC_HI22 are supported but shouldn't be used because of their limited range. */ + /* Following 2 relocations have limited range but unfortunately + clang generates them, as it doesn't implement mcmodel=large properly. + At least our heap and core are under 4G, so it's not a problem + usually. */ + R_SPARC_HI22, + R_SPARC_32, -1 } }, { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ From 40051fedc33f2ec10924d66ae1371940dce2ca8a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 19:20:03 +0100 Subject: [PATCH 0418/1167] configure: Add -fno-unwind-tables if supported. Unwind tables are useless for us bt consume space if present. Ensure that they are not. --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index ada6068d9..2e656dbea 100644 --- a/configure.ac +++ b/configure.ac @@ -937,6 +937,17 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" fi +AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [ + CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_unwind_tables=yes], + [grub_cv_cc_fno_unwind_tables=no]) +]) + +if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" +fi + AC_ARG_ENABLE([efiemu], [AS_HELP_STRING([--enable-efiemu], [build and install the efiemu runtimes (default=guessed)])]) From c67025fad5104fe48daa24115a16373413cddbf4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 31 Dec 2015 21:35:11 +0300 Subject: [PATCH 0419/1167] Add grub-module-verifier files to EXTRA_DIST --- conf/Makefile.extra-dist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 9dd64fdca..b16bd9253 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -50,8 +50,13 @@ EXTRA_DIST += util/import_gcrypth.sed EXTRA_DIST += util/bin2h.c EXTRA_DIST += util/grub-gen-asciih.c EXTRA_DIST += util/grub-gen-widthspec.c +EXTRA_DIST += util/grub-module-verifier.c +EXTRA_DIST += util/grub-module-verifier32.c +EXTRA_DIST += util/grub-module-verifier64.c +EXTRA_DIST += util/grub-module-verifierXX.c EXTRA_DIST += util/grub-pe2elf.c + EXTRA_DIST += m4/gnulib-cache.m4 EXTRA_DIST += m4/glibc2.m4 EXTRA_DIST += m4/gnulib-tool.m4 From af23303cbd551c8b1d70701530916f221a0b47e4 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 31 Dec 2015 22:23:12 +0300 Subject: [PATCH 0420/1167] add dejavu built fonts to cleanfiles --- Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index 994ebbd39..b8423b08d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -91,14 +91,19 @@ if COND_STARFIELD starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_10.pf2 dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_12.pf2 dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_14.pf2 dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_bold_14.pf2 dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_16.pf2 else starfield_DATA = endif From 4d6e9c8a92ce1b1b88980e31f9dd1e8ab78f3888 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 31 Dec 2015 23:00:25 +0300 Subject: [PATCH 0421/1167] remove temporary .bin files (kernel and modules) --- gentpl.py | 2 ++ grub-core/genmod.sh.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gentpl.py b/gentpl.py index 0782e447d..f08bcc404 100644 --- a/gentpl.py +++ b/gentpl.py @@ -729,9 +729,11 @@ def kernel(defn, platform): """if test x$(TARGET_APPLE_LINKER) = x1; then \ $(TARGET_STRIP) -S -x $(""" + cname(defn) + """) -o $@.bin $<; \ $(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -ed2016 -wd1106 -nu -nd $@.bin $@; \ + rm -f $@.bin; \ elif test ! -z '$(TARGET_OBJ2ELF)'; then \ """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \ $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \ + rm -f $@.bin; \ else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \ fi""")) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index f74edd551..ca2e59d5c 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -91,7 +91,7 @@ else -nr:_grub_mod_init:grub_mod_init \ -nr:_grub_mod_fini:grub_mod_fini \ -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 - rm -f $name.bin + rm -f $tmpfile.bin fi if test x@platform@ != xemu; then ./build-grub-module-verifier $tmpfile @target_cpu@ From 80fdaf1d012fa0403f7b75568df926735f070c3c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 22:34:26 +0100 Subject: [PATCH 0422/1167] configure.ac: Reorder efiemu check to after link format check. efiemu is supposed to be disabled when compiling through exe format. Unfortunately format was determined only after efiemu check. Reorder to fix the problem --- configure.ac | 127 +++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/configure.ac b/configure.ac index 2e656dbea..26d2f33c7 100644 --- a/configure.ac +++ b/configure.ac @@ -948,66 +948,6 @@ if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" fi -AC_ARG_ENABLE([efiemu], - [AS_HELP_STRING([--enable-efiemu], - [build and install the efiemu runtimes (default=guessed)])]) -if test x"$enable_efiemu" = xno ; then - efiemu_excuse="explicitly disabled" -fi -if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then - efiemu_excuse="not available on cygwin" -fi -if test x"$target_cpu" != xi386 ; then - efiemu_excuse="only available on i386" -fi -if test x"$platform" = xefi ; then - efiemu_excuse="not available on efi" -fi -if test x"$efiemu_excuse" = x ; then - AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ - CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_efiemu=yes], - [grub_cv_cc_efiemu=no]) - ]) - if test x$grub_cv_cc_efiemu = xno; then - efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" - fi -fi -if test x"$efiemu_excuse" = x ; then - AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ - grub_cv_target_cc_efiemu64_link_format=unknown - for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do - CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" - LDFLAGS="-m64 -Wl,$format -nostdlib -static" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - asm (".globl start; start:"); - asm (".globl _start; _start:"); - asm (".globl __start; __start:"); - void __main (void); - void __main (void) {} - ]], [[]])], [flag=1], [flag=0]) - if test x"$flag" = x1; then - grub_cv_target_cc_efiemu64_link_format="$format" - break - fi - done]) - if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then - efiemu_excuse="no suitable link format for efiemu64 found" - else - EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" - fi -fi -if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then - AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) -fi -if test x"$efiemu_excuse" = x ; then -enable_efiemu=yes -else -enable_efiemu=no -fi -AC_SUBST([enable_efiemu]) -AC_SUBST([EFIEMU64_LINK_FORMAT]) CFLAGS="$TARGET_CFLAGS" @@ -1101,6 +1041,73 @@ else TARGET_IMG_CFLAGS= fi +CFLAGS="$TARGET_CFLAGS" + +AC_ARG_ENABLE([efiemu], + [AS_HELP_STRING([--enable-efiemu], + [build and install the efiemu runtimes (default=guessed)])]) +if test x"$enable_efiemu" = xno ; then + efiemu_excuse="explicitly disabled" +fi + +if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then + efiemu_excuse="not available on cygwin" +fi +if test x"$target_cpu" != xi386 ; then + efiemu_excuse="only available on i386" +fi +if test x"$platform" = xefi ; then + efiemu_excuse="not available on efi" +fi + +if test x"$efiemu_excuse" = x ; then + AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_efiemu=yes], + [grub_cv_cc_efiemu=no]) + ]) + if test x$grub_cv_cc_efiemu = xno; then + efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" + fi +fi +if test x"$efiemu_excuse" = x ; then + AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ + grub_cv_target_cc_efiemu64_link_format=unknown + for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib -static" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + asm (".globl start; start:"); + asm (".globl _start; _start:"); + asm (".globl __start; __start:"); + void __main (void); + void __main (void) {} + ]], [[]])], [flag=1], [flag=0]) + if test x"$flag" = x1; then + grub_cv_target_cc_efiemu64_link_format="$format" + break + fi + done]) + if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then + efiemu_excuse="no suitable link format for efiemu64 found" + else + EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" + fi +fi +if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then + AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) +fi +if test x"$efiemu_excuse" = x ; then +enable_efiemu=yes +else +enable_efiemu=no +fi +AC_SUBST([enable_efiemu]) +AC_SUBST([EFIEMU64_LINK_FORMAT]) + +CFLAGS="$TARGET_CFLAGS" + AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) From ba83ed1538b8765227bcdfbfe6fa013816f85be7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 1 Jan 2016 11:13:54 +0300 Subject: [PATCH 0423/1167] Add missing BUILD_EXEEXT --- Makefile.am | 40 ++++++++++++++++++++-------------------- grub-core/Makefile.am | 2 +- grub-core/genmod.sh.in | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile.am b/Makefile.am index b8423b08d..3872b220c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,20 +89,20 @@ CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT) if COND_STARFIELD starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) -dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE) +dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 10 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_10.pf2 -dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE) +dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 12 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_12.pf2 -dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE) +dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 14 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_14.pf2 -dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE) +dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -b -s 14 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_bold_14.pf2 -dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE) +dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 16 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_16.pf2 else starfield_DATA = @@ -111,28 +111,28 @@ endif EXTRA_DIST += $(starfield_theme_files) EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf -unicode.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1) +unicode.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1) CLEANFILES += unicode.pf2 # Arrows and lines are needed to draw the menu, so always include them UNICODE_ARROWS=0x2190-0x2193 UNICODE_LINES=0x2501-0x251B -ascii.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) +ascii.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) CLEANFILES += ascii.pf2 -euro.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) +euro.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) CLEANFILES += euro.pf2 -ascii.h: $(FONT_SOURCE) build-grub-gen-asciih - ./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1) +ascii.h: $(FONT_SOURCE) build-grub-gen-asciih$(BUILD_EXEEXT) + ./build-grub-gen-asciih$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1) CLEANFILES += ascii.h -widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec - ./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1) +widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec$(BUILD_EXEEXT) + ./build-grub-gen-widthspec$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1) CLEANFILES += widthspec.h # Install config.h into platformdir diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 508e86bcd..90502cb1e 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -394,7 +394,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst -$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier +$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT) TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) platform_DATA += modinfo.sh diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index ca2e59d5c..045817b15 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -94,6 +94,6 @@ else rm -f $tmpfile.bin fi if test x@platform@ != xemu; then - ./build-grub-module-verifier $tmpfile @target_cpu@ + ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@ fi mv $tmpfile $outfile From 19554a6034edfc333143fd7dc4842429a64bbd2d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 2 Jan 2016 19:02:19 +0300 Subject: [PATCH 0424/1167] acpihalt: fix GRUB_DSDT_TEST compilation --- grub-core/commands/acpihalt.c | 2 ++ include/grub/acpi.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index da68b5b52..412a9c9ac 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -26,6 +26,8 @@ #define grub_dprintf(cond, args...) printf ( args ) #define grub_printf printf +#define grub_util_fopen fopen +#define grub_memcmp memcmp typedef uint64_t grub_uint64_t; typedef uint32_t grub_uint32_t; typedef uint16_t grub_uint16_t; diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 8a8110241..10bfbd2cd 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -22,6 +22,8 @@ #ifndef GRUB_DSDT_TEST #include #include +#else +#define GRUB_PACKED __attribute__ ((packed)) #endif #define GRUB_RSDP_SIGNATURE "RSD PTR " From aa7bb4607bb799b2790ea008bcfd8d6ca0a6d752 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 2 Jan 2016 21:33:18 +0300 Subject: [PATCH 0425/1167] acpihalt: add GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD (0x8a) Fixes ACPI halt on ASUSTeK P8B75-V, Bios: American Megatrends v: 0414 date: 04/24/2012 Reported-By: Goh Lip --- grub-core/commands/acpihalt.c | 1 + include/grub/acpi.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 412a9c9ac..9cc7f18e3 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -248,6 +248,7 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, if (!add) return -1; break; + case GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD: case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD: case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD: { diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 10bfbd2cd..a4224e046 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -221,9 +221,10 @@ enum GRUB_ACPI_OPCODE_CONCATRES = 0x84, GRUB_ACPI_OPCODE_MOD = 0x85, GRUB_ACPI_OPCODE_INDEX = 0x88, - GRUB_ACPI_OPCODE_TOSTRING = 0x9c, + GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD = 0x8a, GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b, GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c, + GRUB_ACPI_OPCODE_TOSTRING = 0x9c, GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff }; enum From 300be005a88930e1b9273c7eec7c239b6cf7beae Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 11:54:39 +0100 Subject: [PATCH 0426/1167] Update checksums --- grub-core/tests/checksums.h | 594 ++++++++---------------------------- 1 file changed, 129 insertions(+), 465 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index c9807a0dc..b42d63d25 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,465 +1,129 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xed7d2809, 0xed7d2809, 0x52c14224, 0x52c14224, 0xec52d912, 0xec52d912, 0x63276ae2, 0x63276ae2, 0xeeb4bfa4, 0xeeb4bfa4, 0xdf0f1ff0, 0xdf0f1ff0, 0xe2021708, 0xe2021708, 0x67c17085, 0x67c17085, 0x646e4d78, 0x646e4d78, 0x3b15f4b6, 0x3b15f4b6, 0xf4945ac5, 0xf4945ac5, 0x6cf60c00, 0x6cf60c00, 0x126648cd, 0x126648cd, 0xe7b8e348, 0xe7b8e348, 0x1626e35f, 0x1626e35f, 0x8022976c, 0x8022976c, 0xbc7e6d22, 0xbc7e6d22, 0xa2d50ad6, 0xa2d50ad6, 0x5072fea, 0x5072fea, 0x8481a563, 0x8481a563, 0x60a95143, 0x12fda168, 0xc8fe0549, 0xc8fe0549, }, 45 }, - { "cmdline_cat", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x154ac813, 0x5c191673, 0x154ac813, 0xeb0cc57e, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xeb0cc57e, 0xeb0cc57e, 0x43d1f34, }, 20 }, - { "gfxterm_menu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x28e6b07d, 0xf54b3d6a, 0x28e6b07d, 0x7d0bdbfb, 0x9a2e0d26, 0xb22b0963, 0xb22b0963, 0xb22b0963, 0xeef3ffa3, 0xeef3ffa3, 0xeef3ffa3, 0x36f73b6, 0x36f73b6, 0x36f73b6, 0x59c36f00, 0x7d0bdbfb, 0x7d0bdbfb, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x15bb581c, 0x7da084c6, 0x15bb581c, 0xcedba42f, 0xbc06c96d, 0xb3a8a15b, 0xb3a8a15b, 0xb3a8a15b, 0xe6f70b51, 0xe6f70b51, 0xe6f70b51, 0x8ce38109, 0x8ce38109, 0x8ce38109, 0xaa4593fe, 0xcedba42f, 0xcedba42f, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x817e5fe2, 0x134e87ff, 0x817e5fe2, 0xb83ddd98, 0xdcd8c986, 0x79244533, 0x79244533, 0x79244533, 0x69ae3a7, 0x69ae3a7, 0x69ae3a7, 0xfc10b74f, 0xfc10b74f, 0xfc10b74f, 0xc9cbf769, 0xb83ddd98, 0xb83ddd98, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x95048302, 0x9f5bac7c, 0x95048302, 0x28413b7c, 0x740d78cf, 0x620e8524, 0x620e8524, 0x620e8524, 0x89ab6f58, 0x89ab6f58, 0x89ab6f58, 0x90218e3d, 0x90218e3d, 0x90218e3d, 0x1c3742c9, 0x28413b7c, 0x28413b7c, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x6cf38a7e, 0x35fcd6e8, 0x6cf38a7e, 0x618c203c, 0xe925e70d, 0xff9c8a81, 0xff9c8a81, 0xff9c8a81, 0x90d55690, 0x90d55690, 0x90d55690, 0xd3df13a0, 0xd3df13a0, 0xd3df13a0, 0xcc5a7bed, 0x618c203c, 0x618c203c, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xd610d630, 0x98774981, 0xd610d630, 0x4469957c, 0x9869130b, 0xfb592a0d, 0xfb592a0d, 0xfb592a0d, 0x3deb6e13, 0x3deb6e13, 0x3deb6e13, 0xeaf96ec4, 0xeaf96ec4, 0xeaf96ec4, 0xef4a3312, 0x4469957c, 0x4469957c, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xf5c7a904, 0xaf9e8139, 0xf5c7a904, 0xf108ef6b, 0x91c7d0fe, 0xb57ab567, 0xb57ab567, 0xb57ab567, 0x348943b6, 0x348943b6, 0x348943b6, 0x9b076791, 0x9b076791, 0x9b076791, 0x54e48d80, 0xf108ef6b, 0xf108ef6b, }, 18 }, - { "gfxmenu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xff8ab96b, 0x72a93e7f, 0xff8ab96b, 0x47d54a82, 0x42b837cf, 0x6abd338a, 0x6abd338a, 0x6abd338a, 0x3665c54a, 0x3665c54a, 0x3665c54a, 0xdbf9495f, 0xdbf9495f, 0xdbf9495f, 0x59c36f00, 0x47d54a82, 0x47d54a82, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x73ad05f, 0x8434d91c, 0x73ad05f, 0x5316d3c6, 0xd7e75590, 0xd8493da6, 0xd8493da6, 0xd8493da6, 0x8d1697ac, 0x8d1697ac, 0x8d1697ac, 0xe7021df4, 0xe7021df4, 0xe7021df4, 0xaa4593fe, 0x5316d3c6, 0x5316d3c6, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x83e29007, 0xd4329e28, 0x83e29007, 0x8c37fac6, 0x97d4f246, 0x32287ef3, 0x32287ef3, 0x32287ef3, 0x4d96d867, 0x4d96d867, 0x4d96d867, 0xb71c8c8f, 0xb71c8c8f, 0xb71c8c8f, 0xc9cbf769, 0x8c37fac6, 0x8c37fac6, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe535f843, 0x39fb9c6c, 0xe535f843, 0x2fbd1b9, 0x7c892c8d, 0x3a8a1482, 0x3a8a1482, 0x3a8a1482, 0x2d7a2495, 0x2d7a2495, 0x2d7a2495, 0x84d821d, 0x84d821d, 0x84d821d, 0x5387d57f, 0x2fbd1b9, 0x2fbd1b9, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8f8338d3, 0xdcad6ccd, 0x8f8338d3, 0x30c612d8, 0x36353d2b, 0xa9546353, 0xa9546353, 0xa9546353, 0x960ace5a, 0x960ace5a, 0x960ace5a, 0x62e43bb9, 0x62e43bb9, 0x62e43bb9, 0xf83ee7aa, 0x30c612d8, 0x30c612d8, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xb7a13882, 0x68141e3a, 0xb7a13882, 0x65f6d15, 0x3101c32f, 0xc2b93e36, 0xc2b93e36, 0xc2b93e36, 0x1bee651a, 0x1bee651a, 0x1bee651a, 0xf7d3f08f, 0xf7d3f08f, 0xf7d3f08f, 0x724366e5, 0x65f6d15, 0x65f6d15, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x88a3c3aa, 0x8eade265, 0x88a3c3aa, 0xa5bf47d6, 0x9f8ae196, 0x56e34121, 0x56e34121, 0x56e34121, 0x2ccef01f, 0x2ccef01f, 0x2ccef01f, 0x7d1eee3b, 0x7d1eee3b, 0x7d1eee3b, 0x5387d57f, 0xa5bf47d6, 0xa5bf47d6, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8452c39c, 0x65759f4c, 0x8452c39c, 0x7459c042, 0xf9023dca, 0xe78b8902, 0xe78b8902, 0xe78b8902, 0xf0960107, 0xf0960107, 0xf0960107, 0xd52b2285, 0xd52b2285, 0xd52b2285, 0xf83ee7aa, 0x7459c042, 0x7459c042, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x938d42a2, 0x709bc8ab, 0x938d42a2, 0x4db0e2de, 0xd710f4c, 0x4e9cc80d, 0x4e9cc80d, 0x4e9cc80d, 0x9bc8a372, 0x9bc8a372, 0x9bc8a372, 0xbac90ac7, 0xbac90ac7, 0xbac90ac7, 0x724366e5, 0x4db0e2de, 0x4db0e2de, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xc060102b, 0x960bef0c, 0xc060102b, 0x1589677a, 0xe97d0978, 0xc795e31, 0xc795e31, 0xc795e31, 0xab33090, 0xab33090, 0xab33090, 0xbeea3971, 0xbeea3971, 0xbeea3971, 0x1c955882, 0x1589677a, 0x1589677a, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x6a4b2b8d, 0x274440b, 0x6a4b2b8d, 0xdef115d2, 0xed0808ad, 0x8d8ebcbb, 0x8d8ebcbb, 0x8d8ebcbb, 0x2b9b5d26, 0x2b9b5d26, 0x2b9b5d26, 0x790e10e2, 0x790e10e2, 0x790e10e2, 0x4d266f7a, 0xdef115d2, 0xdef115d2, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xdb8085be, 0x51d897c7, 0xdb8085be, 0xa3ce0221, 0x30fbd5f9, 0x12d25f5, 0x12d25f5, 0x12d25f5, 0xa4a480cb, 0xa4a480cb, 0xa4a480cb, 0xf3adca34, 0xf3adca34, 0xf3adca34, 0x1ed9d731, 0xa3ce0221, 0xa3ce0221, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x475beaa4, 0xa62db977, 0x475beaa4, 0x3a62be0, 0x311b5810, 0x7718601f, 0x7718601f, 0x7718601f, 0x60e85008, 0x60e85008, 0x60e85008, 0x45dff680, 0x45dff680, 0x45dff680, 0x5387d57f, 0x3a62be0, 0x3a62be0, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5788a7ac, 0xd4336209, 0x5788a7ac, 0x354678e9, 0x783d77de, 0xe75c29a6, 0xe75c29a6, 0xe75c29a6, 0xd80284af, 0xd80284af, 0xd80284af, 0x2cec714c, 0x2cec714c, 0x2cec714c, 0xf83ee7aa, 0x354678e9, 0x354678e9, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xd1f64ea0, 0x4abd595a, 0xd1f64ea0, 0x97a6bea1, 0xf22a4cdb, 0x192b1c2, 0x192b1c2, 0x192b1c2, 0xd8c5eaee, 0xd8c5eaee, 0xd8c5eaee, 0x34f87f7b, 0x34f87f7b, 0x34f87f7b, 0x724366e5, 0x97a6bea1, 0x97a6bea1, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xfcd5f4bb, 0x36d1826d, 0xfcd5f4bb, 0x43d7de40, 0x84467c83, 0x4d2fdc34, 0x4d2fdc34, 0x4d2fdc34, 0x37026d0a, 0x37026d0a, 0x37026d0a, 0x66d2732e, 0x66d2732e, 0x66d2732e, 0x5387d57f, 0x43d7de40, 0x43d7de40, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x21e820a3, 0x2f9bf273, 0x21e820a3, 0xaa229449, 0x61b241cd, 0x7f3bf505, 0x7f3bf505, 0x7f3bf505, 0x68267d00, 0x68267d00, 0x68267d00, 0x4d9b5e82, 0x4d9b5e82, 0x4d9b5e82, 0xf83ee7aa, 0xaa229449, 0xaa229449, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6fe66840, 0x64229598, 0x6fe66840, 0xedc02d98, 0x7131f7aa, 0x32dc30eb, 0x32dc30eb, 0x32dc30eb, 0xe7885b94, 0xe7885b94, 0xe7885b94, 0xc689f221, 0xc689f221, 0xc689f221, 0x724366e5, 0xedc02d98, 0xedc02d98, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xdb159e45, 0x9b1475c9, 0xdb159e45, 0xaee6597b, 0x573454, 0xe553631d, 0xe553631d, 0xe553631d, 0xe3990dbc, 0xe3990dbc, 0xe3990dbc, 0x57c0045d, 0x57c0045d, 0x57c0045d, 0x1c955882, 0xaee6597b, 0xaee6597b, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9a43dfc6, 0x67153087, 0x9a43dfc6, 0xe9bd482c, 0xe763cddd, 0x87e579cb, 0x87e579cb, 0x87e579cb, 0x21f09856, 0x21f09856, 0x21f09856, 0x7365d592, 0x7365d592, 0x7365d592, 0x4d266f7a, 0xe9bd482c, 0xe9bd482c, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x78bf287, 0x8e68ddb4, 0x78bf287, 0xb2b0d4a4, 0xcb49fd6e, 0xfa9f0d62, 0xfa9f0d62, 0xfa9f0d62, 0x5f16a85c, 0x5f16a85c, 0x5f16a85c, 0x81fe2a3, 0x81fe2a3, 0x81fe2a3, 0x1ed9d731, 0xb2b0d4a4, 0xb2b0d4a4, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xb7ccf7ca, 0xfe517937, 0xb7ccf7ca, 0xfa1f93fd, 0x83d93b90, 0x95dac67b, 0x95dac67b, 0x95dac67b, 0x7e7f2c07, 0x7e7f2c07, 0x7e7f2c07, 0x67f5cd62, 0x67f5cd62, 0x67f5cd62, 0x1c3742c9, 0xfa1f93fd, 0xfa1f93fd, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x663d292a, 0xa008c39, 0x663d292a, 0xcd82113f, 0x1c0b0f02, 0xab2628e, 0xab2628e, 0xab2628e, 0x65fbbe9f, 0x65fbbe9f, 0x65fbbe9f, 0x26f1fbaf, 0x26f1fbaf, 0x26f1fbaf, 0xcc5a7bed, 0xcd82113f, 0xcd82113f, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xef4a3312, 0xfc2f0ab1, 0x6861f25e, 0xfc2f0ab1, 0x11b6b6f7, 0xcd618f3f, 0xae51b639, 0xae51b639, 0xae51b639, 0x68e3f227, 0x68e3f227, 0x68e3f227, 0xbff1f2f0, 0xbff1f2f0, 0xbff1f2f0, 0xef4a3312, 0x11b6b6f7, 0x11b6b6f7, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf799219, 0xcec61405, 0xbf799219, 0x413f9f74, 0x43d1f34, 0x43d1f34, 0x9dc6a6fb, 0x9dc6a6fb, 0x9dc6a6fb, 0xe2cc0f53, 0xe2cc0f53, 0xe2cc0f53, 0xaec367a, 0xaec367a, 0xaec367a, 0x43d1f34, 0x413f9f74, 0x413f9f74, 0x43d1f34, }, 20 }, - { "gfxterm_ar", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfbdee88, 0x812f047f, 0xfbdee88, 0xf1fbe3e5, 0x43d1f34, 0x43d1f34, 0x6694d5e, 0x6694d5e, 0x6694d5e, 0x7963e4f6, 0x7963e4f6, 0x7963e4f6, 0x9143dddf, 0x9143dddf, 0x9143dddf, 0x43d1f34, 0xf1fbe3e5, 0xf1fbe3e5, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6d1ede55, 0x4bb31527, 0x6d1ede55, 0x9358d338, 0x43d1f34, 0x43d1f34, 0xa3f91b32, 0xa3f91b32, 0xa3f91b32, 0xdcf3b29a, 0xdcf3b29a, 0xdcf3b29a, 0x34d38bb3, 0x34d38bb3, 0x34d38bb3, 0x43d1f34, 0x9358d338, 0x9358d338, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb5c5482e, 0xeec9616, 0xb5c5482e, 0x4b834543, 0x43d1f34, 0x43d1f34, 0xd4fadab2, 0xd4fadab2, 0xd4fadab2, 0xabf0731a, 0xabf0731a, 0xabf0731a, 0x43d04a33, 0x43d04a33, 0x43d04a33, 0x43d1f34, 0x4b834543, 0x4b834543, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc009461b, 0xbaf1821c, 0xc009461b, 0x3e4f4b76, 0x43d1f34, 0x43d1f34, 0x19165017, 0x19165017, 0x19165017, 0x661cf9bf, 0x661cf9bf, 0x661cf9bf, 0x8e3cc096, 0x8e3cc096, 0x8e3cc096, 0x43d1f34, 0x3e4f4b76, 0x3e4f4b76, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd89b7256, 0xe60a4e85, 0xd89b7256, 0x26dd7f3b, 0x43d1f34, 0x43d1f34, 0x55b946c0, 0x55b946c0, 0x55b946c0, 0x2ab3ef68, 0x2ab3ef68, 0x2ab3ef68, 0xc293d641, 0xc293d641, 0xc293d641, 0x43d1f34, 0x26dd7f3b, 0x26dd7f3b, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x58828a1e, 0x11d1547e, 0x58828a1e, 0xa6c48773, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xa6c48773, 0xa6c48773, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x74a1734e, 0x3152f141, 0x74a1734e, 0x8ae77e23, 0x43d1f34, 0x43d1f34, 0x83c19830, 0x83c19830, 0x83c19830, 0xfccb3198, 0xfccb3198, 0xfccb3198, 0x14eb08b1, 0x14eb08b1, 0x14eb08b1, 0x43d1f34, 0x8ae77e23, 0x8ae77e23, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x505523f2, 0x24d00e51, 0x505523f2, 0xae132e9f, 0x43d1f34, 0x43d1f34, 0xcaaadc5e, 0xcaaadc5e, 0xcaaadc5e, 0xb5a075f6, 0xb5a075f6, 0xb5a075f6, 0x5d804cdf, 0x5d804cdf, 0x5d804cdf, 0x43d1f34, 0xae132e9f, 0xae132e9f, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf168f0ba, 0x151608f2, 0xf168f0ba, 0x1f8e266b, 0x9813a416, 0x9813a416, 0x358d1fb0, 0x358d1fb0, 0x358d1fb0, 0xa4569983, 0xa4569983, 0xa4569983, 0x38236c41, 0x38236c41, 0x38236c41, 0x9813a416, 0x1f8e266b, 0x1f8e266b, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x927c4cf9, 0xdefa0b3b, 0x927c4cf9, 0x64636a93, 0x5fcf013d, 0x5fcf013d, 0xae2ee3eb, 0xae2ee3eb, 0xae2ee3eb, 0x7c3efb9d, 0x7c3efb9d, 0x7c3efb9d, 0x63157a60, 0x63157a60, 0x63157a60, 0x5fcf013d, 0x64636a93, 0x64636a93, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d254926, 0x796275ce, 0x2d254926, 0x17c0c9cb, 0xdd28f52b, 0xdd28f52b, 0x79439443, 0x79439443, 0x79439443, 0x587f6da7, 0x587f6da7, 0x587f6da7, 0x420e0e36, 0x420e0e36, 0x420e0e36, 0xdd28f52b, 0x17c0c9cb, 0x17c0c9cb, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x755377f, 0x4e06e91f, 0x755377f, 0xe42f3a5, 0x43d1f34, 0x43d1f34, 0x3ac2d7b5, 0x3ac2d7b5, 0x3ac2d7b5, 0x45c87e1d, 0x45c87e1d, 0x45c87e1d, 0xade84734, 0xade84734, 0xade84734, 0x43d1f34, 0xe42f3a5, 0xe42f3a5, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xcffd463e, 0x59775566, 0xcffd463e, 0xb4e87140, 0x5387d57f, 0x5387d57f, 0xc2a27e06, 0xc2a27e06, 0xc2a27e06, 0x2fb12ca, 0x2fb12ca, 0x2fb12ca, 0xe525905c, 0xe525905c, 0xe525905c, 0x5387d57f, 0xb4e87140, 0xb4e87140, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x91d12daf, 0xdceabc0e, 0x91d12daf, 0xf372b81f, 0xf83ee7aa, 0xf83ee7aa, 0x85a69692, 0x85a69692, 0x85a69692, 0x19df4661, 0x19df4661, 0x19df4661, 0x216cedc9, 0x216cedc9, 0x216cedc9, 0xf83ee7aa, 0xf372b81f, 0xf372b81f, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5f5953b3, 0x1f88963e, 0x5f5953b3, 0x6aeb9112, 0x724366e5, 0x724366e5, 0xc5da2432, 0xc5da2432, 0xc5da2432, 0x82e366c8, 0x82e366c8, 0x82e366c8, 0xefcd4182, 0xefcd4182, 0xefcd4182, 0x724366e5, 0x6aeb9112, 0x6aeb9112, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1227533e, 0xee3616e0, 0x1227533e, 0xc32db32e, 0x5387d57f, 0x5387d57f, 0xa347c834, 0xa347c834, 0xa347c834, 0x7d8987e9, 0x7d8987e9, 0x7d8987e9, 0xee0a15f7, 0xee0a15f7, 0xee0a15f7, 0x5387d57f, 0xc32db32e, 0xc32db32e, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc548a908, 0x2624be34, 0xc548a908, 0x1745599, 0xf83ee7aa, 0xf83ee7aa, 0xaaaf7e14, 0xaaaf7e14, 0xaaaf7e14, 0xd8756d24, 0xd8756d24, 0xd8756d24, 0xe9e03ce2, 0xe9e03ce2, 0xe9e03ce2, 0xf83ee7aa, 0x1745599, 0x1745599, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x30506e44, 0x76cf9d03, 0x30506e44, 0x33485d71, 0x724366e5, 0x724366e5, 0xd12bc953, 0xd12bc953, 0xd12bc953, 0x88bb3a03, 0x88bb3a03, 0x88bb3a03, 0x400c5441, 0x400c5441, 0x400c5441, 0x724366e5, 0x33485d71, 0x33485d71, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xa3238023, 0xa5b82f9e, 0xa3238023, 0x93f8a252, 0x1c955882, 0x1c955882, 0x205b041f, 0x205b041f, 0x205b041f, 0xefac4988, 0xefac4988, 0xefac4988, 0x11c5459d, 0x11c5459d, 0x11c5459d, 0x1c955882, 0x93f8a252, 0x93f8a252, 0x1c955882, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xf651c995, 0x7e1ae3d7, 0xf651c995, 0xdab860af, 0x4d266f7a, 0x4d266f7a, 0x6272be10, 0x6272be10, 0x6272be10, 0x8405a5af, 0x8405a5af, 0x8405a5af, 0x1c3cf13f, 0x1c3cf13f, 0x1c3cf13f, 0x4d266f7a, 0xdab860af, 0xdab860af, 0x4d266f7a, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x2fa6119, 0x30618885, 0x2fa6119, 0xbfbe1b6a, 0x1ed9d731, 0x1ed9d731, 0x11353cf5, 0x11353cf5, 0x11353cf5, 0xbf512230, 0xbf512230, 0xbf512230, 0x9c383386, 0x9c383386, 0x9c383386, 0x1ed9d731, 0xbfbe1b6a, 0xbfbe1b6a, 0x1ed9d731, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x4caf1997, 0xda250acf, 0x4caf1997, 0x2183903f, 0x5387d57f, 0x5387d57f, 0x6be656ff, 0x6be656ff, 0x6be656ff, 0xabbf3a33, 0xabbf3a33, 0xabbf3a33, 0x4c61b8a5, 0x4c61b8a5, 0x4c61b8a5, 0x5387d57f, 0x2183903f, 0x2183903f, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x7b29cc8e, 0x36125d2f, 0x7b29cc8e, 0x1277092, 0xf83ee7aa, 0xf83ee7aa, 0x4830d5b5, 0x4830d5b5, 0x4830d5b5, 0xd4490546, 0xd4490546, 0xd4490546, 0xecfaaeee, 0xecfaaeee, 0xecfaaeee, 0xf83ee7aa, 0x1277092, 0x1277092, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2e644de2, 0x6eb5886f, 0x2e644de2, 0x3d66c6af, 0x724366e5, 0x724366e5, 0x5d800f18, 0x5d800f18, 0x5d800f18, 0x1ab94de2, 0x1ab94de2, 0x1ab94de2, 0x77976aa8, 0x77976aa8, 0x77976aa8, 0x724366e5, 0x3d66c6af, 0x3d66c6af, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x5f11f8eb, 0xa300bd35, 0x5f11f8eb, 0xe2cba3fa, 0x5387d57f, 0x5387d57f, 0xfa2cee75, 0xfa2cee75, 0xfa2cee75, 0x24e2a1a8, 0x24e2a1a8, 0x24e2a1a8, 0xb76133b6, 0xb76133b6, 0xb76133b6, 0x5387d57f, 0xe2cba3fa, 0xe2cba3fa, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x179340b2, 0xf4ff578e, 0x179340b2, 0xe378eba9, 0xf83ee7aa, 0xf83ee7aa, 0xf787fcc2, 0xf787fcc2, 0xf787fcc2, 0x855deff2, 0x855deff2, 0x855deff2, 0xb4c8be34, 0xb4c8be34, 0xb4c8be34, 0xf83ee7aa, 0xe378eba9, 0xe378eba9, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x5703fa5a, 0x119c091d, 0x5703fa5a, 0xa13f0d1a, 0x724366e5, 0x724366e5, 0xd989a04d, 0xd989a04d, 0xd989a04d, 0x8019531d, 0x8019531d, 0x8019531d, 0x48ae3d5f, 0x48ae3d5f, 0x48ae3d5f, 0x724366e5, 0xa13f0d1a, 0xa13f0d1a, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xf38c2b36, 0xf517848b, 0xf38c2b36, 0xa2621779, 0x1c955882, 0x1c955882, 0x153777fa, 0x153777fa, 0x153777fa, 0xdac03a6d, 0xdac03a6d, 0xdac03a6d, 0x24a93678, 0x24a93678, 0x24a93678, 0x1c955882, 0xa2621779, 0xa2621779, 0x1c955882, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb8253868, 0x306e122a, 0xb8253868, 0x83b58e9b, 0x4d266f7a, 0x4d266f7a, 0x98183444, 0x98183444, 0x98183444, 0x7e6f2ffb, 0x7e6f2ffb, 0x7e6f2ffb, 0xe6567b6b, 0xe6567b6b, 0xe6567b6b, 0x4d266f7a, 0x83b58e9b, 0x83b58e9b, 0x4d266f7a, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x40c62f40, 0x725dc6dc, 0x40c62f40, 0x50dfba34, 0x1ed9d731, 0x1ed9d731, 0x32e89a68, 0x32e89a68, 0x32e89a68, 0x9c8c84ad, 0x9c8c84ad, 0x9c8c84ad, 0xbfe5951b, 0xbfe5951b, 0xbfe5951b, 0x1ed9d731, 0x50dfba34, 0x50dfba34, 0x1ed9d731, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xfaeb56f1, 0x1e95aeb9, 0xfaeb56f1, 0xe4ddf18b, 0x9813a416, 0x9813a416, 0x5da5926f, 0x5da5926f, 0x5da5926f, 0xcc7e145c, 0xcc7e145c, 0xcc7e145c, 0x500be19e, 0x500be19e, 0x500be19e, 0x9813a416, 0xe4ddf18b, 0xe4ddf18b, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa11f0307, 0xed9944c5, 0xa11f0307, 0x93a8828e, 0x5fcf013d, 0x5fcf013d, 0xeabf61dc, 0xeabf61dc, 0xeabf61dc, 0x38af79aa, 0x38af79aa, 0x38af79aa, 0x2784f857, 0x2784f857, 0x2784f857, 0x5fcf013d, 0x93a8828e, 0x93a8828e, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeedd0ec5, 0xba9a322d, 0xeedd0ec5, 0x32205338, 0xdd28f52b, 0xdd28f52b, 0x14854a2b, 0x14854a2b, 0x14854a2b, 0x35b9b3cf, 0x35b9b3cf, 0x35b9b3cf, 0x2fc8d05e, 0x2fc8d05e, 0x2fc8d05e, 0xdd28f52b, 0x32205338, 0x32205338, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf2b1715, 0xeb55ef5d, 0xf2b1715, 0x61e172d4, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x61e172d4, 0x61e172d4, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2a517b4, 0x4e235076, 0x2a517b4, 0x85b73555, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x85b73555, 0x85b73555, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x53e34b0f, 0x7a477e7, 0x53e34b0f, 0x7b92ba0b, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x7b92ba0b, 0x7b92ba0b, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcccbb8c0, 0x859866a0, 0xcccbb8c0, 0x2bf5b2f8, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0x2bf5b2f8, 0x2bf5b2f8, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc2dae336, 0x5450f06e, 0xc2dae336, 0x2fd25c3, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x2fd25c3, 0x2fd25c3, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf910eb1d, 0xb42b7abc, 0xf910eb1d, 0x6d5e8f22, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x6d5e8f22, 0x6d5e8f22, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xa038bbb4, 0xe0e97e39, 0xa038bbb4, 0x4211aeac, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x4211aeac, 0x4211aeac, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a2dd1b7, 0xb63c9469, 0x4a2dd1b7, 0xe8aea440, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xe8aea440, 0xe8aea440, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8597e648, 0x66fbf174, 0x8597e648, 0xa99c8f36, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa99c8f36, 0xa99c8f36, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7c1b6088, 0x3a8493cf, 0x7c1b6088, 0xd5d88a3e, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd5d88a3e, 0xd5d88a3e, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x9f45f149, 0x99de5ef4, 0x9f45f149, 0x84437bc3, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x84437bc3, 0x84437bc3, 0x1c955882, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x60f3276d, 0xe8b80d2f, 0x60f3276d, 0x1d7bae65, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x1d7bae65, 0x1d7bae65, 0x4d266f7a, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x66a98ee6, 0x5432677a, 0x66a98ee6, 0x691b88fb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x691b88fb, 0x691b88fb, 0x1ed9d731, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc26d8183, 0x54e792db, 0xc26d8183, 0x1473f9a0, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x1473f9a0, 0x1473f9a0, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x3ed65cd5, 0x73edcd74, 0x3ed65cd5, 0xb2351146, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0xb2351146, 0xb2351146, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xc576da57, 0x85a71fda, 0xc576da57, 0x1ef86a3, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x1ef86a3, 0x1ef86a3, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4778be32, 0xbb69fbec, 0x4778be32, 0x892b70c4, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x892b70c4, 0x892b70c4, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9c6c6004, 0x7f007738, 0x9c6c6004, 0x80b05ef0, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0x80b05ef0, 0x80b05ef0, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x84caa3c1, 0xc2555086, 0x84caa3c1, 0xd82d8d02, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd82d8d02, 0xd82d8d02, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe4dec6e6, 0xe245695b, 0xe4dec6e6, 0x9eed5252, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x9eed5252, 0x9eed5252, 0x1c955882, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x19a935eb, 0x91e21fa9, 0x19a935eb, 0x7358a32a, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x7358a32a, 0x7358a32a, 0x4d266f7a, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xb2b10aa1, 0x802ae33d, 0xb2b10aa1, 0x105ee3bb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x105ee3bb, 0x105ee3bb, 0x1ed9d731, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xeedf19a8, 0xaa1e1e0, 0xeedf19a8, 0x70c50dc2, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x70c50dc2, 0x70c50dc2, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa474246a, 0xe8f263a8, 0xa474246a, 0xe7cea168, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0xe7cea168, 0xe7cea168, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x653aabb4, 0x317d975c, 0x653aabb4, 0xab5387a0, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0xab5387a0, 0xab5387a0, 0xdd28f52b, }, 20 }, - { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, }, 5 }, - { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, }, 5 }, - { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x2b154617, 0x692e98df, 0xaf62fb87, 0xed59254f, 0x26164bc6, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x3b0fbc56, 0xd9d57c0e, 0xfb564a17, 0x198c8a4f, 0xbe502625, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x6e6c9b36, 0x4ae9f137, 0x27664f34, 0x3e32535, 0xfc793332, }, 5 }, - { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x91692eef, 0x89773091, 0xa1551213, 0xb94b0c6d, 0xf1115717, }, 5 }, - { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, }, 5 }, - { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, }, 5 }, - { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x61db45b7, 0x1d867efe, 0x99613325, 0xe53c086c, 0x9543de62, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xa46eb37f, 0xd2a59656, 0x49f8f92d, 0x3f33dc04, 0x7aae512a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xb864a496, 0x6c22313b, 0x1505f93d, 0xc1436c90, 0xe74a6931, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x4af6b480, 0x923db79c, 0xfe8cc449, 0x2647c755, 0x27ee23e3, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x121d5e29, 0xf66c0aed, 0xdf138150, 0x3b62d594, 0x8dec962a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0xae86a12c, 0x4dabbe89, 0x6d30e897, 0x8e1df732, 0x2c0644ab, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x2605d280, 0xc06e3172, 0xef3e6395, 0x9558067, 0xb19ec65b, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x9404ef3b, 0xa4fdf18, 0xad7ef98c, 0x3335c9af, 0xe6f0c255, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xa008b770, 0xb98eb0d8, 0x9304b820, 0x8a82bf88, 0xc610a9d0, }, 5 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24dc7bce, 0x24dc7bce, 0x338542b, 0x338542b, 0x2016b9d1, 0x2016b9d1, 0xc2619a36, 0xc2619a36, 0x10fce1e, 0x10fce1e, 0x8267298e, 0x8267298e, 0xf44246cf, 0xf44246cf, 0x3ee2860f, 0x3ee2860f, 0x1191f916, 0x1191f916, 0xfa8ce1b5, 0xfa8ce1b5, 0xc1f18b8e, 0xc1f18b8e, 0x43f8c0e8, 0x43f8c0e8, 0xbc0d166a, 0xbc0d166a, 0x7b742e8f, 0x7b742e8f, 0x2c3c7f89, 0x2c3c7f89, 0x80148a7e, 0x80148a7e, 0x21daaadf, 0x21daaadf, 0x15e97fa9, 0x15e97fa9, 0x2428d454, 0x2428d454, 0xb12b0f78, 0xb12b0f78, 0x29648b05, 0x8ce36e6f, 0xd26b03dd, 0xd26b03dd, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd09d4d28, 0xd09d4d28, 0xb41a2f17, 0xb41a2f17, 0x56381354, 0x56381354, 0xf2c5615f, 0xf2c5615f, 0xa41822ae, 0xa41822ae, 0xba2e3e60, 0xba2e3e60, 0x1859aaac, 0x1859aaac, 0x6c354a92, 0x6c354a92, 0x652d3eb, 0x652d3eb, 0xffcf0fd8, 0xffcf0fd8, 0xd3c9187c, 0xd3c9187c, 0xdee59346, 0xdee59346, 0x950f6354, 0x950f6354, 0xa2f7e36a, 0xa2f7e36a, 0x3967359a, 0x3967359a, 0x12738c9a, 0x12738c9a, 0xffb94ca3, 0xffb94ca3, 0xd9384791, 0xd9384791, 0xade1fd25, 0xade1fd25, 0xca109ebe, 0xca109ebe, 0x6e794e, 0x20d769cf, 0x29cc1fdc, 0x29cc1fdc, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6cfe9089, 0x6cfe9089, 0xbe85dea2, 0xbe85dea2, 0x5f57923d, 0x5f57923d, 0xd28ad04b, 0xd28ad04b, 0x9ac91b28, 0x9ac91b28, 0x26977f54, 0x26977f54, 0x56cfda54, 0x56cfda54, 0xae54550f, 0xae54550f, 0x5843182b, 0x5843182b, 0xa1524272, 0xa1524272, 0x86b707db, 0x86b707db, 0x4127540e, 0x4127540e, 0xe89ea08e, 0xe89ea08e, 0x85f4dccc, 0x85f4dccc, 0xf910d16c, 0xf910d16c, 0xd43ff6b8, 0xd43ff6b8, 0xcdec4fd0, 0xcdec4fd0, 0xad650879, 0xad650879, 0x6d8e01c7, 0x6d8e01c7, 0x3ce7c69f, 0x3ce7c69f, 0xed54e2ef, 0x141319e, 0x9003a604, 0x9003a604, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x37f1b28e, 0x37f1b28e, 0x248de37a, 0x248de37a, 0x8b84bbe6, 0x8b84bbe6, 0x62efb943, 0x62efb943, 0x50d082fd, 0x50d082fd, 0x68a0c1, 0x68a0c1, 0xa335f8d0, 0xa335f8d0, 0xf26eaa27, 0xf26eaa27, 0x9f661fa2, 0x9f661fa2, 0x9a9c6bcb, 0x9a9c6bcb, 0xa5427057, 0xa5427057, 0x59aabcc8, 0x59aabcc8, 0xd1563970, 0xd1563970, 0x5f65ea2e, 0x5f65ea2e, 0xce189d5e, 0xce189d5e, 0xa0ac6e61, 0xa0ac6e61, 0xf85ec3, 0xf85ec3, 0xa6a5bea8, 0xa6a5bea8, 0xae55a1ba, 0xae55a1ba, 0x23f4e9e3, 0x23f4e9e3, 0x580abc5c, 0x58b54e7f, 0xafe85bbb, 0xafe85bbb, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6d4812ec, 0x6d4812ec, 0x9d93973a, 0x9d93973a, 0x88cb4e17, 0x88cb4e17, 0x81f14f0a, 0x81f14f0a, 0x7f9f1875, 0x7f9f1875, 0x292f8345, 0x292f8345, 0x524cefe0, 0x524cefe0, 0x5d02251, 0x5d02251, 0x61afaf9e, 0x61afaf9e, 0xc327f8b9, 0xc327f8b9, 0xa1ece03d, 0xa1ece03d, 0xbb98b63c, 0xbb98b63c, 0x61b920db, 0x61b920db, 0xb1571b03, 0xb1571b03, 0xd315b012, 0xd315b012, 0xee77780c, 0xee77780c, 0x9b6ce52e, 0x9b6ce52e, 0x3b18a467, 0x3b18a467, 0x5ab91ffb, 0x5ab91ffb, 0x9255edea, 0x9255edea, 0x9ca85712, 0xa249a7fa, 0x213825f8, 0x213825f8, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10bc4224, 0x10bc4224, 0xb8085994, 0xb8085994, 0x6ab26d0a, 0x6ab26d0a, 0xde71396c, 0xde71396c, 0x425a3956, 0x425a3956, 0xb7d2a7e3, 0xb7d2a7e3, 0x658ab388, 0x658ab388, 0x3fadf9dc, 0x3fadf9dc, 0xb29884ae, 0xb29884ae, 0x3a0830a7, 0x3a0830a7, 0xcf41267a, 0xcf41267a, 0x121c9703, 0x121c9703, 0xd126f87c, 0xd126f87c, 0x3b9d5bf6, 0x3b9d5bf6, 0x2a05cbef, 0x2a05cbef, 0x9ad41c2c, 0x9ad41c2c, 0xebf19db8, 0xebf19db8, 0x79f1b335, 0x79f1b335, 0xad2f9e8d, 0xad2f9e8d, 0x99596c48, 0x99596c48, 0x75b1cae6, 0x3cd081b2, 0x23e8ef2f, 0x23e8ef2f, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8920d2ff, 0x8920d2ff, 0x369cb8d2, 0x369cb8d2, 0x880f23e4, 0x880f23e4, 0xf4a02ce2, 0xf4a02ce2, 0x7933f9a4, 0x7933f9a4, 0x488859f0, 0x488859f0, 0x75855108, 0x75855108, 0xf0463685, 0xf0463685, 0xf3e90b78, 0xf3e90b78, 0xac92b2b6, 0xac92b2b6, 0x63131cc5, 0x63131cc5, 0xfb714a00, 0xfb714a00, 0xc495c9a0, 0xc495c9a0, 0x314b6225, 0x314b6225, 0xc0d56232, 0xc0d56232, 0xa051d312, 0xa051d312, 0x9c0d295c, 0x9c0d295c, 0x3f234b5, 0x3f234b5, 0xa4201189, 0xa4201189, 0x23af1b2f, 0x23af1b2f, 0xc787ef0f, 0x2a3c46f8, 0xf03fe2d9, 0xf03fe2d9, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdff707ef, 0xb938eb6c, 0xdff707ef, 0x9c01caa8, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x9c01caa8, 0x9c01caa8, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x59f141e3, 0xfddbc65b, 0x59f141e3, 0x77f4c49c, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0x77f4c49c, 0x77f4c49c, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9ac56bc2, 0x2049341a, 0x9ac56bc2, 0xc7d20646, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0xc7d20646, 0xc7d20646, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd50b603, 0xbef0bf34, 0xd50b603, 0xa306ffdb, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xa306ffdb, 0xa306ffdb, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9408bd4d, 0x84fea62c, 0x9408bd4d, 0xe2ae88fe, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xe2ae88fe, 0xe2ae88fe, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8460b76a, 0xd01813b4, 0x8460b76a, 0x9f656d6d, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0x9f656d6d, 0x9f656d6d, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x115542af, 0xbac49512, 0x115542af, 0xeeea592f, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xeeea592f, 0xeeea592f, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0x35f491f9, 0x35f491f9, 0x35f491f9, 0x692c6739, 0x692c6739, 0x692c6739, 0x40b4a9ab, 0x40b4a9ab, 0x40b4a9ab, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0xeee84c5, 0xeee84c5, 0xeee84c5, 0x5bb12ecf, 0x5bb12ecf, 0x5bb12ecf, 0x3282e686, 0x3282e686, 0x3282e686, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x2cf5262a, 0x2cf5262a, 0x2cf5262a, 0x534b80be, 0x534b80be, 0x534b80be, 0x113fe0c6, 0x113fe0c6, 0x113fe0c6, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x7bd2e3a3, 0x7bd2e3a3, 0x7bd2e3a3, 0x907709df, 0x907709df, 0x907709df, 0x963c092f, 0x963c092f, 0x963c092f, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0xd45c93dc, 0xd45c93dc, 0xd45c93dc, 0xbb154fcd, 0xbb154fcd, 0xbb154fcd, 0xb6e3d1ce, 0xb6e3d1ce, 0xb6e3d1ce, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x304db662, 0x304db662, 0x304db662, 0xf6fff27c, 0xf6fff27c, 0xf6fff27c, 0xe29a22c3, 0xe29a22c3, 0xe29a22c3, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0xe0ddd143, 0xe0ddd143, 0xe0ddd143, 0x612e2792, 0x612e2792, 0x612e2792, 0xf78a9efd, 0xf78a9efd, 0xf78a9efd, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3d69d4f7, 0x5b2df52e, 0x3d69d4f7, 0x7e9f19b0, 0x59c36f00, 0x59c36f00, 0xaa418d14, 0xaa418d14, 0xaa418d14, 0xd4c1e072, 0xd4c1e072, 0xd4c1e072, 0xb637f5a0, 0xb637f5a0, 0xb637f5a0, 0x59c36f00, 0x7e9f19b0, 0x7e9f19b0, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xea153935, 0xadda68ff, 0xea153935, 0xc410bc4a, 0xaa4593fe, 0xaa4593fe, 0x63090f39, 0x63090f39, 0x63090f39, 0xc5fc025e, 0xc5fc025e, 0xc5fc025e, 0xe8c4a926, 0xe8c4a926, 0xe8c4a926, 0xaa4593fe, 0xc410bc4a, 0xc410bc4a, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe677248f, 0x9a146b56, 0xe677248f, 0xbb60490b, 0xc9cbf769, 0xc9cbf769, 0xebd87b6a, 0xebd87b6a, 0xebd87b6a, 0x1500baa6, 0x1500baa6, 0x1500baa6, 0xfc4a05ae, 0xfc4a05ae, 0xfc4a05ae, 0xc9cbf769, 0xbb60490b, 0xbb60490b, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2fe1d8b3, 0x344dc22f, 0x2fe1d8b3, 0x81b7916b, 0x9813a416, 0x9813a416, 0xb42009b, 0xb42009b, 0xb42009b, 0x9a9986a8, 0x9a9986a8, 0x9a9986a8, 0x8323bb78, 0x8323bb78, 0x8323bb78, 0x9813a416, 0x81b7916b, 0x81b7916b, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2f2ab760, 0x373afa93, 0x2f2ab760, 0x598c82d3, 0x5fcf013d, 0x5fcf013d, 0x8a9a15e2, 0x8a9a15e2, 0x8a9a15e2, 0x588a0d94, 0x588a0d94, 0x588a0d94, 0x4ef9320b, 0x4ef9320b, 0x4ef9320b, 0x5fcf013d, 0x598c82d3, 0x598c82d3, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb9de66a8, 0x2b705981, 0xb9de66a8, 0xa2dbbcaf, 0xdd28f52b, 0xdd28f52b, 0x971eb98b, 0x971eb98b, 0x971eb98b, 0xb622406f, 0xb622406f, 0xb622406f, 0xcb9a8be3, 0xcb9a8be3, 0xcb9a8be3, 0xdd28f52b, 0xa2dbbcaf, 0xa2dbbcaf, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84029f68, 0x7385ec77, 0x84029f68, 0x7bbd84e8, 0x43d1f34, 0x43d1f34, 0x73cb201f, 0x73cb201f, 0x73cb201f, 0xcc189b7, 0xcc189b7, 0xcc189b7, 0x95908c31, 0x95908c31, 0x95908c31, 0x43d1f34, 0x7bbd84e8, 0x7bbd84e8, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2446469, 0xca75968f, 0xb2446469, 0xf1b2a92e, 0x59c36f00, 0x59c36f00, 0xc0eac671, 0xc0eac671, 0xc0eac671, 0xbe6aab17, 0xbe6aab17, 0xbe6aab17, 0xdc9cbec5, 0xdc9cbec5, 0xdc9cbec5, 0x59c36f00, 0xf1b2a92e, 0xf1b2a92e, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe219612c, 0x41ad1120, 0xe219612c, 0xcc1ce453, 0xaa4593fe, 0xaa4593fe, 0x1f05167, 0x1f05167, 0x1f05167, 0xa7055c00, 0xa7055c00, 0xa7055c00, 0x8a3df778, 0x8a3df778, 0x8a3df778, 0xaa4593fe, 0xcc1ce453, 0xcc1ce453, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f3ca4a3, 0x3df9621e, 0x9f3ca4a3, 0xc22bc927, 0xc9cbf769, 0xc9cbf769, 0x8f0b71ba, 0x8f0b71ba, 0x8f0b71ba, 0x71d3b076, 0x71d3b076, 0x71d3b076, 0x98990f7e, 0x98990f7e, 0x98990f7e, 0xc9cbf769, 0xc22bc927, 0xc22bc927, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6b1e7755, 0x4532973e, 0x6b1e7755, 0xc5483e8d, 0x9813a416, 0x9813a416, 0xa279dbc8, 0xa279dbc8, 0xa279dbc8, 0x33a25dfb, 0x33a25dfb, 0x33a25dfb, 0x2a18602b, 0x2a18602b, 0x2a18602b, 0x9813a416, 0xc5483e8d, 0xc5483e8d, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa3774c63, 0x38dffb0e, 0xa3774c63, 0xd5d179d0, 0x5fcf013d, 0x5fcf013d, 0x28872666, 0x28872666, 0x28872666, 0xfa973e10, 0xfa973e10, 0xfa973e10, 0xece4018f, 0xece4018f, 0xece4018f, 0x5fcf013d, 0xd5d179d0, 0xd5d179d0, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe9556aa5, 0x77425030, 0xe9556aa5, 0xf250b0a2, 0xdd28f52b, 0xdd28f52b, 0x938cfa6a, 0x938cfa6a, 0x938cfa6a, 0xb2b0038e, 0xb2b0038e, 0xb2b0038e, 0xcf08c802, 0xcf08c802, 0xcf08c802, 0xdd28f52b, 0xf250b0a2, 0xf250b0a2, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9adc43d0, 0xd8ac5204, 0x9adc43d0, 0x65635850, 0x43d1f34, 0x43d1f34, 0xc182db12, 0xc182db12, 0xc182db12, 0xbe8872ba, 0xbe8872ba, 0xbe8872ba, 0x27d9773c, 0x27d9773c, 0x27d9773c, 0x43d1f34, 0x65635850, 0x65635850, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7fd0187d, 0x7d05975c, 0x7fd0187d, 0x3c26d53a, 0x59c36f00, 0x59c36f00, 0xb4fad8de, 0xb4fad8de, 0xb4fad8de, 0xca7ab5b8, 0xca7ab5b8, 0xca7ab5b8, 0xa88ca06a, 0xa88ca06a, 0xa88ca06a, 0x59c36f00, 0x3c26d53a, 0x3c26d53a, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f3fad9, 0xe7a5a67a, 0x54f3fad9, 0x7af67fa6, 0xaa4593fe, 0xaa4593fe, 0xcae58c6a, 0xcae58c6a, 0xcae58c6a, 0x6c10810d, 0x6c10810d, 0x6c10810d, 0x41282a75, 0x41282a75, 0x41282a75, 0xaa4593fe, 0x7af67fa6, 0x7af67fa6, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x869916b8, 0x373dbcc3, 0x869916b8, 0xdb8e7b3c, 0xc9cbf769, 0xc9cbf769, 0xaa0c75c1, 0xaa0c75c1, 0xaa0c75c1, 0x54d4b40d, 0x54d4b40d, 0x54d4b40d, 0xbd9e0b05, 0xbd9e0b05, 0xbd9e0b05, 0xc9cbf769, 0xdb8e7b3c, 0xdb8e7b3c, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb2f32f4, 0xff8e66df, 0xb2f32f4, 0xa5797b2c, 0x9813a416, 0x9813a416, 0x9fc65347, 0x9fc65347, 0x9fc65347, 0xe1dd574, 0xe1dd574, 0xe1dd574, 0x17a7e8a4, 0x17a7e8a4, 0x17a7e8a4, 0x9813a416, 0xa5797b2c, 0xa5797b2c, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x26280874, 0x6f7dd72, 0x26280874, 0x508e3dc7, 0x5fcf013d, 0x5fcf013d, 0x197943fe, 0x197943fe, 0x197943fe, 0xcb695b88, 0xcb695b88, 0xcb695b88, 0xdd1a6417, 0xdd1a6417, 0xdd1a6417, 0x5fcf013d, 0x508e3dc7, 0x508e3dc7, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd23ae631, 0xe5a30d5e, 0xd23ae631, 0xc93f3c36, 0xdd28f52b, 0xdd28f52b, 0x7042f8c, 0x7042f8c, 0x7042f8c, 0x2638d668, 0x2638d668, 0x2638d668, 0x5b801de4, 0x5b801de4, 0x5b801de4, 0xdd28f52b, 0xc93f3c36, 0xc93f3c36, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8d469c0b, 0xabeb5779, 0x8d469c0b, 0x72f9878b, 0x43d1f34, 0x43d1f34, 0xd8397828, 0xd8397828, 0xd8397828, 0xa733d180, 0xa733d180, 0xa733d180, 0x3e62d406, 0x3e62d406, 0x3e62d406, 0x43d1f34, 0x72f9878b, 0x72f9878b, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd668f275, 0x6a2de04f, 0xd668f275, 0x959e3f32, 0x59c36f00, 0x59c36f00, 0xc43520a0, 0xc43520a0, 0xc43520a0, 0xbab54dc6, 0xbab54dc6, 0xbab54dc6, 0xd8435814, 0xd8435814, 0xd8435814, 0x59c36f00, 0x959e3f32, 0x959e3f32, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe170ffb5, 0x17402498, 0xe170ffb5, 0xcf757aca, 0xaa4593fe, 0xaa4593fe, 0x4ec32c62, 0x4ec32c62, 0x4ec32c62, 0xe8362105, 0xe8362105, 0xe8362105, 0xc50e8a7d, 0xc50e8a7d, 0xc50e8a7d, 0xaa4593fe, 0xcf757aca, 0xcf757aca, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf4aef2d6, 0x47a46008, 0xf4aef2d6, 0xa9b99f52, 0xc9cbf769, 0xc9cbf769, 0x4f1a5666, 0x4f1a5666, 0x4f1a5666, 0xb1c297aa, 0xb1c297aa, 0xb1c297aa, 0x588828a2, 0x588828a2, 0x588828a2, 0xc9cbf769, 0xa9b99f52, 0xa9b99f52, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc2ed8f74, 0xb7ab0607, 0xc2ed8f74, 0x6cbbc6ac, 0x9813a416, 0x9813a416, 0x535e7ba8, 0x535e7ba8, 0x535e7ba8, 0xc285fd9b, 0xc285fd9b, 0xc285fd9b, 0xdb3fc04b, 0xdb3fc04b, 0xdb3fc04b, 0x9813a416, 0x6cbbc6ac, 0x6cbbc6ac, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf62383d8, 0x9489f90c, 0xf62383d8, 0x8085b66b, 0x5fcf013d, 0x5fcf013d, 0xb7f78bc2, 0xb7f78bc2, 0xb7f78bc2, 0x65e793b4, 0x65e793b4, 0x65e793b4, 0x7394ac2b, 0x7394ac2b, 0x7394ac2b, 0x5fcf013d, 0x8085b66b, 0x8085b66b, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x753d8bc0, 0x5c9029d6, 0x753d8bc0, 0x6e3851c7, 0xdd28f52b, 0xdd28f52b, 0x1a40e22e, 0x1a40e22e, 0x1a40e22e, 0x3b7c1bca, 0x3b7c1bca, 0x3b7c1bca, 0x46c4d046, 0x46c4d046, 0x46c4d046, 0xdd28f52b, 0x6e3851c7, 0x6e3851c7, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x62a774, 0xbb4b794c, 0x62a774, 0xffddbcf4, 0x43d1f34, 0x43d1f34, 0x83fede87, 0x83fede87, 0x83fede87, 0xfcf4772f, 0xfcf4772f, 0xfcf4772f, 0x65a572a9, 0x65a572a9, 0x65a572a9, 0x43d1f34, 0xffddbcf4, 0xffddbcf4, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2edc6dc9, 0x166a6552, 0x2edc6dc9, 0x6d2aa08e, 0x59c36f00, 0x59c36f00, 0xd214e1a2, 0xd214e1a2, 0xd214e1a2, 0xac948cc4, 0xac948cc4, 0xac948cc4, 0xce629916, 0xce629916, 0xce629916, 0x59c36f00, 0x6d2aa08e, 0x6d2aa08e, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc12e1a21, 0x1e6e7468, 0xc12e1a21, 0xef2b9f5e, 0xaa4593fe, 0xaa4593fe, 0x1c792d02, 0x1c792d02, 0x1c792d02, 0xba8c2065, 0xba8c2065, 0xba8c2065, 0x97b48b1d, 0x97b48b1d, 0x97b48b1d, 0xaa4593fe, 0xef2b9f5e, 0xef2b9f5e, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x510524f7, 0x7f9806b4, 0x510524f7, 0xc124973, 0xc9cbf769, 0xc9cbf769, 0x1a561d55, 0x1a561d55, 0x1a561d55, 0xe48edc99, 0xe48edc99, 0xe48edc99, 0xdc46391, 0xdc46391, 0xdc46391, 0xc9cbf769, 0xc124973, 0xc124973, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1ee6604, 0xd307a4d9, 0xa1ee6604, 0xfb82fdc, 0x9813a416, 0x9813a416, 0x5b7ed439, 0x5b7ed439, 0x5b7ed439, 0xcaa5520a, 0xcaa5520a, 0xcaa5520a, 0xd31f6fda, 0xd31f6fda, 0xd31f6fda, 0x9813a416, 0xfb82fdc, 0xfb82fdc, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e2bb6a8, 0x67c92bf4, 0x4e2bb6a8, 0x388d831b, 0x5fcf013d, 0x5fcf013d, 0xe69beaed, 0xe69beaed, 0xe69beaed, 0x348bf29b, 0x348bf29b, 0x348bf29b, 0x22f8cd04, 0x22f8cd04, 0x22f8cd04, 0x5fcf013d, 0x388d831b, 0x388d831b, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeb6b461d, 0x679ed094, 0xeb6b461d, 0xf06e9c1a, 0xdd28f52b, 0xdd28f52b, 0xdf34624d, 0xdf34624d, 0xdf34624d, 0xfe089ba9, 0xfe089ba9, 0xfe089ba9, 0x83b05025, 0x83b05025, 0x83b05025, 0xdd28f52b, 0xf06e9c1a, 0xf06e9c1a, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc486143c, 0x7b487645, 0xc486143c, 0x3b390fbc, 0x43d1f34, 0x43d1f34, 0x9576cd6b, 0x9576cd6b, 0x9576cd6b, 0xea7c64c3, 0xea7c64c3, 0xea7c64c3, 0x732d6145, 0x732d6145, 0x732d6145, 0x43d1f34, 0x3b390fbc, 0x3b390fbc, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa024d435, 0x8bc3f107, 0xa024d435, 0xe3d21972, 0x59c36f00, 0x59c36f00, 0x9412860d, 0x9412860d, 0x9412860d, 0xea92eb6b, 0xea92eb6b, 0xea92eb6b, 0x8864feb9, 0x8864feb9, 0x8864feb9, 0x59c36f00, 0xe3d21972, 0xe3d21972, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xbf89b975, 0x481e2ecc, 0xbf89b975, 0x918c3c0a, 0xaa4593fe, 0xaa4593fe, 0xa8509e2c, 0xa8509e2c, 0xa8509e2c, 0xea5934b, 0xea5934b, 0xea5934b, 0x239d3833, 0x239d3833, 0x239d3833, 0xaa4593fe, 0x918c3c0a, 0x918c3c0a, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4d84ea04, 0xd1029f5b, 0x4d84ea04, 0x10938780, 0xc9cbf769, 0xc9cbf769, 0x3677fab0, 0x3677fab0, 0x3677fab0, 0xc8af3b7c, 0xc8af3b7c, 0xc8af3b7c, 0x21e58474, 0x21e58474, 0x21e58474, 0xc9cbf769, 0x10938780, 0x10938780, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9e5f6ab3, 0xda3fae82, 0x9e5f6ab3, 0x3009236b, 0x9813a416, 0x9813a416, 0x5710fb5f, 0x5710fb5f, 0x5710fb5f, 0xc6cb7d6c, 0xc6cb7d6c, 0xc6cb7d6c, 0xdf7140bc, 0xdf7140bc, 0xdf7140bc, 0x9813a416, 0x3009236b, 0x3009236b, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x28f46625, 0xf4bfdc80, 0x28f46625, 0x5e525396, 0x5fcf013d, 0x5fcf013d, 0xb3f9b24b, 0xb3f9b24b, 0xb3f9b24b, 0x61e9aa3d, 0x61e9aa3d, 0x61e9aa3d, 0x779a95a2, 0x779a95a2, 0x779a95a2, 0x5fcf013d, 0x5e525396, 0x5e525396, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8c12e300, 0xa71b83e7, 0x8c12e300, 0x97173907, 0xdd28f52b, 0xdd28f52b, 0x2f660f28, 0x2f660f28, 0x2f660f28, 0xe5af6cc, 0xe5af6cc, 0xe5af6cc, 0x73e23d40, 0x73e23d40, 0x73e23d40, 0xdd28f52b, 0x97173907, 0x97173907, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbaaaeec4, 0x7f7cd53b, 0xbaaaeec4, 0x4515f544, 0x43d1f34, 0x43d1f34, 0xd254254f, 0xd254254f, 0xd254254f, 0xad5e8ce7, 0xad5e8ce7, 0xad5e8ce7, 0x340f8961, 0x340f8961, 0x340f8961, 0x43d1f34, 0x4515f544, 0x4515f544, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63166340, 0x5d98fc3, 0x63166340, 0x20e0ae07, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x20e0ae07, 0x20e0ae07, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe0916467, 0x44bbe3df, 0xe0916467, 0xce94e118, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xce94e118, 0xce94e118, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1aad9b94, 0xa021c44c, 0x1aad9b94, 0x47baf610, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x47baf610, 0x47baf610, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb8710521, 0xbd10c16, 0xb8710521, 0x16274cf9, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0x16274cf9, 0x16274cf9, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd62b53b5, 0xc6dd48d4, 0xd62b53b5, 0xa08d6606, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xa08d6606, 0xa08d6606, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10503615, 0x442892cb, 0x10503615, 0xb55ec12, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xb55ec12, 0xb55ec12, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5c9d00a2, 0xf70cd71f, 0x5c9d00a2, 0xa3221b22, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xa3221b22, 0xa3221b22, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc89067b, 0xf339b29f, 0xbc89067b, 0xff7fcb3c, 0x59c36f00, 0x59c36f00, 0x5915b839, 0x5915b839, 0x5915b839, 0x2795d55f, 0x2795d55f, 0x2795d55f, 0x4563c08d, 0x4563c08d, 0x4563c08d, 0x59c36f00, 0xff7fcb3c, 0xff7fcb3c, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb19b98f6, 0xb8ffac95, 0xb19b98f6, 0x9f9e1d89, 0xaa4593fe, 0xaa4593fe, 0x6cb5454, 0x6cb5454, 0x6cb5454, 0xa03e5933, 0xa03e5933, 0xa03e5933, 0x8d06f24b, 0x8d06f24b, 0x8d06f24b, 0xaa4593fe, 0x9f9e1d89, 0x9f9e1d89, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x133d7c3b, 0xd26c8a26, 0x133d7c3b, 0x4e2a11bf, 0xc9cbf769, 0xc9cbf769, 0x36504e54, 0x36504e54, 0x36504e54, 0xc8888f98, 0xc8888f98, 0xc8888f98, 0x21c23090, 0x21c23090, 0x21c23090, 0xc9cbf769, 0x4e2a11bf, 0x4e2a11bf, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbfc94fbe, 0xe32be512, 0xbfc94fbe, 0x119f0666, 0x9813a416, 0x9813a416, 0x8350694d, 0x8350694d, 0x8350694d, 0x128bef7e, 0x128bef7e, 0x128bef7e, 0xb31d2ae, 0xb31d2ae, 0xb31d2ae, 0x9813a416, 0x119f0666, 0x119f0666, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9cf25061, 0xe5e2b458, 0x9cf25061, 0xea5465d2, 0x5fcf013d, 0x5fcf013d, 0xa5bfba08, 0xa5bfba08, 0xa5bfba08, 0x77afa27e, 0x77afa27e, 0x77afa27e, 0x61dc9de1, 0x61dc9de1, 0x61dc9de1, 0x5fcf013d, 0xea5465d2, 0xea5465d2, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc968ecc5, 0xa3105cfb, 0xc968ecc5, 0xd26d36c2, 0xdd28f52b, 0xdd28f52b, 0xff2fd4b8, 0xff2fd4b8, 0xff2fd4b8, 0xde132d5c, 0xde132d5c, 0xde132d5c, 0xa3abe6d0, 0xa3abe6d0, 0xa3abe6d0, 0xdd28f52b, 0xd26d36c2, 0xd26d36c2, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf17f3c, 0xf3672115, 0xf17f3c, 0xff4e64bc, 0x43d1f34, 0x43d1f34, 0x6ec799ab, 0x6ec799ab, 0x6ec799ab, 0x11cd3003, 0x11cd3003, 0x11cd3003, 0x889c3585, 0x889c3585, 0x889c3585, 0x43d1f34, 0xff4e64bc, 0xff4e64bc, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x20f2a62b, 0x12808b5f, 0x20f2a62b, 0x63046b6c, 0x59c36f00, 0x59c36f00, 0x23e6cac6, 0x23e6cac6, 0x23e6cac6, 0x5d66a7a0, 0x5d66a7a0, 0x5d66a7a0, 0x3f90b272, 0x3f90b272, 0x3f90b272, 0x59c36f00, 0x63046b6c, 0x63046b6c, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x52fcbd8f, 0x7119870a, 0x52fcbd8f, 0x7cf938f0, 0xaa4593fe, 0xaa4593fe, 0x4bb9a19, 0x4bb9a19, 0x4bb9a19, 0xa24e977e, 0xa24e977e, 0xa24e977e, 0x8f763c06, 0x8f763c06, 0x8f763c06, 0xaa4593fe, 0x7cf938f0, 0x7cf938f0, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4d74d3f, 0xd2dab4f0, 0xe4d74d3f, 0xb9c020bb, 0xc9cbf769, 0xc9cbf769, 0xa4955f92, 0xa4955f92, 0xa4955f92, 0x5a4d9e5e, 0x5a4d9e5e, 0x5a4d9e5e, 0xb3072156, 0xb3072156, 0xb3072156, 0xc9cbf769, 0xb9c020bb, 0xb9c020bb, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1c2b9ec, 0x34038c40, 0xa1c2b9ec, 0xf94f034, 0x9813a416, 0x9813a416, 0x438820a6, 0x438820a6, 0x438820a6, 0xd253a695, 0xd253a695, 0xd253a695, 0xcbe99b45, 0xcbe99b45, 0xcbe99b45, 0x9813a416, 0xf94f034, 0xf94f034, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x339cc65f, 0xe46f6cec, 0x339cc65f, 0x453af3ec, 0x5fcf013d, 0x5fcf013d, 0xad75b235, 0xad75b235, 0xad75b235, 0x7f65aa43, 0x7f65aa43, 0x7f65aa43, 0x691695dc, 0x691695dc, 0x691695dc, 0x5fcf013d, 0x453af3ec, 0x453af3ec, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1c229a1a, 0x83752c05, 0x1c229a1a, 0x727401d, 0xdd28f52b, 0xdd28f52b, 0x4b4f5d0, 0x4b4f5d0, 0x4b4f5d0, 0x25880c34, 0x25880c34, 0x25880c34, 0x5830c7b8, 0x5830c7b8, 0x5830c7b8, 0xdd28f52b, 0x727401d, 0x727401d, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d69e76c, 0x11e8d41f, 0x4d69e76c, 0xb2d6fcec, 0x43d1f34, 0x43d1f34, 0x15b4256, 0x15b4256, 0x15b4256, 0x7e51ebfe, 0x7e51ebfe, 0x7e51ebfe, 0xe700ee78, 0xe700ee78, 0xe700ee78, 0x43d1f34, 0xb2d6fcec, 0xb2d6fcec, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xecc0313, 0x6803ef90, 0xecc0313, 0x59e1bdcd, 0x59c36f00, 0x59c36f00, 0xbaf5c463, 0xbaf5c463, 0xbaf5c463, 0xc475a905, 0xc475a905, 0xc475a905, 0xa683bcd7, 0xa683bcd7, 0xa683bcd7, 0x59c36f00, 0x59e1bdcd, 0x59e1bdcd, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfb839522, 0x5fa9129a, 0xfb839522, 0x4b244f74, 0xaa4593fe, 0xaa4593fe, 0xf644f45d, 0xf644f45d, 0xf644f45d, 0x50b1f93a, 0x50b1f93a, 0x50b1f93a, 0x7d895242, 0x7d895242, 0x7d895242, 0xaa4593fe, 0x4b244f74, 0x4b244f74, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf84fee63, 0x42c3b1bb, 0xf84fee63, 0xe86af0cd, 0xc9cbf769, 0xc9cbf769, 0x93e5d13b, 0x93e5d13b, 0x93e5d13b, 0x6d3d10f7, 0x6d3d10f7, 0x6d3d10f7, 0x8477afff, 0x8477afff, 0x8477afff, 0xc9cbf769, 0xe86af0cd, 0xe86af0cd, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xcbed2522, 0x784d2c15, 0xcbed2522, 0xfb9cd90d, 0x9813a416, 0x9813a416, 0x94668b23, 0x94668b23, 0x94668b23, 0x5bd0d10, 0x5bd0d10, 0x5bd0d10, 0x1c0730c0, 0x1c0730c0, 0x1c0730c0, 0x9813a416, 0xfb9cd90d, 0xfb9cd90d, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc1ca0a91, 0xd13c11f0, 0xc1ca0a91, 0x6fcde564, 0x5fcf013d, 0x5fcf013d, 0xb6cdf7a2, 0xb6cdf7a2, 0xb6cdf7a2, 0x64ddefd4, 0x64ddefd4, 0x64ddefd4, 0x72aed04b, 0x72aed04b, 0x72aed04b, 0x5fcf013d, 0x6fcde564, 0x6fcde564, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xca477228, 0x9e3fd6f6, 0xca477228, 0x4423b9f2, 0xdd28f52b, 0xdd28f52b, 0x1ff53543, 0x1ff53543, 0x1ff53543, 0x3ec9cca7, 0x3ec9cca7, 0x3ec9cca7, 0x4371072b, 0x4371072b, 0x4371072b, 0xdd28f52b, 0x4423b9f2, 0x4423b9f2, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfe345ca6, 0x55a58b1b, 0xfe345ca6, 0x696cda06, 0x43d1f34, 0x43d1f34, 0x72d541bf, 0x72d541bf, 0x72d541bf, 0xddfe817, 0xddfe817, 0xddfe817, 0x948eed91, 0x948eed91, 0x948eed91, 0x43d1f34, 0x696cda06, 0x696cda06, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4cfdf9ab, 0x2a321528, 0x4cfdf9ab, 0xf4b75661, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0xf4b75661, 0xf4b75661, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x287ff948, 0x8c557ef0, 0x287ff948, 0xebf931c7, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xebf931c7, 0xebf931c7, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ecea36b, 0xe442fcb3, 0x5ecea36b, 0x1cab5f56, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x1cab5f56, 0x1cab5f56, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf6c7d73a, 0x4567de0d, 0xf6c7d73a, 0xb8d47573, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xb8d47573, 0xb8d47573, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x56e3bddb, 0x4615a6ba, 0x56e3bddb, 0xc585b2ec, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xc585b2ec, 0xc585b2ec, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5ebfa46, 0x51935e98, 0x5ebfa46, 0xe26d3e18, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xe26d3e18, 0xe26d3e18, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4995beac, 0xe2046911, 0x4995beac, 0x311de003, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0x311de003, 0x311de003, 0x43d1f34, }, 20 }, + { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, + { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, + { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, + { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, + { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, + { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, + { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, From f2b54835f2e0aa068f82fec99edad671d5f46c08 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:47:30 +0100 Subject: [PATCH 0427/1167] Disable progress indicator in grub-shell. This disables progress indicator for tests. This in turn fixes test flakiness as they ended up timing-dependent. --- grub-core/lib/progress.c | 6 ++++++ tests/util/grub-shell.in | 2 ++ 2 files changed, 8 insertions(+) diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c index 95a4a6281..4b7cbbca6 100644 --- a/grub-core/lib/progress.c +++ b/grub-core/lib/progress.c @@ -38,11 +38,17 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), grub_uint64_t now; static grub_uint64_t last_progress_update_time; grub_file_t file = data; + const char *e; file->progress_offset += length; if (call_depth) return; + e = grub_env_get ("enable_progress_indicator"); + if (e && e[0] == '0') { + return; + } + call_depth = 1; now = grub_get_time_ms (); diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 6d2b1327e..31a1f294d 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -289,6 +289,8 @@ fi cfgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 cat <${cfgfile} grubshell=yes +enable_progress_indicator=0 +export enable_progress_indicator EOF From 3f430a0126ae36ec0750125bd498194fa56cc615 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:49:12 +0100 Subject: [PATCH 0428/1167] Move file loading functions to grub-emu. So that we can use it in grub-emu as well as utils. --- grub-core/kern/emu/misc.c | 48 +++++++++++++++++++++++++++++++++++++++ util/misc.c | 48 --------------------------------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index bb606da28..06985013d 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -149,3 +149,51 @@ grub_get_time_ms (void) return (tv.tv_sec * 1000 + tv.tv_usec / 1000); } + +size_t +grub_util_get_image_size (const char *path) +{ + FILE *f; + size_t ret; + off_t sz; + + f = grub_util_fopen (path, "rb"); + + if (!f) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); + + fseeko (f, 0, SEEK_END); + + sz = ftello (f); + if (sz < 0) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); + if (sz != (size_t) sz) + grub_util_error (_("file `%s' is too big"), path); + ret = (size_t) sz; + + fclose (f); + + return ret; +} + +void +grub_util_load_image (const char *path, char *buf) +{ + FILE *fp; + size_t size; + + grub_util_info ("reading %s", path); + + size = grub_util_get_image_size (path); + + fp = grub_util_fopen (path, "rb"); + if (! fp) + grub_util_error (_("cannot open `%s': %s"), path, + strerror (errno)); + + if (fread (buf, 1, size, fp) != size) + grub_util_error (_("cannot read `%s': %s"), path, + strerror (errno)); + + fclose (fp); +} diff --git a/util/misc.c b/util/misc.c index b8ec69108..d545212d9 100644 --- a/util/misc.c +++ b/util/misc.c @@ -74,32 +74,6 @@ grub_util_get_path (const char *dir, const char *file) return path; } -size_t -grub_util_get_image_size (const char *path) -{ - FILE *f; - size_t ret; - off_t sz; - - f = grub_util_fopen (path, "rb"); - - if (!f) - grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); - - fseeko (f, 0, SEEK_END); - - sz = ftello (f); - if (sz < 0) - grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); - if (sz != (size_t) sz) - grub_util_error (_("file `%s' is too big"), path); - ret = (size_t) sz; - - fclose (f); - - return ret; -} - char * grub_util_read_image (const char *path) { @@ -126,28 +100,6 @@ grub_util_read_image (const char *path) return img; } -void -grub_util_load_image (const char *path, char *buf) -{ - FILE *fp; - size_t size; - - grub_util_info ("reading %s", path); - - size = grub_util_get_image_size (path); - - fp = grub_util_fopen (path, "rb"); - if (! fp) - grub_util_error (_("cannot open `%s': %s"), path, - strerror (errno)); - - if (fread (buf, 1, size, fp) != size) - grub_util_error (_("cannot read `%s': %s"), path, - strerror (errno)); - - fclose (fp); -} - void grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out, const char *name) From f86fd54cf08cc5d0fb62766f98cc86e3ae4c741e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:59:44 +0100 Subject: [PATCH 0429/1167] Add memdisk support to grub-emu. Use it to add custom files, so that tests which need them work. --- grub-core/kern/emu/main.c | 42 ++++++++++++++++++++++++++++++++++++++- tests/util/grub-shell.in | 11 +++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 4b509139c..51e8a5715 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -86,11 +86,16 @@ grub_machine_fini (int flags) +#define OPT_MEMDISK 257 + static struct argp_option options[] = { {"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2}, {"device-map", 'm', N_("FILE"), 0, /* TRANSLATORS: There are many devices in device map. */ N_("use FILE as the device map [default=%s]"), 0}, + {"memdisk", OPT_MEMDISK, N_("FILE"), 0, + /* TRANSLATORS: There are many devices in device map. */ + N_("use FILE as memdisk"), 0}, {"directory", 'd', N_("DIR"), 0, N_("use GRUB files in the directory DIR [default=%s]"), 0}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, @@ -119,6 +124,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) struct arguments { const char *dev_map; + const char *mem_disk; int hold; }; @@ -131,6 +137,9 @@ argp_parser (int key, char *arg, struct argp_state *state) switch (key) { + case OPT_MEMDISK: + arguments->mem_disk = arg; + break; case 'r': free (root_dev); root_dev = xstrdup (arg); @@ -180,9 +189,13 @@ main (int argc, char *argv[]) struct arguments arguments = { .dev_map = DEFAULT_DEVICE_MAP, - .hold = 0 + .hold = 0, + .mem_disk = 0, }; volatile int hold = 0; + size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0; + struct grub_module_info *modinfo; + char *mods; grub_util_host_init (&argc, &argv); @@ -194,6 +207,33 @@ main (int argc, char *argv[]) exit(1); } + if (arguments.mem_disk) + { + memdisk_size = ALIGN_UP(grub_util_get_image_size (arguments.mem_disk), 512); + total_module_size += memdisk_size + sizeof (struct grub_module_header); + } + + mods = xmalloc (total_module_size); + modinfo = grub_memset (mods, 0, total_module_size); + mods = (char *) (modinfo + 1); + + modinfo->magic = GRUB_MODULE_MAGIC; + modinfo->offset = sizeof (struct grub_module_info); + modinfo->size = total_module_size; + + if (arguments.mem_disk) + { + struct grub_module_header *header = (struct grub_module_header *) mods; + header->type = OBJ_TYPE_MEMDISK; + header->size = memdisk_size + sizeof (*header); + mods += sizeof (*header); + + grub_util_load_image (arguments.mem_disk, mods); + mods += memdisk_size; + } + + grub_modbase = (grub_addr_t) modinfo; + hold = arguments.hold; /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ if (hold && verbosity > 0) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 31a1f294d..884c823d8 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -449,7 +449,8 @@ if [ x$boot = xnet ]; then [ -z "$files" ] || copy_extra_files "$netdir" $files timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -boot n -net "user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext" -net nic | cat | tr -d "\r" | do_trim elif [ x$boot = xemu ]; then - grubdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + rootdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + grubdir="$rootdir/boot/grub" mkdir -p "$grubdir/fonts" mkdir -p "$grubdir/themes" mkdir -p "$grubdir/locale" @@ -462,8 +463,12 @@ elif [ x$boot = xemu ]; then done cp "${cfgfile}" "$grubdir/grub.cfg" cp "${source}" "$grubdir/testcase.cfg" - @builddir@/grub-core/grub-emu -m "$device_map" -d "$grubdir" | tr -d "\r" | do_trim - rm -rf "$grubdir" + [ -z "$files" ] || copy_extra_files "$rootdir" $files + roottar="$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + (cd "$rootdir"; tar cf "$roottar" .) + @builddir@/grub-core/grub-emu -m "$device_map" --memdisk "$roottar" -r memdisk -d "/boot/grub" | tr -d "\r" | do_trim + test -n "$debug" || rm -rf "$rootdir" + test -n "$debug" || rm -f "$roottar" else timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -${device}"${isofile}" ${bootdev} | cat | tr -d "\r" | do_trim fi From 9f8f9e62afc4f14802d6bd6bb69719bbc245a8c2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 16:36:21 +0100 Subject: [PATCH 0430/1167] minixfs_test: Check if mkfs.minixfs supports -B option. --- tests/minixfs_test.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/minixfs_test.in b/tests/minixfs_test.in index 8075ba890..1784b1261 100644 --- a/tests/minixfs_test.in +++ b/tests/minixfs_test.in @@ -16,10 +16,20 @@ if ! which mkfs.minix >/dev/null 2>&1; then fi if ! mkfs.minix -h | grep -- -v > /dev/null; then + echo "mkfs.minix doesn't support minix2fs; cannot test minix*fs." + exit 77 +fi + +if ! mkfs.minix -h | grep -- -3 > /dev/null; then echo "mkfs.minix doesn't support minix3fs; cannot test minix*fs." exit 77 fi +if ! mkfs.minix -h | grep -- -B > /dev/null; then + echo "mkfs.minix doesn't support variable block size; cannot test minix*fs." + exit 77 +fi + "@builddir@/grub-fs-tester" minix "@builddir@/grub-fs-tester" minix2 "@builddir@/grub-fs-tester" minix3 From 716c9f2675e27949fb9ff13a76736d9330503b32 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:51:03 +0100 Subject: [PATCH 0431/1167] Adjust bootcheck tests for multiboot/coreboot/qemu to match real support. coreboot has ACPI while 2 others don't. *BSD need ACPI and have trouble without it. Don't even attempt to boot *BSD on multiboot or qemu targets. On coreboot boot all *BSD except 32-bit NetBSD which apparently does some early BIOS calls. --- Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3872b220c..a3719458e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -353,25 +353,25 @@ BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd- endif if COND_i386_multiboot -# FreeBSD requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 +# *BSD requires ACPI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 +endif + + +if COND_i386_qemu +# *BSD requires ACPI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 endif if COND_i386_coreboot -# Freebsd requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 -endif - -if COND_i386_qemu -# FreeBSD requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_i386_pc #pc chainloader by definition is only for i386-pc #ntldr and bootmgr require BIOS. -#legacy protocol makes early BIOS calls. -# NetBSD crashes early on non-BIOS +#legacy protocol (linux16) makes early BIOS calls. +# 32-bit NetBSD crashes early on non-BIOS BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 bootcheck-pc-chainloader bootcheck-ntldr bootcheck-linux16-i386 bootcheck-linux16-x86_64 bootcheck-knetbsd-i386 endif From 607d66116a67e5a13eb0d46076f26dedc988e6a4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:53:42 +0100 Subject: [PATCH 0432/1167] iee1275/datetime: Fix off-by-1 error. --- grub-core/lib/ieee1275/datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c index 74578f15a..b81fba2ed 100644 --- a/grub-core/lib/ieee1275/datetime.c +++ b/grub-core/lib/ieee1275/datetime.c @@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime) datetime->year = args.year; datetime->month = args.month; - datetime->day = args.day; + datetime->day = args.day + 1; datetime->hour = args.hour; datetime->minute = args.minute; datetime->second = args.second; @@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime) args.year = datetime->year; args.month = datetime->month; - args.day = datetime->day; + args.day = datetime->day - 1; args.hour = datetime->hour; args.minute = datetime->minute; args.second = datetime->second; From 86e3b4ba1af430c8d58598876b714eb99c5f535f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:54:06 +0100 Subject: [PATCH 0433/1167] hddboot_test: reenable on OVMF OVMF now supports booting from disks. --- tests/hddboot_test.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/hddboot_test.in b/tests/hddboot_test.in index 2cbbf97ec..c229716a6 100644 --- a/tests/hddboot_test.in +++ b/tests/hddboot_test.in @@ -29,9 +29,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in # FIXME: currently grub-shell uses only -kernel for loongson mipsel-loongson) exit 0;; - # FIXME: OVMF skips HDDs for automatic boot and has no USB support - *-efi) - exit 0;; esac if [ "$(echo hello | "${grubshell}" --boot=hd)" != "Hello World" ]; then From 44876dd64e75b47f99d574bc3db1c87db670645c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:54:42 +0100 Subject: [PATCH 0434/1167] grub-shell: On i386-ieee1275 don't try to switch to console. console goes to serial as well, so this doesn't stop garbage from going to serial. But it creates garbage itself. --- tests/util/grub-shell.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 884c823d8..040ef04cd 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -331,7 +331,8 @@ cat <>${cfgfile} source "\$prefix/testcase.cfg" # Stop serial output to suppress "ACPI shutdown failed" error. EOF -if [ x$console != x ]; then +# Attempt to switch to console on i386-ieee1275 causes "screen not found" message +if [ x$console != x ] && [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" != xi386-ieee1275 ]; then echo "terminal_output $console" >>${cfgfile} fi echo "${halt_cmd}" >>${cfgfile} From db5eb6225dddaaa90e2e54642f31ca14fadf145b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:55:45 +0100 Subject: [PATCH 0435/1167] grub-shell: Use new cbfstool syntax. --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 040ef04cd..8f475cd58 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -402,7 +402,7 @@ fi if [ x$boot = xcoreboot ]; then imgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 cp "${GRUB_COREBOOT_ROM}" "${imgfile}" - "${GRUB_CBFSTOOL}" "${imgfile}" add-payload "${rom_directory}/coreboot.elf" fallback/payload + "${GRUB_CBFSTOOL}" "${imgfile}" add-payload -f "${rom_directory}/coreboot.elf" -n fallback/payload bootdev="-bios ${imgfile}" device="cdrom " test -z "$debug" || echo "Coreboot image: ${imgfile}" >&2 From 06c94739a57f9241868fe76d8e0a797eb547540a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:26:45 +0100 Subject: [PATCH 0436/1167] Disable NetBSD bootcheck on EFI until it supports ACPI on EFI. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index a3719458e..70a8af873 100644 --- a/Makefile.am +++ b/Makefile.am @@ -345,11 +345,13 @@ bootcheck-ntldr: ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg grub-shell ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ntldr.bin=ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null if COND_i386_efi -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 +# NetBSD has no support for finding ACPI on EFI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_x86_64_efi -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 +# NetBSD has no support for finding ACPI on EFI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_i386_multiboot From 6e4174f6f9197619baa41ddc7d718f3c634f0aab Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:27:56 +0100 Subject: [PATCH 0437/1167] arm64: Disable tests that need native drivers. --- tests/ahci_test.in | 2 +- tests/ehci_test.in | 2 +- tests/ohci_test.in | 2 +- tests/pata_test.in | 2 +- tests/uhci_test.in | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ahci_test.in b/tests/ahci_test.in index e7d26ac07..40441768e 100644 --- a/tests/ahci_test.in +++ b/tests/ahci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/ehci_test.in b/tests/ehci_test.in index 5cfe726df..8de56ee98 100644 --- a/tests/ehci_test.in +++ b/tests/ehci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/ohci_test.in b/tests/ohci_test.in index f841bd25c..da517629f 100644 --- a/tests/ohci_test.in +++ b/tests/ohci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/pata_test.in b/tests/pata_test.in index 07d17b781..4bf644fe6 100644 --- a/tests/pata_test.in +++ b/tests/pata_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-arc) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; i386-ieee1275) disk=hdb diff --git a/tests/uhci_test.in b/tests/uhci_test.in index 3dea51c01..5ec503033 100644 --- a/tests/uhci_test.in +++ b/tests/uhci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac From 62328a95c9825fff749cd79a7ccc1060986ca7b2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:28:47 +0100 Subject: [PATCH 0438/1167] Allow GRUB_QEMU_OPTS to override machine. --- tests/util/grub-shell.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 8f475cd58..c52c8c7eb 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -97,13 +97,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips-qemu_mips) boot=mips_qemu qemu=qemu-system-mips - qemuopts="$qemuopts -M mips" + qemuopts="-M mips $qemuopts" console=vga_text ;; mips-arc) boot=cd qemu=qemu-system-mips64 - qemuopts="$qemuopts -M indy" + qemuopts="-M indy $qemuopts" serial_port=arc/serial0/line0 console= trim=1 @@ -111,7 +111,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-arc) boot=cd qemu=qemu-system-mips64el - qemuopts="$qemuopts -M magnum -no-reboot" + qemuopts="-M magnum $qemuopts -no-reboot" serial_port=arc/multi0/serial0 console=console halt_cmd=reboot @@ -120,13 +120,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-qemu_mips) boot=mipsel_qemu qemu=qemu-system-mipsel - qemuopts="$qemuopts -M mips" + qemuopts="-M mips $qemuopts" console=vga_text ;; mipsel-loongson) boot=mipsel_fulong2e qemu=qemu-system-mips64el - qemuopts="$qemuopts -M fulong2e" + qemuopts="-M fulong2e $qemuopts" console= trim=1 ;; From a2dcab70f8df956c15bf13e7cc1b815b751b8c12 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:29:53 +0100 Subject: [PATCH 0439/1167] x86_64-efi: Automatically add -bios OVMF.fd to qemu in tests. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index c52c8c7eb..59061677d 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -170,6 +170,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 + qemuopts="-bios OVMF.fd $qemuopts" ;; *) boot=hd From 7eb27a49e92623587f400ff58de3e9b1a31ba894 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Thu, 7 Jan 2016 20:53:41 +0100 Subject: [PATCH 0440/1167] arm-efi: Reduce timer event frequency by 10 Timer event to keep grub msec counter was running at 1000HZ. This was too fast for UEFI timer driver and resulted in a 10x slowdown in grub time versus wallclock. Reduce the timer event frequency and increase tick increment accordingly to keep better time. --- grub-core/kern/arm/efi/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c index 2572ca8b7..06df60e2f 100644 --- a/grub-core/kern/arm/efi/init.c +++ b/grub-core/kern/arm/efi/init.c @@ -38,7 +38,7 @@ static void increment_timer (grub_efi_event_t event __attribute__ ((unused)), void *context __attribute__ ((unused))) { - tmr++; + tmr += 10; } void @@ -52,7 +52,7 @@ grub_machine_init (void) efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt); - efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 10000); + efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 100000); grub_install_get_time_ms (grub_efi_get_time_ms); } From 9efd79f376a873af14e380b7143efd2343bde24c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 21:02:53 +0100 Subject: [PATCH 0441/1167] grub-shell: Support arm64-efi --- tests/util/grub-shell.in | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 59061677d..cff597ea1 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -65,7 +65,7 @@ serial_port=com0 serial_null= halt_cmd=halt pseries=n -disk=hda +disk="hda " case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-emu) device_map=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 @@ -145,7 +145,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in qemu=qemu-system-i386 console=console trim=1 - disk=hdb + disk="hdb " ;; i386-qemu) boot=qemu @@ -164,6 +164,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 + qemuopts="-bios OVMF32.fd $qemuopts" ;; x86_64-efi) qemu=qemu-system-x86_64 @@ -172,6 +173,15 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in trim=1 qemuopts="-bios OVMF.fd $qemuopts" ;; + arm64-efi) + qemu=qemu-system-aarch64 + boot=hd + console=console + trim=1 + qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts" + disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" + serial_port=efi0 + ;; *) boot=hd qemu=qemu-system-i386 @@ -227,13 +237,13 @@ for option in "$@"; do echo "Too many disks" 1>&2 exit 1; fi - qemuopts="$qemuopts -$disk $dsk" - if [ "$disk" = hda ]; then - disk=hdb; - elif [ "$disk" = hdb ]; then + qemuopts="$qemuopts -$disk$dsk" + if [ "$disk" = "hda " ]; then + disk="hdb "; + elif [ "$disk" = "hdb " ]; then # CDROM is hdc - disk=hdd - elif [ "$disk" = hdd ]; then + disk="hdd " + elif [ "$disk" = "hdd " ]; then # CDROM is hdc disk=error fi @@ -360,7 +370,9 @@ if [ x$boot != xnet ] && [ x$boot != xemu ]; then ${files} >/dev/null 2>&1 fi if [ x$boot = xhd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + device="device virtio-blk-device,drive=hd0 -drive if=none,id=hd0,file=" + elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then device="hdb " else device="hda " @@ -368,7 +380,9 @@ if [ x$boot = xhd ]; then bootdev="-boot c" fi if [ x$boot = xcd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + device="device virtio-blk-device,drive=cd0 -drive if=none,id=cd0,media=cdrom,file=" + elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then device="-drive if=ide,media=cdrom,file=" else device="cdrom " From e4c49cab9b5d4ba77881b3829402b8b7fdb84382 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 21:10:05 +0100 Subject: [PATCH 0442/1167] arm64/setjmp: Add missing move for arg1 == 0 case. --- grub-core/lib/arm64/setjmp.S | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S index eabfd99b2..ffcabf6e4 100644 --- a/grub-core/lib/arm64/setjmp.S +++ b/grub-core/lib/arm64/setjmp.S @@ -50,6 +50,7 @@ FUNCTION(grub_longjmp) ldp x29, x30, [x0], #16 ldr x2, [x0] mov sp, x2 + mov x0, #1 cmp x1, #0 csel x0, x1, x0, ne ret From b4787552b02c7a3a124f1d2178309383c36f5c03 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 09:49:08 +0100 Subject: [PATCH 0443/1167] Tests: Support arm-efi --- tests/ahci_test.in | 2 +- tests/ehci_test.in | 2 +- tests/ohci_test.in | 2 +- tests/partmap_test.in | 3 +++ tests/pata_test.in | 2 +- tests/uhci_test.in | 2 +- tests/util/grub-shell.in | 15 ++++++++++++--- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/ahci_test.in b/tests/ahci_test.in index 40441768e..1d01d1f59 100644 --- a/tests/ahci_test.in +++ b/tests/ahci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/ehci_test.in b/tests/ehci_test.in index 8de56ee98..7dd8d3e8f 100644 --- a/tests/ehci_test.in +++ b/tests/ehci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/ohci_test.in b/tests/ohci_test.in index da517629f..7fede6f26 100644 --- a/tests/ohci_test.in +++ b/tests/ohci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/partmap_test.in b/tests/partmap_test.in index 4230ba228..f8dc456fb 100644 --- a/tests/partmap_test.in +++ b/tests/partmap_test.in @@ -88,6 +88,9 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-arc) disk=arc/scsi0/disk0/rdisk0 ;; + arm*-efi) + disk=hd3 + ;; *) disk=hd0 ;; diff --git a/tests/pata_test.in b/tests/pata_test.in index 4bf644fe6..c1d0f63ea 100644 --- a/tests/pata_test.in +++ b/tests/pata_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-arc) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; i386-ieee1275) disk=hdb diff --git a/tests/uhci_test.in b/tests/uhci_test.in index 5ec503033..89e2c1805 100644 --- a/tests/uhci_test.in +++ b/tests/uhci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index cff597ea1..5ba2c299c 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -182,6 +182,15 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" serial_port=efi0 ;; + arm-efi) + qemu=qemu-system-arm + boot=hd + console=console + trim=1 + qemuopts="-machine virt -bios /usr/share/ovmf-arm/QEMU_EFI.fd $qemuopts" + disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" + serial_port=efi0 + ;; *) boot=hd qemu=qemu-system-i386 @@ -233,7 +242,7 @@ for option in "$@"; do echo "(hd$disk) $dsk" >> "$device_map" disk="$((disk+1))" else - if [ $disk = error ]; then + if [ "$disk" = error ]; then echo "Too many disks" 1>&2 exit 1; fi @@ -370,7 +379,7 @@ if [ x$boot != xnet ] && [ x$boot != xemu ]; then ${files} >/dev/null 2>&1 fi if [ x$boot = xhd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then device="device virtio-blk-device,drive=hd0 -drive if=none,id=hd0,file=" elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then device="hdb " @@ -380,7 +389,7 @@ if [ x$boot = xhd ]; then bootdev="-boot c" fi if [ x$boot = xcd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then device="device virtio-blk-device,drive=cd0 -drive if=none,id=cd0,media=cdrom,file=" elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then device="-drive if=ide,media=cdrom,file=" From efc04d65c74912972b00b1ebf15312685e317a05 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 Jan 2016 11:05:16 +0300 Subject: [PATCH 0444/1167] grub-module-verifier: fix unintended sign extension Found by: Coverity scan. CID: 156533, 156532 --- util/grub-module-verifierXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 25988ebc2..f612d51f3 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -337,7 +337,7 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_mod /* Make sure that every section is within the core. */ if (size < grub_target_to_host (e->e_shoff) - + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) + + (grub_uint32_t) grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) { grub_util_error ("ELF sections outside core"); } From 8ab2675ede4313ea62cf88c22fa2760de2020423 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 Jan 2016 11:16:56 +0300 Subject: [PATCH 0445/1167] hfs: fix memory leak Found by: Coverity scan. CID: 156531 --- grub-core/fs/hfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 0ebc71b62..fc3683178 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1308,6 +1308,7 @@ grub_hfs_open (struct grub_file *file, const char *name) if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG)) { grub_free (data); + grub_free (found); grub_dl_unref (my_mod); return grub_errno; } From 97c41e121620796a77f04965a0c839f87eb50290 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 10:53:31 +0300 Subject: [PATCH 0446/1167] efiemu: fix unintended sign extension Found by: Coverity scan. CID: 73883, 73637 --- grub-core/efiemu/loadcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c index 6968b3719..e68e7e4d1 100644 --- a/grub-core/efiemu/loadcore.c +++ b/grub-core/efiemu/loadcore.c @@ -343,7 +343,7 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, const char *filename, return grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type")); /* Make sure that every section is within the core. */ - if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum) + if ((grub_size_t) core_size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum) return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), filename); From 12bf87466f80cbc2b81d64ff46b8db9d76fcbaf6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 10:59:51 +0300 Subject: [PATCH 0447/1167] efiemu: change code to avoid Coverity false positive CID: 73623 --- grub-core/efiemu/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c index f2140ad29..f6813b1ed 100644 --- a/grub-core/efiemu/main.c +++ b/grub-core/efiemu/main.c @@ -196,7 +196,7 @@ grub_efiemu_load_file (const char *filename) { grub_file_close (file); grub_efiemu_unload (); - return grub_errno; + return err; } grub_dprintf ("efiemu", "mm initialized\n"); From 67d9ce82acce5caa62f45cbd47b6008b76cc6e4a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 11:05:33 +0300 Subject: [PATCH 0448/1167] efiemu: check return value of grub_efiemu_write_value Found by: Coverity scan. CID: 73590 --- grub-core/efiemu/prepare.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c index 84c3368a8..99ddb5abb 100644 --- a/grub-core/efiemu/prepare.c +++ b/grub-core/efiemu/prepare.c @@ -83,10 +83,16 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks, ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off); /* Put pointer to the list of configuration tables in system table */ - grub_efiemu_write_value - (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0, - conftable_handle, 0, 1, - sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table)); + err = grub_efiemu_write_value + (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0, + conftable_handle, 0, 1, + sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table)); + if (err) + { + grub_efiemu_unload (); + return err; + } + SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables; /* Fill the list of configuration tables */ From 57e7f1b775f6c152eff1dd88a8c1399799828112 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:10:10 +0300 Subject: [PATCH 0449/1167] setup: fix memory leak Found by: Coverity scan. CID: 73680, 73715 --- util/setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/setup.c b/util/setup.c index 8f20e9983..d74567d0a 100644 --- a/util/setup.c +++ b/util/setup.c @@ -353,6 +353,10 @@ SETUP (const char *dir, } grub_util_info ("guessed root_dev `%s' from " "dir `%s'", root_dev->disk->name, dir); + + for (cur = root_devices; *cur; cur++) + free (*cur); + free (root_devices); } grub_util_info ("setting the root device to `%s'", root); From 0e075ac3856cb14d722504e1386ebf73cd170fe9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:28:42 +0300 Subject: [PATCH 0450/1167] util/setup: fix grub_util_path_list leak Add helper grub_util_free_path_list and use it where appropriate. Found by: Coverity scan. CID: 73727 --- include/grub/util/resolve.h | 1 + util/grub-install-common.c | 2 ++ util/mkimage.c | 10 ++-------- util/resolve.c | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/grub/util/resolve.h b/include/grub/util/resolve.h index f42df32f9..8923a6e6c 100644 --- a/include/grub/util/resolve.h +++ b/include/grub/util/resolve.h @@ -31,5 +31,6 @@ struct grub_util_path_list * grub_util_resolve_dependencies (const char *prefix, const char *dep_list_file, char *modules[]); +void grub_util_free_path_list (struct grub_util_path_list *path_list); #endif /* ! GRUB_UTIL_RESOLVE_HEADER */ diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 25983089f..452b230da 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -765,6 +765,8 @@ grub_install_copy_files (const char *src, grub_install_compress_file (srcf, dstf, 1); free (dstf); } + + grub_util_free_path_list (path_list); } const char *pkglib_DATA[] = {"efiemu32.o", "efiemu64.o", diff --git a/util/mkimage.c b/util/mkimage.c index dc4046185..c3365bbbd 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -996,7 +996,7 @@ grub_install_generate_image (const char *dir, const char *prefix, size_t prefix_size = 0; char *kernel_path; size_t offset; - struct grub_util_path_list *path_list, *p, *next; + struct grub_util_path_list *path_list, *p; size_t bss_size; grub_uint64_t start_address; void *rel_section = 0; @@ -1904,11 +1904,5 @@ grub_install_generate_image (const char *dir, const char *prefix, free (kernel_path); free (rel_section); - while (path_list) - { - next = path_list->next; - free ((void *) path_list->name); - free (path_list); - path_list = next; - } + grub_util_free_path_list (path_list); } diff --git a/util/resolve.c b/util/resolve.c index 002bfbd72..3e887d2ff 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -271,3 +271,17 @@ grub_util_resolve_dependencies (const char *prefix, return prev; } } + +void +grub_util_free_path_list (struct grub_util_path_list *path_list) +{ + struct grub_util_path_list *next; + + while (path_list) + { + next = path_list->next; + free ((void *) path_list->name); + free (path_list); + path_list = next; + } +} From fa2af21ec8fd4410f6a9bb7412c6402e1b6565ca Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:43:04 +0300 Subject: [PATCH 0451/1167] gfxmenu: fix memory leak Found by: Coverity scan. CID: 73766 --- grub-core/gfxmenu/font.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c index 64d52670b..756c24f20 100644 --- a/grub-core/gfxmenu/font.c +++ b/grub-core/gfxmenu/font.c @@ -45,6 +45,7 @@ grub_font_draw_string (const char *str, grub_font_t font, grub_uint32_t *logical; grub_ssize_t logical_len, visual_len; struct grub_unicode_glyph *visual, *ptr; + grub_err_t err; logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); if (logical_len < 0) @@ -56,24 +57,28 @@ grub_font_draw_string (const char *str, grub_font_t font, if (visual_len < 0) return grub_errno; + err = GRUB_ERR_NONE; for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++) { - grub_err_t err; struct grub_font_glyph *glyph; glyph = grub_font_construct_glyph (font, ptr); if (!glyph) - return grub_errno; + { + err = grub_errno; + goto out; + } err = grub_font_draw_glyph (glyph, color, x, baseline_y); - x += glyph->device_width; if (err) - return err; + goto out; + x += glyph->device_width; } +out: for (ptr = visual; ptr < visual + visual_len; ptr++) grub_unicode_destroy_glyph (ptr); grub_free (visual); - return GRUB_ERR_NONE; + return err; } /* Get the width in pixels of the specified UTF-8 string, when rendered in From d5cc487d3963a65e87ac7d816b390afcd3ffabf0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:49:37 +0300 Subject: [PATCH 0452/1167] grub-probe: fix memory leak Found by: Coverity scan. CID: 73783 --- util/grub-probe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/grub-probe.c b/util/grub-probe.c index b1f533626..36b7f8bcb 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -668,6 +668,13 @@ probe (const char *path, char **device_names, char delim) for (curdrive = drives_names; *curdrive; curdrive++) free (*curdrive); free (drives_names); + + if (path != NULL) + { + for (curdev = device_names; *curdev; curdev++) + free (*curdev); + free (device_names); + } } static struct argp_option options[] = { From 725548a2855e357cd5cd243dddef355295e63110 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 14:13:36 +0300 Subject: [PATCH 0453/1167] grub-mklayout: check subscript bounds Found by: Coverity scan. CID: 73686 --- util/grub-mklayout.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 1a4f1b4c8..d171c2700 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -384,6 +384,13 @@ write_keymaps (FILE *in, FILE *out, const char *out_filename) sscanf (line, "keycode %u = %60s %60s %60s %60s", &keycode_linux, normal, shift, normalalt, shiftalt); + if (keycode_linux >= ARRAY_SIZE (linux_to_usb_map)) + { + /* TRANSLATORS: scan code is keyboard key numeric identifier. */ + fprintf (stderr, _("Unknown keyboard scan code 0x%02x\n"), keycode_linux); + continue; + } + /* Not used. */ if (keycode_linux == 0x77 /* Pause */ /* Some obscure keys */ From bd60f5a207f9d8e594520d32f909aafdb4f5fffb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 18:15:27 +0300 Subject: [PATCH 0454/1167] rescue_parser: restructure code to avoid Coverity false positive If line contains single word, line and argv[0] are aliases, so no NULL dereference is possible, but Coverity does not know it. Change code to avoid ambiguity and also remove redundant call to grub_strchr. CID: 86725 --- grub-core/kern/rescue_parser.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/kern/rescue_parser.c b/grub-core/kern/rescue_parser.c index ab3d04160..633836699 100644 --- a/grub-core/kern/rescue_parser.c +++ b/grub-core/kern/rescue_parser.c @@ -43,13 +43,17 @@ grub_rescue_parse_line (char *line, /* In case of an assignment set the environment accordingly instead of calling a function. */ - if (n == 1 && grub_strchr (line, '=')) + if (n == 1) { char *val = grub_strchr (args[0], '='); - val[0] = 0; - grub_env_set (args[0], val + 1); - val[0] = '='; - goto quit; + + if (val) + { + val[0] = 0; + grub_env_set (args[0], val + 1); + val[0] = '='; + goto quit; + } } /* Get the command name. */ @@ -72,6 +76,7 @@ grub_rescue_parse_line (char *line, } quit: + /* Arguments are returned in single memory chunk separated by zeroes */ grub_free (args[0]); grub_free (args); From aafd205c926df01b039e588134e3798913bcbe3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 18:55:55 +0300 Subject: [PATCH 0455/1167] xfs: fix possible inode corruption in directory scan grub_xfs_iterate_dir did not restore first character after inline name when match was found. Dependning on XFS format this character could be inode number and we could return to the same node later in find_file if processing cycled symlinks. CID: 86724 --- grub-core/fs/xfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index a03526b32..ca9c0c37a 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -775,7 +775,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, c = de->name[de->len]; de->name[de->len] = '\0'; if (iterate_dir_call_hook (ino, de->name, &ctx)) - return 1; + { + de->name[de->len] = c; + return 1; + } de->name[de->len] = c; de = grub_xfs_inline_next_de(dir->data, head, de); From 9fecb0588ee9a8059a75fb3ec9acf3948b54e4f9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 19:41:26 +0300 Subject: [PATCH 0456/1167] kern/elf: fix unintended sign extension Found by: Coverity scan. CID: 73729, 73735, 73758, 73760 --- grub-core/kern/elfXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c index b91c39d9e..1859d1880 100644 --- a/grub-core/kern/elfXX.c +++ b/grub-core/kern/elfXX.c @@ -12,7 +12,7 @@ grub_elfXX_load_phdrs (grub_elf_t elf) if (elf->phdrs) return GRUB_ERR_NONE; - phdrs_size = elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize; + phdrs_size = (grub_uint32_t) elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize; grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n", (unsigned long long) elf->ehdr.ehdrXX.e_phoff, From 31f6506c57b976148fd1d3d4e72943712b6e0c8d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 19:58:51 +0300 Subject: [PATCH 0457/1167] loader/multiboot: fix unintended sign extension Found by: Coveruty scan. CID: 73700, 73763 --- grub-core/loader/multiboot_elfxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 6a220bdc1..a7bebcb3c 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -72,7 +72,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_error (GRUB_ERR_UNKNOWN_OS, N_("this ELF file is not of the right type")); /* FIXME: Should we support program headers at strange locations? */ - if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) + if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset"); phdr_base = (char *) buffer + ehdr->e_phoff; From dc27d254f2cb7f4b0fef52fb8c9e9f89881b1f4c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 20:54:54 +0300 Subject: [PATCH 0458/1167] util/getroot: delete dead code is_part cannot be non-zero at this point. Found by: Coveruty scan. CID: 73838 --- util/getroot.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/util/getroot.c b/util/getroot.c index 36f1730c0..92c0d709b 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -383,9 +383,6 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) grub_util_info ("%s starts from %" GRUB_HOST_PRIuLONG_LONG, os_dev, (unsigned long long) ctx.start); - if (ctx.start == 0 && !is_part) - return name; - grub_util_info ("opening the device %s", name); disk = grub_disk_open (name); free (name); From 670c43af27dee281bb61e2a50855b61f96b7e1fa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 21:05:44 +0300 Subject: [PATCH 0459/1167] mkimage: fix unintended sign extension Found by: Coverity scan. CID: 73691, 73717 --- util/grub-mkimagexx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a1ddc6269..0e0c6f7a1 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1465,7 +1465,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, section_entsize = grub_target_to_host16 (e->e_shentsize); num_sections = grub_target_to_host16 (e->e_shnum); - if (kernel_size < section_offset + section_entsize * num_sections) + if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections) grub_util_error (_("premature end of file %s"), kernel_path); sections = (Elf_Shdr *) (kernel_img + section_offset); From 5a5a3c69630ea117f54c07e891007fe3374581ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 21:25:22 +0300 Subject: [PATCH 0460/1167] setup: fix NULL pointer dereference Check return value of grub_guess_root_devices Found by: Coverity scan. CID: 73638, 73751 --- util/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/setup.c b/util/setup.c index d74567d0a..8aa5a39a7 100644 --- a/util/setup.c +++ b/util/setup.c @@ -312,6 +312,9 @@ SETUP (const char *dir, char **cur; int found = 0; + if (!root_devices) + grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir); + for (cur = root_devices; *cur; cur++) { char *drive; From 269a522c7db1f383ccf0998a7cf9c4b1797ea0d9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 10:41:04 +0300 Subject: [PATCH 0461/1167] hostdisk: fix device detection Condition was apparently reversed so GRUB assumed all devices were files. This later made it skip BLKFLSBUF ioctl on Linux which caused various page cache coherency issues. Observed were - failure to validate blocklist install (read content did not match just written) - failure to detect Linux MD on disk after online hot addition (GRUB got stale superblock) Closes: 46691 --- grub-core/kern/emu/hostdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 610518d0c..87e3e2512 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) { struct stat st; # if GRUB_DISK_DEVS_ARE_CHAR - if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode)) # else - if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode)) # endif data->is_disk = 1; } From 528256932b8586587c7b339418d3865206717b60 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 11:33:13 +0300 Subject: [PATCH 0462/1167] net: remove dead and redundant code server cannot be NULL at this point (we return error earlier if it is). Also structure is zalloc'ed, so no need to explicitly initialize members to 0. Found by: Coverity scan. CID: 73837 --- grub-core/net/net.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index a0472d5d4..85b0cf774 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1322,20 +1322,13 @@ grub_net_open_real (const char *name) if (!ret) return NULL; ret->protocol = proto; - if (server) + ret->server = grub_strdup (server); + if (!ret->server) { - ret->server = grub_strdup (server); - if (!ret->server) - { - grub_free (ret); - return NULL; - } + grub_free (ret); + return NULL; } - else - ret->server = NULL; ret->fs = &grub_net_fs; - ret->offset = 0; - ret->eof = 0; return ret; } } From 962b69d9503bdd91120d2c0fcfd17ae6d37db71c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 11:51:34 +0300 Subject: [PATCH 0463/1167] grub-mkimage: remove redundant NULL check Found by: Coverity scan. CID: 73737 --- util/grub-mkimage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 1e0bcf1bf..10375f4d2 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -304,8 +304,7 @@ main (int argc, char *argv[]) grub_util_file_sync (fp); fclose (fp); - if (arguments.dir) - free (arguments.dir); + free (arguments.dir); if (arguments.output) free (arguments.output); From 66768b99f15033bf55bc6c360cae6a6660be5c5f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 16:08:06 +0300 Subject: [PATCH 0464/1167] grub-install: include ehci in list of native modules This matches behavior of "nativedisk" command. Reported and tested by Smith Henry --- util/grub-install.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-install.c b/util/grub-install.c index eabd6de4d..6c89c2b0c 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1282,6 +1282,7 @@ main (int argc, char *argv[]) grub_install_push_module ("ahci"); grub_install_push_module ("ohci"); grub_install_push_module ("uhci"); + grub_install_push_module ("ehci"); grub_install_push_module ("usbms"); } else if (disk_module && disk_module[0]) From 8fe17d91afc610d99458102a2a81abfdd542f4c0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:26:30 +0300 Subject: [PATCH 0465/1167] acpi: fix memory leak Found by: Coverity scan. CID: 96673 --- grub-core/commands/acpi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index ece49b4a9..b5c2f27c1 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -593,6 +593,9 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) if (! table->addr) { free_tables (); + grub_free (exclude); + grub_free (load_only); + grub_free (table); return grub_errno; } table->next = acpi_tables; From 1bff60e5aac71552aafe0dc5e08ff62ef32ee711 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:37:43 +0300 Subject: [PATCH 0466/1167] nativedisk: fix memory leak Based on Coverity scan. CID: 96660 Extended to also cover other error return places. --- grub-core/commands/nativedisk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index b3bc4639c..345f97c4d 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -198,7 +198,10 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), return grub_errno; if (get_uuid (NULL, &uuid_root, 0)) - return grub_errno; + { + grub_free (mods); + return grub_errno; + } prefdev = grub_file_get_device_name (prefix); if (grub_errno) @@ -210,6 +213,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), if (get_uuid (prefdev, &uuid_prefix, 0)) { grub_free (uuid_root); + grub_free (prefdev); + grub_free (mods); return grub_errno; } @@ -289,12 +294,15 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), } grub_free (uuid_root); grub_free (uuid_prefix); + grub_free (prefdev); + grub_free (mods); return GRUB_ERR_NONE; fail: grub_free (uuid_root); grub_free (uuid_prefix); + grub_free (prefdev); for (i = 0; i < mods_loaded; i++) if (mods[i]) @@ -302,6 +310,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), mods[i]->fini = 0; grub_dl_unload (mods[i]); } + grub_free (mods); + return grub_errno; } From 5db2190f2cd12706d1df00303dc9eaf7a78b08e1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:41:44 +0300 Subject: [PATCH 0467/1167] parttool: fix memory leak Found by: Coverity scan. CID: 96652 --- grub-core/commands/parttool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index 42c590e1a..693e2cb42 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -283,6 +283,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } if (! cur) { + grub_free (parsed); grub_device_close (dev); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), args[i]); From f3c84fa79847ee365742153a2f3cd47e678aef4a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:53:26 +0300 Subject: [PATCH 0468/1167] password_pbkdf2: fix memory leak Found by: Coverity scan. CID: 96656 --- grub-core/commands/password_pbkdf2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c index c6a77c8c5..da636e621 100644 --- a/grub-core/commands/password_pbkdf2.c +++ b/grub-core/commands/password_pbkdf2.c @@ -45,6 +45,7 @@ check_password (const char *user, const char *entered, void *pin) grub_uint8_t *buf; struct pbkdf2_password *pass = pin; gcry_err_code_t err; + grub_err_t ret; buf = grub_malloc (pass->buflen); if (!buf) @@ -55,17 +56,17 @@ check_password (const char *user, const char *entered, void *pin) pass->salt, pass->saltlen, pass->c, buf, pass->buflen); if (err) + ret = grub_crypto_gcry_error (err); + else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) + ret = GRUB_ACCESS_DENIED; + else { - grub_free (buf); - return grub_crypto_gcry_error (err); + grub_auth_authenticate (user); + ret = GRUB_ERR_NONE; } - if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) - return GRUB_ACCESS_DENIED; - - grub_auth_authenticate (user); - - return GRUB_ERR_NONE; + grub_free (buf); + return ret; } static inline int From 6c35ce72bad698051f82b087cd026f8e5331f915 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:10:12 +0300 Subject: [PATCH 0469/1167] verify: fix memory leak Found by: Coverity scan. CID: 96643 --- grub-core/commands/verify.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 9620a3b4c..67cb1c785 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -324,19 +324,19 @@ grub_load_public_key (grub_file_t f) if (grub_file_read (f, &l, sizeof (l)) != sizeof (l)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT; if (lb > READBUF_SIZE - sizeof (grub_uint16_t)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } grub_memcpy (buffer, &l, sizeof (l)); @@ -346,10 +346,16 @@ grub_load_public_key (grub_file_t f) buffer, lb + sizeof (grub_uint16_t), 0)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } } + if (i < pkalgos[pk].nmpipub) + { + grub_free (sk); + goto fail; + } + GRUB_MD_SHA1->final (fingerprint_context); grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20); From e9d71db53a1f3e14abfdcf879f734ce1211175f0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:16:34 +0300 Subject: [PATCH 0470/1167] efidisk: fix memory leak Found by: Coverity scan. CID: 96644 --- grub-core/disk/efi/efidisk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index a8783a3c1..1c00e3ec8 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -85,6 +85,12 @@ make_devices (void) { /* Uggh. */ grub_free (handles); + while (devices) + { + d = devices->next; + grub_free (devices); + devices = d; + } return 0; } From dbb0f9fa4fe7a9c3721178edf2421825dce5ad07 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:25:40 +0300 Subject: [PATCH 0471/1167] efiemu: fix memory leak Found by: Coverity scan. CID: 156610 --- grub-core/efiemu/loadcore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c index e68e7e4d1..44085ef81 100644 --- a/grub-core/efiemu/loadcore.c +++ b/grub-core/efiemu/loadcore.c @@ -154,7 +154,10 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e) s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE : GRUB_EFI_RUNTIME_SERVICES_DATA); if (seg->handle < 0) - return grub_errno; + { + grub_free (seg); + return grub_errno; + } seg->off = 0; } From a4b1326f0d0382be62bb224ea5532ab3fae1b440 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:33:34 +0300 Subject: [PATCH 0472/1167] gfxmenu: fix memory leak Found by: Coverity scan. CID: 96657 --- grub-core/gfxmenu/gfxmenu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c index f49fce802..8a17dda2c 100644 --- a/grub-core/gfxmenu/gfxmenu.c +++ b/grub-core/gfxmenu/gfxmenu.c @@ -63,14 +63,14 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested) return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "theme"); - instance = grub_zalloc (sizeof (*instance)); - if (!instance) - return grub_errno; - err = grub_video_get_info (&mode_info); if (err) return err; + instance = grub_zalloc (sizeof (*instance)); + if (!instance) + return grub_errno; + if (theme_path[0] != '/' && theme_path[0] != '(') { const char *prefix; From 9daf7aae8b917155b253951b83cbc8e5bed7f636 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:41:48 +0300 Subject: [PATCH 0473/1167] truecrypt: fix memory leak Found by: Coverity scan. CID: 156611 --- grub-core/loader/i386/pc/truecrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c index 159eab1a7..9ea4fde42 100644 --- a/grub-core/loader/i386/pc/truecrypt.c +++ b/grub-core/loader/i386/pc/truecrypt.c @@ -205,7 +205,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)), fail: if (!grub_errno) - return grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO"); + grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO"); if (file) grub_file_close (file); From 29862fdc3a921b9d3cf34ae15e779907d554b6ce Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:43:43 +0300 Subject: [PATCH 0474/1167] xnu: fix memory leak Found by: Coverity scan. CID: 96663 --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 2fe1fdc1f..a4a6f932e 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -338,7 +338,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor * utf8 = grub_malloc (namelen * 4 + 1); if (!utf8) { - grub_free (utf8); + grub_free (utf16); return grub_errno; } From 26533fe6bca59e340fe33c658c0a3c8aca3f04ff Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 22:36:53 +0300 Subject: [PATCH 0475/1167] normal: fix memory leak Found by: Coverity scan. CID: 96641, 96670, 96667 --- grub-core/normal/menu_entry.c | 7 ++++++- grub-core/normal/term.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 2b732250d..b80d161dd 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -476,7 +476,10 @@ insert_string (struct screen *screen, const char *s, int update) (grub_uint8_t *) s, (p - s), 0); if (! ensure_space (current_linep, size)) - return 0; + { + grub_free (unicode_msg); + return 0; + } grub_memmove (current_linep->buf + screen->column + size, current_linep->buf + screen->column, @@ -1265,6 +1268,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (! screen->lines[i].pos) { grub_print_error (); + destroy_screen (screen); grub_errno = GRUB_ERR_NONE; return; } @@ -1274,6 +1278,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (!screen->terms) { grub_print_error (); + destroy_screen (screen); grub_errno = GRUB_ERR_NONE; return; } diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 4c2238b25..ac5d69f0f 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -77,8 +77,6 @@ print_more (void) grub_term_output_t term; grub_uint32_t *unicode_str, *unicode_last_position; - pos = grub_term_save_pos (); - /* TRANSLATORS: This has to fit on one line. It's ok to include few words but don't write poems. */ grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str, @@ -90,6 +88,8 @@ print_more (void) return; } + pos = grub_term_save_pos (); + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); FOR_ACTIVE_TERM_OUTPUTS(term) From b95e92678882f56056c64ae29092bc9cf129905f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 22:50:30 +0300 Subject: [PATCH 0476/1167] script: fix memory leak Found by: Coverity scan. CID: 96637 --- grub-core/script/execute.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index bb70ebf17..a8502d907 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -681,18 +681,14 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, } *op = '\0'; - if (grub_script_argv_append (&result, p, op - p)) - { - grub_free (p); - need_cleanup = 1; - /* Fall through to cleanup */ - } + need_cleanup = grub_script_argv_append (&result, p, op - p); + grub_free (p); + /* Fall through to cleanup */ } else { - if (append (&result, values[i], 1)) - need_cleanup = 1; - /* Fall through to cleanup */ + need_cleanup = append (&result, values[i], 1); + /* Fall through to cleanup */ } } From 4f8fe948b95d662cdf02effcda6cdfff36b1c4b1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 13 Jan 2016 20:15:07 +0300 Subject: [PATCH 0477/1167] loader: Unintended sign extension CID: 96707, 96699, 96693, 96691, 96711, 96709, 96708, 96703, 96702, 96700, 96698, 96696, 96695, 96692, 96710, 96705 --- grub-core/kern/dl.c | 2 +- grub-core/loader/i386/bsdXX.c | 24 ++++++++++++------------ grub-core/loader/multiboot_elfxx.c | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 3a438e92f..59a6ef4ca 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -605,7 +605,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) } /* Make sure that every section is within the core. */ - if (size < e->e_shoff + e->e_shentsize * e->e_shnum) + if (size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum) { grub_error (GRUB_ERR_BAD_OS, "ELF sections outside core"); return 0; diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 9f57cfa82..0d14deeb7 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -48,15 +48,15 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS)) return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic")); - *shdr = grub_malloc (e->e_shnum * e->e_shentsize); + *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize); if (! *shdr) return grub_errno; if (grub_file_seek (file, e->e_shoff) == (grub_off_t) -1) return grub_errno; - if (grub_file_read (file, *shdr, e->e_shnum * e->e_shentsize) - != e->e_shnum * e->e_shentsize) + if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize) + != (grub_uint32_t) e->e_shnum * e->e_shentsize) { if (grub_errno) return grub_errno; @@ -200,8 +200,8 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, if (chunk_size < sizeof (e)) chunk_size = sizeof (e); - chunk_size += e.e_phnum * e.e_phentsize; - chunk_size += e.e_shnum * e.e_shentsize; + chunk_size += (grub_uint32_t) e.e_phnum * e.e_phentsize; + chunk_size += (grub_uint32_t) e.e_shnum * e.e_shentsize; { grub_relocator_chunk_t ch; @@ -253,14 +253,14 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, curload = module + sizeof (e); load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_shoff, - e.e_shnum * e.e_shentsize); + (grub_uint32_t) e.e_shnum * e.e_shentsize); e.e_shoff = curload - module; - curload += e.e_shnum * e.e_shentsize; + curload += (grub_uint32_t) e.e_shnum * e.e_shentsize; load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_phoff, - e.e_phnum * e.e_phentsize); + (grub_uint32_t) e.e_phnum * e.e_phentsize); e.e_phoff = curload - module; - curload += e.e_phnum * e.e_phentsize; + curload += (grub_uint32_t) e.e_phnum * e.e_phentsize; *kern_end = curload; @@ -462,7 +462,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, chunk_size = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)) + ALIGN_UP (strsize, sizeof (grub_freebsd_addr_t)) - + sizeof (e) + e.e_shnum * e.e_shentsize; + + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t)); { @@ -498,10 +498,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, s2 = (Elf_Shdr *) curload; grub_memcpy (curload, s, e.e_shentsize); if (s == symsh) - s2->sh_offset = sizeof (e) + e.e_shnum * e.e_shentsize; + s2->sh_offset = sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; else if (s == strsh) s2->sh_offset = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)) - + sizeof (e) + e.e_shnum * e.e_shentsize; + + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; else s2->sh_offset = 0; s2->sh_addr = s2->sh_offset; diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index a7bebcb3c..e3a39b609 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -164,7 +164,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi { grub_uint8_t *shdr, *shdrptr; - shdr = grub_malloc (ehdr->e_shnum * ehdr->e_shentsize); + shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize); if (!shdr) return grub_errno; @@ -174,7 +174,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_errno; } - if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize) + if (grub_file_read (file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize) != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize) { if (!grub_errno) From eefa3239c2aa9531e45a9a3a98cb605b2b563827 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:34:02 +0300 Subject: [PATCH 0478/1167] legacycfg: fix memory leaks and add NULL check Memory leaks found by Coverity scan. CID: 96642, 96645 --- grub-core/commands/legacycfg.c | 43 +++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index d42d7779e..dd9d9f18f 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -253,6 +253,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), struct grub_command *cmd; char **cutargs; int cutargc; + grub_err_t err = GRUB_ERR_NONE; for (i = 0; i < 2; i++) { @@ -314,6 +315,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); + if (!cutargs) + return grub_errno; cutargc = argc - 1; grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2)); cutargs[0] = args[0]; @@ -333,7 +336,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, cutargc, cutargs)) { kernel_type = LINUX; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -348,7 +351,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, argc, args)) { kernel_type = MULTIBOOT; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -413,7 +416,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, cutargc, cutargs)) { kernel_type = KFREEBSD; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -422,6 +425,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), char **bsdargs; int bsdargc; char bsddevname[sizeof ("wdXXXXXXXXXXXXY")]; + int found = 0; + if (bsd_device == -1) { bsdargs = cutargs; @@ -432,6 +437,11 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), char rbuf[3] = "-r"; bsdargc = cutargc + 2; bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc); + if (!bsdargs) + { + err = grub_errno; + goto out; + } grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0])); bsdargs[argc] = rbuf; bsdargs[argc + 1] = bsddevname; @@ -447,7 +457,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, bsdargc, bsdargs)) { kernel_type = KNETBSD; - return GRUB_ERR_NONE; + found = 1; + goto free_bsdargs; } } grub_errno = GRUB_ERR_NONE; @@ -460,20 +471,28 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, bsdargc, bsdargs)) { kernel_type = KOPENBSD; - return GRUB_ERR_NONE; + found = 1; + goto free_bsdargs; } } grub_errno = GRUB_ERR_NONE; } + +free_bsdargs: if (bsdargs != cutargs) grub_free (bsdargs); + if (found) + goto out; } } } while (0); - return grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s", - args[0]); + err = grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s", + args[0]); +out: + grub_free (cutargs); + return err; } static grub_err_t @@ -534,15 +553,17 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused char **newargs; grub_err_t err; char nounzipbuf[10] = "--nounzip"; + + cmd = grub_command_find ("module"); + if (!cmd) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), + "module"); + newargs = grub_malloc ((argc + 1) * sizeof (newargs[0])); if (!newargs) return grub_errno; grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0])); newargs[0] = nounzipbuf; - cmd = grub_command_find ("module"); - if (!cmd) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), - "module"); err = cmd->func (cmd, argc + 1, newargs); grub_free (newargs); From 9b4256bf059f30e3f707cd3eb0d8e6db96b19a3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:48:33 +0300 Subject: [PATCH 0479/1167] net: fix memory leaks Found by: Coverity scan. CID: 96638, 96648 --- grub-core/net/net.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 85b0cf774..d07029b34 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -299,12 +299,6 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, char *ptr; grub_net_network_level_address_t addr; - name = grub_malloc (grub_strlen (card->name) - + GRUB_NET_MAX_STR_HWADDR_LEN - + sizeof (":link")); - if (!name) - return NULL; - addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; addr.ipv6[0] = grub_cpu_to_be64_compile_time (0xfe80ULL << 48); addr.ipv6[1] = grub_net_ipv6_get_id (hwaddr); @@ -317,6 +311,12 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, return inf; } + name = grub_malloc (grub_strlen (card->name) + + GRUB_NET_MAX_STR_HWADDR_LEN + + sizeof (":link")); + if (!name) + return NULL; + ptr = grub_stpcpy (name, card->name); if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0) { @@ -1421,7 +1421,10 @@ grub_net_fs_open (struct grub_file *file_out, const char *name) file->device->net->packs.last = NULL; file->device->net->name = grub_strdup (name); if (!file->device->net->name) - return grub_errno; + { + grub_free (file); + return grub_errno; + } err = file->device->net->protocol->open (file, name); if (err) From d4561cd080b6511e62bfbf27f443262fd7a5e5be Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:59:50 +0300 Subject: [PATCH 0480/1167] tcp: fix memory leaks Found by: Coverity scan. CID: 96639, 96647 --- grub-core/net/tcp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 576f68498..e8ad34b84 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -606,10 +606,15 @@ grub_net_tcp_open (char *server, nb = grub_netbuff_alloc (sizeof (*tcph) + 128); if (!nb) - return NULL; + { + grub_free (socket); + return NULL; + } + err = grub_netbuff_reserve (nb, 128); if (err) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } @@ -617,12 +622,14 @@ grub_net_tcp_open (char *server, err = grub_netbuff_put (nb, sizeof (*tcph)); if (err) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } socket->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); if (!socket->pq) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } @@ -978,6 +985,7 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb, cmp); if (!sock->pq) { + grub_free (sock); grub_netbuff_free (nb); return grub_errno; } From 77002c65d3532384682dd1ac861f4349089c5704 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 21:27:57 +0300 Subject: [PATCH 0481/1167] tftp: fix memory leaks in open If protocol open fails, file is immediately freed, so data was leaked. Found by: Coverity scan. CID: 96659 --- grub-core/net/tftp.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 1319671ff..7d90bf66e 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -326,7 +326,10 @@ tftp_open (struct grub_file *file, const char *filename) grub_netbuff_reserve (&nb, 1500); err = grub_netbuff_push (&nb, sizeof (*tftph)); if (err) - return err; + { + grub_free (data); + return err; + } tftph = (struct tftphdr *) nb.data; @@ -361,19 +364,26 @@ tftp_open (struct grub_file *file, const char *filename) err = grub_netbuff_unput (&nb, nb.tail - (nb.data + hdrlen)); if (err) - return err; + { + grub_free (data); + return err; + } file->not_easily_seekable = 1; file->data = data; data->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); if (!data->pq) - return grub_errno; + { + grub_free (data); + return grub_errno; + } err = grub_net_resolve_address (file->device->net->server, &addr); if (err) { destroy_pq (data); + grub_free (data); return err; } @@ -383,6 +393,7 @@ tftp_open (struct grub_file *file, const char *filename) if (!data->sock) { destroy_pq (data); + grub_free (data); return grub_errno; } @@ -396,6 +407,7 @@ tftp_open (struct grub_file *file, const char *filename) { grub_net_udp_close (data->sock); destroy_pq (data); + grub_free (data); return err; } grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION), @@ -412,6 +424,7 @@ tftp_open (struct grub_file *file, const char *filename) { grub_net_udp_close (data->sock); destroy_pq (data); + grub_free (data); return grub_errno; } From f826d914e2fc390b6e7b6767e6aefcea8dbe95a7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 21:47:28 +0300 Subject: [PATCH 0482/1167] grub-probe: fix memory leak Found by: Coverity scan. CID: 73783 --- util/grub-probe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 36b7f8bcb..8ac527d2f 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -279,7 +279,7 @@ probe (const char *path, char **device_names, char delim) printf ("%s", *curdev); putchar (delim); } - return; + goto free_device_names; } if (print == PRINT_DISK) @@ -297,7 +297,7 @@ probe (const char *path, char **device_names, char delim) putchar (delim); free (disk); } - return; + goto free_device_names; } for (curdev = device_names; *curdev; curdev++) @@ -669,6 +669,7 @@ probe (const char *path, char **device_names, char delim) free (*curdrive); free (drives_names); +free_device_names: if (path != NULL) { for (curdev = device_names; *curdev; curdev++) From 95440b41d33c30ebd12d16f042d60ca700a8f4d8 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 16 Jan 2016 20:37:15 +0000 Subject: [PATCH 0483/1167] ahci, ehci: Fix typos --- grub-core/bus/usb/ehci.c | 2 +- grub-core/disk/ahci.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index 8ece40086..c986c24f6 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -1121,7 +1121,7 @@ grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td, token = grub_le_to_cpu32 (td->token); to_transfer = (token & GRUB_EHCI_TOTAL_MASK) >> GRUB_EHCI_TOTAL_OFF; - /* Check state of TD - if it did not transfered + /* Check state of TD - if it did not transfer * whole data then set last_trans - it should be last executed TD * in case when something went wrong. */ if (transfer && (td->size != to_transfer)) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index fc640d5d4..494a1b773 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct grub_ahci_cmd_head { grub_uint32_t config; - grub_uint32_t transfered; + grub_uint32_t transferred; grub_uint64_t command_table_base; grub_uint32_t unused[4]; }; @@ -954,7 +954,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, grub_dprintf ("ahci", "AHCI tfd = %x\n", dev->hba->ports[dev->port].task_file_data); - dev->command_list[0].transfered = 0; + dev->command_list[0].transferred = 0; dev->command_list[0].command_table_base = grub_dma_get_phys (dev->command_table_chunk); @@ -1044,7 +1044,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, dev->hba->ports[dev->port].command_issue, dev->hba->ports[dev->port].intstatus, dev->hba->ports[dev->port].task_file_data, - dev->command_list[0].transfered, + dev->command_list[0].transferred, dev->hba->ports[dev->port].sata_error, ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x00], ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]); From 92bbf2571463e230682406a9d631580f928af11f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 16 Jan 2016 20:40:55 +0000 Subject: [PATCH 0484/1167] loader/bsd: Fix signed/unsigned comparison --- grub-core/loader/i386/bsdXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 0d14deeb7..af6741d15 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -56,7 +56,7 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) return grub_errno; if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize) - != (grub_uint32_t) e->e_shnum * e->e_shentsize) + != (grub_ssize_t) ((grub_uint32_t) e->e_shnum * e->e_shentsize)) { if (grub_errno) return grub_errno; From 47e67d809cca22b77ea73ab4dbe04cfd5b11bae1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 20 Jan 2016 15:56:55 +0000 Subject: [PATCH 0485/1167] Remove pragmas related to -Wunreachable-code -Wunreachable-code has been a no-op since GCC 4.5; GRUB hasn't been compiled with it since 2012; and GCC 6 produces "error: '-Wunreachable-code' is not an option that controls warnings" for these. Fixes Debian bug #812047. --- grub-core/lib/pbkdf2.c | 1 - grub-core/script/parser.y | 1 - 2 files changed, 2 deletions(-) diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c index 01cee3951..28aa96c46 100644 --- a/grub-core/lib/pbkdf2.c +++ b/grub-core/lib/pbkdf2.c @@ -31,7 +31,6 @@ GRUB_MOD_LICENSE ("GPLv2+"); desired derived output length DKLEN. Output buffer is DK which must have room for at least DKLEN octets. The output buffer will be filled with the derived data. */ -#pragma GCC diagnostic ignored "-Wunreachable-code" gcry_err_code_t grub_crypto_pbkdf2 (const struct gcry_md_spec *md, diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y index 1d60e9de2..4f0ab8319 100644 --- a/grub-core/script/parser.y +++ b/grub-core/script/parser.y @@ -30,7 +30,6 @@ #include "grub_script.tab.h" -#pragma GCC diagnostic ignored "-Wunreachable-code" #pragma GCC diagnostic ignored "-Wmissing-declarations" %} From 7c6c2ad42c3a3a2cbe73ef7808cc6b85fc895ac0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 16:22:19 +0100 Subject: [PATCH 0486/1167] i386-ieee1275: Increase maximum heap size to accomodate highres graphi tests --- grub-core/kern/ieee1275/init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 4303509f2..12590225e 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -46,11 +46,19 @@ #define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) /* The maximum heap size we're going to claim */ +#ifdef __i386__ +#define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) +#else #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024) +#endif /* If possible, we will avoid claiming heap above this address, because it seems to cause relocation problems with OSes that link at 4 MiB */ +#ifdef __i386__ +#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024) +#else #define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) +#endif extern char _start[]; extern char _end[]; From cc2ed410391773c2b6f094d9d699ac219adbc499 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 16:22:47 +0100 Subject: [PATCH 0487/1167] arm: Ignore qemu clock bug --- grub-core/tests/sleep_test.c | 9 ++++++++- tests/grub_cmd_sleep.in | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grub-core/tests/sleep_test.c b/grub-core/tests/sleep_test.c index 3dda30312..3d11c717c 100644 --- a/grub-core/tests/sleep_test.c +++ b/grub-core/tests/sleep_test.c @@ -33,12 +33,19 @@ sleep_test (void) { struct grub_datetime st, en; grub_int32_t stu = 0, enu = 0; + int is_delayok; grub_test_assert (!grub_get_datetime (&st), "Couldn't retrieve start time"); grub_millisleep (10000); grub_test_assert (!grub_get_datetime (&en), "Couldn't retrieve end time"); grub_test_assert (grub_datetime2unixtime (&st, &stu), "Invalid date"); grub_test_assert (grub_datetime2unixtime (&en, &enu), "Invalid date"); - grub_test_assert (enu - stu >= 9 && enu - stu <= 11, "Interval out of range: %d", enu-stu); + is_delayok = (enu - stu >= 9 && enu - stu <= 11); +#ifdef __arm__ + /* Ignore QEMU bug */ + if (enu - stu >= 15 && enu - stu <= 17) + is_delayok = 1; +#endif + grub_test_assert (is_delayok, "Interval out of range: %d", enu-stu); } diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in index 1c84fbfbb..eb362aa24 100644 --- a/tests/grub_cmd_sleep.in +++ b/tests/grub_cmd_sleep.in @@ -14,6 +14,11 @@ dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell` dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)" dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)" +# Ignore QEMU bug +if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then + exit 0; +fi + if [ $((dt2 - dt1)) -gt 11 ] || [ $((dt2 - dt1)) -lt 9 ]; then echo "Interval not in range $dt2-$dt1 != 10" exit 1 From 0edd750e50698854068358ea53528100a9192902 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 10:18:47 +0100 Subject: [PATCH 0488/1167] xen_boot: Remove obsolete module type distinctions. --- grub-core/loader/arm64/xen_boot.c | 148 ++++++------------------------ 1 file changed, 30 insertions(+), 118 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index d1a218929..a914eb8e2 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -37,16 +37,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XEN_HYPERVISOR_NAME "xen_hypervisor" - -#define MODULE_DEFAULT_ALIGN (0x0) -#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN - -#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" -#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" -#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" #define MODULE_CUSTOM_COMPATIBLE "multiboot,module" /* This maximum size is defined in Power.org ePAPR V1.1 @@ -74,14 +64,6 @@ enum module_type }; typedef enum module_type module_type_t; -struct fdt_node_info -{ - module_type_t type; - - const char *compat_string; - grub_size_t compat_string_size; -}; - struct xen_hypervisor_header { struct grub_arm64_linux_kernel_header efi_head; @@ -98,7 +80,7 @@ struct xen_boot_binary { struct xen_boot_binary *next; struct xen_boot_binary **prev; - const char *name; + int is_hypervisor; grub_addr_t start; grub_size_t size; @@ -106,8 +88,6 @@ struct xen_boot_binary char *cmdline; int cmdline_size; - - struct fdt_node_info node_info; }; static grub_dl_t my_mod; @@ -116,19 +96,6 @@ static int loaded; static struct xen_boot_binary *xen_hypervisor; static struct xen_boot_binary *module_head; -static const grub_size_t module_default_align[] = { - MODULE_IMAGE_MIN_ALIGN, - MODULE_INITRD_MIN_ALIGN, - MODULE_XSM_MIN_ALIGN, - MODULE_CUSTOM_MIN_ALIGN -}; - -static const compat_string_struct_t default_compat_string[] = { - FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE), - FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE), - FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE), - FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE) -}; static __inline grub_addr_t xen_boot_address_align (grub_addr_t start, grub_size_t align) @@ -136,20 +103,6 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align) return (align ? (ALIGN_UP (start, align)) : start); } -/* set module type according to command name. */ -static grub_err_t -set_module_type (grub_command_t cmd, struct xen_boot_binary *module) -{ - if (!grub_strcmp (cmd->name, "xen_linux")) - module->node_info.type = MODULE_IMAGE; - else if (!grub_strcmp (cmd->name, "xen_initrd")) - module->node_info.type = MODULE_INITRD; - else if (!grub_strcmp (cmd->name, "xen_xsm")) - module->node_info.type = MODULE_XSM; - - return GRUB_ERR_NONE; -} - static grub_err_t prepare_xen_hypervisor_params (void *xen_boot_fdt) { @@ -203,15 +156,11 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", - module->node_info.compat_string, - (grub_uint32_t) module-> - node_info.compat_string_size); + MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1); if (retval) return grub_error (GRUB_ERR_IO, "failed to update FDT"); - grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n", - module->name, module->node_info.compat_string, - module->node_info.compat_string_size); + grub_dprintf ("xen_loader", "Module\n"); retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node, xen_boot_address_align (module->start, @@ -223,7 +172,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) if (module->cmdline && module->cmdline_size > 0) { grub_dprintf ("xen_loader", - "Module %s cmdline : %s @ %p size:%d\n", module->name, + "Module cmdline : %s @ %p size:%d\n", module->cmdline, module->cmdline, module->cmdline_size); retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs", @@ -233,8 +182,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) } else { - grub_dprintf ("xen_loader", "Module %s has not bootargs!\n", - module->name); + grub_dprintf ("xen_loader", "Module has no bootargs!\n"); } return GRUB_ERR_NONE; @@ -251,8 +199,8 @@ finalize_params_xen_boot (void) additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size; FOR_LIST_ELEMENTS (module, module_head) { - additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module-> - node_info.compat_string_size + module->cmdline_size; + additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + sizeof(MODULE_CUSTOM_COMPATIBLE) - 1 + + module->cmdline_size; } xen_boot_fdt = grub_fdt_load (additional_size); @@ -275,8 +223,7 @@ finalize_params_xen_boot (void) { if (module->start && module->size > 0) { - grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n", - module->name, + grub_dprintf ("xen_loader", "Module @ 0x%lx size:0x%lx\n", xen_boot_address_align (module->start, module->align), module->size); if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE) @@ -284,7 +231,7 @@ finalize_params_xen_boot (void) } else { - grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name); + grub_dprintf ("xen_loader", "Module info error!\n"); goto fail; } } @@ -327,19 +274,16 @@ single_binary_unload (struct xen_boot_binary *binary) { grub_free (binary->cmdline); grub_dprintf ("xen_loader", - "Module %s cmdline memory free @ %p size: %d\n", - binary->name, binary->cmdline, binary->cmdline_size); + "Module cmdline memory free @ %p size: %d\n", + binary->cmdline, binary->cmdline_size); } - if (binary->node_info.type == MODULE_CUSTOM) - grub_free ((void *) binary->node_info.compat_string); - - if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME)) + if (!binary->is_hypervisor) grub_list_remove (GRUB_AS_LIST (binary)); grub_dprintf ("xen_loader", - "Module %s struct memory free @ %p size: 0x%lx\n", - binary->name, binary, sizeof (binary)); + "Module struct memory free @ %p size: 0x%lx\n", + binary, sizeof (binary)); grub_free (binary); return; @@ -377,8 +321,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, int argc, char *argv[]) { binary->size = grub_file_size (file); - grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", - binary->name, binary->size); + grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size); binary->start = (grub_addr_t) grub_efi_allocate_pages (0, @@ -391,8 +334,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, return; } - grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", - binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + grub_dprintf ("xen_loader", "Xen_boot numpages: 0x%lx\n", + GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); if (grub_file_read (file, (void *) xen_boot_address_align (binary->start, binary->align), @@ -416,7 +359,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, binary->cmdline_size); grub_dprintf ("xen_loader", - "Xen_boot %s cmdline @ %p %s, size: %d\n", binary->name, + "Xen_boot cmdline @ %p %s, size: %d\n", binary->cmdline, binary->cmdline, binary->cmdline_size); } else @@ -430,7 +373,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, } static grub_err_t -grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) +grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), + int argc, char *argv[]) { struct xen_boot_binary *module = NULL; @@ -454,34 +398,10 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) if (!module) return grub_errno; - /* process all the options and get module type */ - if (set_module_type (cmd, module) != GRUB_ERR_NONE) - goto fail; - switch (module->node_info.type) - { - case MODULE_IMAGE: - case MODULE_INITRD: - case MODULE_XSM: - module->node_info.compat_string = - default_compat_string[module->node_info.type].compat_string; - module->node_info.compat_string_size = - default_compat_string[module->node_info.type].size; - break; + module->is_hypervisor = 0; + module->align = 4096; - case MODULE_CUSTOM: - /* we have set the node_info in set_module_type */ - break; - - default: - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); - } - module->name = module->node_info.compat_string; - module->align = module_default_align[module->node_info.type]; - - grub_dprintf ("xen_loader", "Init %s module and node info:\n" - "compatible %s\ncompat_string_size 0x%lx\n", - module->name, module->node_info.compat_string, - module->node_info.compat_string_size); + grub_dprintf ("xen_loader", "Init module and node info\n"); file = grub_file_open (argv[0]); if (!file) @@ -491,7 +411,7 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) if (grub_errno == GRUB_ERR_NONE) grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); -fail: + fail: if (file) grub_file_close (file); if (grub_errno != GRUB_ERR_NONE) @@ -535,7 +455,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (!xen_hypervisor) return grub_errno; - xen_hypervisor->name = XEN_HYPERVISOR_NAME; + xen_hypervisor->is_hypervisor = 1; xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment; xen_boot_binary_load (xen_hypervisor, file, argc, argv); @@ -559,29 +479,21 @@ fail: } static grub_command_t cmd_xen_hypervisor; -static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; +static grub_command_t cmd_xen_module; GRUB_MOD_INIT (xen_boot) { cmd_xen_hypervisor = grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0, N_("Load a xen hypervisor.")); - cmd_xen_linux = - grub_register_command ("xen_linux", grub_cmd_xen_module, 0, - N_("Load a xen linux kernel for dom0.")); - cmd_xen_initrd = - grub_register_command ("xen_initrd", grub_cmd_xen_module, 0, - N_("Load a xen initrd for dom0.")); - cmd_xen_xsm = - grub_register_command ("xen_xsm", grub_cmd_xen_module, 0, - N_("Load a xen security module.")); + cmd_xen_module = + grub_register_command ("xen_module", grub_cmd_xen_module, 0, + N_("Load a xen module.")); my_mod = mod; } GRUB_MOD_FINI (xen_boot) { grub_unregister_command (cmd_xen_hypervisor); - grub_unregister_command (cmd_xen_linux); - grub_unregister_command (cmd_xen_initrd); - grub_unregister_command (cmd_xen_xsm); + grub_unregister_command (cmd_xen_module); } From 64e2d139fe1c9133b0eda0a9da8e8c2c03368dea Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 22 Jan 2016 11:05:32 +0100 Subject: [PATCH 0489/1167] Restore terminal settings on grub-emu exit. --- grub-core/kern/emu/main.c | 6 ++++++ grub-core/kern/emu/misc.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 51e8a5715..953a93c8a 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -65,6 +65,12 @@ grub_reboot (void) longjmp (main_env, 1); } +void +grub_exit (void) +{ + grub_reboot (); +} + void grub_machine_init (void) { diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 06985013d..d361feb00 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -134,11 +134,13 @@ xasprintf (const char *fmt, ...) } #endif +#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void grub_exit (void) { exit (1); } +#endif grub_uint64_t grub_get_time_ms (void) From dab148891ee64ba5420a11bdddad9983fc387954 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 13:27:36 +0100 Subject: [PATCH 0490/1167] Document expr1 expr2 syntax for test command --- docs/grub.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 9a25a0bdb..f9173cc27 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5042,6 +5042,8 @@ the length of @var{string} is zero @var{expression} is false @item @var{expression1} @code{-a} @var{expression2} both @var{expression1} and @var{expression2} are true +@item @var{expression1} @var{expression2} +both @var{expression1} and @var{expression2} are true. This syntax is not POSIX-compliant and is not recommended. @item @var{expression1} @code{-o} @var{expression2} either @var{expression1} or @var{expression2} is true @end table From ae3b83a4d4df75a01198a2fed7542391e7c449e0 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Fri, 22 Jan 2016 13:32:30 +0100 Subject: [PATCH 0491/1167] efiemu: Handle persistent RAM and unknown possible future additions. --- grub-core/efiemu/mm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index d4a4f3aad..13af4ad0d 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -99,7 +99,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size, grub_size_t align_overhead; struct grub_efiemu_memrequest *ret, *cur, *prev; /* Check that the request is correct */ - if (type >= GRUB_EFI_MAX_MEMORY_TYPE || type <= GRUB_EFI_LOADER_CODE) + if (type <= GRUB_EFI_LOADER_CODE || type == GRUB_EFI_PERSISTENT_MEMORY || + type >= GRUB_EFI_MAX_MEMORY_TYPE) return -2; /* Add new size to requested size */ @@ -166,6 +167,13 @@ efiemu_alloc_requests (void) GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_PAL_CODE + + /* + * These are not allocatable: + * GRUB_EFI_RESERVED_MEMORY_TYPE + * GRUB_EFI_PERSISTENT_MEMORY + * >= GRUB_EFI_MAX_MEMORY_TYPE + */ }; /* Compute total memory needed */ @@ -402,6 +410,10 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_ACPI_MEMORY_NVS); + case GRUB_MEMORY_PRAM: + case GRUB_MEMORY_PMEM: + return grub_efiemu_add_to_mmap (addr, size, + GRUB_EFI_PERSISTENT_MEMORY); default: grub_dprintf ("efiemu", "Unknown memory type %d. Assuming unusable\n", type); @@ -445,7 +457,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) case GRUB_EFI_MEMORY_MAPPED_IO: case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE: case GRUB_EFI_PAL_CODE: - case GRUB_EFI_MAX_MEMORY_TYPE: + default: hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, GRUB_MEMORY_RESERVED, hook_data); break; @@ -468,6 +480,12 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, GRUB_MEMORY_NVS, hook_data); break; + + case GRUB_EFI_PERSISTENT_MEMORY: + hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, + GRUB_MEMORY_PMEM, hook_data); + break; + } return 0; @@ -503,7 +521,8 @@ grub_efiemu_mmap_sort_and_uniq (void) [GRUB_EFI_ACPI_MEMORY_NVS] = 3, [GRUB_EFI_MEMORY_MAPPED_IO] = 4, [GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 4, - [GRUB_EFI_PAL_CODE] = 4 + [GRUB_EFI_PAL_CODE] = 4, + [GRUB_EFI_PERSISTENT_MEMORY] = 4 }; int i, j, k, done; From 5f2b285bf8d645bf0c7a46dd5434d83824f23278 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 13:50:53 +0100 Subject: [PATCH 0492/1167] Document cpuid -p --- docs/grub.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index f9173cc27..0afdd8ccd 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4073,12 +4073,15 @@ after @command{configfile} returns. @node cpuid @subsection cpuid -@deffn Command cpuid [-l] +@deffn Command cpuid [-l] [-p] Check for CPU features. This command is only available on x86 systems. With the @option{-l} option, return true if the CPU supports long mode (64-bit). +With the @option{-p} option, return true if the CPU supports Physical +Address Extension (PAE). + If invoked without options, this command currently behaves as if it had been invoked with @option{-l}. This may change in the future. @end deffn From b6a03dfd327489d53ee07c6d7d593b99c7b7cb62 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 14:10:30 +0100 Subject: [PATCH 0493/1167] efiemu: Fix compilation failure --- grub-core/efiemu/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index 13af4ad0d..e606dbffc 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_ACPI_MEMORY_NVS); - case GRUB_MEMORY_PRAM: - case GRUB_MEMORY_PMEM: + case GRUB_MEMORY_PERSISTENT: + case GRUB_MEMORY_PERSISTENT_LEGACY: return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_PERSISTENT_MEMORY); default: @@ -483,7 +483,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) case GRUB_EFI_PERSISTENT_MEMORY: hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, - GRUB_MEMORY_PMEM, hook_data); + GRUB_MEMORY_PERSISTENT, hook_data); break; } From 605eecc985b677d196b558d4d8cec6592a68e462 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 19:09:37 +0100 Subject: [PATCH 0494/1167] arm64: Add support for relocations needed for linaro gcc --- grub-core/kern/arm64/dl.c | 18 ++++++++++++++ grub-core/kern/arm64/dl_helper.c | 40 ++++++++++++++++++++++++++++++++ include/grub/arm64/reloc.h | 8 +++++++ include/grub/elf.h | 3 +++ util/grub-mkimagexx.c | 31 +++++++++++++++++++++++++ util/grub-module-verifier.c | 8 ++++++- 6 files changed, 107 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c index e19ba6a0d..cf50d7250 100644 --- a/grub-core/kern/arm64/dl.c +++ b/grub-core/kern/arm64/dl.c @@ -132,6 +132,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, *abs_place = (grub_uint64_t) sym_addr; } break; + case R_AARCH64_ADD_ABS_LO12_NC: + grub_arm64_set_abs_lo12 (place, sym_addr); + break; + case R_AARCH64_LDST64_ABS_LO12_NC: + grub_arm64_set_abs_lo12_ldst64 (place, sym_addr); + break; case R_AARCH64_CALL26: case R_AARCH64_JUMP26: { @@ -154,6 +160,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, grub_arm64_set_xxxx26_offset (place, offset); } break; + case R_AARCH64_ADR_PREL_PG_HI21: + { + grub_int64_t offset = (sym_addr & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL); + + if (!grub_arm64_check_hi21_signed (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "HI21 out of range"); + + grub_arm64_set_hi21 (place, offset); + } + break; + default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("relocation 0x%x is not implemented yet"), diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c index d213ab93e..f031b1ae9 100644 --- a/grub-core/kern/arm64/dl_helper.c +++ b/grub-core/kern/arm64/dl_helper.c @@ -53,3 +53,43 @@ grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset) *place &= insmask; *place |= grub_cpu_to_le32 (offset >> 2) & ~insmask; } + +int +grub_arm64_check_hi21_signed (grub_int64_t offset) +{ + if (offset != (grub_int64_t)(grub_int32_t)offset) + return 0; + return 1; +} + +void +grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0x9f00001f); + grub_uint32_t val; + + offset >>= 12; + + val = ((offset & 3) << 29) | (((offset >> 2) & 0x7ffff) << 5); + + *place &= insmask; + *place |= grub_cpu_to_le32 (val) & ~insmask; +} + +void +grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff); + + *place &= insmask; + *place |= grub_cpu_to_le32 (target << 10) & ~insmask; +} + +void +grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfff803ff); + + *place &= insmask; + *place |= grub_cpu_to_le32 (target << 7) & ~insmask; +} diff --git a/include/grub/arm64/reloc.h b/include/grub/arm64/reloc.h index 4aed3d715..452c14822 100644 --- a/include/grub/arm64/reloc.h +++ b/include/grub/arm64/reloc.h @@ -22,5 +22,13 @@ int grub_arm_64_check_xxxx26_offset (grub_int64_t offset); void grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset); +int +grub_arm64_check_hi21_signed (grub_int64_t offset); +void +grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset); +void +grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target); +void +grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target); #endif diff --git a/include/grub/elf.h b/include/grub/elf.h index caa796390..db15acecf 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -2068,6 +2068,9 @@ typedef Elf32_Addr Elf32_Conflict; #define R_AARCH64_NONE 0 /* No relocation. */ #define R_AARCH64_ABS64 257 /* Direct 64 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */ +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 #define R_AARCH64_JUMP26 282 /* 26-bit relative. */ #define R_AARCH64_CALL26 283 /* 26-bit relative. */ #define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0e0c6f7a1..06b6a724d 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -836,6 +836,14 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, *target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr); } break; + case R_AARCH64_ADD_ABS_LO12_NC: + grub_arm64_set_abs_lo12 ((grub_uint32_t *) target, + sym_addr); + break; + case R_AARCH64_LDST64_ABS_LO12_NC: + grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) target, + sym_addr); + break; case R_AARCH64_JUMP26: case R_AARCH64_CALL26: { @@ -848,6 +856,17 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, sym_addr); } break; + case R_AARCH64_ADR_PREL_PG_HI21: + { + sym_addr &= ~0xfffULL; + sym_addr -= (offset + SUFFIX (entry_point)) & ~0xfffULL; + if (!grub_arm64_check_hi21_signed (sym_addr)) + grub_util_error ("%s", "CALL26 Relocation out of range"); + + grub_arm64_set_hi21((grub_uint32_t *)target, + sym_addr); + } + break; default: grub_util_error (_("relocation 0x%x is not implemented yet"), (unsigned int) ELF_R_TYPE (info)); @@ -1200,6 +1219,15 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, case R_AARCH64_CALL26: case R_AARCH64_JUMP26: break; + /* Page-relative relocations do not require fixup entries. */ + case R_AARCH64_ADR_PREL_PG_HI21: + /* We page-align the whole kernel, so no need + for fixup entries. + */ + case R_AARCH64_ADD_ABS_LO12_NC: + case R_AARCH64_LDST64_ABS_LO12_NC: + break; + default: grub_util_error (_("relocation 0x%x is not implemented yet"), (unsigned int) ELF_R_TYPE (info)); @@ -1343,6 +1371,9 @@ SUFFIX (locate_sections) (const char *kernel_path, Elf_Shdr *s; *all_align = 1; + /* Page-aligning simplifies relocation handling. */ + if (image_target->elf_target == EM_AARCH64) + *all_align = 4096; section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index e217dcddc..405c91170 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -107,7 +107,13 @@ struct grub_module_verifier_arch archs[] = { R_AARCH64_CALL26, R_AARCH64_JUMP26, -1 - } }, + }, (int[]){ + R_AARCH64_ADR_PREL_PG_HI21, + R_AARCH64_ADD_ABS_LO12_NC, + R_AARCH64_LDST64_ABS_LO12_NC, + -1 + } + }, }; From ff84a9b868ea36da23248da780b8e85bdc4c183d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 19:28:08 +0100 Subject: [PATCH 0495/1167] Error out if mtools invocation fails. --- util/grub-mkrescue.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index da0dc021a..238d4840e 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -787,9 +787,14 @@ main (int argc, char *argv[]) free (efidir_efi_boot); efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img"); - grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", + int rv; + rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", efiimgfat, "::", NULL }); - grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL }); + if (rv != 0) + grub_util_error ("`%s` invocation failed\n", "mformat"); + rv = grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL }); + if (rv != 0) + grub_util_error ("`%s` invocation failed\n", "mformat"); xorriso_push ("--efi-boot"); xorriso_push ("efi.img"); xorriso_push ("-efi-boot-part"); From 7290bb5623cd8d9b50b756d0ea40eb6a269985e7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 1 Feb 2016 20:13:48 +0300 Subject: [PATCH 0496/1167] 10_linux: avoid multi-device root= kernel argument If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too. This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case. Closes: 45709 --- util/grub.d/10_linux.in | 4 +++- util/grub.d/20_linux_xen.in | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 859b608f6..5a78513ae 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index f532fb98f..46045db1a 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} From 67dba97e4598eaf2deb14da044fbfb1c119cf76f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 3 Feb 2016 20:34:55 +0300 Subject: [PATCH 0497/1167] support modules without symbol table all_video module does not have any code or data and exists solely for .moddeps section to pull in dependencies. This makes all symbols unneeded. While in current binutils (last released version as of this commit is 2.26) ``strip --strip-unneeded'' unintentionally adds section symbols for each existing section, this behavior was considered a bug and changed in commit 14f2c699ddca1e2f706342dffc59a6c7e23e844c to completely strip symbol table in this case. Older binutils (verified with 2.17) and some other toolchains (at least elftoolchain r3223M), both used in FreeBSD, remove symbol table in all_video as well. Relax run-time check and do not return error for modules without symbol table. Add additional checks to module verifier to make sure such modules a) have non-empty .moddeps section. Without either externally visible symbols or .moddeps modules are completely useless and should not be built. b) do not have any relocations. Closes: 46986 v2: add run-time check for empty symbol table if relocations are present as suggested by Vladimir. --- grub-core/kern/dl.c | 8 +++++++- util/grub-module-verifierXX.c | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 59a6ef4ca..e394cd96f 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -333,8 +333,11 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) if (s->sh_type == SHT_SYMTAB) break; + /* Module without symbol table may still be used to pull in dependencies. + We verify at build time that such modules do not contain any relocations + that may reference symbol table. */ if (i == e->e_shnum) - return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); + return GRUB_ERR_NONE; #ifdef GRUB_MODULES_MACHINE_READONLY mod->symtab = grub_malloc (s->sh_size); @@ -576,6 +579,9 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) if (seg) { + if (!mod->symtab) + return grub_error (GRUB_ERR_BAD_MODULE, "relocation without symbol table"); + err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg); if (err) return err; diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index f612d51f3..9c04caa63 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -176,7 +176,7 @@ get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word break; if (i == grub_target_to_host16 (e->e_shnum)) - grub_util_error ("no symbol table"); + return NULL; sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); *size = grub_target_to_host (s->sh_size); @@ -191,7 +191,21 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) Elf_Word size, entsize; unsigned i; + /* Module without symbol table and without .moddeps section is useless + at boot time, so catch it early to prevent build errors */ sym = get_symtab (arch, e, &size, &entsize); + if (!sym) + { + Elf_Shdr *s = find_section (arch, e, ".moddeps"); + + if (!s) + grub_util_error ("no symbol table and no .moddeps section"); + + if (!s->sh_size) + grub_util_error ("no symbol table and empty .moddeps section"); + + return; + } for (i = 0; i < size / entsize; @@ -243,6 +257,8 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e Elf_Word symtabsize, symtabentsize; symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); + if (!symtab) + grub_util_error ("relocation without symbol table"); for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); From 2d425ffdd57845e4c967b468f8cee164d2ddc85f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 11 Feb 2016 11:58:28 +0100 Subject: [PATCH 0498/1167] xnu: supply ramsize to the kernel. Without this info recent kernels crash as they allocate no heap. --- grub-core/loader/i386/xnu.c | 23 +++++++++++++++++++++++ include/grub/i386/xnu.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a4a6f932e..7962b0e1d 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -897,6 +897,28 @@ grub_xnu_set_video (struct grub_xnu_boot_params_common *params) return GRUB_ERR_NONE; } +static int +total_ram_hook (grub_uint64_t addr __attribute__ ((unused)), grub_uint64_t size, + grub_memory_type_t type, + void *data) +{ + grub_uint64_t *result = data; + + if (type != GRUB_MEMORY_AVAILABLE) + return 0; + *result += size; + return 0; +} + +static grub_uint64_t +get_total_ram (void) +{ + grub_uint64_t result = 0; + + grub_mmap_iterate (total_ram_hook, &result); + return result; +} + /* Boot xnu. */ grub_err_t grub_xnu_boot (void) @@ -973,6 +995,7 @@ grub_xnu_boot (void) { bootparams_common = &bootparams->v2.common; bootparams->v2.fsbfreq = fsbfreq; + bootparams->v2.ram_size = get_total_ram(); } else bootparams_common = &bootparams->v1.common; diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h index a076b8a97..062a7ddbe 100644 --- a/include/grub/i386/xnu.h +++ b/include/grub/i386/xnu.h @@ -89,7 +89,8 @@ struct grub_xnu_boot_params_v2 grub_uint64_t efi_runtime_first_page_virtual; grub_uint32_t efi_system_table; - grub_uint32_t unused2[11]; + grub_uint32_t unused2[9]; + grub_uint64_t ram_size; grub_uint64_t fsbfreq; grub_uint32_t unused3[734]; } GRUB_PACKED; From df4df4d887fab794139adea5e7deee98ded046da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 11 Feb 2016 12:30:45 +0100 Subject: [PATCH 0499/1167] xnu: Include relocated EFI in heap size. --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 7962b0e1d..7b11c65f0 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -1103,7 +1103,7 @@ grub_xnu_boot (void) bootparams_common->efi_mmap = memory_map_target; bootparams_common->efi_mmap_size = memory_map_size; bootparams_common->heap_start = grub_xnu_heap_target_start; - bootparams_common->heap_size = grub_xnu_heap_size; + bootparams_common->heap_size = curruntimepage * GRUB_XNU_PAGESIZE - grub_xnu_heap_target_start; /* Parameters for asm helper. */ grub_xnu_stack = bootparams_common->heap_start From 281baeecd3613eadb985f81cfe1b00ef937eb9e2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 09:10:08 +0100 Subject: [PATCH 0500/1167] Fix emu compilation error on arm. --- grub-core/kern/emu/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 953a93c8a..f91280f68 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -201,7 +201,7 @@ main (int argc, char *argv[]) volatile int hold = 0; size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0; struct grub_module_info *modinfo; - char *mods; + void *mods; grub_util_host_init (&argc, &argv); @@ -232,10 +232,10 @@ main (int argc, char *argv[]) struct grub_module_header *header = (struct grub_module_header *) mods; header->type = OBJ_TYPE_MEMDISK; header->size = memdisk_size + sizeof (*header); - mods += sizeof (*header); + mods = header + 1; grub_util_load_image (arguments.mem_disk, mods); - mods += memdisk_size; + mods = (char *) mods + memdisk_size; } grub_modbase = (grub_addr_t) modinfo; From 8ad190cac258f2070a94f1250c0fb91eca6f7685 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 09:11:06 +0100 Subject: [PATCH 0501/1167] Make unaligned types public. This simplifies code which has to handle those types. --- include/grub/types.h | 74 ++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/include/grub/types.h b/include/grub/types.h index e732efb5c..b93e48201 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -254,55 +254,49 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x) #endif /* ! WORDS_BIGENDIAN */ -static inline grub_uint16_t grub_get_unaligned16 (const void *ptr) +struct grub_unaligned_uint16 { - struct grub_unaligned_uint16_t - { - grub_uint16_t d; - } GRUB_PACKED; - const struct grub_unaligned_uint16_t *dd - = (const struct grub_unaligned_uint16_t *) ptr; - return dd->d; -} - -static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val) + grub_uint16_t val; +} GRUB_PACKED; +struct grub_unaligned_uint32 { - struct grub_unaligned_uint16_t - { - grub_uint16_t d; - } GRUB_PACKED; - struct grub_unaligned_uint16_t *dd = (struct grub_unaligned_uint16_t *) ptr; - dd->d = val; -} - -static inline grub_uint32_t grub_get_unaligned32 (const void *ptr) -{ - struct grub_unaligned_uint32_t - { - grub_uint32_t d; - } GRUB_PACKED; - const struct grub_unaligned_uint32_t *dd - = (const struct grub_unaligned_uint32_t *) ptr; - return dd->d; -} - -static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val) -{ - struct grub_unaligned_uint32_t - { - grub_uint32_t d; - } GRUB_PACKED; - struct grub_unaligned_uint32_t *dd = (struct grub_unaligned_uint32_t *) ptr; - dd->d = val; -} - + grub_uint32_t val; +} GRUB_PACKED; struct grub_unaligned_uint64 { grub_uint64_t val; } GRUB_PACKED; +typedef struct grub_unaligned_uint16 grub_unaligned_uint16_t; +typedef struct grub_unaligned_uint32 grub_unaligned_uint32_t; typedef struct grub_unaligned_uint64 grub_unaligned_uint64_t; +static inline grub_uint16_t grub_get_unaligned16 (const void *ptr) +{ + const struct grub_unaligned_uint16 *dd + = (const struct grub_unaligned_uint16 *) ptr; + return dd->val; +} + +static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val) +{ + struct grub_unaligned_uint16 *dd = (struct grub_unaligned_uint16 *) ptr; + dd->val = val; +} + +static inline grub_uint32_t grub_get_unaligned32 (const void *ptr) +{ + const struct grub_unaligned_uint32 *dd + = (const struct grub_unaligned_uint32 *) ptr; + return dd->val; +} + +static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val) +{ + struct grub_unaligned_uint32 *dd = (struct grub_unaligned_uint32 *) ptr; + dd->val = val; +} + static inline grub_uint64_t grub_get_unaligned64 (const void *ptr) { const struct grub_unaligned_uint64 *dd From b29638222ec75c93f19e16f7ee4b091fe6cc1650 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:35:48 +0100 Subject: [PATCH 0502/1167] Make grub_acpi_find_fadt accessible generically --- grub-core/kern/acpi.c | 85 +++++++++++++++++++++++++++++++ grub-core/kern/i386/tsc_pmtimer.c | 85 ------------------------------- include/grub/acpi.h | 2 +- 3 files changed, 86 insertions(+), 86 deletions(-) diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c index 02c1f4f6f..5746ac00c 100644 --- a/grub-core/kern/acpi.c +++ b/grub-core/kern/acpi.c @@ -32,3 +32,88 @@ grub_byte_checksum (void *base, grub_size_t size) ret += *ptr; return ret; } + +static void * +grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) +{ + grub_size_t s; + grub_unaligned_uint32_t *ptr; + + if (!rsdt) + return 0; + + if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) + return 0; + + ptr = (grub_unaligned_uint32_t *) (rsdt + 1); + s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; + tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +static void * +grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) +{ + grub_size_t s; + grub_unaligned_uint64_t *ptr; + + if (!xsdt) + return 0; + + if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) + return 0; + + ptr = (grub_unaligned_uint64_t *) (xsdt + 1); + s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; +#if GRUB_CPU_SIZEOF_VOID_P != 8 + if (ptr->val >> 32) + continue; +#endif + tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +struct grub_acpi_fadt * +grub_acpi_find_fadt (void) +{ + struct grub_acpi_fadt *fadt = 0; + struct grub_acpi_rsdp_v10 *rsdpv1; + struct grub_acpi_rsdp_v20 *rsdpv2; + rsdpv1 = grub_machine_acpi_get_rsdpv1 (); + if (rsdpv1) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv1->rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + rsdpv2 = grub_machine_acpi_get_rsdpv2 (); + if (rsdpv2) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + if (rsdpv2 +#if GRUB_CPU_SIZEOF_VOID_P != 8 + && !(rsdpv2->xsdt_addr >> 32) +#endif + ) + fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->xsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + return 0; +} diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c index 6a47ab7be..2495e6fd4 100644 --- a/grub-core/kern/i386/tsc_pmtimer.c +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -27,91 +27,6 @@ #include #include -static void * -grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) -{ - grub_size_t s; - grub_uint32_t *ptr; - - if (!rsdt) - return 0; - - if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) - return 0; - - ptr = (grub_uint32_t *) (rsdt + 1); - s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); - for (; s; s--, ptr++) - { - struct grub_acpi_table_header *tbl; - tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; - if (grub_memcmp (tbl->signature, sig, 4) == 0) - return tbl; - } - return 0; -} - -static void * -grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) -{ - grub_size_t s; - grub_uint64_t *ptr; - - if (!xsdt) - return 0; - - if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) - return 0; - - ptr = (grub_uint64_t *) (xsdt + 1); - s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); - for (; s; s--, ptr++) - { - struct grub_acpi_table_header *tbl; -#if GRUB_CPU_SIZEOF_VOID_P != 8 - if (*ptr >> 32) - continue; -#endif - tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; - if (grub_memcmp (tbl->signature, sig, 4) == 0) - return tbl; - } - return 0; -} - -struct grub_acpi_fadt * -grub_acpi_find_fadt (void) -{ - struct grub_acpi_fadt *fadt = 0; - struct grub_acpi_rsdp_v10 *rsdpv1; - struct grub_acpi_rsdp_v20 *rsdpv2; - rsdpv1 = grub_machine_acpi_get_rsdpv1 (); - if (rsdpv1) - fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv1->rsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - rsdpv2 = grub_machine_acpi_get_rsdpv2 (); - if (rsdpv2) - fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - if (rsdpv2 -#if GRUB_CPU_SIZEOF_VOID_P != 8 - && !(rsdpv2->xsdt_addr >> 32) -#endif - ) - fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv2->xsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - return 0; -} - int grub_tsc_calibrate_from_pmtimer (void) { diff --git a/include/grub/acpi.h b/include/grub/acpi.h index a4224e046..66148f684 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -242,6 +242,6 @@ enum }; struct grub_acpi_fadt * -grub_acpi_find_fadt (void); +EXPORT_FUNC(grub_acpi_find_fadt) (void); #endif /* ! GRUB_ACPI_HEADER */ From 1933d3737133314c97e42f6ad928f00ed6e71120 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:38:51 +0100 Subject: [PATCH 0503/1167] Make grub_cpu_is_tsc_supported generally available. --- grub-core/kern/i386/tsc.c | 16 ---------------- include/grub/i386/tsc.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index 82cdea491..2e85289d8 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -43,22 +43,6 @@ grub_tsc_get_time_ms (void) return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; } -static __inline int -grub_cpu_is_tsc_supported (void) -{ -#ifndef GRUB_MACHINE_XEN - grub_uint32_t a,b,c,d; - if (! grub_cpu_is_cpuid_supported ()) - return 0; - - grub_cpuid(1,a,b,c,d); - - return (d & (1 << 4)) != 0; -#else - return 1; -#endif -} - static int calibrate_tsc_hardcode (void) { diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 71fa7ca2f..a0aa2c573 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -51,4 +51,20 @@ grub_get_tsc (void) return (((grub_uint64_t) hi) << 32) | lo; } +static __inline int +grub_cpu_is_tsc_supported (void) +{ +#ifndef GRUB_MACHINE_XEN + grub_uint32_t a,b,c,d; + if (! grub_cpu_is_cpuid_supported ()) + return 0; + + grub_cpuid(1,a,b,c,d); + + return (d & (1 << 4)) != 0; +#else + return 1; +#endif +} + #endif /* ! KERNEL_CPU_TSC_HEADER */ From d9a3bfead8236377c2f46eb75c4fd7fef93696ea Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:40:51 +0100 Subject: [PATCH 0504/1167] Split pmtimer wait and tsc measurement from pmtimer tsc calibration. --- grub-core/Makefile.am | 2 ++ grub-core/kern/i386/tsc_pmtimer.c | 47 ++++++++++++++++++++----------- include/grub/i386/pmtimer.h | 37 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 include/grub/i386/pmtimer.h diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 90502cb1e..04e9395fd 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -107,6 +107,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h endif if COND_i386_coreboot @@ -162,6 +163,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h endif if COND_ia64_efi diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c index 2495e6fd4..c9c361699 100644 --- a/grub-core/kern/i386/tsc_pmtimer.c +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -24,44 +24,35 @@ #include #include #include +#include #include #include -int -grub_tsc_calibrate_from_pmtimer (void) +grub_uint64_t +grub_pmtimer_wait_count_tsc (grub_port_t pmtimer, + grub_uint16_t num_pm_ticks) { grub_uint32_t start; grub_uint32_t last; grub_uint32_t cur, end; - struct grub_acpi_fadt *fadt; - grub_port_t p; grub_uint64_t start_tsc; grub_uint64_t end_tsc; int num_iter = 0; - fadt = grub_acpi_find_fadt (); - if (!fadt) - return 0; - p = fadt->pmtimer; - if (!p) - return 0; - - start = grub_inl (p) & 0xffffff; + start = grub_inl (pmtimer) & 0xffffff; last = start; - /* It's 3.579545 MHz clock. Wait 1 ms. */ - end = start + 3580; + end = start + num_pm_ticks; start_tsc = grub_get_tsc (); while (1) { - cur = grub_inl (p) & 0xffffff; + cur = grub_inl (pmtimer) & 0xffffff; if (cur < last) cur |= 0x1000000; num_iter++; if (cur >= end) { end_tsc = grub_get_tsc (); - grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); - return 1; + return end_tsc - start_tsc; } /* Check for broken PM timer. 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) @@ -73,3 +64,25 @@ grub_tsc_calibrate_from_pmtimer (void) } } } + +int +grub_tsc_calibrate_from_pmtimer (void) +{ + struct grub_acpi_fadt *fadt; + grub_port_t pmtimer; + grub_uint64_t tsc_diff; + + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + pmtimer = fadt->pmtimer; + if (!pmtimer) + return 0; + + /* It's 3.579545 MHz clock. Wait 1 ms. */ + tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580); + if (tsc_diff == 0) + return 0; + grub_tsc_rate = grub_divmod64 ((1ULL << 32), tsc_diff, 0); + return 1; +} diff --git a/include/grub/i386/pmtimer.h b/include/grub/i386/pmtimer.h new file mode 100644 index 000000000..ac091806a --- /dev/null +++ b/include/grub/i386/pmtimer.h @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 . + */ + +#ifndef KERNEL_CPU_PMTIMER_HEADER +#define KERNEL_CPU_PMTIMER_HEADER 1 + +#include +#include + +/* + Preconditions: + * Caller has ensured that both pmtimer and tsc are supported + * 1 <= num_pm_ticks <= 3580 + Return: + * Number of TSC ticks elapsed + * 0 on failure. +*/ +grub_uint64_t +EXPORT_FUNC(grub_pmtimer_wait_count_tsc) (grub_port_t pmtimer, + grub_uint16_t num_pm_ticks); + +#endif From e5c930019104f4ad958c8c327097a1efed144374 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:33:41 +0100 Subject: [PATCH 0505/1167] printf: Fix and test %% behaviour in presence of subsequenbt args. --- grub-core/kern/misc.c | 7 +++++++ tests/printf_unit_test.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 906d2c2f7..e3f851633 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -740,6 +740,12 @@ parse_printf_args (const char *fmt0, struct printf_args *args, fmt++; c = *fmt++; + if (c == '%') + { + n--; + continue; + } + if (c == 'l') { c = *fmt++; @@ -876,6 +882,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, if (c == '%') { write_char (str, &count, max_len,c); + n--; continue; } diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c index eb76bd002..d7b12c6db 100644 --- a/tests/printf_unit_test.c +++ b/tests/printf_unit_test.c @@ -66,6 +66,9 @@ printf_test (void) grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3); snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3); grub_test_assert (strcmp (real, expected) == 0, MSG); + grub_snprintf (real, sizeof (real), "%%0%dd ", 1); + snprintf (expected, sizeof (expected), "%%0%dd ", 1); + grub_test_assert (strcmp (real, expected) == 0, MSG); } GRUB_UNIT_TEST ("printf_unit_test", printf_test); From 342d6edb970dd8af21feea3acf02905a5d117e38 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:34:54 +0100 Subject: [PATCH 0506/1167] yylex: use grub_fatal for exit. lexer calls yylex_fatal on fatal internal errors. yylex_fatal itself is declared as noreturn and calls exit. Returning from noreturn function has unpredictable consequences. --- grub-core/script/yylex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l index 9c2cfe115..95b219170 100644 --- a/grub-core/script/yylex.l +++ b/grub-core/script/yylex.l @@ -92,7 +92,7 @@ typedef size_t yy_size_t; #define stdout 0 #define fprintf(...) 0 -#define exit(...) +#define exit(...) grub_fatal("fatal error in lexer") #endif } From e72de13b9e36dd0ab32eddb1848d403e3bbe7862 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:39:38 +0100 Subject: [PATCH 0507/1167] Add RNG module. --- grub-core/Makefile.core.def | 16 +++++ grub-core/lib/i386/random.c | 103 +++++++++++++++++++++++++++++++ grub-core/lib/random.c | 120 ++++++++++++++++++++++++++++++++++++ include/grub/random.h | 33 ++++++++++ 4 files changed, 272 insertions(+) create mode 100644 grub-core/lib/i386/random.c create mode 100644 grub-core/lib/random.c create mode 100644 include/grub/random.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 0cc40bb2b..18e3208be 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1686,6 +1686,22 @@ module = { x86 = loader/xnu.c; enable = x86; +} + +module = { + name = random; + x86 = lib/i386/random.c; + common = lib/random.c; + + i386_multiboot = kern/i386/tsc_pmtimer.c; + i386_coreboot = kern/i386/tsc_pmtimer.c; + i386_pc = kern/i386/tsc_pmtimer.c; + + enable = i386_multiboot; + enable = i386_coreboot; + enable = i386_pc; + enable = i386_efi; + enable = x86_64_efi; }; module = { diff --git a/grub-core/lib/i386/random.c b/grub-core/lib/i386/random.c new file mode 100644 index 000000000..cd83d2f8f --- /dev/null +++ b/grub-core/lib/i386/random.c @@ -0,0 +1,103 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include +#include +#include +#include + +static int have_tsc = -1, have_pmtimer = -1; +static grub_port_t pmtimer_port; + +static int +detect_pmtimer (void) +{ + struct grub_acpi_fadt *fadt; + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + pmtimer_port = fadt->pmtimer; + if (!pmtimer_port) + return 0; + return 1; +} + +static int +pmtimer_tsc_get_random_bit (void) +{ + /* It's hard to come up with figures about pmtimer and tsc jitter but + 50 ppm seems to be typical. So we need 10^6/50 tsc cycles to get drift + of one tsc cycle. With TSC at least of 800 MHz it means 1/(50*800) + = 1/40000 s or about 3579545 / 40000 = 90 pmtimer ticks. + This gives us rate of 40000 bit/s or 5 kB/s. + */ + grub_uint64_t tsc_diff; + tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer_port, 90); + if (tsc_diff == 0) + { + have_pmtimer = 0; + return -1; + } + return tsc_diff & 1; +} + +static int +pmtimer_tsc_get_random_byte (void) +{ + grub_uint8_t ret = 0; + int i, c; + for (i = 0; i < 8; i++) + { + c = pmtimer_tsc_get_random_bit (); + if (c < 0) + return -1; + ret |= c << i; + } + return ret; +} + +static int +pmtimer_fill_buffer (void *buffer, grub_size_t sz) +{ + grub_uint8_t *p = buffer; + int c; + while (sz) + { + c = pmtimer_tsc_get_random_byte (); + if (c < 0) + return 0; + *p++ = c; + sz--; + } + return 1; +} + +int +grub_crypto_arch_get_random (void *buffer, grub_size_t sz) +{ + if (have_tsc == -1) + have_tsc = grub_cpu_is_tsc_supported (); + if (!have_tsc) + return 0; + if (have_pmtimer == -1) + have_pmtimer = detect_pmtimer (); + if (!have_pmtimer) + return 0; + return pmtimer_fill_buffer (buffer, sz); +} diff --git a/grub-core/lib/random.c b/grub-core/lib/random.c new file mode 100644 index 000000000..43b966438 --- /dev/null +++ b/grub-core/lib/random.c @@ -0,0 +1,120 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +grub_err_t +grub_crypto_get_random (void *buffer, grub_size_t sz) +{ + /* This is an arbitrer between different methods. + TODO: Add more methods in the future. */ + /* TODO: Add some PRNG smartness to reduce damage from bad entropy. */ + if (grub_crypto_arch_get_random (buffer, sz)) + return GRUB_ERR_NONE; + return grub_error (GRUB_ERR_IO, "no random sources found"); +} + +static int +get_num_digits (int val) +{ + int ret = 0; + while (val != 0) + { + ret++; + val /= 10; + } + if (ret == 0) + return 1; + return ret; +} + +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + +static grub_err_t +grub_cmd_hexdump_random (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) +{ + grub_size_t length = 64; + grub_err_t err; + void *buffer; + grub_uint8_t *ptr; + int stats[256]; + int i, digits = 2; + char template[10]; + + if (argc >= 1) + length = grub_strtoull (args[0], 0, 0); + + if (length == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "length pust be positive"); + + buffer = grub_malloc (length); + if (!buffer) + return grub_errno; + + err = grub_crypto_get_random (buffer, length); + if (err) + { + grub_free (buffer); + return err; + } + + hexdump (0, buffer, length); + grub_memset(stats, 0, sizeof(stats)); + for (ptr = buffer; ptr < (grub_uint8_t *) buffer + length; ptr++) + stats[*ptr]++; + grub_printf ("Statistics:\n"); + for (i = 0; i < 256; i++) + { + int z = get_num_digits (stats[i]); + if (z > digits) + digits = z; + } + + grub_snprintf (template, sizeof (template), "%%0%dd ", digits); + + for (i = 0; i < 256; i++) + { + grub_printf ("%s", template);//, stats[i]); + if ((i & 0xf) == 0xf) + grub_printf ("\n"); + } + + grub_free (buffer); + + return 0; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT (random) +{ + cmd = grub_register_command ("hexdump_random", grub_cmd_hexdump_random, + N_("[LENGTH]"), + N_("Hexdump random data.")); +} + +GRUB_MOD_FINI (random) +{ + grub_unregister_command (cmd); +} diff --git a/include/grub/random.h b/include/grub/random.h new file mode 100644 index 000000000..4b75c0e2b --- /dev/null +++ b/include/grub/random.h @@ -0,0 +1,33 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#ifndef GRUB_RANDOM_HEADER +#define GRUB_RANDOM_HEADER 1 + +#include +#include + +/* Not peer-reviewed. May not be any better than string of zeros. */ +grub_err_t +grub_crypto_get_random (void *buffer, grub_size_t sz); + +/* Do not use directly. Use grub_crypto_get_random instead. */ +int +grub_crypto_arch_get_random (void *buffer, grub_size_t sz); + +#endif From 22aa31bcc33ff480a8d94931d08235c12b4eecd8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:40:10 +0100 Subject: [PATCH 0508/1167] xnu: Supply random seed. Now we're able to load kernels up to El Capitan. --- grub-core/Makefile.core.def | 13 +++++++++++-- grub-core/loader/i386/xnu.c | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 18e3208be..58438c48d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1685,8 +1685,17 @@ module = { x86 = loader/i386/xnu.c; x86 = loader/xnu.c; - enable = x86; -} + /* Code is pretty generic but relies on RNG which + is available only on few platforms. It's not a + big deal as xnu needs ACPI anyway and we have + RNG on all platforms with ACPI. + */ + enable = i386_multiboot; + enable = i386_coreboot; + enable = i386_pc; + enable = i386_efi; + enable = x86_64_efi; +}; module = { name = random; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 7b11c65f0..59ef73a73 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -35,6 +35,7 @@ #include #include #include +#include #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -577,11 +578,31 @@ static grub_err_t grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out) { struct grub_xnu_devtree_key *efikey; + struct grub_xnu_devtree_key *chosenkey; struct grub_xnu_devtree_key *cfgtablekey; struct grub_xnu_devtree_key *curval; struct grub_xnu_devtree_key *runtimesrvkey; struct grub_xnu_devtree_key *platformkey; unsigned i, j; + grub_err_t err; + + chosenkey = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen"); + if (! chosenkey) + return grub_errno; + + /* Random seed. */ + curval = grub_xnu_create_value (&(chosenkey->first_child), "random-seed"); + if (! curval) + return grub_errno; + curval->datasize = 64; + curval->data = grub_malloc (curval->datasize); + if (! curval->data) + return grub_errno; + /* Our random is not peer-reviewed but xnu uses this seed only for + ASLR in kernel. */ + err = grub_crypto_get_random (curval->data, curval->datasize); + if (err) + return err; /* The value "model". */ /* FIXME: may this value be sometimes different? */ From 127cfea8bec7a06b27c0df393728e20e276e9543 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:41:28 +0100 Subject: [PATCH 0509/1167] default_payload: Include syslinuxcfg, all filesystems and xnu. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 70a8af873..71c23e50d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From 6f4189ffc19283b7a7ea8129d38a63bd4285f337 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:42:04 +0100 Subject: [PATCH 0510/1167] powerpc: Trim header in tests. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 5ba2c299c..663cde663 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -82,6 +82,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in serial_port=escc-ch-b serial_null="-serial null" netbootext=elf + trim=1 ;; sparc64-ieee1275) From 4598cafa7d0a71ba39fbe59a8df1a9195994feec Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:43:02 +0100 Subject: [PATCH 0511/1167] arm64: Use cpu timer for timekeeping. --- grub-core/Makefile.core.def | 2 +- grub-core/kern/arm64/efi/init.c | 60 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 grub-core/kern/arm64/efi/init.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 58438c48d..887450110 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -213,7 +213,7 @@ kernel = { arm_efi = kern/arm/efi/init.c; arm_efi = kern/arm/efi/misc.c; - arm64_efi = kern/arm/efi/init.c; + arm64_efi = kern/arm64/efi/init.c; i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/mmap.c; diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c new file mode 100644 index 000000000..6224999ec --- /dev/null +++ b/grub-core/kern/arm64/efi/init.c @@ -0,0 +1,60 @@ +/* init.c - initialize an arm-based EFI system */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +static grub_uint64_t timer_frequency_in_khz; + +static grub_uint64_t +grub_efi_get_time_ms (void) +{ + grub_uint64_t tmr; + asm volatile("mrs %0, cntvct_el0" : "=r" (tmr)); + + return tmr / timer_frequency_in_khz; +} + + +void +grub_machine_init (void) +{ + grub_uint64_t timer_frequency; + + grub_efi_init (); + + asm volatile("mrs %0, cntfrq_el0" : "=r" (timer_frequency)); + timer_frequency_in_khz = timer_frequency / 1000; + + grub_install_get_time_ms (grub_efi_get_time_ms); +} + +void +grub_machine_fini (int flags) +{ + if (!(flags & GRUB_LOADER_FLAG_NORETURN)) + return; + + grub_efi_fini (); +} From 7c35f65aaca8539d3fccea17e3ff6fc0e71143a4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 15:42:26 +0100 Subject: [PATCH 0512/1167] xnu: Add new kernel path to autoconfig. --- util/grub.d/10_xnu.in | 3 +++ util/grub.d/30_os-prober.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/util/grub.d/10_xnu.in b/util/grub.d/10_xnu.in index 51ee2f427..9c40b4536 100644 --- a/util/grub.d/10_xnu.in +++ b/util/grub.d/10_xnu.in @@ -56,6 +56,9 @@ EOF fi if [ /kernelcache -nt /System/Library/Extensions ]; then $1 /kernelcache boot-uuid=\${uuid} rd=*uuid + elif [ -f /System/Library/Kernels/kernel ]; then + $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid + xnu_kextdir /System/Library/Extensions else $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 5604ce2b6..515a68c7a 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -71,6 +71,9 @@ EOF fi if [ /kernelcache -nt /System/Library/Extensions ]; then $1 /kernelcache boot-uuid=\${uuid} rd=*uuid + elif [ -f /System/Library/Kernels/kernel ]; then + $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid + xnu_kextdir /System/Library/Extensions else $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then From 6e1ace590afd02abbdfdf05cff0672fc3906365a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 15:46:05 +0100 Subject: [PATCH 0513/1167] Change -v to -V for version of shell utils. --- util/grub-kbdcomp.in | 4 ++-- util/grub-mkconfig.in | 2 +- util/grub-reboot.in | 4 ++-- util/grub-set-default.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index 715c483af..a15ec24e5 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -25,7 +25,7 @@ usage () { gettext "Make GRUB keyboard layout file."; echo echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")" echo gettext_printf "%s generates a keyboard layout for GRUB using ckbcomp\n" "$self" @@ -54,7 +54,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; -o | --output) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 3183744bf..203b07696 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -85,7 +85,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; -o | --output) diff --git a/util/grub-reboot.in b/util/grub-reboot.in index 225fe5f21..4d4f75704 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -47,7 +47,7 @@ usage () { gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self" gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")" print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg" echo @@ -81,7 +81,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; diff --git a/util/grub-set-default.in b/util/grub-set-default.in index 83a7be12f..6036f81e5 100644 --- a/util/grub-set-default.in +++ b/util/grub-set-default.in @@ -49,7 +49,7 @@ usage () { gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir" echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")" print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg" echo @@ -79,7 +79,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; From eba6db6323caf2c25e3531902b73c4a1a40a2d1a Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 12 Feb 2016 15:58:22 +0100 Subject: [PATCH 0514/1167] relocator: Fix integer underflow. --- grub-core/lib/relocator.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index f759c7f41..ea3ebc719 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -736,26 +736,36 @@ malloc_in_range (struct grub_relocator *rel, } isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw) && !nblockfw))); - if (!isinsidebefore && isinsideafter) - starta = from_low_priv ? ALIGN_UP (events[j].pos, align) - : ALIGN_DOWN (events[j].pos - size, align) + size; - if (isinsidebefore && !isinsideafter && from_low_priv) - { - target = starta; - if (target < start) - target = start; - if (target + size <= end && target + size <= events[j].pos) - /* Found an usable address. */ - goto found; - } - if (isinsidebefore && !isinsideafter && !from_low_priv) - { - target = starta - size; - if (target > end - size) - target = end - size; - if (target >= start && target >= events[j].pos) - goto found; - } + if (from_low_priv) { + if (!isinsidebefore && isinsideafter) + starta = ALIGN_UP (events[j].pos, align); + + if (isinsidebefore && !isinsideafter) + { + target = starta; + if (target < start) + target = start; + if (target + size <= end && target + size <= events[j].pos) + /* Found an usable address. */ + goto found; + } + } else { + if (!isinsidebefore && isinsideafter) + { + if (events[j].pos >= size) + starta = ALIGN_DOWN (events[j].pos - size, align) + size; + else + starta = 0; + } + if (isinsidebefore && !isinsideafter && starta >= size) + { + target = starta - size; + if (target > end - size) + target = end - size; + if (target >= start && target >= events[j].pos) + goto found; + } + } } } From feef882f98f335b2725edc53af76f5ff50551949 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 16:08:04 +0100 Subject: [PATCH 0515/1167] grub-shell: Update 32-bit OVMF binary name. --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 663cde663..7848b4222 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -165,7 +165,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 - qemuopts="-bios OVMF32.fd $qemuopts" + qemuopts="-bios OVMF-ia32.fd $qemuopts" ;; x86_64-efi) qemu=qemu-system-x86_64 From ce01054ec3f8f8d03fba434de94ab00118c16593 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 12 Feb 2016 16:31:23 +0100 Subject: [PATCH 0516/1167] lz4: Fix pointer overflow --- grub-core/fs/zfs/zfs_lz4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c index 1212a8986..2f73449f0 100644 --- a/grub-core/fs/zfs/zfs_lz4.c +++ b/grub-core/fs/zfs/zfs_lz4.c @@ -184,6 +184,8 @@ LZ4_uncompress_unknownOutputSize(const char *source, } } /* copy literals */ + if ((grub_addr_t) length > ~(grub_addr_t)op) + goto _output_error; cpy = op + length; if ((cpy > oend - COPYLENGTH) || (ip + length > iend - COPYLENGTH)) { From a2ab8c2172367e25f79617cad878102bd5f8a336 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 17:51:52 +0100 Subject: [PATCH 0517/1167] TODO: Remove obsolete link --- TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TODO b/TODO index 6ec1521cd..a9b6d3523 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,3 @@ glance. So write to first. For bug tracking, refer to: http://savannah.gnu.org/bugs/?group=grub - -Our wiki also lists some areas that need work: - - http://grub.enbug.org/ From f96b34224e50dbba055f7744406038d5beccf2a6 Mon Sep 17 00:00:00 2001 From: Andreas Freimuth Date: Fri, 12 Feb 2016 19:19:11 +0100 Subject: [PATCH 0518/1167] Add Thinkpad T410s button cmos address. --- docs/grub.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 0afdd8ccd..82f6fa459 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2538,6 +2538,8 @@ team are: 85:3 @item Asus EeePC 1005PE 84:1 (unconfirmed) +@item LENOVO ThinkPad T410s (2912W1C) +101:3 @end table To take full advantage of this function, install GRUB into the MBR From 080a20861c08397bfef5eb1471b6124a82a0777c Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Fri, 12 Feb 2016 23:16:03 +0100 Subject: [PATCH 0519/1167] OBP available region contains grub. Start at grub_phys_end. This prevents a problem where grub was being overwritten since grub_phys_start does not start at a zero offset within the memory map. --- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index d44d7a113..67ef04883 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, if (addr + ctx->size >= end) return 0; - if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr = ALIGN_UP (grub_phys_end, FOUR_MB); - if (addr + ctx->size >= end) - return 0; - } - if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) + /* OBP available region contains grub. Start at grub_phys_end. */ + /* grub_phys_start does not start at the beginning of the memory region */ + if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end)) { addr = ALIGN_UP (grub_phys_end, FOUR_MB); if (addr + ctx->size >= end) return 0; } + grub_dprintf("loader", + "addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n", + addr, grub_phys_start, grub_phys_end); + if (loaded) { grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB); From 25492a0f047cb7a6583ae195568599c296a604d6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Jan 2016 13:48:26 +0100 Subject: [PATCH 0520/1167] Add wbinvd around bios call. Via C3 has problems with cache coherency when transitioning between the modes, so flush it around bios calls. --- grub-core/kern/i386/int.S | 11 +++++++++++ grub-core/kern/i386/pc/init.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/grub-core/kern/i386/int.S b/grub-core/kern/i386/int.S index 7edace404..862a54202 100644 --- a/grub-core/kern/i386/int.S +++ b/grub-core/kern/i386/int.S @@ -44,6 +44,13 @@ FUNCTION(grub_bios_interrupt) movl 24(%edx), %esi movl 28(%edx), %edx + /* + Via C3 CPUs have cache coherence problems, so we need to call + wbinvd at these 2 points. As wbinvd slows down boot, don't do + it on non-VIA. 9090 is nop nop. */ +VARIABLE(grub_bios_via_workaround1) + .byte 0x90, 0x90 + PROT_TO_REAL .code16 pushf @@ -92,6 +99,10 @@ intno: movw %ax, LOCAL(bios_register_es) popf + +VARIABLE(grub_bios_via_workaround2) + .byte 0x90, 0x90 + REAL_TO_PROT .code32 diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c index 3c8160aab..27bc68b8a 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -184,6 +185,26 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size, return 0; } +extern grub_uint16_t grub_bios_via_workaround1, grub_bios_via_workaround2; + +/* Via needs additional wbinvd. */ +static void +grub_via_workaround_init (void) +{ + grub_uint32_t manufacturer[3], max_cpuid; + if (! grub_cpu_is_cpuid_supported ()) + return; + + grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]); + + if (grub_memcmp (manufacturer, "CentaurHauls", 12) != 0) + return; + + grub_bios_via_workaround1 = 0x090f; + grub_bios_via_workaround2 = 0x090f; + asm volatile ("wbinvd"); +} + void grub_machine_init (void) { @@ -193,6 +214,9 @@ grub_machine_init (void) #endif grub_addr_t modend; + /* This has to happen before any BIOS calls. */ + grub_via_workaround_init (); + grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR + (_edata - _start); /* Initialize the console as early as possible. */ From 5cae910665ac0de9e409e3b606232cd66854081e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 17:56:41 +0100 Subject: [PATCH 0521/1167] Fix warnings when compiling with -O3 --- conf/Makefile.common | 2 +- grub-core/commands/i386/cmostest.c | 6 +++--- grub-core/fs/ntfscomp.c | 2 +- grub-core/fs/zfs/zfs.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 11296b550..6db04343a 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -65,7 +65,7 @@ grubconfdir = $(sysconfdir)/grub.d platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-maybe-uninitialized CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CFLAGS_POSIX = -fno-builtin diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c index e5dea0769..c839b704d 100644 --- a/grub-core/commands/i386/cmostest.c +++ b/grub-core/commands/i386/cmostest.c @@ -45,7 +45,7 @@ static grub_err_t grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; @@ -67,7 +67,7 @@ static grub_err_t grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; @@ -85,7 +85,7 @@ static grub_err_t grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c index 2e1ce51a8..3cd97d337 100644 --- a/grub-core/fs/ntfscomp.c +++ b/grub-core/fs/ntfscomp.c @@ -104,7 +104,7 @@ decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest) if (tag & 1) { grub_uint32_t i, len, delta, code, lmask, dshift; - grub_uint16_t word; + grub_uint16_t word = 0; if (decomp_get16 (cc, &word)) return grub_errno; diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c4ead29fb..6e1fff9e9 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3132,7 +3132,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) { void *osp; blkptr_t *bp; - grub_size_t ospsize; + grub_size_t ospsize = 0; grub_err_t err; grub_dprintf ("zfs", "endian = %d\n", mdn->endian); From fabde8324d1fccb79778d180aee30894c0b10c63 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 17:58:05 +0100 Subject: [PATCH 0522/1167] Remove -Wno-maybe-uninitialized as it may not be present. --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 6db04343a..11296b550 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -65,7 +65,7 @@ grubconfdir = $(sysconfdir)/grub.d platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-maybe-uninitialized +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CFLAGS_POSIX = -fno-builtin From 59ec05bcf8bb443853c109039752cefdfc1c5e13 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:09:44 +0100 Subject: [PATCH 0523/1167] mm: Avoid integer overflow. --- grub-core/kern/mm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 1c3d02388..ee88ff611 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -325,6 +325,15 @@ grub_memalign (grub_size_t align, grub_size_t size) if (!grub_mm_base) goto fail; + if (size > ~(grub_size_t) align) + goto fail; + + /* We currently assume at least a 32-bit grub_size_t, + so limiting allocations to - 1MiB + in name of sanity is beneficial. */ + if ((size + align) > ~(grub_size_t) 0x100000) + goto fail; + align = (align >> GRUB_MM_ALIGN_LOG2); if (align == 0) align = 1; From 8d69065f5282e1f9e0b09a166586ce3a6b897581 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:10:31 +0100 Subject: [PATCH 0524/1167] default_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES). This allows coreboot building system to add extra modules depending on user config. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 71c23e50d..cccd466aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From 01d50c25398d124c275f05ca2926657e2198bed4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:11:51 +0100 Subject: [PATCH 0525/1167] default_payload.elf: Include password_pbkdf2. Withoout this module we may end up in a system where no password is accepted. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index cccd466aa..f132a8839 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From e3745f908706c07fa249616255ed993ef5704351 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:19:18 +0100 Subject: [PATCH 0526/1167] default_payload.elf: Always rebuild and remove before build. It's difficult to know all dependencies. Since it's manual and cheap target anyway, simply always rebuild it. --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f132a8839..288e621d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -409,7 +409,8 @@ BOOTCHECK_TIMEOUT=180 bootcheck: $(BOOTCHECKS) if COND_i386_coreboot -default_payload.elf: grub-mkstandalone grub-mkimage +default_payload.elf: grub-mkstandalone grub-mkimage FORCE + rm $@ pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif From 625934ec0f208836c6f2dbe7bd8ad658cbdd8537 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 29 Jan 2016 15:26:58 +0100 Subject: [PATCH 0527/1167] menu_entry: Disable cursor during update_screen() When running grub in a VGA console of a KVM pseries guest on PowerPC, you can see the cursor sweeping over the whole line when entering a character in editor mode. This is visible because grub always refreshes the whole line when entering a character in editor mode, and drawing characters is quite a slow operation with the firmware used for the powerpc pseries guests (SLOF). To avoid this ugliness, the cursor should be disabled when refreshing the screen contents during update_screen(). Signed-off-by: Thomas Huth --- grub-core/normal/menu_entry.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index b80d161dd..eeeee5580 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -254,6 +254,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, mode = ALL_LINES; } + grub_term_setcursor (term_screen->term, 0); + if (mode != NO_LINE) { /* Draw lines. This code is tricky, because this must calculate logical @@ -361,6 +363,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, } + grub_term_setcursor (term_screen->term, 1); + grub_term_refresh (term_screen->term); } From bc220962e366b1b46769ed6f9fa5be603ba58ab5 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 15 Feb 2016 10:53:45 -0800 Subject: [PATCH 0528/1167] ieee1275: prevent buffer over-read Prevent buffer over-read in grub_machine_mmap_iterate. This was causing phys_base from being calculated properly. This then caused the wrong value to be placed in ramdisk_image within struct linux_hdrs. Which prevented the ramdisk from loading on boot. Newer SPARC systems contain more than 8 available memory entries. For example on a T5-8 with 2TB of memory, the memory layout could look like this: T5-8 Memory reg 00000000 30000000 0000003f b0000000 00000800 00000000 00000040 00000000 00001000 00000000 00000040 00000000 00001800 00000000 00000040 00000000 00002000 00000000 00000040 00000000 00002800 00000000 00000040 00000000 00003000 00000000 00000040 00000000 00003800 00000000 00000040 00000000 available 00003800 00000000 0000003f ffcae000 00003000 00000000 00000040 00000000 00002800 00000000 00000040 00000000 00002000 00000000 00000040 00000000 00001800 00000000 00000040 00000000 00001000 00000000 00000040 00000000 00000800 00000000 00000040 00000000 00000000 70000000 0000003f 70000000 00000000 6eef8000 00000000 00002000 00000000 30400000 00000000 3eaf6000 name memory Signed-off-by: Eric Snowberg --- grub-core/kern/ieee1275/mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index 911bb0011..d7f6a1bde 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -25,7 +25,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) { grub_ieee1275_phandle_t root; grub_ieee1275_phandle_t memory; - grub_uint32_t available[32]; + grub_uint32_t available[128]; grub_ssize_t available_size; grub_uint32_t address_cells = 1; grub_uint32_t size_cells = 1; @@ -49,6 +49,9 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) sizeof available, &available_size)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); + if (available_size > sizeof (available)) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, + "/memory response buffer exceeded"); if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) { From be4e9d20a559ea0ddab5c1abe512a3d875742389 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 20 Feb 2016 09:12:15 +0100 Subject: [PATCH 0529/1167] Refresh before abort This ensures that abort message is actually visible to the user. --- grub-core/kern/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index e3f851633..d1a54df6c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1106,6 +1106,8 @@ grub_fatal (const char *fmt, ...) grub_vprintf (_(fmt), ap); va_end (ap); + grub_refresh (); + grub_abort (); } From 0678b5d629a4c9a7258d24a0af10920d0e965da7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 22 Feb 2016 03:25:50 +0100 Subject: [PATCH 0530/1167] usb_keyboard: Remove useless include This prevents non-PCI machines from having USB. --- grub-core/term/usb_keyboard.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c index 3b7484635..e67b8f785 100644 --- a/grub-core/term/usb_keyboard.c +++ b/grub-core/term/usb_keyboard.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include From 054d1325e9ece974aecb478e6b43ca6c37d0bb3e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 22 Feb 2016 03:32:50 +0100 Subject: [PATCH 0531/1167] Improve EHCI logging Add dprintf's on common error paths and remove some entries which are too noisy. --- grub-core/bus/usb/ehci.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index c986c24f6..ae1efb214 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -1289,16 +1289,26 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, grub_ehci_td_t td_prev = NULL; int i; struct grub_ehci_transfer_controller_data *cdata; + grub_uint32_t status; /* Check if EHCI is running and AL is enabled */ - if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) - & GRUB_EHCI_ST_HC_HALTED) != 0) + status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); + if ((status & GRUB_EHCI_ST_HC_HALTED) != 0) /* XXX: Fix it: Currently we don't do anything to restart EHCI */ - return GRUB_USB_ERR_INTERNAL; - if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) + { + grub_dprintf ("ehci", "setup_transfer: halted, status = 0x%x\n", + status); + return GRUB_USB_ERR_INTERNAL; + } + status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); + if ((status & (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0) /* XXX: Fix it: Currently we don't do anything to restart EHCI */ - return GRUB_USB_ERR_INTERNAL; + { + grub_dprintf ("ehci", "setup_transfer: no AS/PS, status = 0x%x\n", + status); + return GRUB_USB_ERR_INTERNAL; + } /* Allocate memory for controller transfer data. */ cdata = grub_malloc (sizeof (*cdata)); @@ -1310,6 +1320,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, cdata->qh_virt = grub_ehci_find_qh (e, transfer); if (!cdata->qh_virt) { + grub_dprintf ("ehci", "setup_transfer: no QH\n"); grub_free (cdata); return GRUB_USB_ERR_INTERNAL; } @@ -1319,6 +1330,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, cdata->td_alt_virt = grub_ehci_alloc_td (e); if (!cdata->td_alt_virt) { + grub_dprintf ("ehci", "setup_transfer: no TDs\n"); grub_free (cdata); return GRUB_USB_ERR_INTERNAL; } @@ -1345,6 +1357,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual); grub_free (cdata); + grub_dprintf ("ehci", "setup_transfer: no TD\n"); return GRUB_USB_ERR_INTERNAL; } @@ -1777,11 +1790,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed) status = grub_ehci_port_read (e, port); - grub_dprintf ("ehci", "detect_dev: EHCI STATUS: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)); - grub_dprintf ("ehci", "detect_dev: iobase=%p, port=%d, status=0x%02x\n", - e->iobase, port, status); - /* Connect Status Change bit - it detects change of connection */ if (status & GRUB_EHCI_PORT_CONNECT_CH) { From 15dfea842c03fd373b0b39e98716051815416e95 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 23 Feb 2016 09:12:14 +0300 Subject: [PATCH 0532/1167] multiboot2: zero reserved field in memory map Documentation says, bootloader should set reserved field to zero. Reported by Wink Saville --- grub-core/loader/multiboot_mbi2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index d7c19bc99..f147d674d 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -420,6 +420,7 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size, (*mmap_entry)->addr = addr; (*mmap_entry)->len = size; (*mmap_entry)->type = type; + (*mmap_entry)->zero = 0; (*mmap_entry)++; return 0; From 1b782e902e69516f82158203674d4951a40c82d4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 23 Feb 2016 23:14:41 +0300 Subject: [PATCH 0533/1167] search: actually skip floppy with --no-floppy grub_device_iterate() ignores device when iterator returns 1, not 0. Reported by Carlos E. R. --- grub-core/commands/search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index 440303a4e..7dd32e445 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -64,7 +64,7 @@ iterate_device (const char *name, void *data) /* Skip floppy drives when requested. */ if (ctx->no_floppy && name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') - return 0; + return 1; #ifdef DO_SEARCH_FS_UUID #define compare_fn grub_strcasecmp From 94c56a4c65c9b2c0cb99f225fadffc2ca990c9d1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 08:57:31 +0100 Subject: [PATCH 0534/1167] ieee1275: fix signed comparison --- grub-core/kern/ieee1275/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index d7f6a1bde..bf325eadf 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -49,7 +49,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) sizeof available, &available_size)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); - if (available_size > sizeof (available)) + if (available_size < 0 || (grub_size_t) available_size > sizeof (available)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "/memory response buffer exceeded"); From eb9f401fc1e919fa29602d4d7b9b4378338e16e9 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 10 Feb 2016 13:21:00 -0800 Subject: [PATCH 0535/1167] net: fix ipv6 routing ipv6 routing in grub2 is broken, we cannot talk to anything outside our local network or anything that doesn't route in our global namespace. This patch fixes this by doing a couple of things 1) Read the router information off of the router advertisement. If we have a router lifetime we need to take the source address and create a route from it. 2) Changes the routing stuff slightly to allow you to specify a gateway _and_ an interface. Since the router advertisements come in on the link local address we need to associate it with the global address on the card. So when we are processing the router advertisement, either use the SLAAC interface we create and add the route to that interface, or loop through the global addresses we currently have on our interface and associate it with one of those addresses. We need to have a special case here for the default route so that it gets used, we do this by setting the masksize to 0 to mean it encompasses all networks. The routing code will automatically select the best route so if there is a closer match we will use that. With this patch I can now talk to ipv6 addresses outside of my local network. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/bootp.c | 2 +- grub-core/net/drivers/ieee1275/ofnet.c | 4 +- grub-core/net/icmp6.c | 63 +++++++++++++++++++++++++- grub-core/net/net.c | 40 ++++++---------- include/grub/net.h | 25 +++++++++- 5 files changed, 103 insertions(+), 31 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 4fdeac3ef..a088244b4 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -82,7 +82,7 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) grub_memcpy (&gw.ipv4, ptr, sizeof (gw.ipv4)); rname = grub_xasprintf ("%s:default", name); if (rname) - grub_net_add_route_gw (rname, target, gw); + grub_net_add_route_gw (rname, target, gw, NULL); grub_free (rname); } break; diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index eff9085ed..6bd3b922e 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -151,7 +151,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; grub_net_link_level_address_t hw_addr; grub_net_interface_flags_t flags = 0; - struct grub_net_network_level_interface *inter; + struct grub_net_network_level_interface *inter = NULL; hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -221,7 +221,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, target.ipv4.masksize = 0; rname = grub_xasprintf ("%s:default", ((*card)->name)); if (rname) - grub_net_add_route_gw (rname, target, gateway_addr); + grub_net_add_route_gw (rname, target, gateway_addr, inter); else return grub_errno; } diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 7953e68ec..2cbd95dce 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -115,6 +115,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, grub_uint8_t ttl) { struct icmp_header *icmph; + struct grub_net_network_level_interface *orig_inf = inf; grub_err_t err; grub_uint16_t checksum; @@ -345,14 +346,31 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, { grub_uint8_t *ptr; struct option_header *ohdr; + struct router_adv *radv; + struct grub_net_network_level_interface *route_inf = NULL; + int default_route = 0; if (icmph->code) break; + radv = (struct router_adv *)nb->data; err = grub_netbuff_pull (nb, sizeof (struct router_adv)); if (err) { grub_netbuff_free (nb); return err; } + if (grub_be_to_cpu16 (radv->router_lifetime) > 0) + { + struct grub_net_route *route; + + FOR_NET_ROUTES (route) + { + if (!grub_memcmp (&route->gw, source, sizeof (route->gw))) + break; + } + if (route == NULL) + default_route = 1; + } + for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail; ptr += ohdr->len * 8) { @@ -413,7 +431,11 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, /* Update lease time if needed here once we have lease times. */ if (inf) - continue; + { + if (!route_inf) + route_inf = inf; + continue; + } grub_dprintf ("net", "creating slaac\n"); @@ -429,12 +451,51 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, inf = grub_net_add_addr (name, card, &addr, &slaac->address, 0); + if (!route_inf) + route_inf = inf; grub_net_add_route (name, netaddr, inf); grub_free (name); } } } } + if (default_route) + { + char *name; + grub_net_network_level_netaddress_t netaddr; + name = grub_xasprintf ("%s:ra:default6", card->name); + if (!name) + { + grub_errno = GRUB_ERR_NONE; + goto next; + } + /* Default routes take alll of the traffic, so make the mask huge */ + netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + netaddr.ipv6.masksize = 0; + netaddr.ipv6.base[0] = 0; + netaddr.ipv6.base[1] = 0; + + /* May not have gotten slaac info, find a global address on this + card. */ + if (route_inf == NULL) + { + FOR_NET_NETWORK_LEVEL_INTERFACES (inf) + { + if (inf->card == card && inf != orig_inf + && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 + && grub_net_hwaddr_cmp(&inf->hwaddress, + &orig_inf->hwaddress) == 0) + { + route_inf = inf; + break; + } + } + } + if (route_inf != NULL) + grub_net_add_route_gw (name, netaddr, *source, route_inf); + grub_free (name); + } +next: if (ptr != nb->tail) break; } diff --git a/grub-core/net/net.c b/grub-core/net/net.c index d07029b34..942459527 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -37,21 +37,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); char *grub_net_default_server; -struct grub_net_route -{ - struct grub_net_route *next; - struct grub_net_route **prev; - grub_net_network_level_netaddress_t target; - char *name; - struct grub_net_network_level_protocol *prot; - int is_gateway; - union - { - struct grub_net_network_level_interface *interface; - grub_net_network_level_address_t gw; - }; -}; - struct grub_net_route *grub_net_routes = NULL; struct grub_net_network_level_interface *grub_net_network_level_interfaces = NULL; struct grub_net_card *grub_net_cards = NULL; @@ -410,14 +395,6 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)), return err; } -static inline void -grub_net_route_register (struct grub_net_route *route) -{ - grub_list_push (GRUB_AS_LIST_P (&grub_net_routes), - GRUB_AS_LIST (route)); -} - -#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next) static int parse_ip (const char *val, grub_uint32_t *ip, const char **rest) @@ -524,6 +501,8 @@ match_net (const grub_net_network_level_netaddress_t *net, case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6: { grub_uint64_t mask[2]; + if (net->ipv6.masksize == 0) + return 1; if (net->ipv6.masksize <= 64) { mask[0] = 0xffffffffffffffffULL << (64 - net->ipv6.masksize); @@ -687,7 +666,14 @@ grub_net_route_address (grub_net_network_level_address_t addr, return GRUB_ERR_NONE; } if (depth == 0) - *gateway = bestroute->gw; + { + *gateway = bestroute->gw; + if (bestroute->interface != NULL) + { + *interf = bestroute->interface; + return GRUB_ERR_NONE; + } + } curtarget = bestroute->gw; } @@ -1109,7 +1095,8 @@ grub_net_add_route (const char *name, grub_err_t grub_net_add_route_gw (const char *name, grub_net_network_level_netaddress_t target, - grub_net_network_level_address_t gw) + grub_net_network_level_address_t gw, + struct grub_net_network_level_interface *inter) { struct grub_net_route *route; @@ -1127,6 +1114,7 @@ grub_net_add_route_gw (const char *name, route->target = target; route->is_gateway = 1; route->gw = gw; + route->interface = inter; grub_net_route_register (route); @@ -1152,7 +1140,7 @@ grub_cmd_addroute (struct grub_command *cmd __attribute__ ((unused)), err = grub_net_resolve_address (args[3], &gw); if (err) return err; - return grub_net_add_route_gw (args[0], target, gw); + return grub_net_add_route_gw (args[0], target, gw, NULL); } else { diff --git a/include/grub/net.h b/include/grub/net.h index 538baa33e..2192fa186 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -191,6 +191,18 @@ typedef struct grub_net_network_level_netaddress }; } grub_net_network_level_netaddress_t; +struct grub_net_route +{ + struct grub_net_route *next; + struct grub_net_route **prev; + grub_net_network_level_netaddress_t target; + char *name; + struct grub_net_network_level_protocol *prot; + int is_gateway; + struct grub_net_network_level_interface *interface; + grub_net_network_level_address_t gw; +}; + #define FOR_PACKETS(cont,var) for (var = (cont).first; var; var = var->next) static inline grub_err_t @@ -367,6 +379,16 @@ grub_net_card_unregister (struct grub_net_card *card); #define FOR_NET_CARDS_SAFE(var, next) for (var = grub_net_cards, next = (var ? var->next : 0); var; var = next, next = (var ? var->next : 0)) +extern struct grub_net_route *grub_net_routes; + +static inline void +grub_net_route_register (struct grub_net_route *route) +{ + grub_list_push (GRUB_AS_LIST_P (&grub_net_routes), + GRUB_AS_LIST (route)); +} + +#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next) struct grub_net_session * grub_net_open_tcp (char *address, grub_uint16_t port); @@ -392,7 +414,8 @@ grub_net_add_route (const char *name, grub_err_t grub_net_add_route_gw (const char *name, grub_net_network_level_netaddress_t target, - grub_net_network_level_address_t gw); + grub_net_network_level_address_t gw, + struct grub_net_network_level_interface *inter); #define GRUB_NET_BOOTP_MAC_ADDR_LEN 16 From 5486a4e12b7ad18f06156bb042a350a39d355c22 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:12:35 +0100 Subject: [PATCH 0536/1167] Makefile: Don't delete default_payload.elf if it doesn't exist. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 288e621d3..00a9663b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage FORCE - rm $@ + test -f $@ && rm $@ || true pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif From 06a3b0b214d077cc2a52a6295175de3c79c04113 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:37:47 +0100 Subject: [PATCH 0537/1167] Regenerate checksums --- grub-core/tests/checksums.h | 196 ++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index b42d63d25..2320158d4 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,101 +1,101 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24dc7bce, 0x24dc7bce, 0x338542b, 0x338542b, 0x2016b9d1, 0x2016b9d1, 0xc2619a36, 0xc2619a36, 0x10fce1e, 0x10fce1e, 0x8267298e, 0x8267298e, 0xf44246cf, 0xf44246cf, 0x3ee2860f, 0x3ee2860f, 0x1191f916, 0x1191f916, 0xfa8ce1b5, 0xfa8ce1b5, 0xc1f18b8e, 0xc1f18b8e, 0x43f8c0e8, 0x43f8c0e8, 0xbc0d166a, 0xbc0d166a, 0x7b742e8f, 0x7b742e8f, 0x2c3c7f89, 0x2c3c7f89, 0x80148a7e, 0x80148a7e, 0x21daaadf, 0x21daaadf, 0x15e97fa9, 0x15e97fa9, 0x2428d454, 0x2428d454, 0xb12b0f78, 0xb12b0f78, 0x29648b05, 0x8ce36e6f, 0xd26b03dd, 0xd26b03dd, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd09d4d28, 0xd09d4d28, 0xb41a2f17, 0xb41a2f17, 0x56381354, 0x56381354, 0xf2c5615f, 0xf2c5615f, 0xa41822ae, 0xa41822ae, 0xba2e3e60, 0xba2e3e60, 0x1859aaac, 0x1859aaac, 0x6c354a92, 0x6c354a92, 0x652d3eb, 0x652d3eb, 0xffcf0fd8, 0xffcf0fd8, 0xd3c9187c, 0xd3c9187c, 0xdee59346, 0xdee59346, 0x950f6354, 0x950f6354, 0xa2f7e36a, 0xa2f7e36a, 0x3967359a, 0x3967359a, 0x12738c9a, 0x12738c9a, 0xffb94ca3, 0xffb94ca3, 0xd9384791, 0xd9384791, 0xade1fd25, 0xade1fd25, 0xca109ebe, 0xca109ebe, 0x6e794e, 0x20d769cf, 0x29cc1fdc, 0x29cc1fdc, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6cfe9089, 0x6cfe9089, 0xbe85dea2, 0xbe85dea2, 0x5f57923d, 0x5f57923d, 0xd28ad04b, 0xd28ad04b, 0x9ac91b28, 0x9ac91b28, 0x26977f54, 0x26977f54, 0x56cfda54, 0x56cfda54, 0xae54550f, 0xae54550f, 0x5843182b, 0x5843182b, 0xa1524272, 0xa1524272, 0x86b707db, 0x86b707db, 0x4127540e, 0x4127540e, 0xe89ea08e, 0xe89ea08e, 0x85f4dccc, 0x85f4dccc, 0xf910d16c, 0xf910d16c, 0xd43ff6b8, 0xd43ff6b8, 0xcdec4fd0, 0xcdec4fd0, 0xad650879, 0xad650879, 0x6d8e01c7, 0x6d8e01c7, 0x3ce7c69f, 0x3ce7c69f, 0xed54e2ef, 0x141319e, 0x9003a604, 0x9003a604, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x37f1b28e, 0x37f1b28e, 0x248de37a, 0x248de37a, 0x8b84bbe6, 0x8b84bbe6, 0x62efb943, 0x62efb943, 0x50d082fd, 0x50d082fd, 0x68a0c1, 0x68a0c1, 0xa335f8d0, 0xa335f8d0, 0xf26eaa27, 0xf26eaa27, 0x9f661fa2, 0x9f661fa2, 0x9a9c6bcb, 0x9a9c6bcb, 0xa5427057, 0xa5427057, 0x59aabcc8, 0x59aabcc8, 0xd1563970, 0xd1563970, 0x5f65ea2e, 0x5f65ea2e, 0xce189d5e, 0xce189d5e, 0xa0ac6e61, 0xa0ac6e61, 0xf85ec3, 0xf85ec3, 0xa6a5bea8, 0xa6a5bea8, 0xae55a1ba, 0xae55a1ba, 0x23f4e9e3, 0x23f4e9e3, 0x580abc5c, 0x58b54e7f, 0xafe85bbb, 0xafe85bbb, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6d4812ec, 0x6d4812ec, 0x9d93973a, 0x9d93973a, 0x88cb4e17, 0x88cb4e17, 0x81f14f0a, 0x81f14f0a, 0x7f9f1875, 0x7f9f1875, 0x292f8345, 0x292f8345, 0x524cefe0, 0x524cefe0, 0x5d02251, 0x5d02251, 0x61afaf9e, 0x61afaf9e, 0xc327f8b9, 0xc327f8b9, 0xa1ece03d, 0xa1ece03d, 0xbb98b63c, 0xbb98b63c, 0x61b920db, 0x61b920db, 0xb1571b03, 0xb1571b03, 0xd315b012, 0xd315b012, 0xee77780c, 0xee77780c, 0x9b6ce52e, 0x9b6ce52e, 0x3b18a467, 0x3b18a467, 0x5ab91ffb, 0x5ab91ffb, 0x9255edea, 0x9255edea, 0x9ca85712, 0xa249a7fa, 0x213825f8, 0x213825f8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10bc4224, 0x10bc4224, 0xb8085994, 0xb8085994, 0x6ab26d0a, 0x6ab26d0a, 0xde71396c, 0xde71396c, 0x425a3956, 0x425a3956, 0xb7d2a7e3, 0xb7d2a7e3, 0x658ab388, 0x658ab388, 0x3fadf9dc, 0x3fadf9dc, 0xb29884ae, 0xb29884ae, 0x3a0830a7, 0x3a0830a7, 0xcf41267a, 0xcf41267a, 0x121c9703, 0x121c9703, 0xd126f87c, 0xd126f87c, 0x3b9d5bf6, 0x3b9d5bf6, 0x2a05cbef, 0x2a05cbef, 0x9ad41c2c, 0x9ad41c2c, 0xebf19db8, 0xebf19db8, 0x79f1b335, 0x79f1b335, 0xad2f9e8d, 0xad2f9e8d, 0x99596c48, 0x99596c48, 0x75b1cae6, 0x3cd081b2, 0x23e8ef2f, 0x23e8ef2f, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8920d2ff, 0x8920d2ff, 0x369cb8d2, 0x369cb8d2, 0x880f23e4, 0x880f23e4, 0xf4a02ce2, 0xf4a02ce2, 0x7933f9a4, 0x7933f9a4, 0x488859f0, 0x488859f0, 0x75855108, 0x75855108, 0xf0463685, 0xf0463685, 0xf3e90b78, 0xf3e90b78, 0xac92b2b6, 0xac92b2b6, 0x63131cc5, 0x63131cc5, 0xfb714a00, 0xfb714a00, 0xc495c9a0, 0xc495c9a0, 0x314b6225, 0x314b6225, 0xc0d56232, 0xc0d56232, 0xa051d312, 0xa051d312, 0x9c0d295c, 0x9c0d295c, 0x3f234b5, 0x3f234b5, 0xa4201189, 0xa4201189, 0x23af1b2f, 0x23af1b2f, 0xc787ef0f, 0x2a3c46f8, 0xf03fe2d9, 0xf03fe2d9, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdff707ef, 0xb938eb6c, 0xdff707ef, 0x9c01caa8, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x9c01caa8, 0x9c01caa8, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x59f141e3, 0xfddbc65b, 0x59f141e3, 0x77f4c49c, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0x77f4c49c, 0x77f4c49c, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9ac56bc2, 0x2049341a, 0x9ac56bc2, 0xc7d20646, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0xc7d20646, 0xc7d20646, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd50b603, 0xbef0bf34, 0xd50b603, 0xa306ffdb, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xa306ffdb, 0xa306ffdb, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9408bd4d, 0x84fea62c, 0x9408bd4d, 0xe2ae88fe, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xe2ae88fe, 0xe2ae88fe, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8460b76a, 0xd01813b4, 0x8460b76a, 0x9f656d6d, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0x9f656d6d, 0x9f656d6d, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x115542af, 0xbac49512, 0x115542af, 0xeeea592f, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xeeea592f, 0xeeea592f, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0x35f491f9, 0x35f491f9, 0x35f491f9, 0x692c6739, 0x692c6739, 0x692c6739, 0x40b4a9ab, 0x40b4a9ab, 0x40b4a9ab, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0xeee84c5, 0xeee84c5, 0xeee84c5, 0x5bb12ecf, 0x5bb12ecf, 0x5bb12ecf, 0x3282e686, 0x3282e686, 0x3282e686, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x2cf5262a, 0x2cf5262a, 0x2cf5262a, 0x534b80be, 0x534b80be, 0x534b80be, 0x113fe0c6, 0x113fe0c6, 0x113fe0c6, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x7bd2e3a3, 0x7bd2e3a3, 0x7bd2e3a3, 0x907709df, 0x907709df, 0x907709df, 0x963c092f, 0x963c092f, 0x963c092f, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0xd45c93dc, 0xd45c93dc, 0xd45c93dc, 0xbb154fcd, 0xbb154fcd, 0xbb154fcd, 0xb6e3d1ce, 0xb6e3d1ce, 0xb6e3d1ce, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x304db662, 0x304db662, 0x304db662, 0xf6fff27c, 0xf6fff27c, 0xf6fff27c, 0xe29a22c3, 0xe29a22c3, 0xe29a22c3, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0xe0ddd143, 0xe0ddd143, 0xe0ddd143, 0x612e2792, 0x612e2792, 0x612e2792, 0xf78a9efd, 0xf78a9efd, 0xf78a9efd, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3d69d4f7, 0x5b2df52e, 0x3d69d4f7, 0x7e9f19b0, 0x59c36f00, 0x59c36f00, 0xaa418d14, 0xaa418d14, 0xaa418d14, 0xd4c1e072, 0xd4c1e072, 0xd4c1e072, 0xb637f5a0, 0xb637f5a0, 0xb637f5a0, 0x59c36f00, 0x7e9f19b0, 0x7e9f19b0, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xea153935, 0xadda68ff, 0xea153935, 0xc410bc4a, 0xaa4593fe, 0xaa4593fe, 0x63090f39, 0x63090f39, 0x63090f39, 0xc5fc025e, 0xc5fc025e, 0xc5fc025e, 0xe8c4a926, 0xe8c4a926, 0xe8c4a926, 0xaa4593fe, 0xc410bc4a, 0xc410bc4a, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe677248f, 0x9a146b56, 0xe677248f, 0xbb60490b, 0xc9cbf769, 0xc9cbf769, 0xebd87b6a, 0xebd87b6a, 0xebd87b6a, 0x1500baa6, 0x1500baa6, 0x1500baa6, 0xfc4a05ae, 0xfc4a05ae, 0xfc4a05ae, 0xc9cbf769, 0xbb60490b, 0xbb60490b, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2fe1d8b3, 0x344dc22f, 0x2fe1d8b3, 0x81b7916b, 0x9813a416, 0x9813a416, 0xb42009b, 0xb42009b, 0xb42009b, 0x9a9986a8, 0x9a9986a8, 0x9a9986a8, 0x8323bb78, 0x8323bb78, 0x8323bb78, 0x9813a416, 0x81b7916b, 0x81b7916b, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2f2ab760, 0x373afa93, 0x2f2ab760, 0x598c82d3, 0x5fcf013d, 0x5fcf013d, 0x8a9a15e2, 0x8a9a15e2, 0x8a9a15e2, 0x588a0d94, 0x588a0d94, 0x588a0d94, 0x4ef9320b, 0x4ef9320b, 0x4ef9320b, 0x5fcf013d, 0x598c82d3, 0x598c82d3, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb9de66a8, 0x2b705981, 0xb9de66a8, 0xa2dbbcaf, 0xdd28f52b, 0xdd28f52b, 0x971eb98b, 0x971eb98b, 0x971eb98b, 0xb622406f, 0xb622406f, 0xb622406f, 0xcb9a8be3, 0xcb9a8be3, 0xcb9a8be3, 0xdd28f52b, 0xa2dbbcaf, 0xa2dbbcaf, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84029f68, 0x7385ec77, 0x84029f68, 0x7bbd84e8, 0x43d1f34, 0x43d1f34, 0x73cb201f, 0x73cb201f, 0x73cb201f, 0xcc189b7, 0xcc189b7, 0xcc189b7, 0x95908c31, 0x95908c31, 0x95908c31, 0x43d1f34, 0x7bbd84e8, 0x7bbd84e8, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2446469, 0xca75968f, 0xb2446469, 0xf1b2a92e, 0x59c36f00, 0x59c36f00, 0xc0eac671, 0xc0eac671, 0xc0eac671, 0xbe6aab17, 0xbe6aab17, 0xbe6aab17, 0xdc9cbec5, 0xdc9cbec5, 0xdc9cbec5, 0x59c36f00, 0xf1b2a92e, 0xf1b2a92e, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe219612c, 0x41ad1120, 0xe219612c, 0xcc1ce453, 0xaa4593fe, 0xaa4593fe, 0x1f05167, 0x1f05167, 0x1f05167, 0xa7055c00, 0xa7055c00, 0xa7055c00, 0x8a3df778, 0x8a3df778, 0x8a3df778, 0xaa4593fe, 0xcc1ce453, 0xcc1ce453, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f3ca4a3, 0x3df9621e, 0x9f3ca4a3, 0xc22bc927, 0xc9cbf769, 0xc9cbf769, 0x8f0b71ba, 0x8f0b71ba, 0x8f0b71ba, 0x71d3b076, 0x71d3b076, 0x71d3b076, 0x98990f7e, 0x98990f7e, 0x98990f7e, 0xc9cbf769, 0xc22bc927, 0xc22bc927, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6b1e7755, 0x4532973e, 0x6b1e7755, 0xc5483e8d, 0x9813a416, 0x9813a416, 0xa279dbc8, 0xa279dbc8, 0xa279dbc8, 0x33a25dfb, 0x33a25dfb, 0x33a25dfb, 0x2a18602b, 0x2a18602b, 0x2a18602b, 0x9813a416, 0xc5483e8d, 0xc5483e8d, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa3774c63, 0x38dffb0e, 0xa3774c63, 0xd5d179d0, 0x5fcf013d, 0x5fcf013d, 0x28872666, 0x28872666, 0x28872666, 0xfa973e10, 0xfa973e10, 0xfa973e10, 0xece4018f, 0xece4018f, 0xece4018f, 0x5fcf013d, 0xd5d179d0, 0xd5d179d0, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe9556aa5, 0x77425030, 0xe9556aa5, 0xf250b0a2, 0xdd28f52b, 0xdd28f52b, 0x938cfa6a, 0x938cfa6a, 0x938cfa6a, 0xb2b0038e, 0xb2b0038e, 0xb2b0038e, 0xcf08c802, 0xcf08c802, 0xcf08c802, 0xdd28f52b, 0xf250b0a2, 0xf250b0a2, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9adc43d0, 0xd8ac5204, 0x9adc43d0, 0x65635850, 0x43d1f34, 0x43d1f34, 0xc182db12, 0xc182db12, 0xc182db12, 0xbe8872ba, 0xbe8872ba, 0xbe8872ba, 0x27d9773c, 0x27d9773c, 0x27d9773c, 0x43d1f34, 0x65635850, 0x65635850, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7fd0187d, 0x7d05975c, 0x7fd0187d, 0x3c26d53a, 0x59c36f00, 0x59c36f00, 0xb4fad8de, 0xb4fad8de, 0xb4fad8de, 0xca7ab5b8, 0xca7ab5b8, 0xca7ab5b8, 0xa88ca06a, 0xa88ca06a, 0xa88ca06a, 0x59c36f00, 0x3c26d53a, 0x3c26d53a, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f3fad9, 0xe7a5a67a, 0x54f3fad9, 0x7af67fa6, 0xaa4593fe, 0xaa4593fe, 0xcae58c6a, 0xcae58c6a, 0xcae58c6a, 0x6c10810d, 0x6c10810d, 0x6c10810d, 0x41282a75, 0x41282a75, 0x41282a75, 0xaa4593fe, 0x7af67fa6, 0x7af67fa6, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x869916b8, 0x373dbcc3, 0x869916b8, 0xdb8e7b3c, 0xc9cbf769, 0xc9cbf769, 0xaa0c75c1, 0xaa0c75c1, 0xaa0c75c1, 0x54d4b40d, 0x54d4b40d, 0x54d4b40d, 0xbd9e0b05, 0xbd9e0b05, 0xbd9e0b05, 0xc9cbf769, 0xdb8e7b3c, 0xdb8e7b3c, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb2f32f4, 0xff8e66df, 0xb2f32f4, 0xa5797b2c, 0x9813a416, 0x9813a416, 0x9fc65347, 0x9fc65347, 0x9fc65347, 0xe1dd574, 0xe1dd574, 0xe1dd574, 0x17a7e8a4, 0x17a7e8a4, 0x17a7e8a4, 0x9813a416, 0xa5797b2c, 0xa5797b2c, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x26280874, 0x6f7dd72, 0x26280874, 0x508e3dc7, 0x5fcf013d, 0x5fcf013d, 0x197943fe, 0x197943fe, 0x197943fe, 0xcb695b88, 0xcb695b88, 0xcb695b88, 0xdd1a6417, 0xdd1a6417, 0xdd1a6417, 0x5fcf013d, 0x508e3dc7, 0x508e3dc7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd23ae631, 0xe5a30d5e, 0xd23ae631, 0xc93f3c36, 0xdd28f52b, 0xdd28f52b, 0x7042f8c, 0x7042f8c, 0x7042f8c, 0x2638d668, 0x2638d668, 0x2638d668, 0x5b801de4, 0x5b801de4, 0x5b801de4, 0xdd28f52b, 0xc93f3c36, 0xc93f3c36, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8d469c0b, 0xabeb5779, 0x8d469c0b, 0x72f9878b, 0x43d1f34, 0x43d1f34, 0xd8397828, 0xd8397828, 0xd8397828, 0xa733d180, 0xa733d180, 0xa733d180, 0x3e62d406, 0x3e62d406, 0x3e62d406, 0x43d1f34, 0x72f9878b, 0x72f9878b, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd668f275, 0x6a2de04f, 0xd668f275, 0x959e3f32, 0x59c36f00, 0x59c36f00, 0xc43520a0, 0xc43520a0, 0xc43520a0, 0xbab54dc6, 0xbab54dc6, 0xbab54dc6, 0xd8435814, 0xd8435814, 0xd8435814, 0x59c36f00, 0x959e3f32, 0x959e3f32, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe170ffb5, 0x17402498, 0xe170ffb5, 0xcf757aca, 0xaa4593fe, 0xaa4593fe, 0x4ec32c62, 0x4ec32c62, 0x4ec32c62, 0xe8362105, 0xe8362105, 0xe8362105, 0xc50e8a7d, 0xc50e8a7d, 0xc50e8a7d, 0xaa4593fe, 0xcf757aca, 0xcf757aca, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf4aef2d6, 0x47a46008, 0xf4aef2d6, 0xa9b99f52, 0xc9cbf769, 0xc9cbf769, 0x4f1a5666, 0x4f1a5666, 0x4f1a5666, 0xb1c297aa, 0xb1c297aa, 0xb1c297aa, 0x588828a2, 0x588828a2, 0x588828a2, 0xc9cbf769, 0xa9b99f52, 0xa9b99f52, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc2ed8f74, 0xb7ab0607, 0xc2ed8f74, 0x6cbbc6ac, 0x9813a416, 0x9813a416, 0x535e7ba8, 0x535e7ba8, 0x535e7ba8, 0xc285fd9b, 0xc285fd9b, 0xc285fd9b, 0xdb3fc04b, 0xdb3fc04b, 0xdb3fc04b, 0x9813a416, 0x6cbbc6ac, 0x6cbbc6ac, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf62383d8, 0x9489f90c, 0xf62383d8, 0x8085b66b, 0x5fcf013d, 0x5fcf013d, 0xb7f78bc2, 0xb7f78bc2, 0xb7f78bc2, 0x65e793b4, 0x65e793b4, 0x65e793b4, 0x7394ac2b, 0x7394ac2b, 0x7394ac2b, 0x5fcf013d, 0x8085b66b, 0x8085b66b, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x753d8bc0, 0x5c9029d6, 0x753d8bc0, 0x6e3851c7, 0xdd28f52b, 0xdd28f52b, 0x1a40e22e, 0x1a40e22e, 0x1a40e22e, 0x3b7c1bca, 0x3b7c1bca, 0x3b7c1bca, 0x46c4d046, 0x46c4d046, 0x46c4d046, 0xdd28f52b, 0x6e3851c7, 0x6e3851c7, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x62a774, 0xbb4b794c, 0x62a774, 0xffddbcf4, 0x43d1f34, 0x43d1f34, 0x83fede87, 0x83fede87, 0x83fede87, 0xfcf4772f, 0xfcf4772f, 0xfcf4772f, 0x65a572a9, 0x65a572a9, 0x65a572a9, 0x43d1f34, 0xffddbcf4, 0xffddbcf4, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2edc6dc9, 0x166a6552, 0x2edc6dc9, 0x6d2aa08e, 0x59c36f00, 0x59c36f00, 0xd214e1a2, 0xd214e1a2, 0xd214e1a2, 0xac948cc4, 0xac948cc4, 0xac948cc4, 0xce629916, 0xce629916, 0xce629916, 0x59c36f00, 0x6d2aa08e, 0x6d2aa08e, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc12e1a21, 0x1e6e7468, 0xc12e1a21, 0xef2b9f5e, 0xaa4593fe, 0xaa4593fe, 0x1c792d02, 0x1c792d02, 0x1c792d02, 0xba8c2065, 0xba8c2065, 0xba8c2065, 0x97b48b1d, 0x97b48b1d, 0x97b48b1d, 0xaa4593fe, 0xef2b9f5e, 0xef2b9f5e, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x510524f7, 0x7f9806b4, 0x510524f7, 0xc124973, 0xc9cbf769, 0xc9cbf769, 0x1a561d55, 0x1a561d55, 0x1a561d55, 0xe48edc99, 0xe48edc99, 0xe48edc99, 0xdc46391, 0xdc46391, 0xdc46391, 0xc9cbf769, 0xc124973, 0xc124973, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1ee6604, 0xd307a4d9, 0xa1ee6604, 0xfb82fdc, 0x9813a416, 0x9813a416, 0x5b7ed439, 0x5b7ed439, 0x5b7ed439, 0xcaa5520a, 0xcaa5520a, 0xcaa5520a, 0xd31f6fda, 0xd31f6fda, 0xd31f6fda, 0x9813a416, 0xfb82fdc, 0xfb82fdc, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e2bb6a8, 0x67c92bf4, 0x4e2bb6a8, 0x388d831b, 0x5fcf013d, 0x5fcf013d, 0xe69beaed, 0xe69beaed, 0xe69beaed, 0x348bf29b, 0x348bf29b, 0x348bf29b, 0x22f8cd04, 0x22f8cd04, 0x22f8cd04, 0x5fcf013d, 0x388d831b, 0x388d831b, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeb6b461d, 0x679ed094, 0xeb6b461d, 0xf06e9c1a, 0xdd28f52b, 0xdd28f52b, 0xdf34624d, 0xdf34624d, 0xdf34624d, 0xfe089ba9, 0xfe089ba9, 0xfe089ba9, 0x83b05025, 0x83b05025, 0x83b05025, 0xdd28f52b, 0xf06e9c1a, 0xf06e9c1a, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc486143c, 0x7b487645, 0xc486143c, 0x3b390fbc, 0x43d1f34, 0x43d1f34, 0x9576cd6b, 0x9576cd6b, 0x9576cd6b, 0xea7c64c3, 0xea7c64c3, 0xea7c64c3, 0x732d6145, 0x732d6145, 0x732d6145, 0x43d1f34, 0x3b390fbc, 0x3b390fbc, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa024d435, 0x8bc3f107, 0xa024d435, 0xe3d21972, 0x59c36f00, 0x59c36f00, 0x9412860d, 0x9412860d, 0x9412860d, 0xea92eb6b, 0xea92eb6b, 0xea92eb6b, 0x8864feb9, 0x8864feb9, 0x8864feb9, 0x59c36f00, 0xe3d21972, 0xe3d21972, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xbf89b975, 0x481e2ecc, 0xbf89b975, 0x918c3c0a, 0xaa4593fe, 0xaa4593fe, 0xa8509e2c, 0xa8509e2c, 0xa8509e2c, 0xea5934b, 0xea5934b, 0xea5934b, 0x239d3833, 0x239d3833, 0x239d3833, 0xaa4593fe, 0x918c3c0a, 0x918c3c0a, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4d84ea04, 0xd1029f5b, 0x4d84ea04, 0x10938780, 0xc9cbf769, 0xc9cbf769, 0x3677fab0, 0x3677fab0, 0x3677fab0, 0xc8af3b7c, 0xc8af3b7c, 0xc8af3b7c, 0x21e58474, 0x21e58474, 0x21e58474, 0xc9cbf769, 0x10938780, 0x10938780, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9e5f6ab3, 0xda3fae82, 0x9e5f6ab3, 0x3009236b, 0x9813a416, 0x9813a416, 0x5710fb5f, 0x5710fb5f, 0x5710fb5f, 0xc6cb7d6c, 0xc6cb7d6c, 0xc6cb7d6c, 0xdf7140bc, 0xdf7140bc, 0xdf7140bc, 0x9813a416, 0x3009236b, 0x3009236b, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x28f46625, 0xf4bfdc80, 0x28f46625, 0x5e525396, 0x5fcf013d, 0x5fcf013d, 0xb3f9b24b, 0xb3f9b24b, 0xb3f9b24b, 0x61e9aa3d, 0x61e9aa3d, 0x61e9aa3d, 0x779a95a2, 0x779a95a2, 0x779a95a2, 0x5fcf013d, 0x5e525396, 0x5e525396, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8c12e300, 0xa71b83e7, 0x8c12e300, 0x97173907, 0xdd28f52b, 0xdd28f52b, 0x2f660f28, 0x2f660f28, 0x2f660f28, 0xe5af6cc, 0xe5af6cc, 0xe5af6cc, 0x73e23d40, 0x73e23d40, 0x73e23d40, 0xdd28f52b, 0x97173907, 0x97173907, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbaaaeec4, 0x7f7cd53b, 0xbaaaeec4, 0x4515f544, 0x43d1f34, 0x43d1f34, 0xd254254f, 0xd254254f, 0xd254254f, 0xad5e8ce7, 0xad5e8ce7, 0xad5e8ce7, 0x340f8961, 0x340f8961, 0x340f8961, 0x43d1f34, 0x4515f544, 0x4515f544, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63166340, 0x5d98fc3, 0x63166340, 0x20e0ae07, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x20e0ae07, 0x20e0ae07, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe0916467, 0x44bbe3df, 0xe0916467, 0xce94e118, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xce94e118, 0xce94e118, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1aad9b94, 0xa021c44c, 0x1aad9b94, 0x47baf610, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x47baf610, 0x47baf610, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb8710521, 0xbd10c16, 0xb8710521, 0x16274cf9, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0x16274cf9, 0x16274cf9, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd62b53b5, 0xc6dd48d4, 0xd62b53b5, 0xa08d6606, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xa08d6606, 0xa08d6606, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10503615, 0x442892cb, 0x10503615, 0xb55ec12, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xb55ec12, 0xb55ec12, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5c9d00a2, 0xf70cd71f, 0x5c9d00a2, 0xa3221b22, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xa3221b22, 0xa3221b22, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc89067b, 0xf339b29f, 0xbc89067b, 0xff7fcb3c, 0x59c36f00, 0x59c36f00, 0x5915b839, 0x5915b839, 0x5915b839, 0x2795d55f, 0x2795d55f, 0x2795d55f, 0x4563c08d, 0x4563c08d, 0x4563c08d, 0x59c36f00, 0xff7fcb3c, 0xff7fcb3c, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb19b98f6, 0xb8ffac95, 0xb19b98f6, 0x9f9e1d89, 0xaa4593fe, 0xaa4593fe, 0x6cb5454, 0x6cb5454, 0x6cb5454, 0xa03e5933, 0xa03e5933, 0xa03e5933, 0x8d06f24b, 0x8d06f24b, 0x8d06f24b, 0xaa4593fe, 0x9f9e1d89, 0x9f9e1d89, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x133d7c3b, 0xd26c8a26, 0x133d7c3b, 0x4e2a11bf, 0xc9cbf769, 0xc9cbf769, 0x36504e54, 0x36504e54, 0x36504e54, 0xc8888f98, 0xc8888f98, 0xc8888f98, 0x21c23090, 0x21c23090, 0x21c23090, 0xc9cbf769, 0x4e2a11bf, 0x4e2a11bf, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbfc94fbe, 0xe32be512, 0xbfc94fbe, 0x119f0666, 0x9813a416, 0x9813a416, 0x8350694d, 0x8350694d, 0x8350694d, 0x128bef7e, 0x128bef7e, 0x128bef7e, 0xb31d2ae, 0xb31d2ae, 0xb31d2ae, 0x9813a416, 0x119f0666, 0x119f0666, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9cf25061, 0xe5e2b458, 0x9cf25061, 0xea5465d2, 0x5fcf013d, 0x5fcf013d, 0xa5bfba08, 0xa5bfba08, 0xa5bfba08, 0x77afa27e, 0x77afa27e, 0x77afa27e, 0x61dc9de1, 0x61dc9de1, 0x61dc9de1, 0x5fcf013d, 0xea5465d2, 0xea5465d2, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc968ecc5, 0xa3105cfb, 0xc968ecc5, 0xd26d36c2, 0xdd28f52b, 0xdd28f52b, 0xff2fd4b8, 0xff2fd4b8, 0xff2fd4b8, 0xde132d5c, 0xde132d5c, 0xde132d5c, 0xa3abe6d0, 0xa3abe6d0, 0xa3abe6d0, 0xdd28f52b, 0xd26d36c2, 0xd26d36c2, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf17f3c, 0xf3672115, 0xf17f3c, 0xff4e64bc, 0x43d1f34, 0x43d1f34, 0x6ec799ab, 0x6ec799ab, 0x6ec799ab, 0x11cd3003, 0x11cd3003, 0x11cd3003, 0x889c3585, 0x889c3585, 0x889c3585, 0x43d1f34, 0xff4e64bc, 0xff4e64bc, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x20f2a62b, 0x12808b5f, 0x20f2a62b, 0x63046b6c, 0x59c36f00, 0x59c36f00, 0x23e6cac6, 0x23e6cac6, 0x23e6cac6, 0x5d66a7a0, 0x5d66a7a0, 0x5d66a7a0, 0x3f90b272, 0x3f90b272, 0x3f90b272, 0x59c36f00, 0x63046b6c, 0x63046b6c, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x52fcbd8f, 0x7119870a, 0x52fcbd8f, 0x7cf938f0, 0xaa4593fe, 0xaa4593fe, 0x4bb9a19, 0x4bb9a19, 0x4bb9a19, 0xa24e977e, 0xa24e977e, 0xa24e977e, 0x8f763c06, 0x8f763c06, 0x8f763c06, 0xaa4593fe, 0x7cf938f0, 0x7cf938f0, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4d74d3f, 0xd2dab4f0, 0xe4d74d3f, 0xb9c020bb, 0xc9cbf769, 0xc9cbf769, 0xa4955f92, 0xa4955f92, 0xa4955f92, 0x5a4d9e5e, 0x5a4d9e5e, 0x5a4d9e5e, 0xb3072156, 0xb3072156, 0xb3072156, 0xc9cbf769, 0xb9c020bb, 0xb9c020bb, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1c2b9ec, 0x34038c40, 0xa1c2b9ec, 0xf94f034, 0x9813a416, 0x9813a416, 0x438820a6, 0x438820a6, 0x438820a6, 0xd253a695, 0xd253a695, 0xd253a695, 0xcbe99b45, 0xcbe99b45, 0xcbe99b45, 0x9813a416, 0xf94f034, 0xf94f034, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x339cc65f, 0xe46f6cec, 0x339cc65f, 0x453af3ec, 0x5fcf013d, 0x5fcf013d, 0xad75b235, 0xad75b235, 0xad75b235, 0x7f65aa43, 0x7f65aa43, 0x7f65aa43, 0x691695dc, 0x691695dc, 0x691695dc, 0x5fcf013d, 0x453af3ec, 0x453af3ec, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1c229a1a, 0x83752c05, 0x1c229a1a, 0x727401d, 0xdd28f52b, 0xdd28f52b, 0x4b4f5d0, 0x4b4f5d0, 0x4b4f5d0, 0x25880c34, 0x25880c34, 0x25880c34, 0x5830c7b8, 0x5830c7b8, 0x5830c7b8, 0xdd28f52b, 0x727401d, 0x727401d, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d69e76c, 0x11e8d41f, 0x4d69e76c, 0xb2d6fcec, 0x43d1f34, 0x43d1f34, 0x15b4256, 0x15b4256, 0x15b4256, 0x7e51ebfe, 0x7e51ebfe, 0x7e51ebfe, 0xe700ee78, 0xe700ee78, 0xe700ee78, 0x43d1f34, 0xb2d6fcec, 0xb2d6fcec, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xecc0313, 0x6803ef90, 0xecc0313, 0x59e1bdcd, 0x59c36f00, 0x59c36f00, 0xbaf5c463, 0xbaf5c463, 0xbaf5c463, 0xc475a905, 0xc475a905, 0xc475a905, 0xa683bcd7, 0xa683bcd7, 0xa683bcd7, 0x59c36f00, 0x59e1bdcd, 0x59e1bdcd, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfb839522, 0x5fa9129a, 0xfb839522, 0x4b244f74, 0xaa4593fe, 0xaa4593fe, 0xf644f45d, 0xf644f45d, 0xf644f45d, 0x50b1f93a, 0x50b1f93a, 0x50b1f93a, 0x7d895242, 0x7d895242, 0x7d895242, 0xaa4593fe, 0x4b244f74, 0x4b244f74, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf84fee63, 0x42c3b1bb, 0xf84fee63, 0xe86af0cd, 0xc9cbf769, 0xc9cbf769, 0x93e5d13b, 0x93e5d13b, 0x93e5d13b, 0x6d3d10f7, 0x6d3d10f7, 0x6d3d10f7, 0x8477afff, 0x8477afff, 0x8477afff, 0xc9cbf769, 0xe86af0cd, 0xe86af0cd, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xcbed2522, 0x784d2c15, 0xcbed2522, 0xfb9cd90d, 0x9813a416, 0x9813a416, 0x94668b23, 0x94668b23, 0x94668b23, 0x5bd0d10, 0x5bd0d10, 0x5bd0d10, 0x1c0730c0, 0x1c0730c0, 0x1c0730c0, 0x9813a416, 0xfb9cd90d, 0xfb9cd90d, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc1ca0a91, 0xd13c11f0, 0xc1ca0a91, 0x6fcde564, 0x5fcf013d, 0x5fcf013d, 0xb6cdf7a2, 0xb6cdf7a2, 0xb6cdf7a2, 0x64ddefd4, 0x64ddefd4, 0x64ddefd4, 0x72aed04b, 0x72aed04b, 0x72aed04b, 0x5fcf013d, 0x6fcde564, 0x6fcde564, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xca477228, 0x9e3fd6f6, 0xca477228, 0x4423b9f2, 0xdd28f52b, 0xdd28f52b, 0x1ff53543, 0x1ff53543, 0x1ff53543, 0x3ec9cca7, 0x3ec9cca7, 0x3ec9cca7, 0x4371072b, 0x4371072b, 0x4371072b, 0xdd28f52b, 0x4423b9f2, 0x4423b9f2, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfe345ca6, 0x55a58b1b, 0xfe345ca6, 0x696cda06, 0x43d1f34, 0x43d1f34, 0x72d541bf, 0x72d541bf, 0x72d541bf, 0xddfe817, 0xddfe817, 0xddfe817, 0x948eed91, 0x948eed91, 0x948eed91, 0x43d1f34, 0x696cda06, 0x696cda06, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4cfdf9ab, 0x2a321528, 0x4cfdf9ab, 0xf4b75661, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0xf4b75661, 0xf4b75661, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x287ff948, 0x8c557ef0, 0x287ff948, 0xebf931c7, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xebf931c7, 0xebf931c7, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ecea36b, 0xe442fcb3, 0x5ecea36b, 0x1cab5f56, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x1cab5f56, 0x1cab5f56, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf6c7d73a, 0x4567de0d, 0xf6c7d73a, 0xb8d47573, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xb8d47573, 0xb8d47573, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x56e3bddb, 0x4615a6ba, 0x56e3bddb, 0xc585b2ec, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xc585b2ec, 0xc585b2ec, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5ebfa46, 0x51935e98, 0x5ebfa46, 0xe26d3e18, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xe26d3e18, 0xe26d3e18, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4995beac, 0xe2046911, 0x4995beac, 0x311de003, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0x311de003, 0x311de003, 0x43d1f34, }, 20 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24285504, 0x24285504, 0x3cc7ae1, 0x3cc7ae1, 0x20e2971b, 0x20e2971b, 0xc295b4fc, 0xc295b4fc, 0x1fbe0d4, 0x1fbe0d4, 0x82930744, 0x82930744, 0xf4b66805, 0xf4b66805, 0x3e16a8c5, 0x3e16a8c5, 0x1165d7dc, 0x1165d7dc, 0xfa78cf7f, 0xfa78cf7f, 0xc105a544, 0xc105a544, 0x430cee22, 0x430cee22, 0xbcf938a0, 0xbcf938a0, 0x7b800045, 0x7b800045, 0x2cc85143, 0x2cc85143, 0x80e0a4b4, 0x80e0a4b4, 0x212e8415, 0x212e8415, 0x151d5163, 0x151d5163, 0x24dcfa9e, 0x24dcfa9e, 0xb1df21b2, 0xb1df21b2, 0x2990a5cf, 0x8c1740a5, 0xd29f2d17, 0xd29f2d17, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b224886, 0x2b224886, 0x4fa52ab9, 0x4fa52ab9, 0xad8716fa, 0xad8716fa, 0x97a64f1, 0x97a64f1, 0x5fa72700, 0x5fa72700, 0x41913bce, 0x41913bce, 0xe3e6af02, 0xe3e6af02, 0x978a4f3c, 0x978a4f3c, 0xfdedd645, 0xfdedd645, 0x4700a76, 0x4700a76, 0x28761dd2, 0x28761dd2, 0x255a96e8, 0x255a96e8, 0x6eb066fa, 0x6eb066fa, 0x5948e6c4, 0x5948e6c4, 0xc2d83034, 0xc2d83034, 0xe9cc8934, 0xe9cc8934, 0x406490d, 0x406490d, 0x2287423f, 0x2287423f, 0x565ef88b, 0x565ef88b, 0x31af9b10, 0x31af9b10, 0xfbd17ce0, 0xdb686c61, 0xd2731a72, 0xd2731a72, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x999febcd, 0x999febcd, 0x4be4a5e6, 0x4be4a5e6, 0xaa36e979, 0xaa36e979, 0x27ebab0f, 0x27ebab0f, 0x6fa8606c, 0x6fa8606c, 0xd3f60410, 0xd3f60410, 0xa3aea110, 0xa3aea110, 0x5b352e4b, 0x5b352e4b, 0xad22636f, 0xad22636f, 0x54333936, 0x54333936, 0x73d67c9f, 0x73d67c9f, 0xb4462f4a, 0xb4462f4a, 0x1dffdbca, 0x1dffdbca, 0x7095a788, 0x7095a788, 0xc71aa28, 0xc71aa28, 0x215e8dfc, 0x215e8dfc, 0x388d3494, 0x388d3494, 0x5804733d, 0x5804733d, 0x98ef7a83, 0x98ef7a83, 0xc986bddb, 0xc986bddb, 0x183599ab, 0xf4204ada, 0x6562dd40, 0x6562dd40, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xea25e7f1, 0xea25e7f1, 0xf959b605, 0xf959b605, 0x5650ee99, 0x5650ee99, 0xbf3bec3c, 0xbf3bec3c, 0x8d04d782, 0x8d04d782, 0xddbcf5be, 0xddbcf5be, 0x7ee1adaf, 0x7ee1adaf, 0x2fbaff58, 0x2fbaff58, 0x42b24add, 0x42b24add, 0x47483eb4, 0x47483eb4, 0x78962528, 0x78962528, 0x847ee9b7, 0x847ee9b7, 0xc826c0f, 0xc826c0f, 0x82b1bf51, 0x82b1bf51, 0x13ccc821, 0x13ccc821, 0x7d783b1e, 0x7d783b1e, 0xdd2c0bbc, 0xdd2c0bbc, 0x7b71ebd7, 0x7b71ebd7, 0x7381f4c5, 0x7381f4c5, 0xfe20bc9c, 0xfe20bc9c, 0x85dee923, 0x85611b00, 0x723c0ec4, 0x723c0ec4, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc52dc5f, 0xbc52dc5f, 0x4c895989, 0x4c895989, 0x59d180a4, 0x59d180a4, 0x50eb81b9, 0x50eb81b9, 0xae85d6c6, 0xae85d6c6, 0xf8354df6, 0xf8354df6, 0x83562153, 0x83562153, 0xd4caece2, 0xd4caece2, 0xb0b5612d, 0xb0b5612d, 0x123d360a, 0x123d360a, 0x70f62e8e, 0x70f62e8e, 0x6a82788f, 0x6a82788f, 0xb0a3ee68, 0xb0a3ee68, 0x604dd5b0, 0x604dd5b0, 0x20f7ea1, 0x20f7ea1, 0x3f6db6bf, 0x3f6db6bf, 0x4a762b9d, 0x4a762b9d, 0xea026ad4, 0xea026ad4, 0x8ba3d148, 0x8ba3d148, 0x434f2359, 0x434f2359, 0x4db299a1, 0x73536949, 0xf022eb4b, 0xf022eb4b, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7cfd676, 0x7cfd676, 0xaf7bcdc6, 0xaf7bcdc6, 0x7dc1f958, 0x7dc1f958, 0xc902ad3e, 0xc902ad3e, 0x5529ad04, 0x5529ad04, 0xa0a133b1, 0xa0a133b1, 0x72f927da, 0x72f927da, 0x28de6d8e, 0x28de6d8e, 0xa5eb10fc, 0xa5eb10fc, 0x2d7ba4f5, 0x2d7ba4f5, 0xd832b228, 0xd832b228, 0x56f0351, 0x56f0351, 0xc6556c2e, 0xc6556c2e, 0x2ceecfa4, 0x2ceecfa4, 0x3d765fbd, 0x3d765fbd, 0x8da7887e, 0x8da7887e, 0xfc8209ea, 0xfc8209ea, 0x6e822767, 0x6e822767, 0xba5c0adf, 0xba5c0adf, 0x8e2af81a, 0x8e2af81a, 0x62c25eb4, 0x2ba315e0, 0x349b7b7d, 0x349b7b7d, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x361fdea5, 0x361fdea5, 0x89a3b488, 0x89a3b488, 0x37302fbe, 0x37302fbe, 0x4b9f20b8, 0x4b9f20b8, 0xc60cf5fe, 0xc60cf5fe, 0xf7b755aa, 0xf7b755aa, 0xcaba5d52, 0xcaba5d52, 0x4f793adf, 0x4f793adf, 0x4cd60722, 0x4cd60722, 0x13adbeec, 0x13adbeec, 0xdc2c109f, 0xdc2c109f, 0x444e465a, 0x444e465a, 0x7baac5fa, 0x7baac5fa, 0x8e746e7f, 0x8e746e7f, 0x7fea6e68, 0x7fea6e68, 0x1f6edf48, 0x1f6edf48, 0x23322506, 0x23322506, 0xbccd38ef, 0xbccd38ef, 0x1b1f1dd3, 0x1b1f1dd3, 0x9c901775, 0x9c901775, 0x78b8e355, 0x95034aa2, 0x4f00ee83, 0x4f00ee83, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdf032925, 0xb9ccc5a6, 0xdf032925, 0x9cf5e462, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x9cf5e462, 0x9cf5e462, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa24e444d, 0x664c3f5, 0xa24e444d, 0x8c4bc132, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x8c4bc132, 0x8c4bc132, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6fa41086, 0xd5284f5e, 0x6fa41086, 0x32b37d02, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x32b37d02, 0x32b37d02, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd084e37c, 0x6324ea4b, 0xd084e37c, 0x7ed2aaa4, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x7ed2aaa4, 0x7ed2aaa4, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x451273fe, 0x55e4689f, 0x451273fe, 0x33b4464d, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x33b4464d, 0x33b4464d, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x93132338, 0xc76b87e6, 0x93132338, 0x8816f93f, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x8816f93f, 0x8816f93f, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6a4ef5, 0x5fb9948, 0xae6a4ef5, 0x51d55575, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x51d55575, 0x51d55575, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0x5fefa0d1, 0x5fefa0d1, 0x5fefa0d1, 0xde1c5600, 0xde1c5600, 0xde1c5600, 0x48b8ef6f, 0x48b8ef6f, 0x48b8ef6f, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x25ba43d4, 0x43fe620d, 0x25ba43d4, 0x664c8e93, 0x59c36f00, 0x59c36f00, 0xb2921a37, 0xb2921a37, 0xb2921a37, 0xcc127751, 0xcc127751, 0xcc127751, 0xaee46283, 0xaee46283, 0xaee46283, 0x59c36f00, 0x664c8e93, 0x664c8e93, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2aa2a72b, 0x6d6df6e1, 0x2aa2a72b, 0x4a72254, 0xaa4593fe, 0xaa4593fe, 0xa3be9127, 0xa3be9127, 0xa3be9127, 0x54b9c40, 0x54b9c40, 0x54b9c40, 0x28733738, 0x28733738, 0x28733738, 0xaa4593fe, 0x4a72254, 0x4a72254, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e799f98, 0xe21ad041, 0x9e799f98, 0xc36ef21c, 0xc9cbf769, 0xc9cbf769, 0x93d6c07d, 0x93d6c07d, 0x93d6c07d, 0x6d0e01b1, 0x6d0e01b1, 0x6d0e01b1, 0x8444beb9, 0x8444beb9, 0x8444beb9, 0xc9cbf769, 0xc36ef21c, 0xc36ef21c, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7ffc43fd, 0x64505961, 0x7ffc43fd, 0xd1aa0a25, 0x9813a416, 0x9813a416, 0x5b5f9bd5, 0x5b5f9bd5, 0x5b5f9bd5, 0xca841de6, 0xca841de6, 0xca841de6, 0xd33e2036, 0xd33e2036, 0xd33e2036, 0x9813a416, 0xd1aa0a25, 0xd1aa0a25, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x570ca3fc, 0x4f1cee0f, 0x570ca3fc, 0x21aa964f, 0x5fcf013d, 0x5fcf013d, 0xf2bc017e, 0xf2bc017e, 0xf2bc017e, 0x20ac1908, 0x20ac1908, 0x20ac1908, 0x36df2697, 0x36df2697, 0x36df2697, 0x5fcf013d, 0x21aa964f, 0x21aa964f, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcf9798d3, 0x5d39a7fa, 0xcf9798d3, 0xd49242d4, 0xdd28f52b, 0xdd28f52b, 0xe15747f0, 0xe15747f0, 0xe15747f0, 0xc06bbe14, 0xc06bbe14, 0xc06bbe14, 0xbdd37598, 0xbdd37598, 0xbdd37598, 0xdd28f52b, 0xd49242d4, 0xd49242d4, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6154e8, 0x59e627f7, 0xae6154e8, 0x51de4f68, 0x43d1f34, 0x43d1f34, 0x59a8eb9f, 0x59a8eb9f, 0x59a8eb9f, 0x26a24237, 0x26a24237, 0x26a24237, 0xbff347b1, 0xbff347b1, 0xbff347b1, 0x43d1f34, 0x51de4f68, 0x51de4f68, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2b04aa3, 0xca81b845, 0xb2b04aa3, 0xf14687e4, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xf14687e4, 0xf14687e4, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x19a66482, 0xba12148e, 0x19a66482, 0x37a3e1fd, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0x37a3e1fd, 0x37a3e1fd, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6a5ddfe7, 0xc898195a, 0x6a5ddfe7, 0x374ab263, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x374ab263, 0x374ab263, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb6ca222a, 0x98e6c241, 0xb6ca222a, 0x189c6bf2, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x189c6bf2, 0x189c6bf2, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x726d82d0, 0xe9c535bd, 0x726d82d0, 0x4cbb763, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x4cbb763, 0x4cbb763, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfe26fef7, 0x6031c462, 0xfe26fef7, 0xe52324f0, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0xe52324f0, 0xe52324f0, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x25e34f8a, 0x67935e5e, 0x25e34f8a, 0xda5c540a, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xda5c540a, 0xda5c540a, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67038f5e, 0x65d6007f, 0x67038f5e, 0x24f54219, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x24f54219, 0x24f54219, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944464c7, 0x27123864, 0x944464c7, 0xba41e1b8, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0xba41e1b8, 0xba41e1b8, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfe97adaf, 0x4f3307d4, 0xfe97adaf, 0xa380c02b, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xa380c02b, 0xa380c02b, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b32a9ba, 0xaf93fd91, 0x5b32a9ba, 0xf564e062, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf564e062, 0xf564e062, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e0e1ce8, 0x7ed1c9ee, 0x5e0e1ce8, 0x28a8295b, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x28a8295b, 0x28a8295b, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa473184a, 0x93eaf325, 0xa473184a, 0xbf76c24d, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0xbf76c24d, 0xbf76c24d, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa725578b, 0x81889cf9, 0xa725578b, 0x589a4c0b, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x589a4c0b, 0x589a4c0b, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd69cdcbf, 0x6ad9ce85, 0xd69cdcbf, 0x956a11f8, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0x956a11f8, 0x956a11f8, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1acffa1b, 0xecff2136, 0x1acffa1b, 0x34ca7f64, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0x34ca7f64, 0x34ca7f64, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1cf8992, 0xb2c51b4c, 0x1cf8992, 0x5cd8e416, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x5cd8e416, 0x5cd8e416, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1f39da0b, 0x6a7f5378, 0x1f39da0b, 0xb16f93d3, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb16f93d3, 0xb16f93d3, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x27394d6b, 0x459337bf, 0x27394d6b, 0x519f78d8, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x519f78d8, 0x519f78d8, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x624e1f92, 0x4be3bd84, 0x624e1f92, 0x794bc595, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x794bc595, 0x794bc595, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf5dab2e, 0x4747516, 0xbf5dab2e, 0x40e2b0ae, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x40e2b0ae, 0x40e2b0ae, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2e284303, 0x169e4b98, 0x2e284303, 0x6dde8e44, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x6dde8e44, 0x6dde8e44, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3a911f8f, 0xe5d171c6, 0x3a911f8f, 0x14949af0, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x14949af0, 0x14949af0, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa4645fb3, 0x8af97df0, 0xa4645fb3, 0xf9733237, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xf9733237, 0xf9733237, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c3a337b, 0xed3f1a6, 0x7c3a337b, 0xd26c7aa3, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd26c7aa3, 0xd26c7aa3, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9f31781b, 0xb6d3e547, 0x9f31781b, 0xe9974da8, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xe9974da8, 0xe9974da8, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfc18d24f, 0x70ed44c6, 0xfc18d24f, 0xe71d0848, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0xe71d0848, 0xe71d0848, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7bb91866, 0xc4777a1f, 0x7bb91866, 0x840603e6, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0x840603e6, 0x840603e6, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa0d0faff, 0x8b37dfcd, 0xa0d0faff, 0xe32637b8, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xe32637b8, 0xe32637b8, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4436bcdb, 0xb3a12b62, 0x4436bcdb, 0x6a3339a4, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0x6a3339a4, 0x6a3339a4, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8e59140, 0x2463e41f, 0xb8e59140, 0xe5f2fcc4, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xe5f2fcc4, 0xe5f2fcc4, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x438b3fcc, 0x7ebfbfd, 0x438b3fcc, 0xeddd7614, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xeddd7614, 0xeddd7614, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf9eea896, 0x25a51233, 0xf9eea896, 0x8f489d25, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0x8f489d25, 0x8f489d25, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9b617752, 0xb06817b5, 0x9b617752, 0x8064ad55, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x8064ad55, 0x8064ad55, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x595e29e, 0xc043d961, 0x595e29e, 0xfa2af91e, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xfa2af91e, 0xfa2af91e, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63e24d8a, 0x52da109, 0x63e24d8a, 0x201480cd, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x201480cd, 0x201480cd, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1b2e61c9, 0xbf04e671, 0x1b2e61c9, 0x352be4b6, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x352be4b6, 0x352be4b6, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefcce0d0, 0x5540bf08, 0xefcce0d0, 0xb2db8d54, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xb2db8d54, 0xb2db8d54, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x65a5505e, 0xd6055969, 0x65a5505e, 0xcbf31986, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcbf31986, 0xcbf31986, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7319d06, 0x17c78667, 0x7319d06, 0x7197a8b5, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x7197a8b5, 0x7197a8b5, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x723a247, 0x535b0699, 0x723a247, 0x1c267840, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x1c267840, 0x1c267840, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xe3a20cf8, 0x4833db45, 0xe3a20cf8, 0x1c1d1778, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x1c1d1778, 0x1c1d1778, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24b38cd5, 0x6b033831, 0x24b38cd5, 0x67454192, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x67454192, 0x67454192, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f09885, 0x5d94ace6, 0x54f09885, 0x7af51dfa, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0x7af51dfa, 0x7af51dfa, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x53c2ee74, 0x92931869, 0x53c2ee74, 0xed583f0, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0xed583f0, 0xed583f0, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e5ded6f, 0x12bf47c3, 0x4e5ded6f, 0xe00ba4b7, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe00ba4b7, 0xe00ba4b7, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3566adf6, 0x4c7649cf, 0x3566adf6, 0x43c09845, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x43c09845, 0x43c09845, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec1bda0d, 0x86636a33, 0xec1bda0d, 0xf71e000a, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0xf71e000a, 0xf71e000a, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x619415be, 0x92024b97, 0x619415be, 0x9e2b0e3e, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0x9e2b0e3e, 0x9e2b0e3e, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x200688e1, 0x1274a595, 0x200688e1, 0x63f045a6, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x63f045a6, 0x63f045a6, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa943b821, 0x8aa682a4, 0xa943b821, 0x87463d5e, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x87463d5e, 0x87463d5e, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x11b6367b, 0x27bbcfb4, 0x11b6367b, 0x4ca15bff, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x4ca15bff, 0x4ca15bff, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c16ec93, 0xe9d7d93f, 0x7c16ec93, 0xd240a54b, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd240a54b, 0xd240a54b, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe28608ec, 0x3575a25f, 0xe28608ec, 0x94203d5f, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0x94203d5f, 0x94203d5f, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb510e48, 0x9406b857, 0xb510e48, 0x1054d44f, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0x1054d44f, 0x1054d44f, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf256eb36, 0xaed7d845, 0xf256eb36, 0xde9f0b6, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0xde9f0b6, 0xde9f0b6, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe382dd9, 0x68f7c15a, 0xe382dd9, 0x59159307, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x59159307, 0x59159307, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c908c, 0xa4161734, 0x3c908c, 0xb09b4ada, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0xb09b4ada, 0xb09b4ada, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd2e9527, 0xb7a2caff, 0xd2e9527, 0x1d0b8b89, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x1d0b8b89, 0x1d0b8b89, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1639705d, 0xa599796a, 0x1639705d, 0x26488c72, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x26488c72, 0x26488c72, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x10d0c422, 0x26df43, 0x10d0c422, 0xbed72bd7, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0xbed72bd7, 0xbed72bd7, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd34e67a, 0x894c42a4, 0xdd34e67a, 0x53502da0, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x53502da0, 0x53502da0, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x410b50fc, 0xea9a8741, 0x410b50fc, 0xd653d65c, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xd653d65c, 0xd653d65c, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4c09d761, 0x2ac63be2, 0x4c09d761, 0xf44378ab, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xf44378ab, 0xf44378ab, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd3c0fce6, 0x77ea7b5e, 0xd3c0fce6, 0x10463469, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x10463469, 0x10463469, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xabafd82f, 0x112387f7, 0xabafd82f, 0xe9ca2412, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xe9ca2412, 0xe9ca2412, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2b138245, 0x98b38b72, 0x2b138245, 0x6500200c, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x6500200c, 0x6500200c, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x87f97368, 0x970f6809, 0x87f97368, 0x149f7c5f, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x149f7c5f, 0x149f7c5f, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x12986e14, 0x46e0caca, 0x12986e14, 0xf51eaa4a, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xf51eaa4a, 0xf51eaa4a, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf6aab2f6, 0x5d3b654b, 0xf6aab2f6, 0x8e22ec59, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x8e22ec59, 0x8e22ec59, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From b00e4c2bd9fd051678a8aadafa95ad14b3c866ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Feb 2016 21:44:37 +0300 Subject: [PATCH 0538/1167] efidisk: prevent errors from diskfilter scan of removable drives Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This actually matches pretty close (we obviously attempt to read outside of media) and avoids adding more error codes. This affects only internally initiated scans. If read/write from removable is explicitly requested, we still return an error and text explanation is more clear for user than generic error. Reported and tested by Andreas Loew --- grub-core/disk/efi/efidisk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 1c00e3ec8..ea753446d 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -547,7 +547,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, buf, 0); - if (status != GRUB_EFI_SUCCESS) + if (status == GRUB_EFI_NO_MEDIA) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx from `%s'"), (unsigned long long) sector, @@ -568,7 +570,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1); - if (status != GRUB_EFI_SUCCESS) + if (status == GRUB_EFI_NO_MEDIA) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx to `%s'"), (unsigned long long) sector, disk->name); From 109189ce01ea6467055ca56b725ce263597db6d4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 27 Feb 2016 15:16:48 +0300 Subject: [PATCH 0539/1167] efidisk: fix misplaced parenthesis in b00e4c2 --- grub-core/disk/efi/efidisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index ea753446d..75bb4a9ca 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -548,7 +548,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, buf, 0); if (status == GRUB_EFI_NO_MEDIA) - return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name); else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx from `%s'"), @@ -571,7 +571,7 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1); if (status == GRUB_EFI_NO_MEDIA) - return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name); else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx to `%s'"), From 070e190305986dff1d528af08b964667f29dc914 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:56:28 +0100 Subject: [PATCH 0540/1167] Use console rather than serial_efi0 on arm64-efi in tests --- tests/util/grub-shell.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 7848b4222..ab19dbbf5 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -74,6 +74,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk=0 # To skip "Welcome to GRUB" and color setttings trim=1 + serial_port= ;; powerpc-ieee1275) boot=hd @@ -181,7 +182,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in trim=1 qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts" disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" - serial_port=efi0 + serial_port= ;; arm-efi) qemu=qemu-system-arm @@ -322,7 +323,7 @@ fi if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ]; then echo insmod escc >>${cfgfile} fi -if [ "${grub_modinfo_platform}" != emu ]; then +if [ "${serial_port}" != "" ]; then echo "serial ${serial_port}" >>${cfgfile} term="serial_${serial_port}" else From 8c26dace6f4db4245b57f05257c07b1253eb7490 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 12:26:56 +0100 Subject: [PATCH 0541/1167] cat: Don't switch terminal mode when there is nothing to highlight. This just pollutes serial console. --- grub-core/commands/cat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c index 8a7f1af78..88d904436 100644 --- a/grub-core/commands/cat.c +++ b/grub-core/commands/cat.c @@ -140,10 +140,13 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args) grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); } - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - for (j = 0; j < utcount; j++) - grub_printf ("<%x>", (unsigned int) utbuf[j]); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + if (utcount) + { + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + for (j = 0; j < utcount; j++) + grub_printf ("<%x>", (unsigned int) utbuf[j]); + grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + } grub_xputs ("\n"); grub_refresh (); From 2ebef43cf6276168c72b63f7bd66fad3b030973e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 14:56:22 +0100 Subject: [PATCH 0542/1167] bsd: Ensure that kernel is loaded before loading module. kernel_type may be set to the type of failed kernel. This patching-up is easier than to reflow kernel loading routines. --- grub-core/loader/i386/bsd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index bc377b362..7f96515da 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1889,6 +1889,10 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), grub_err_t err; void *src; + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded"); @@ -1992,6 +1996,10 @@ grub_cmd_netbsd_module (grub_command_t cmd, { grub_uint32_t type; + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_NETBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded"); @@ -2070,6 +2078,10 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)), if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_OPENBSD) return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded"); From 36212460d3565b18439a3a8130b28e6c97702c6a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:26:44 +0100 Subject: [PATCH 0543/1167] mkimage.c: Split into separate files. util/grub-mkimagexx.c is included in a special way into mkimage.c. Interoperation between defines makes this very tricky. Instead just have a clean interface and compile util/grub-mkimage*.c separately from mkimage.c --- Makefile.util.def | 10 ++ include/grub/util/mkimage.h | 170 ++++++++++++++++++++++ util/grub-mkimage32.c | 22 +++ util/grub-mkimage64.c | 22 +++ util/grub-mkimagexx.c | 244 ++++++++++++++++++++++---------- util/mkimage.c | 275 ++---------------------------------- 6 files changed, 406 insertions(+), 337 deletions(-) create mode 100644 include/grub/util/mkimage.h create mode 100644 util/grub-mkimage32.c create mode 100644 util/grub-mkimage64.c diff --git a/Makefile.util.def b/Makefile.util.def index db7e8ec2a..ed9b4c697 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -172,6 +172,8 @@ program = { common = util/grub-mkimage.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/resolve.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/osdep/init.c; @@ -510,6 +512,8 @@ program = { common = util/render-label.c; common = util/glue-efi.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -552,6 +556,8 @@ program = { common = util/render-label.c; common = util/glue-efi.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -595,6 +601,8 @@ program = { common = util/grub-install.c; common = util/probe.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -632,6 +640,8 @@ program = { common = util/grub-mknetdir.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h new file mode 100644 index 000000000..564adbce7 --- /dev/null +++ b/include/grub/util/mkimage.h @@ -0,0 +1,170 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#ifndef GRUB_UTIL_MKIMAGE_HEADER +#define GRUB_UTIL_MKIMAGE_HEADER 1 + +/* Private header. Use only in mkimage-related sources. */ +char * +grub_mkimage_load_image32 (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target); +char * +grub_mkimage_load_image64 (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target); +void +grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf32_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size); +void +grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf64_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size); + +struct grub_install_image_target_desc +{ + const char *dirname; + const char *names[6]; + grub_size_t voidp_sizeof; + int bigendian; + enum { + IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, + IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, + IMAGE_I386_IEEE1275, + IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, + IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, + IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO + } id; + enum + { + PLATFORM_FLAGS_NONE = 0, + PLATFORM_FLAGS_DECOMPRESSORS = 2, + PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4, + } flags; + unsigned total_module_size; + unsigned decompressor_compressed_size; + unsigned decompressor_uncompressed_size; + unsigned decompressor_uncompressed_addr; + unsigned link_align; + grub_uint16_t elf_target; + unsigned section_align; + signed vaddr_offset; + grub_uint64_t link_addr; + unsigned mod_gap, mod_align; + grub_compression_t default_compression; + grub_uint16_t pe_target; +}; + +#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) +#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x))) +#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x))) +#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x))) +#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x))) +#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x))) +#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x))) + +static inline grub_uint32_t +grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target, + grub_uint32_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu32 (in); + else + return grub_le_to_cpu32 (in); +} + +static inline grub_uint64_t +grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target, + grub_uint64_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu64 (in); + else + return grub_le_to_cpu64 (in); +} + +static inline grub_uint64_t +grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target, + grub_uint64_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be64 (in); + else + return grub_cpu_to_le64 (in); +} + +static inline grub_uint32_t +grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target, + grub_uint32_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be32 (in); + else + return grub_cpu_to_le32 (in); +} + +static inline grub_uint16_t +grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target, + grub_uint16_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu16 (in); + else + return grub_le_to_cpu16 (in); +} + +static inline grub_uint16_t +grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target, + grub_uint16_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be16 (in); + else + return grub_cpu_to_le16 (in); +} + +static inline grub_uint64_t +grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) +{ + if (image_target->voidp_sizeof == 8) + return grub_host_to_target64_real (image_target, in); + else + return grub_host_to_target32_real (image_target, in); +} + +static inline grub_uint64_t +grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) +{ + if (image_target->voidp_sizeof == 8) + return grub_target_to_host64_real (image_target, in); + else + return grub_target_to_host32_real (image_target, in); +} + +#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val)) + +#endif diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c new file mode 100644 index 000000000..9b31397bc --- /dev/null +++ b/util/grub-mkimage32.c @@ -0,0 +1,22 @@ +#define MKIMAGE_ELF32 1 + +# define SUFFIX(x) x ## 32 +# define ELFCLASSXX ELFCLASS32 +# define Elf_Ehdr Elf32_Ehdr +# define Elf_Phdr Elf32_Phdr +# define Elf_Nhdr Elf32_Nhdr +# define Elf_Addr Elf32_Addr +# define Elf_Sym Elf32_Sym +# define Elf_Off Elf32_Off +# define Elf_Shdr Elf32_Shdr +# define Elf_Rela Elf32_Rela +# define Elf_Rel Elf32_Rel +# define Elf_Word Elf32_Word +# define Elf_Half Elf32_Half +# define Elf_Section Elf32_Section +# define ELF_R_SYM(val) ELF32_R_SYM(val) +# define ELF_R_TYPE(val) ELF32_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) +#define XEN_NOTE_SIZE 132 + +#include "grub-mkimagexx.c" diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c new file mode 100644 index 000000000..d83345924 --- /dev/null +++ b/util/grub-mkimage64.c @@ -0,0 +1,22 @@ +#define MKIMAGE_ELF64 1 + +# define SUFFIX(x) x ## 64 +# define ELFCLASSXX ELFCLASS64 +# define Elf_Ehdr Elf64_Ehdr +# define Elf_Phdr Elf64_Phdr +# define Elf_Nhdr Elf64_Nhdr +# define Elf_Addr Elf64_Addr +# define Elf_Sym Elf64_Sym +# define Elf_Off Elf64_Off +# define Elf_Shdr Elf64_Shdr +# define Elf_Rela Elf64_Rela +# define Elf_Rel Elf64_Rel +# define Elf_Word Elf64_Word +# define Elf_Half Elf64_Half +# define Elf_Section Elf64_Section +# define ELF_R_SYM(val) ELF64_R_SYM(val) +# define ELF_R_TYPE(val) ELF64_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) +#define XEN_NOTE_SIZE 120 + +#include "grub-mkimagexx.c" diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 06b6a724d..03874be57 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -17,58 +17,172 @@ * along with GRUB. If not, see . */ -#undef ELF_R_SYM -#undef ELF_R_TYPE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#if defined(MKIMAGE_ELF32) -# define SUFFIX(x) x ## 32 -# define ELFCLASSXX ELFCLASS32 -# define Elf_Ehdr Elf32_Ehdr -# define Elf_Phdr Elf32_Phdr -# define Elf_Nhdr Elf32_Nhdr -# define Elf_Addr Elf32_Addr -# define Elf_Sym Elf32_Sym -# define Elf_Off Elf32_Off -# define Elf_Shdr Elf32_Shdr -# define Elf_Rela Elf32_Rela -# define Elf_Rel Elf32_Rel -# define Elf_Word Elf32_Word -# define Elf_Half Elf32_Half -# define Elf_Section Elf32_Section -# define ELF_R_SYM(val) ELF32_R_SYM(val) -# define ELF_R_TYPE(val) ELF32_R_TYPE(val) -# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) -#define XEN_NOTE_SIZE 132 -#elif defined(MKIMAGE_ELF64) -# define SUFFIX(x) x ## 64 -# define ELFCLASSXX ELFCLASS64 -# define Elf_Ehdr Elf64_Ehdr -# define Elf_Phdr Elf64_Phdr -# define Elf_Nhdr Elf64_Nhdr -# define Elf_Addr Elf64_Addr -# define Elf_Sym Elf64_Sym -# define Elf_Off Elf64_Off -# define Elf_Shdr Elf64_Shdr -# define Elf_Rela Elf64_Rela -# define Elf_Rel Elf64_Rel -# define Elf_Word Elf64_Word -# define Elf_Half Elf64_Half -# define Elf_Section Elf64_Section -# define ELF_R_SYM(val) ELF64_R_SYM(val) -# define ELF_R_TYPE(val) ELF64_R_TYPE(val) -# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) -#define XEN_NOTE_SIZE 120 -#else -#error "I'm confused" -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma GCC diagnostic ignored "-Wcast-align" static Elf_Addr SUFFIX (entry_point); -static void -SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target, - int note, char **core_img, size_t *core_size, - Elf_Addr target_addr, grub_size_t align, - size_t kernel_size, size_t bss_size) +/* These structures are defined according to the CHRP binding to IEEE1275, + "Client Program Format" section. */ + +struct grub_ieee1275_note_desc +{ + grub_uint32_t real_mode; + grub_uint32_t real_base; + grub_uint32_t real_size; + grub_uint32_t virt_base; + grub_uint32_t virt_size; + grub_uint32_t load_base; +}; + +#define GRUB_IEEE1275_NOTE_NAME "PowerPC" +#define GRUB_IEEE1275_NOTE_TYPE 0x1275 + +struct grub_ieee1275_note +{ + Elf32_Nhdr header; + char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)]; + struct grub_ieee1275_note_desc descriptor; +}; + +#define GRUB_XEN_NOTE_NAME "Xen" + +struct fixup_block_list +{ + struct fixup_block_list *next; + int state; + struct grub_pe32_fixup_block b; +}; + +#define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) + +#ifdef MKIMAGE_ELF32 + +/* + * R_ARM_THM_CALL/THM_JUMP24 + * + * Relocate Thumb (T32) instruction set relative branches: + * B.W, BL and BLX + */ +static grub_err_t +grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + offset = grub_arm_thm_call_get_offset (target); + + grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr); + + offset += sym_addr; + + grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n", + target, sym_addr, offset); + + /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel + is bigger than 2M (currently under 150K) then we probably have a problem + somewhere else. */ + if (offset < -0x200000 || offset >= 0x200000) + return grub_error (GRUB_ERR_BAD_MODULE, + "THM_CALL Relocation out of range."); + + grub_dprintf ("dl", " relative destination = %p", + (char *) target + offset); + + return grub_arm_thm_call_set_offset (target, offset); +} + +/* + * R_ARM_THM_JUMP19 + * + * Relocate conditional Thumb (T32) B.W + */ +static grub_err_t +grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + if (!(sym_addr & 1)) + return grub_error (GRUB_ERR_BAD_MODULE, + "Relocation targeting wrong execution state"); + + offset = grub_arm_thm_jump19_get_offset (target); + + /* Adjust and re-truncate offset */ + offset += sym_addr; + + if (!grub_arm_thm_jump19_check_offset (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "THM_JUMP19 Relocation out of range."); + + grub_arm_thm_jump19_set_offset (target, offset); + + return GRUB_ERR_NONE; +} + +/* + * R_ARM_JUMP24 + * + * Relocate ARM (A32) B + */ +static grub_err_t +grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + if (sym_addr & 1) + return grub_error (GRUB_ERR_BAD_MODULE, + "Relocation targeting wrong execution state"); + + offset = grub_arm_jump24_get_offset (target); + offset += sym_addr; + + if (!grub_arm_jump24_check_offset (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "JUMP24 Relocation out of range."); + + + grub_arm_jump24_set_offset (target, offset); + + return GRUB_ERR_NONE; +} + +#endif + +void +SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size) { char *elf_img; size_t program_size; @@ -1457,13 +1571,13 @@ SUFFIX (locate_sections) (const char *kernel_path, return section_addresses; } -static char * -SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, - const struct grub_install_image_target_desc *image_target) +char * +SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; const char *strtab; @@ -1671,23 +1785,3 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, return out_img; } - - -#undef SUFFIX -#undef ELFCLASSXX -#undef Elf_Ehdr -#undef Elf_Phdr -#undef Elf_Nhdr -#undef Elf_Shdr -#undef Elf_Addr -#undef Elf_Sym -#undef Elf_Off -#undef Elf_Rela -#undef Elf_Rel -#undef ELF_R_TYPE -#undef ELF_R_SYM -#undef Elf_Word -#undef Elf_Half -#undef Elf_Section -#undef ELF_ST_TYPE -#undef XEN_NOTE_SIZE diff --git a/util/mkimage.c b/util/mkimage.c index c3365bbbd..86bb78190 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -46,6 +46,7 @@ #include #include #include +#include #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) @@ -53,45 +54,13 @@ #include #endif +#pragma GCC diagnostic ignored "-Wcast-align" + #define TARGET_NO_FIELD 0xffffffff /* use 2015-01-01T00:00:00+0000 as a stock timestamp */ #define STABLE_EMBEDDING_TIMESTAMP 1420070400 -struct grub_install_image_target_desc -{ - const char *dirname; - const char *names[6]; - grub_size_t voidp_sizeof; - int bigendian; - enum { - IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, - IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, - IMAGE_I386_IEEE1275, - IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, - IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, - IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO - } id; - enum - { - PLATFORM_FLAGS_NONE = 0, - PLATFORM_FLAGS_DECOMPRESSORS = 2, - PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4, - } flags; - unsigned total_module_size; - unsigned decompressor_compressed_size; - unsigned decompressor_uncompressed_size; - unsigned decompressor_uncompressed_addr; - unsigned link_align; - grub_uint16_t elf_target; - unsigned section_align; - signed vaddr_offset; - grub_uint64_t link_addr; - unsigned mod_gap, mod_align; - grub_compression_t default_compression; - grub_uint16_t pe_target; -}; - #define EFI32_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \ + GRUB_PE32_SIGNATURE_SIZE \ + sizeof (struct grub_pe32_coff_header) \ @@ -603,119 +572,6 @@ static const struct grub_install_image_target_desc image_targets[] = }, }; -#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) -#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x))) -#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x))) -#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x))) -#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x))) -#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x))) -#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x))) - -static inline grub_uint32_t -grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target, - grub_uint32_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu32 (in); - else - return grub_le_to_cpu32 (in); -} - -static inline grub_uint64_t -grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target, - grub_uint64_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu64 (in); - else - return grub_le_to_cpu64 (in); -} - -static inline grub_uint64_t -grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target, - grub_uint64_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be64 (in); - else - return grub_cpu_to_le64 (in); -} - -static inline grub_uint32_t -grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target, - grub_uint32_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be32 (in); - else - return grub_cpu_to_le32 (in); -} - -static inline grub_uint16_t -grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target, - grub_uint16_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu16 (in); - else - return grub_le_to_cpu16 (in); -} - -static inline grub_uint16_t -grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target, - grub_uint16_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be16 (in); - else - return grub_cpu_to_le16 (in); -} - -static inline grub_uint64_t -grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) -{ - if (image_target->voidp_sizeof == 8) - return grub_host_to_target64_real (image_target, in); - else - return grub_host_to_target32_real (image_target, in); -} - -static inline grub_uint64_t -grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) -{ - if (image_target->voidp_sizeof == 8) - return grub_target_to_host64_real (image_target, in); - else - return grub_target_to_host32_real (image_target, in); -} - -#define GRUB_IEEE1275_NOTE_NAME "PowerPC" -#define GRUB_IEEE1275_NOTE_TYPE 0x1275 - -/* These structures are defined according to the CHRP binding to IEEE1275, - "Client Program Format" section. */ - -struct grub_ieee1275_note_desc -{ - grub_uint32_t real_mode; - grub_uint32_t real_base; - grub_uint32_t real_size; - grub_uint32_t virt_base; - grub_uint32_t virt_size; - grub_uint32_t load_base; -}; - -struct grub_ieee1275_note -{ - Elf32_Nhdr header; - char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)]; - struct grub_ieee1275_note_desc descriptor; -}; - -#define GRUB_XEN_NOTE_NAME "Xen" - -#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val)) - #include static void *SzAlloc(void *p __attribute__ ((unused)), size_t size) { return xmalloc(size); } @@ -830,111 +686,6 @@ compress_kernel (const struct grub_install_image_target_desc *image_target, char *core_size = kernel_size; } -struct fixup_block_list -{ - struct fixup_block_list *next; - int state; - struct grub_pe32_fixup_block b; -}; - -/* - * R_ARM_THM_CALL/THM_JUMP24 - * - * Relocate Thumb (T32) instruction set relative branches: - * B.W, BL and BLX - */ -static grub_err_t -grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - offset = grub_arm_thm_call_get_offset (target); - - grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr); - - offset += sym_addr; - - grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n", - target, sym_addr, offset); - - /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel - is bigger than 2M (currently under 150K) then we probably have a problem - somewhere else. */ - if (offset < -0x200000 || offset >= 0x200000) - return grub_error (GRUB_ERR_BAD_MODULE, - "THM_CALL Relocation out of range."); - - grub_dprintf ("dl", " relative destination = %p", - (char *) target + offset); - - return grub_arm_thm_call_set_offset (target, offset); -} - -/* - * R_ARM_THM_JUMP19 - * - * Relocate conditional Thumb (T32) B.W - */ -static grub_err_t -grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - if (!(sym_addr & 1)) - return grub_error (GRUB_ERR_BAD_MODULE, - "Relocation targeting wrong execution state"); - - offset = grub_arm_thm_jump19_get_offset (target); - - /* Adjust and re-truncate offset */ - offset += sym_addr; - - if (!grub_arm_thm_jump19_check_offset (offset)) - return grub_error (GRUB_ERR_BAD_MODULE, - "THM_JUMP19 Relocation out of range."); - - grub_arm_thm_jump19_set_offset (target, offset); - - return GRUB_ERR_NONE; -} - -/* - * R_ARM_JUMP24 - * - * Relocate ARM (A32) B - */ -static grub_err_t -grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - if (sym_addr & 1) - return grub_error (GRUB_ERR_BAD_MODULE, - "Relocation targeting wrong execution state"); - - offset = grub_arm_jump24_get_offset (target); - offset += sym_addr; - - if (!grub_arm_jump24_check_offset (offset)) - return grub_error (GRUB_ERR_BAD_MODULE, - "JUMP24 Relocation out of range."); - - - grub_arm_jump24_set_offset (target, offset); - - return GRUB_ERR_NONE; -} - -#pragma GCC diagnostic ignored "-Wcast-align" - -#define MKIMAGE_ELF32 1 -#include "grub-mkimagexx.c" -#undef MKIMAGE_ELF32 - -#define MKIMAGE_ELF64 1 -#include "grub-mkimagexx.c" -#undef MKIMAGE_ELF64 - const struct grub_install_image_target_desc * grub_install_get_image_target (const char *arg) { @@ -1063,13 +814,13 @@ grub_install_generate_image (const char *dir, const char *prefix, (unsigned long long) total_module_size); if (image_target->voidp_sizeof == 4) - kernel_img = load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, + total_module_size, &start_address, &rel_section, + &reloc_size, &align, image_target); else - kernel_img = load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, + total_module_size, &start_address, &rel_section, + &reloc_size, &align, image_target); if (image_target->id == IMAGE_XEN && align < 4096) align = 4096; @@ -1890,11 +1641,11 @@ grub_install_generate_image (const char *dir, const char *prefix, else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) - generate_elf32 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, + target_addr, align, kernel_size, bss_size); else - generate_elf64 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, + target_addr, align, kernel_size, bss_size); } break; } From dd3969e7ec3a09bb4625aef5a852d4ffcf04b639 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:54:37 +0100 Subject: [PATCH 0544/1167] mkimagexx: Split PE and generic part for relocations. As a preparation for U-Boot relocations, split emitting PE-relocations from parsing source ELF-relocations. --- util/grub-mkimagexx.c | 415 ++++++++++++++++++++++-------------------- 1 file changed, 219 insertions(+), 196 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 03874be57..a39803a06 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1095,9 +1095,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, /* Add a PE32's fixup entry for a relocation. Return the resulting address after having written to the file OUT. */ static Elf_Addr -SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type, - Elf_Addr addr, int flush, Elf_Addr current_address, - const struct grub_install_image_target_desc *image_target) +add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type, + Elf_Addr addr, int flush, Elf_Addr current_address, + const struct grub_install_image_target_desc *image_target) { struct grub_pe32_fixup_block *b; @@ -1187,22 +1187,222 @@ SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type, return current_address; } +struct translate_context +{ + struct fixup_block_list *lst, *lst0; + Elf_Addr current_address; +}; + +static void +translate_reloc_start (struct translate_context *ctx) +{ + ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); + memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); + ctx->current_address = 0; +} + +static void +translate_relocation (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + /* Necessary to relocate only absolute addresses. */ + switch (image_target->elf_target) + { + case EM_386: + if (ELF_R_TYPE (info) == R_386_32) + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_HIGHLOW, + addr, 0, ctx->current_address, + image_target); + } + break; + case EM_X86_64: + if ((ELF_R_TYPE (info) == R_X86_64_32) || + (ELF_R_TYPE (info) == R_X86_64_32S)) + { + grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)"); + } + else if (ELF_R_TYPE (info) == R_X86_64_64) + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, + 0, ctx->current_address, + image_target); + } + break; + case EM_IA_64: + switch (ELF_R_TYPE (info)) + { + case R_IA64_PCREL64LSB: + case R_IA64_LDXMOV: + case R_IA64_PCREL21B: + case R_IA64_LTOFF_FPTR22: + case R_IA64_LTOFF22X: + case R_IA64_LTOFF22: + case R_IA64_GPREL22: + case R_IA64_SEGREL64LSB: + break; + + case R_IA64_FPTR64LSB: + case R_IA64_DIR64LSB: +#if 1 + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, + 0, ctx->current_address, + image_target); + } +#endif + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + case EM_AARCH64: + switch (ELF_R_TYPE (info)) + { + case R_AARCH64_ABS64: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, 0, ctx->current_address, + image_target); + } + break; + /* Relative relocations do not require fixup entries. */ + case R_AARCH64_CALL26: + case R_AARCH64_JUMP26: + break; + /* Page-relative relocations do not require fixup entries. */ + case R_AARCH64_ADR_PREL_PG_HI21: + /* We page-align the whole kernel, so no need + for fixup entries. + */ + case R_AARCH64_ADD_ABS_LO12_NC: + case R_AARCH64_LDST64_ABS_LO12_NC: + break; + + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + break; +#if defined(MKIMAGE_ELF32) + case EM_ARM: + switch (ELF_R_TYPE (info)) + { + case R_ARM_V4BX: + /* Relative relocations do not require fixup entries. */ + case R_ARM_JUMP24: + case R_ARM_THM_CALL: + case R_ARM_THM_JUMP19: + case R_ARM_THM_JUMP24: + case R_ARM_CALL: + { + grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address); + } + break; + /* Create fixup entry for PE/COFF loader */ + case R_ARM_ABS32: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_HIGHLOW, + addr, 0, ctx->current_address, + image_target); + } + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; +#endif /* defined(MKIMAGE_ELF32) */ + default: + grub_util_error ("unknown machine type 0x%x", image_target->elf_target); + } +} + +static Elf_Addr +finish_reloc_translation (struct translate_context *ctx, void **out, + const struct grub_install_image_target_desc *image_target) +{ + ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); + + { + grub_uint8_t *ptr; + ptr = *out = xmalloc (ctx->current_address); + for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next) + if (ctx->lst->state) + { + memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size)); + ptr += grub_target_to_host32 (ctx->lst->b.block_size); + } + assert ((ctx->current_address + (grub_uint8_t *) *out) == ptr); + } + + for (ctx->lst = ctx->lst0; ctx->lst; ) + { + struct fixup_block_list *next; + next = ctx->lst->next; + free (ctx->lst); + ctx->lst = next; + } + + return ctx->current_address; +} + +static void +translate_reloc_jumpers (struct translate_context *ctx, + Elf_Addr jumpers, grub_size_t njumpers, + const struct grub_install_image_target_desc *image_target) +{ + unsigned i; + for (i = 0; i < njumpers; i++) + ctx->current_address = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + jumpers + 8 * i, + 0, ctx->current_address, + image_target); +} + /* Make a .reloc section. */ static Elf_Addr -SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, - Elf_Addr *section_addresses, Elf_Shdr *sections, - Elf_Half section_entsize, Elf_Half num_sections, - const char *strtab, - Elf_Addr jumpers, grub_size_t njumpers, - const struct grub_install_image_target_desc *image_target) +make_reloc_section (Elf_Ehdr *e, void **out, + Elf_Addr *section_addresses, Elf_Shdr *sections, + Elf_Half section_entsize, Elf_Half num_sections, + const char *strtab, + Elf_Addr jumpers, grub_size_t njumpers, + const struct grub_install_image_target_desc *image_target) { unsigned i; Elf_Shdr *s; - struct fixup_block_list *lst, *lst0; - Elf_Addr current_address = 0; + struct translate_context ctx; - lst = lst0 = xmalloc (sizeof (*lst) + 2 * 0x1000); - memset (lst, 0, sizeof (*lst) + 2 * 0x1000); + translate_reloc_start (&ctx); for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) @@ -1231,199 +1431,22 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, { Elf_Addr info; Elf_Addr offset; + Elf_Addr addr; offset = grub_target_to_host (r->r_offset); info = grub_target_to_host (r->r_info); - /* Necessary to relocate only absolute addresses. */ - switch (image_target->elf_target) - { - case EM_386: - if (ELF_R_TYPE (info) == R_386_32) - { - Elf_Addr addr; + addr = section_address + offset; - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_HIGHLOW, - addr, 0, current_address, - image_target); - } - break; - case EM_X86_64: - if ((ELF_R_TYPE (info) == R_X86_64_32) || - (ELF_R_TYPE (info) == R_X86_64_32S)) - { - grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)"); - } - else if (ELF_R_TYPE (info) == R_X86_64_64) - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, - 0, current_address, - image_target); - } - break; - case EM_IA_64: - switch (ELF_R_TYPE (info)) - { - case R_IA64_PCREL64LSB: - case R_IA64_LDXMOV: - case R_IA64_PCREL21B: - case R_IA64_LTOFF_FPTR22: - case R_IA64_LTOFF22X: - case R_IA64_LTOFF22: - case R_IA64_GPREL22: - case R_IA64_SEGREL64LSB: - break; - - case R_IA64_FPTR64LSB: - case R_IA64_DIR64LSB: -#if 1 - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, - 0, current_address, - image_target); - } -#endif - break; - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; - case EM_AARCH64: - switch (ELF_R_TYPE (info)) - { - case R_AARCH64_ABS64: - { - Elf_Addr addr; - - addr = section_address + offset; - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, 0, current_address, - image_target); - } - break; - /* Relative relocations do not require fixup entries. */ - case R_AARCH64_CALL26: - case R_AARCH64_JUMP26: - break; - /* Page-relative relocations do not require fixup entries. */ - case R_AARCH64_ADR_PREL_PG_HI21: - /* We page-align the whole kernel, so no need - for fixup entries. - */ - case R_AARCH64_ADD_ABS_LO12_NC: - case R_AARCH64_LDST64_ABS_LO12_NC: - break; - - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; - break; -#if defined(MKIMAGE_ELF32) - case EM_ARM: - switch (ELF_R_TYPE (info)) - { - case R_ARM_V4BX: - /* Relative relocations do not require fixup entries. */ - case R_ARM_JUMP24: - case R_ARM_THM_CALL: - case R_ARM_THM_JUMP19: - case R_ARM_THM_JUMP24: - case R_ARM_CALL: - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) current_address); - } - break; - /* Create fixup entry for PE/COFF loader */ - case R_ARM_ABS32: - { - Elf_Addr addr; - - addr = section_address + offset; - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_HIGHLOW, - addr, 0, current_address, - image_target); - } - break; - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; -#endif /* defined(MKIMAGE_ELF32) */ - default: - grub_util_error ("unknown machine type 0x%x", image_target->elf_target); - } + translate_relocation (&ctx, addr, info, image_target); } } if (image_target->elf_target == EM_IA_64) - for (i = 0; i < njumpers; i++) - current_address = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - jumpers + 8 * i, - 0, current_address, - image_target); + translate_reloc_jumpers (&ctx, jumpers, njumpers, + image_target); - current_address = SUFFIX (add_fixup_entry) (&lst, 0, 0, 1, current_address, image_target); - - { - grub_uint8_t *ptr; - ptr = *out = xmalloc (current_address); - for (lst = lst0; lst; lst = lst->next) - if (lst->state) - { - memcpy (ptr, &lst->b, grub_target_to_host32 (lst->b.block_size)); - ptr += grub_target_to_host32 (lst->b.block_size); - } - assert ((current_address + (grub_uint8_t *) *out) == ptr); - } - - for (lst = lst0; lst; ) - { - struct fixup_block_list *next; - next = lst->next; - free (lst); - lst = next; - } - - return current_address; + return finish_reloc_translation (&ctx, out, image_target); } /* Determine if this section is a text section. Return false if this From 73a9c742fe15ab62b3a828f6600556b142f71f93 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 19 Feb 2016 01:49:53 +0100 Subject: [PATCH 0545/1167] Encapsulate image layout into a separate structure. Currently we pass around a lot of pointer. Instead put all relevant data into one structure. --- include/grub/util/mkimage.h | 32 ++++++---- util/grub-mkimagexx.c | 116 ++++++++++++++++++------------------ util/mkimage.c | 112 +++++++++++++++++----------------- 3 files changed, 133 insertions(+), 127 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 564adbce7..8169939a7 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -19,20 +19,32 @@ #ifndef GRUB_UTIL_MKIMAGE_HEADER #define GRUB_UTIL_MKIMAGE_HEADER 1 +struct grub_mkimage_layout +{ + size_t exec_size; + size_t kernel_size; + size_t bss_size; + grub_uint64_t start_address; + void *reloc_section; + size_t reloc_size; + size_t align; + grub_size_t ia64jmp_off; + grub_size_t tramp_off; + grub_size_t ia64_got_off; + grub_size_t got_size; + unsigned ia64jmpnum; +}; + /* Private header. Use only in mkimage-related sources. */ char * -grub_mkimage_load_image32 (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +grub_mkimage_load_image32 (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target); char * -grub_mkimage_load_image64 (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +grub_mkimage_load_image64 (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target); void grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a39803a06..74f86f5df 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1346,22 +1346,23 @@ translate_relocation (struct translate_context *ctx, } } -static Elf_Addr -finish_reloc_translation (struct translate_context *ctx, void **out, +static void +finish_reloc_translation (struct translate_context *ctx, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); { grub_uint8_t *ptr; - ptr = *out = xmalloc (ctx->current_address); + layout->reloc_section = ptr = xmalloc (ctx->current_address); for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next) if (ctx->lst->state) { memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size)); ptr += grub_target_to_host32 (ctx->lst->b.block_size); } - assert ((ctx->current_address + (grub_uint8_t *) *out) == ptr); + assert ((ctx->current_address + (grub_uint8_t *) layout->reloc_section) == ptr); } for (ctx->lst = ctx->lst0; ctx->lst; ) @@ -1372,7 +1373,7 @@ finish_reloc_translation (struct translate_context *ctx, void **out, ctx->lst = next; } - return ctx->current_address; + layout->reloc_size = ctx->current_address; } static void @@ -1390,8 +1391,8 @@ translate_reloc_jumpers (struct translate_context *ctx, } /* Make a .reloc section. */ -static Elf_Addr -make_reloc_section (Elf_Ehdr *e, void **out, +static void +make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Addr *section_addresses, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, @@ -1446,7 +1447,7 @@ make_reloc_section (Elf_Ehdr *e, void **out, translate_reloc_jumpers (&ctx, jumpers, njumpers, image_target); - return finish_reloc_translation (&ctx, out, image_target); + finish_reloc_translation (&ctx, layout, image_target); } /* Determine if this section is a text section. Return false if this @@ -1498,8 +1499,7 @@ static Elf_Addr * SUFFIX (locate_sections) (const char *kernel_path, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, - size_t *exec_size, size_t *kernel_sz, - size_t *all_align, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { int i; @@ -1507,10 +1507,10 @@ SUFFIX (locate_sections) (const char *kernel_path, Elf_Addr *section_addresses; Elf_Shdr *s; - *all_align = 1; + layout->align = 1; /* Page-aligning simplifies relocation handling. */ if (image_target->elf_target == EM_AARCH64) - *all_align = 4096; + layout->align = 4096; section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); @@ -1521,8 +1521,8 @@ SUFFIX (locate_sections) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) - && grub_host_to_target32 (s->sh_addralign) > *all_align) - *all_align = grub_host_to_target32 (s->sh_addralign); + && grub_host_to_target32 (s->sh_addralign) > layout->align) + layout->align = grub_host_to_target32 (s->sh_addralign); /* .text */ @@ -1562,7 +1562,7 @@ SUFFIX (locate_sections) (const char *kernel_path, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *exec_size = current_address; + layout->exec_size = current_address; /* .data */ for (i = 0, s = sections; @@ -1590,16 +1590,14 @@ SUFFIX (locate_sections) (const char *kernel_path, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *kernel_sz = current_address; + layout->kernel_size = current_address; return section_addresses; } char * -SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; @@ -1614,12 +1612,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, Elf_Off section_offset; Elf_Half section_entsize; grub_size_t kernel_size; - grub_size_t ia64jmp_off = 0, tramp_off = 0, ia64_got_off = 0; - unsigned ia64jmpnum = 0; Elf_Shdr *symtab_section = 0; - grub_size_t got = 0; - *start = 0; + grub_memset (layout, 0, sizeof (*layout)); + + layout->start_address = 0; kernel_size = grub_util_get_image_size (kernel_path); kernel_img = xmalloc (kernel_size); @@ -1646,7 +1643,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, section_addresses = SUFFIX (locate_sections) (kernel_path, sections, section_entsize, num_sections, strtab, - exec_size, kernel_sz, align, + layout, image_target); section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections); @@ -1656,7 +1653,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, if (image_target->id != IMAGE_EFI) { - Elf_Addr current_address = *kernel_sz; + Elf_Addr current_address = layout->kernel_size; for (i = 0, s = sections; i < num_sections; @@ -1686,15 +1683,15 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *bss_size = current_address - *kernel_sz; + layout->bss_size = current_address - layout->kernel_size; } else - *bss_size = 0; + layout->bss_size = 0; if (image_target->id == IMAGE_SPARC64_AOUT || image_target->id == IMAGE_SPARC64_RAW || image_target->id == IMAGE_SPARC64_CDCORE) - *kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align); + layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); if (image_target->id == IMAGE_EFI) { @@ -1715,13 +1712,13 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, { grub_size_t tramp; - *kernel_sz = ALIGN_UP (*kernel_sz, 16); + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); tramp = arm_get_trampoline_size (e, sections, section_entsize, num_sections, image_target); - tramp_off = *kernel_sz; - *kernel_sz += ALIGN_UP (tramp, 16); + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); } #endif @@ -1730,61 +1727,62 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, { grub_size_t tramp; - *kernel_sz = ALIGN_UP (*kernel_sz, 16); + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - grub_ia64_dl_get_tramp_got_size (e, &tramp, &got); + grub_ia64_dl_get_tramp_got_size (e, &tramp, &layout->got_size); - tramp_off = *kernel_sz; - *kernel_sz += ALIGN_UP (tramp, 16); + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); - ia64jmp_off = *kernel_sz; - ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, + layout->ia64jmp_off = layout->kernel_size; + layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, image_target); - *kernel_sz += 16 * ia64jmpnum; + layout->kernel_size += 16 * layout->ia64jmpnum; - ia64_got_off = *kernel_sz; - *kernel_sz += ALIGN_UP (got, 16); + layout->ia64_got_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif } else { - *reloc_size = 0; - *reloc_section = NULL; + layout->reloc_size = 0; + layout->reloc_section = NULL; } - out_img = xmalloc (*kernel_sz + total_module_size); - memset (out_img, 0, *kernel_sz + total_module_size); + out_img = xmalloc (layout->kernel_size + total_module_size); + memset (out_img, 0, layout->kernel_size + total_module_size); if (image_target->id == IMAGE_EFI) { - *start = SUFFIX (relocate_symbols) (e, sections, symtab_section, + layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, section_vaddresses, section_entsize, num_sections, - (char *) out_img + ia64jmp_off, - ia64jmp_off + (char *) out_img + layout->ia64jmp_off, + layout->ia64jmp_off + image_target->vaddr_offset, image_target); - if (*start == 0) + if (layout->start_address == 0) grub_util_error ("start symbol is not defined"); - SUFFIX (entry_point) = (Elf_Addr) *start; + SUFFIX (entry_point) = (Elf_Addr) layout->start_address; /* Resolve addresses in the virtual address space. */ SUFFIX (relocate_addresses) (e, sections, section_addresses, section_entsize, num_sections, strtab, - out_img, tramp_off, ia64_got_off, + out_img, layout->tramp_off, + layout->ia64_got_off, image_target); - *reloc_size = SUFFIX (make_reloc_section) (e, reloc_section, - section_vaddresses, sections, - section_entsize, num_sections, - strtab, ia64jmp_off - + image_target->vaddr_offset, - 2 * ia64jmpnum + (got / 8), - image_target); + make_reloc_section (e, layout, + section_vaddresses, sections, + section_entsize, num_sections, + strtab, layout->ia64jmp_off + + image_target->vaddr_offset, + 2 * layout->ia64jmpnum + (layout->got_size / 8), + image_target); } for (i = 0, s = sections; diff --git a/util/mkimage.c b/util/mkimage.c index 86bb78190..ab58d34c0 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -742,17 +742,14 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_compression_t comp) { char *kernel_img, *core_img; - size_t kernel_size, total_module_size, core_size, exec_size; + size_t total_module_size, core_size; size_t memdisk_size = 0, config_size = 0; size_t prefix_size = 0; char *kernel_path; size_t offset; struct grub_util_path_list *path_list, *p; - size_t bss_size; - grub_uint64_t start_address; - void *rel_section = 0; - size_t reloc_size = 0, align; size_t decompress_size = 0; + struct grub_mkimage_layout layout; if (comp == GRUB_COMPRESSION_AUTO) comp = image_target->default_compression; @@ -814,15 +811,13 @@ grub_install_generate_image (const char *dir, const char *prefix, (unsigned long long) total_module_size); if (image_target->voidp_sizeof == 4) - kernel_img = grub_mkimage_load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image32 (kernel_path, total_module_size, + &layout, image_target); else - kernel_img = grub_mkimage_load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); - if (image_target->id == IMAGE_XEN && align < 4096) - align = 4096; + kernel_img = grub_mkimage_load_image64 (kernel_path, total_module_size, + &layout, image_target); + if (image_target->id == IMAGE_XEN && layout.align < 4096) + layout.align = 4096; if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS) && (image_target->total_module_size != TARGET_NO_FIELD)) @@ -831,7 +826,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) { - memmove (kernel_img + total_module_size, kernel_img, kernel_size); + memmove (kernel_img + total_module_size, kernel_img, layout.kernel_size); memset (kernel_img, 0, total_module_size); } @@ -842,14 +837,14 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) modinfo = (struct grub_module_info64 *) kernel_img; else - modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size); + modinfo = (struct grub_module_info64 *) (kernel_img + layout.kernel_size); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64)); modinfo->size = grub_host_to_target_addr (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) offset = sizeof (struct grub_module_info64); else - offset = kernel_size + sizeof (struct grub_module_info64); + offset = layout.kernel_size + sizeof (struct grub_module_info64); } else { @@ -858,14 +853,14 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) modinfo = (struct grub_module_info32 *) kernel_img; else - modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size); + modinfo = (struct grub_module_info32 *) (kernel_img + layout.kernel_size); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32)); modinfo->size = grub_host_to_target_addr (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) offset = sizeof (struct grub_module_info32); else - offset = kernel_size + sizeof (struct grub_module_info32); + offset = layout.kernel_size + sizeof (struct grub_module_info32); } for (p = path_list; p; p = p->next) @@ -944,8 +939,8 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_util_info ("kernel_img=%p, kernel_size=0x%" GRUB_HOST_PRIxLONG_LONG, kernel_img, - (unsigned long long) kernel_size); - compress_kernel (image_target, kernel_img, kernel_size + total_module_size, + (unsigned long long) layout.kernel_size); + compress_kernel (image_target, kernel_img, layout.kernel_size + total_module_size, &core_img, &core_size, comp); free (kernel_img); @@ -997,7 +992,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->decompressor_uncompressed_size != TARGET_NO_FIELD) *((grub_uint32_t *) (decompress_img + image_target->decompressor_uncompressed_size)) - = grub_host_to_target32 (kernel_size + total_module_size); + = grub_host_to_target32 (layout.kernel_size + total_module_size); if (image_target->decompressor_uncompressed_addr != TARGET_NO_FIELD) { @@ -1030,16 +1025,17 @@ grub_install_generate_image (const char *dir, const char *prefix, case IMAGE_I386_PC_ELTORITO: if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > 0x78000 || (core_size > (0xffff << GRUB_DISK_SECTOR_BITS)) - || (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)) + || (layout.kernel_size + layout.bss_size + + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)) grub_util_error (_("core image is too big (0x%x > 0x%x)"), GRUB_KERNEL_I386_PC_LINK_ADDR + (unsigned) core_size, 0x78000); /* fallthrough */ case IMAGE_COREBOOT: case IMAGE_QEMU: - if (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) + if (layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) grub_util_error (_("kernel image is too big (0x%x > 0x%x)"), - (unsigned) kernel_size + (unsigned) bss_size + (unsigned) layout.kernel_size + (unsigned) layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR, 0x68000); break; @@ -1161,13 +1157,13 @@ grub_install_generate_image (const char *dir, const char *prefix, reloc_addr = ALIGN_UP (header_size + core_size, image_target->section_align); - pe_size = ALIGN_UP (reloc_addr + reloc_size, + pe_size = ALIGN_UP (reloc_addr + layout.reloc_size, image_target->section_align); - pe_img = xmalloc (reloc_addr + reloc_size); + pe_img = xmalloc (reloc_addr + layout.reloc_size); memset (pe_img, 0, header_size); memcpy ((char *) pe_img + header_size, core_img, core_size); memset ((char *) pe_img + header_size + core_size, 0, reloc_addr - (header_size + core_size)); - memcpy ((char *) pe_img + reloc_addr, rel_section, reloc_size); + memcpy ((char *) pe_img + reloc_addr, layout.reloc_section, layout.reloc_size); header = pe_img; /* The magic. */ @@ -1201,14 +1197,14 @@ grub_install_generate_image (const char *dir, const char *prefix, (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE + sizeof (struct grub_pe32_coff_header)); o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC); - o->code_size = grub_host_to_target32 (exec_size); - o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size + o->code_size = grub_host_to_target32 (layout.exec_size); + o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size - header_size); - o->bss_size = grub_cpu_to_le32 (bss_size); - o->entry_addr = grub_cpu_to_le32 (start_address); + o->bss_size = grub_cpu_to_le32 (layout.bss_size); + o->entry_addr = grub_cpu_to_le32 (layout.start_address); o->code_base = grub_cpu_to_le32 (header_size); - o->data_base = grub_host_to_target32 (header_size + exec_size); + o->data_base = grub_host_to_target32 (header_size + layout.exec_size); o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); @@ -1226,7 +1222,7 @@ grub_install_generate_image (const char *dir, const char *prefix, o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES); o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr); - o->base_relocation_table.size = grub_host_to_target32 (reloc_size); + o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size); sections = o + 1; } else @@ -1239,11 +1235,11 @@ grub_install_generate_image (const char *dir, const char *prefix, (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE + sizeof (struct grub_pe32_coff_header)); o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC); - o->code_size = grub_host_to_target32 (exec_size); - o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size + o->code_size = grub_host_to_target32 (layout.exec_size); + o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size - header_size); - o->bss_size = grub_cpu_to_le32 (bss_size); - o->entry_addr = grub_cpu_to_le32 (start_address); + o->bss_size = grub_cpu_to_le32 (layout.bss_size); + o->entry_addr = grub_cpu_to_le32 (layout.start_address); o->code_base = grub_cpu_to_le32 (header_size); o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); @@ -1262,15 +1258,15 @@ grub_install_generate_image (const char *dir, const char *prefix, = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES); o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr); - o->base_relocation_table.size = grub_host_to_target32 (reloc_size); + o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size); sections = o + 1; } /* The sections. */ text_section = sections; strcpy (text_section->name, ".text"); - text_section->virtual_size = grub_cpu_to_le32 (exec_size); + text_section->virtual_size = grub_cpu_to_le32 (layout.exec_size); text_section->virtual_address = grub_cpu_to_le32 (header_size); - text_section->raw_data_size = grub_cpu_to_le32 (exec_size); + text_section->raw_data_size = grub_cpu_to_le32 (layout.exec_size); text_section->raw_data_offset = grub_cpu_to_le32 (header_size); text_section->characteristics = grub_cpu_to_le32_compile_time ( GRUB_PE32_SCN_CNT_CODE @@ -1279,10 +1275,10 @@ grub_install_generate_image (const char *dir, const char *prefix, data_section = text_section + 1; strcpy (data_section->name, ".data"); - data_section->virtual_size = grub_cpu_to_le32 (kernel_size - exec_size); - data_section->virtual_address = grub_cpu_to_le32 (header_size + exec_size); - data_section->raw_data_size = grub_cpu_to_le32 (kernel_size - exec_size); - data_section->raw_data_offset = grub_cpu_to_le32 (header_size + exec_size); + data_section->virtual_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size); + data_section->virtual_address = grub_cpu_to_le32 (header_size + layout.exec_size); + data_section->raw_data_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size); + data_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.exec_size); data_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ @@ -1291,8 +1287,8 @@ grub_install_generate_image (const char *dir, const char *prefix, #if 0 bss_section = data_section + 1; strcpy (bss_section->name, ".bss"); - bss_section->virtual_size = grub_cpu_to_le32 (bss_size); - bss_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size); + bss_section->virtual_size = grub_cpu_to_le32 (layout.bss_size); + bss_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size); bss_section->raw_data_size = 0; bss_section->raw_data_offset = 0; bss_section->characteristics @@ -1305,10 +1301,10 @@ grub_install_generate_image (const char *dir, const char *prefix, mods_section = data_section + 1; strcpy (mods_section->name, "mods"); - mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size); - mods_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size + bss_size); - mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size); - mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + kernel_size); + mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size); + mods_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size + layout.bss_size); + mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size); + mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.kernel_size); mods_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ @@ -1316,9 +1312,9 @@ grub_install_generate_image (const char *dir, const char *prefix, reloc_section = mods_section + 1; strcpy (reloc_section->name, ".reloc"); - reloc_section->virtual_size = grub_cpu_to_le32 (reloc_size); - reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + bss_size); - reloc_section->raw_data_size = grub_cpu_to_le32 (reloc_size); + reloc_section->virtual_size = grub_cpu_to_le32 (layout.reloc_size); + reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + layout.bss_size); + reloc_section->raw_data_size = grub_cpu_to_le32 (layout.reloc_size); reloc_section->raw_data_offset = grub_cpu_to_le32 (reloc_addr); reloc_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA @@ -1589,7 +1585,7 @@ grub_install_generate_image (const char *dir, const char *prefix, target_addr = (image_target->link_addr - decompress_size); else target_addr = ALIGN_UP (image_target->link_addr - + kernel_size + total_module_size, 32); + + layout.kernel_size + total_module_size, 32); ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section)); grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section)); @@ -1636,16 +1632,16 @@ grub_install_generate_image (const char *dir, const char *prefix, target_addr = (image_target->link_addr - decompress_size); else target_addr = ALIGN_UP (image_target->link_addr - + kernel_size + total_module_size, 32); + + layout.kernel_size + total_module_size, 32); } else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + target_addr, layout.align, layout.kernel_size, layout.bss_size); else grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + target_addr, layout.align, layout.kernel_size, layout.bss_size); } break; } @@ -1653,7 +1649,7 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_util_write_image (core_img, core_size, out, outname); free (core_img); free (kernel_path); - free (rel_section); + free (layout.reloc_section); grub_util_free_path_list (path_list); } From df21fff50456c6db9f487af0a3383e9e365595af Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:57:21 +0100 Subject: [PATCH 0546/1167] Provide __bss_start and _end symbols in grub-mkimage. For this ensure that all bss sections are merged. We need this to correctly prelink non-PE relocatable images. --- include/grub/util/mkimage.h | 2 + util/grub-mkimagexx.c | 137 +++++++++++++++++++++++------------- 2 files changed, 89 insertions(+), 50 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 8169939a7..25a49d5c3 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -33,6 +33,8 @@ struct grub_mkimage_layout grub_size_t ia64_got_off; grub_size_t got_size; unsigned ia64jmpnum; + Elf_Addr bss_start; + Elf_Addr end; }; /* Private header. Use only in mkimage-related sources. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 74f86f5df..433322d85 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -490,6 +490,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Shdr *symtab_section, Elf_Addr *section_addresses, Elf_Half section_entsize, Elf_Half num_sections, void *jumpers, Elf_Addr jumpers_addr, + Elf_Addr bss_start, Elf_Addr end, const struct grub_install_image_target_desc *image_target) { Elf_Word symtab_size, sym_size, num_syms; @@ -528,16 +529,22 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, } else if (cur_index == STN_UNDEF) { - if (sym->st_name) + if (sym->st_name && grub_strcmp (name, "__bss_start")) + sym->st_value = bss_start; + else if (sym->st_name && grub_strcmp (name, "__end")) + sym->st_value = end; + else if (sym->st_name) grub_util_error ("undefined symbol %s", name); else continue; } else if (cur_index >= num_sections) grub_util_error ("section %d does not exist", cur_index); - - sym->st_value = (grub_target_to_host (sym->st_value) - + section_addresses[cur_index]); + else + { + sym->st_value = (grub_target_to_host (sym->st_value) + + section_addresses[cur_index]); + } if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info) == STT_FUNC) @@ -1462,9 +1469,7 @@ SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_de == (SHF_EXECINSTR | SHF_ALLOC)); } -/* Determine if this section is a data section. This assumes that - BSS is also a data section, since the converter initializes BSS - when producing PE32 to avoid a bug in EFI implementations. */ +/* Determine if this section is a data section. */ static int SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { @@ -1472,7 +1477,16 @@ SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_de && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) - == SHF_ALLOC); + == SHF_ALLOC) && !(grub_target_to_host32 (s->sh_type) == SHT_NOBITS); +} + +static int +SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) +{ + if (!is_relocatable (image_target)) + return 0; + return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) + == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS); } /* Return if the ELF header is valid. */ @@ -1492,6 +1506,32 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i return 1; } +static Elf_Addr +SUFFIX (put_section) (Elf_Shdr *s, int i, + Elf_Addr current_address, + Elf_Addr *section_addresses, + const char *strtab, + const struct grub_install_image_target_desc *image_target) +{ + Elf_Word align = grub_host_to_target_addr (s->sh_addralign); + const char *name = strtab + grub_host_to_target32 (s->sh_name); + + if (align) + current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + align) + - image_target->vaddr_offset; + + grub_util_info ("locating the section %s at 0x%" + GRUB_HOST_PRIxLONG_LONG, + name, (unsigned long long) current_address); + if (!is_relocatable (image_target)) + current_address = grub_host_to_target_addr (s->sh_addr) + - image_target->link_addr; + section_addresses[i] = current_address; + current_address += grub_host_to_target_addr (s->sh_size); + return current_address; +} + /* Locate section addresses by merging code sections and data sections into .text and .data, respectively. Return the array of section addresses. */ @@ -1531,32 +1571,22 @@ SUFFIX (locate_sections) (const char *kernel_path, i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_text_section) (s, image_target)) { - Elf_Word align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); - if (align) - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - align) - image_target->vaddr_offset; - grub_util_info ("locating the section %s at 0x%" - GRUB_HOST_PRIxLONG_LONG, - name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); + if (!is_relocatable (image_target) && + grub_host_to_target_addr (s->sh_addr) != image_target->link_addr) { - current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - if (grub_host_to_target_addr (s->sh_addr) - != image_target->link_addr) - { - char *msg - = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx" - " instead of 0x%llx: ld.gold bug?"), - kernel_path, - (unsigned long long) grub_host_to_target_addr (s->sh_addr), - (unsigned long long) image_target->link_addr); - grub_util_error ("%s", msg); - } + char *msg + = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx" + " instead of 0x%llx: ld.gold bug?"), + kernel_path, + (unsigned long long) grub_host_to_target_addr (s->sh_addr), + (unsigned long long) image_target->link_addr); + grub_util_error ("%s", msg); } - section_addresses[i] = current_address; - current_address += grub_host_to_target_addr (s->sh_size); } current_address = ALIGN_UP (current_address + image_target->vaddr_offset, @@ -1569,27 +1599,31 @@ SUFFIX (locate_sections) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target)) - { - Elf_Word align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); - - if (align) - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - align) - - image_target->vaddr_offset; - - grub_util_info ("locating the section %s at 0x%" - GRUB_HOST_PRIxLONG_LONG, - name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) - current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - section_addresses[i] = current_address; - current_address += grub_host_to_target_addr (s->sh_size); - } + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; + + layout->bss_start = current_address; + + /* .bss */ + for (i = 0, s = sections; + i < num_sections; + i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + if (SUFFIX (is_bss_section) (s, image_target)) + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); + + current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + image_target->section_align) - image_target->vaddr_offset; + layout->end = current_address; layout->kernel_size = current_address; return section_addresses; } @@ -1789,8 +1823,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target) + || SUFFIX (is_bss_section) (s, image_target) || SUFFIX (is_text_section) (s, image_target)) { + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. */ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) memset (out_img + section_addresses[i], 0, grub_host_to_target_addr (s->sh_size)); From 5bcb7d394c26d212cebf59c9b70a42a11f90d2bc Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:58:38 +0100 Subject: [PATCH 0547/1167] Allow _start == 0 with relocatable images --- util/grub-mkimagexx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 433322d85..fff811266 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -495,7 +495,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, { Elf_Word symtab_size, sym_size, num_syms; Elf_Off symtab_offset; - Elf_Addr start_address = 0; + Elf_Addr start_address = (Elf_Addr) -1; Elf_Sym *sym; Elf_Word i; Elf_Shdr *strtab_section; @@ -560,7 +560,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, (unsigned long long) sym->st_value, (unsigned long long) section_addresses[cur_index]); - if (! start_address) + if (start_address == (Elf_Addr)-1) if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) start_address = sym->st_value; } @@ -1797,7 +1797,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->ia64jmp_off + image_target->vaddr_offset, image_target); - if (layout->start_address == 0) + if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); SUFFIX (entry_point) = (Elf_Addr) layout->start_address; From 86ef66d977274051a9174437e97f923d9e97d9e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 19 Feb 2016 00:43:36 +0100 Subject: [PATCH 0548/1167] arm-uboot: Make self-relocatable to allow loading at any address --- grub-core/Makefile.core.def | 2 +- grub-core/kern/arm/uboot/startup.S | 60 +++++- include/grub/arm/uboot/kernel.h | 2 +- include/grub/offsets.h | 2 +- include/grub/util/mkimage.h | 5 +- util/grub-mkimagexx.c | 313 +++++++++++++++++++++++------ util/mkimage.c | 8 +- 7 files changed, 305 insertions(+), 87 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 887450110..58b4208b0 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -90,7 +90,7 @@ kernel = { i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; emu_cflags = '$(CFLAGS_GNULIB)'; emu_cppflags = '$(CPPFLAGS_GNULIB)'; - arm_uboot_ldflags = '-Wl,-Ttext=0x08000000'; + arm_uboot_ldflags = '-Wl,-r,-d'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; i386_pc_startup = kern/i386/pc/startup.S; diff --git a/grub-core/kern/arm/uboot/startup.S b/grub-core/kern/arm/uboot/startup.S index 0c4a5f670..5efaae16e 100644 --- a/grub-core/kern/arm/uboot/startup.S +++ b/grub-core/kern/arm/uboot/startup.S @@ -55,10 +55,6 @@ FUNCTION(_start) VARIABLE(grub_total_module_size) .long 0 -VARIABLE(grub_uboot_machine_type) - .long 0 -VARIABLE(grub_uboot_boot_data) - .long 0 VARIABLE(grub_modbase) .long 0 bss_start_ptr: @@ -66,29 +62,66 @@ bss_start_ptr: end_ptr: .long EXT_C(_end) + @ Memory map at start: + @ * text+data + @ * list relocations + @ * modules + @ Before we enter C, we need to apply the relocations + @ and get following map: + @ * text+data + @ * BSS (cleared) + @ * stack + @ * modules + @ + @ To make things easier we ensure + @ that BSS+stack is larger than list of relocations + @ by increasing stack if necessarry. + @ This allows us to always unconditionally copy backwards + @ Currently list of relocations is ~5K and stack is set + @ to be at least 256K + FUNCTION(codestart) @ Store context: Machine ID, atags/dtb, ... @ U-Boot API signature is stored on the U-Boot heap @ Stack pointer used as start address for signature probing mov r12, sp adr sp, entry_state - push {r4-r12,lr} @ store U-Boot context (sp in r12) + push {r1-r12,lr} @ store U-Boot context (sp in r12) - str r1, EXT_C(grub_uboot_machine_type) - str r2, EXT_C(grub_uboot_boot_data) - - @ Modules have been stored as a blob in BSS, - @ they need to be manually relocated to _end + adr r1, _start ldr r0, bss_start_ptr @ src + add r0, r0, r1 + + add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) + mvn r2, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) + and r0, r0, r2 +1: + ldr r3, [r0], #4 @load next offset + @ both -2 and -1 are treated the same as we have only one type of relocs + @ -2 means "end of this type of relocs" and -1 means "end of all relocs" + add r2, r3, #2 + cmp r2, #1 + bls reloc_done + @ Adjust next offset + ldr r2, [r3, r1] + add r2, r2, r1 + str r2, [r3, r1] + b 1b + +reloc_done: + + @ Modules have been stored as a blob + @ they need to be manually relocated to _end add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) - and r0, r0, r1 + and r0, r0, r1 @ src = aligned end of relocations ldr r1, end_ptr @ dst = End of BSS ldr r2, grub_total_module_size @ blob size add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE and r1, r1, #~0x7 @ Ensure 8-byte alignment + sub sp, r1, #8 add r1, r1, #1024 @@ -157,6 +190,11 @@ FUNCTION(grub_uboot_return) .align 3 @ U-boot context stack space entry_state_end: +VARIABLE(grub_uboot_machine_type) + .long 0 @ r1 +VARIABLE(grub_uboot_boot_data) + .long 0 @ r2 + .long 0 @ r3 .long 0 @ r4 .long 0 @ r5 .long 0 @ r6 diff --git a/include/grub/arm/uboot/kernel.h b/include/grub/arm/uboot/kernel.h index 06e543324..ce0b149cc 100644 --- a/include/grub/arm/uboot/kernel.h +++ b/include/grub/arm/uboot/kernel.h @@ -26,7 +26,7 @@ #endif /* ! ASM_FILE */ -#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000 +#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE #define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (16 * 1024 * 1024) #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ diff --git a/include/grub/offsets.h b/include/grub/offsets.h index 85e7401ae..c88c86d4d 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -54,6 +54,7 @@ /* The offset of GRUB_TOTAL_MODULE_SIZE. */ #define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8 +#define GRUB_KERNEL_ARM_STACK_SIZE 0x40000 #define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12 @@ -120,7 +121,6 @@ #define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 0x8 #define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE 0x4 -#define GRUB_KERNEL_ARM_UBOOT_LINK_ADDR 0x08000000 /* Minimal gap between _end and the start of the modules. It's a hack for PowerMac to prevent "CLAIM failed" error. The real fix is to diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 25a49d5c3..2a4894213 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -33,8 +33,8 @@ struct grub_mkimage_layout grub_size_t ia64_got_off; grub_size_t got_size; unsigned ia64jmpnum; - Elf_Addr bss_start; - Elf_Addr end; + grub_uint32_t bss_start; + grub_uint32_t end; }; /* Private header. Use only in mkimage-related sources. */ @@ -83,6 +83,7 @@ struct grub_install_image_target_desc unsigned decompressor_compressed_size; unsigned decompressor_uncompressed_size; unsigned decompressor_uncompressed_addr; + unsigned reloc_table_offset; unsigned link_align; grub_uint16_t elf_target; unsigned section_align; diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index fff811266..353a9407a 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -86,6 +86,12 @@ struct fixup_block_list #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) +static int +is_relocatable (const struct grub_install_image_target_desc *image_target) +{ + return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT; +} + #ifdef MKIMAGE_ELF32 /* @@ -529,9 +535,9 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, } else if (cur_index == STN_UNDEF) { - if (sym->st_name && grub_strcmp (name, "__bss_start")) + if (sym->st_name && grub_strcmp (name, "__bss_start") == 0) sym->st_value = bss_start; - else if (sym->st_name && grub_strcmp (name, "__end")) + else if (sym->st_name && grub_strcmp (name, "_end") == 0) sym->st_value = end; else if (sym->st_name) grub_util_error ("undefined symbol %s", name); @@ -1008,7 +1014,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_util_info (" ABS32:\toffset=%d\t(0x%08x)", (int) sym_addr, (int) sym_addr); /* Data will be naturally aligned */ - sym_addr += 0x400; + if (image_target->id == IMAGE_EFI) + sym_addr += 0x400; *target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr); } break; @@ -1194,25 +1201,45 @@ add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type, return current_address; } +struct raw_reloc +{ + struct raw_reloc *next; + grub_uint32_t offset; + enum raw_reloc_type { + RAW_RELOC_NONE = -1, + RAW_RELOC_32 = 0, + RAW_RELOC_MAX = 1, + } type; +}; + struct translate_context { + /* PE */ struct fixup_block_list *lst, *lst0; Elf_Addr current_address; + + /* Raw */ + struct raw_reloc *raw_relocs; }; static void -translate_reloc_start (struct translate_context *ctx) +translate_reloc_start (struct translate_context *ctx, + const struct grub_install_image_target_desc *image_target) { - ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); - memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); - ctx->current_address = 0; + grub_memset (ctx, 0, sizeof (*ctx)); + if (image_target->id == IMAGE_EFI) + { + ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); + memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); + ctx->current_address = 0; + } } static void -translate_relocation (struct translate_context *ctx, - Elf_Addr addr, - Elf_Addr info, - const struct grub_install_image_target_desc *image_target) +translate_relocation_pe (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) { /* Necessary to relocate only absolute addresses. */ switch (image_target->elf_target) @@ -1353,10 +1380,68 @@ translate_relocation (struct translate_context *ctx, } } +static enum raw_reloc_type +classify_raw_reloc (Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + /* Necessary to relocate only absolute addresses. */ + switch (image_target->elf_target) + { + case EM_ARM: + switch (ELF_R_TYPE (info)) + { + case R_ARM_V4BX: + case R_ARM_JUMP24: + case R_ARM_THM_CALL: + case R_ARM_THM_JUMP19: + case R_ARM_THM_JUMP24: + case R_ARM_CALL: + return RAW_RELOC_NONE; + case R_ARM_ABS32: + return RAW_RELOC_32; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + default: + grub_util_error ("unknown machine type 0x%x", image_target->elf_target); + } +} + static void -finish_reloc_translation (struct translate_context *ctx, - struct grub_mkimage_layout *layout, +translate_relocation_raw (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, const struct grub_install_image_target_desc *image_target) +{ + enum raw_reloc_type class = classify_raw_reloc (info, image_target); + struct raw_reloc *rel; + if (class == RAW_RELOC_NONE) + return; + rel = xmalloc (sizeof (*rel)); + rel->next = ctx->raw_relocs; + rel->type = class; + rel->offset = addr; + ctx->raw_relocs = rel; +} + +static void +translate_relocation (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + if (image_target->id == IMAGE_EFI) + translate_relocation_pe (ctx, addr, info, image_target); + else + translate_relocation_raw (ctx, addr, info, image_target); +} + +static void +finish_reloc_translation_pe (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) { ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); @@ -1381,14 +1466,90 @@ finish_reloc_translation (struct translate_context *ctx, } layout->reloc_size = ctx->current_address; + if (image_target->elf_target == EM_ARM && layout->reloc_size > GRUB_KERNEL_ARM_STACK_SIZE) + grub_util_error ("Reloc section (%d) is bigger than stack size (%d). " + "This breaks assembly assumptions. Please increase stack size", + (int) layout->reloc_size, + (int) GRUB_KERNEL_ARM_STACK_SIZE); } +/* + Layout: + + + + + ... + + + each relocation starts with 32-bit offset. Rest depends on relocation. + mkimage stops when it sees first unknown type or end marker. + This allows images to be created with mismatched mkimage and + kernel as long as no relocations are present in kernel that mkimage + isn't aware of (in which case mkimage aborts). + This also allows simple assembly to do the relocs. +*/ + +#define RAW_SEPARATOR 0xfffffffe +#define RAW_END_MARKER 0xffffffff + +static void +finish_reloc_translation_raw (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) +{ + size_t count = 0, sz; + enum raw_reloc_type highest = RAW_RELOC_NONE; + enum raw_reloc_type curtype; + struct raw_reloc *cur; + grub_uint32_t *p; + if (!ctx->raw_relocs) + { + layout->reloc_section = p = xmalloc (sizeof (grub_uint32_t)); + p[0] = RAW_END_MARKER; + layout->reloc_size = sizeof (grub_uint32_t); + return; + } + for (cur = ctx->raw_relocs; cur; cur = cur->next) + { + count++; + if (cur->type > highest) + highest = cur->type; + } + /* highest separators, count relocations and one end marker. */ + sz = (highest + count + 1) * sizeof (grub_uint32_t); + layout->reloc_section = p = xmalloc (sz); + for (curtype = 0; curtype <= highest; curtype++) + { + /* Support for special cases would go here. */ + for (cur = ctx->raw_relocs; cur; cur = cur->next) + if (cur->type == curtype) + { + *p++ = cur->offset; + } + *p++ = RAW_SEPARATOR; + } + *--p = RAW_END_MARKER; + layout->reloc_size = sz; +} + +static void +finish_reloc_translation (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) +{ + if (image_target->id == IMAGE_EFI) + finish_reloc_translation_pe (ctx, layout, image_target); + else + finish_reloc_translation_raw (ctx, layout, image_target); +} + + static void translate_reloc_jumpers (struct translate_context *ctx, Elf_Addr jumpers, grub_size_t njumpers, const struct grub_install_image_target_desc *image_target) { unsigned i; + assert (image_target->id == IMAGE_EFI); for (i = 0; i < njumpers; i++) ctx->current_address = add_fixup_entry (&ctx->lst, GRUB_PE32_REL_BASED_DIR64, @@ -1403,14 +1564,13 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Addr *section_addresses, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, - Elf_Addr jumpers, grub_size_t njumpers, const struct grub_install_image_target_desc *image_target) { unsigned i; Elf_Shdr *s; struct translate_context ctx; - translate_reloc_start (&ctx); + translate_reloc_start (&ctx, image_target); for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) @@ -1451,7 +1611,10 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, } if (image_target->elf_target == EM_IA_64) - translate_reloc_jumpers (&ctx, jumpers, njumpers, + translate_reloc_jumpers (&ctx, + layout->ia64jmp_off + + image_target->vaddr_offset, + 2 * layout->ia64jmpnum + (layout->got_size / 8), image_target); finish_reloc_translation (&ctx, layout, image_target); @@ -1462,7 +1625,7 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, static int SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { - if (image_target->id != IMAGE_EFI + if (!is_relocatable (image_target) && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) @@ -1473,7 +1636,7 @@ SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_de static int SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { - if (image_target->id != IMAGE_EFI + if (!is_relocatable (image_target) && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) @@ -1536,14 +1699,13 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, into .text and .data, respectively. Return the array of section addresses. */ static Elf_Addr * -SUFFIX (locate_sections) (const char *kernel_path, +SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { int i; - Elf_Addr current_address; Elf_Addr *section_addresses; Elf_Shdr *s; @@ -1555,7 +1717,7 @@ SUFFIX (locate_sections) (const char *kernel_path, section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); - current_address = 0; + layout->kernel_size = 0; for (i = 0, s = sections; i < num_sections; @@ -1571,8 +1733,8 @@ SUFFIX (locate_sections) (const char *kernel_path, i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_text_section) (s, image_target)) { - current_address = SUFFIX (put_section) (s, i, - current_address, + layout->kernel_size = SUFFIX (put_section) (s, i, + layout->kernel_size, section_addresses, strtab, image_target); @@ -1589,42 +1751,63 @@ SUFFIX (locate_sections) (const char *kernel_path, } } - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - layout->exec_size = current_address; + layout->exec_size = layout->kernel_size; /* .data */ for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target)) - current_address = SUFFIX (put_section) (s, i, - current_address, + layout->kernel_size = SUFFIX (put_section) (s, i, + layout->kernel_size, section_addresses, strtab, image_target); - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - image_target->section_align) - image_target->vaddr_offset; +#ifdef MKIMAGE_ELF32 + if (image_target->elf_target == EM_ARM) + { + grub_size_t tramp; + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, + image_target->section_align) - image_target->vaddr_offset; - layout->bss_start = current_address; + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); + + tramp = arm_get_trampoline_size (e, sections, section_entsize, + num_sections, image_target); + + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); + } +#endif + + layout->bss_start = layout->kernel_size; + layout->end = layout->kernel_size; /* .bss */ for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_bss_section) (s, image_target)) - current_address = SUFFIX (put_section) (s, i, - current_address, - section_addresses, - strtab, - image_target); + layout->end = SUFFIX (put_section) (s, i, + layout->end, + section_addresses, + strtab, + image_target); - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - layout->end = current_address; - layout->kernel_size = current_address; + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. + Platforms other than EFI and U-boot shouldn't have .bss in + their binaries as we build with -Wl,-Ttext. + */ + if (image_target->id != IMAGE_UBOOT) + layout->kernel_size = layout->end; + return section_addresses; } @@ -1674,7 +1857,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + grub_host_to_target16 (e->e_shstrndx) * section_entsize); strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - section_addresses = SUFFIX (locate_sections) (kernel_path, + section_addresses = SUFFIX (locate_sections) (e, kernel_path, sections, section_entsize, num_sections, strtab, layout, @@ -1685,7 +1868,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, for (i = 0; i < num_sections; i++) section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; - if (image_target->id != IMAGE_EFI) + if (!is_relocatable (image_target)) { Elf_Addr current_address = layout->kernel_size; @@ -1706,7 +1889,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + if (!is_relocatable (image_target)) current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; @@ -1724,10 +1907,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (image_target->id == IMAGE_SPARC64_AOUT || image_target->id == IMAGE_SPARC64_RAW + || image_target->id == IMAGE_UBOOT || image_target->id == IMAGE_SPARC64_CDCORE) layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); - if (image_target->id == IMAGE_EFI) + if (is_relocatable (image_target)) { symtab_section = NULL; for (i = 0, s = sections; @@ -1740,22 +1924,6 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, } if (! symtab_section) grub_util_error ("%s", _("no symbol table")); - -#ifdef MKIMAGE_ELF32 - if (image_target->elf_target == EM_ARM) - { - grub_size_t tramp; - - layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - - tramp = arm_get_trampoline_size (e, sections, section_entsize, - num_sections, image_target); - - layout->tramp_off = layout->kernel_size; - layout->kernel_size += ALIGN_UP (tramp, 16); - } -#endif - #ifdef MKIMAGE_ELF64 if (image_target->elf_target == EM_IA_64) { @@ -1770,14 +1938,13 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->ia64jmp_off = layout->kernel_size; layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, - image_target); + image_target); layout->kernel_size += 16 * layout->ia64jmpnum; layout->ia64_got_off = layout->kernel_size; layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif - } else { @@ -1788,7 +1955,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, out_img = xmalloc (layout->kernel_size + total_module_size); memset (out_img, 0, layout->kernel_size + total_module_size); - if (image_target->id == IMAGE_EFI) + if (is_relocatable (image_target)) { layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, section_vaddresses, section_entsize, @@ -1796,6 +1963,8 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, (char *) out_img + layout->ia64jmp_off, layout->ia64jmp_off + image_target->vaddr_offset, + layout->bss_start, + layout->end, image_target); if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); @@ -1813,21 +1982,31 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, make_reloc_section (e, layout, section_vaddresses, sections, section_entsize, num_sections, - strtab, layout->ia64jmp_off - + image_target->vaddr_offset, - 2 * layout->ia64jmpnum + (layout->got_size / 8), + strtab, image_target); + if (image_target->id != IMAGE_EFI) + { + out_img = xrealloc (out_img, layout->kernel_size + total_module_size + + ALIGN_UP (layout->reloc_size, image_target->mod_align)); + memcpy (out_img + layout->kernel_size, layout->reloc_section, layout->reloc_size); + memset (out_img + layout->kernel_size + layout->reloc_size, 0, + total_module_size + ALIGN_UP (layout->reloc_size, image_target->mod_align) - layout->reloc_size); + layout->kernel_size += ALIGN_UP (layout->reloc_size, image_target->mod_align); + } } for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target) - || SUFFIX (is_bss_section) (s, image_target) + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. + Platforms other than EFI and U-boot shouldn't have .bss in + their binaries as we build with -Wl,-Ttext. + */ + || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id != IMAGE_UBOOT)) || SUFFIX (is_text_section) (s, image_target)) { - /* Explicitly initialize BSS - when producing PE32 to avoid a bug in EFI implementations. */ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) memset (out_img + section_addresses[i], 0, grub_host_to_target_addr (s->sh_size)); diff --git a/util/mkimage.c b/util/mkimage.c index ab58d34c0..9ad4cfe42 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -88,6 +88,7 @@ static const struct grub_install_image_target_desc image_targets[] = .decompressor_compressed_size = TARGET_NO_FIELD, .decompressor_uncompressed_size = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .reloc_table_offset = TARGET_NO_FIELD, .section_align = 1, .vaddr_offset = 0, .link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR, @@ -527,7 +528,6 @@ static const struct grub_install_image_target_desc image_targets[] = .decompressor_uncompressed_addr = TARGET_NO_FIELD, .section_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, .vaddr_offset = 0, - .link_addr = GRUB_KERNEL_ARM_UBOOT_LINK_ADDR, .elf_target = EM_ARM, .mod_gap = GRUB_KERNEL_ARM_UBOOT_MOD_GAP, .mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, @@ -1522,9 +1522,9 @@ grub_install_generate_image (const char *dir, const char *prefix, hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC); hdr->ih_time = grub_cpu_to_be32 (STABLE_EMBEDDING_TIMESTAMP); hdr->ih_size = grub_cpu_to_be32 (core_size); - hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr); - hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr); - hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL; + hdr->ih_load = 0; + hdr->ih_ep = 0; + hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL_NOLOAD; hdr->ih_os = GRUB_UBOOT_IH_OS_LINUX; hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM; hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE; From 0f076d75d04d76ab83e8472715eec71da0cb55ff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 12:06:48 +0100 Subject: [PATCH 0549/1167] ehci: Fix memory coherence This is a no-op on x86 but necessarry on ARM and may be necessarry on MIPS. --- grub-core/bus/usb/ehci.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index ae1efb214..5f4297bb2 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -337,6 +338,21 @@ struct grub_ehci static struct grub_ehci *ehci; +static void +sync_all_caches (struct grub_ehci *e) +{ + if (!e) + return; + if (e->td_virt) + grub_arch_sync_dma_caches (e->td_virt, sizeof (struct grub_ehci_td) * + GRUB_EHCI_N_TD); + if (e->qh_virt) + grub_arch_sync_dma_caches (e->qh_virt, sizeof (struct grub_ehci_qh) * + GRUB_EHCI_N_QH); + if (e->framelist_virt) + grub_arch_sync_dma_caches (e->framelist_virt, 4096); +} + /* EHCC registers access functions */ static inline grub_uint32_t grub_ehci_ehcc_read32 (struct grub_ehci *e, grub_uint32_t addr) @@ -437,6 +453,8 @@ grub_ehci_reset (struct grub_ehci *e) { grub_uint64_t maxtime; + sync_all_caches (e); + grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, GRUB_EHCI_CMD_HC_RESET | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); @@ -840,6 +858,8 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, e->next = ehci; ehci = e; + sync_all_caches (e); + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n"); grub_dprintf ("ehci", @@ -1020,6 +1040,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer) /* Found proper existing (and linked) QH, do setup of QH */ grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter); grub_ehci_setup_qh (qh_iter, transfer); + sync_all_caches (e); return qh_iter; } @@ -1291,6 +1312,8 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, struct grub_ehci_transfer_controller_data *cdata; grub_uint32_t status; + sync_all_caches (e); + /* Check if EHCI is running and AL is enabled */ status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); if ((status & GRUB_EHCI_ST_HC_HALTED) != 0) @@ -1399,6 +1422,8 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, * i.e. reset token */ cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0); + sync_all_caches (e); + /* Finito */ transfer->controller_data = cdata; @@ -1447,6 +1472,8 @@ grub_ehci_parse_notrun (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + /* Additionally, do something with EHCI to make it running (what?) */ /* Try enable EHCI and AL */ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, @@ -1482,6 +1509,8 @@ grub_ehci_parse_halt (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + /* Evaluation of error code - currently we don't have GRUB USB error * codes for some EHCI states, GRUB_USB_ERR_DATA is used for them. * Order of evaluation is critical, specially bubble/stall. */ @@ -1515,6 +1544,8 @@ grub_ehci_parse_success (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + return GRUB_USB_ERR_NONE; } @@ -1528,6 +1559,8 @@ grub_ehci_check_transfer (grub_usb_controller_t dev, transfer->controller_data; grub_uint32_t token, token_ftd; + sync_all_caches (e); + grub_dprintf ("ehci", "check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n", grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS), @@ -1594,6 +1627,9 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, int i; grub_uint64_t maxtime; grub_uint32_t qh_phys; + + sync_all_caches (e); + grub_uint32_t interrupt = cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK; @@ -1613,6 +1649,7 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, grub_ehci_free_tds (e, cdata->td_first_virt, transfer, &actual); grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n"); return GRUB_USB_ERR_NONE; } @@ -1635,6 +1672,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, /* Unlink QH from AL */ e->qh_virt[i].qh_hptr = cdata->qh_virt->qh_hptr; + sync_all_caches (e); + /* If this is an interrupt transfer, we just wait for the periodic * schedule to advance a few times and then assume that the EHCI * controller has read the updated QH. */ @@ -1689,6 +1728,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, grub_dprintf ("ehci", "cancel_transfer: end\n"); + sync_all_caches (e); + return GRUB_USB_ERR_NONE; } From ca028db3d47387bbbd24b40f085751ca98a09183 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 12:07:01 +0100 Subject: [PATCH 0550/1167] usbtrans: Fix memory coherence and use-after-free. --- grub-core/bus/usb/usbtrans.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index ee8680853..9266e4931 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -24,6 +24,7 @@ #include #include #include +#include static inline unsigned int @@ -101,6 +102,8 @@ grub_usb_control_msg (grub_usb_device_t dev, data_addr = grub_dma_get_phys (data_chunk); grub_memcpy ((char *) data, data_in, size); + grub_arch_sync_dma_caches (data, size); + grub_dprintf ("usb", "control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n", reqtype, request, value, index, (unsigned long)size); @@ -161,6 +164,8 @@ grub_usb_control_msg (grub_usb_device_t dev, setupdata->value = value; setupdata->index = index; setupdata->length = size; + grub_arch_sync_dma_caches (setupdata, sizeof (*setupdata)); + transfer->transactions[0].size = sizeof (*setupdata); transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP; transfer->transactions[0].data = setupdata_addr; @@ -202,11 +207,13 @@ grub_usb_control_msg (grub_usb_device_t dev, grub_free (transfer->transactions); grub_free (transfer); - grub_dma_free (data_chunk); grub_dma_free (setupdata_chunk); + grub_arch_sync_dma_caches (data, size0); grub_memcpy (data_in, (char *) data, size0); + grub_dma_free (data_chunk); + return err; } @@ -236,7 +243,10 @@ grub_usb_bulk_setup_readwrite (grub_usb_device_t dev, data = grub_dma_get_virt (data_chunk); data_addr = grub_dma_get_phys (data_chunk); if (type == GRUB_USB_TRANSFER_TYPE_OUT) - grub_memcpy ((char *) data, data_in, size); + { + grub_memcpy ((char *) data, data_in, size); + grub_arch_sync_dma_caches (data, size); + } /* Create a transfer. */ transfer = grub_malloc (sizeof (struct grub_usb_transfer)); @@ -306,9 +316,13 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer) dev->toggle[transfer->endpoint] = toggle; if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN) - grub_memcpy (transfer->data, (void *) - grub_dma_get_virt (transfer->data_chunk), - transfer->size + 1); + { + grub_arch_sync_dma_caches (grub_dma_get_virt (transfer->data_chunk), + transfer->size + 1); + grub_memcpy (transfer->data, (void *) + grub_dma_get_virt (transfer->data_chunk), + transfer->size + 1); + } grub_free (transfer->transactions); grub_dma_free (transfer->data_chunk); From 51f375d688529b7c1819ba40188ee52b9333887c Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Sat, 27 Feb 2016 13:44:59 +0100 Subject: [PATCH 0551/1167] efidisk: Respect block_io_protocol buffer alignment Returned from the OpenProtocol operation, the grub_efi_block_io_media structure contains the io_align field, specifying the minimum alignment required for buffers used in any data transfers with the device. Make grub_efidisk_readwrite() allocate a temporary buffer, aligned to this boundary, if the buffer passed to it does not already meet the requirements. Also sanity check the io_align field in grub_efidisk_open() for power-of-two-ness and bail if invalid. --- grub-core/disk/efi/efidisk.c | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 75bb4a9ca..3b79f7bbc 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -493,8 +493,15 @@ grub_efidisk_open (const char *name, struct grub_disk *disk) m = d->block_io->media; /* FIXME: Probably it is better to store the block size in the disk, and total sectors should be replaced with total blocks. */ - grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n", - m, (unsigned long long) m->last_block, m->block_size); + grub_dprintf ("efidisk", + "m = %p, last block = %llx, block size = %x, io align = %x\n", + m, (unsigned long long) m->last_block, m->block_size, + m->io_align); + + /* Ensure required buffer alignment is a power of two (or is zero). */ + if (m->io_align & (m->io_align - 1)) + return grub_error (GRUB_ERR_IO, "invalid buffer alignment %d", m->io_align); + disk->total_sectors = m->last_block + 1; /* Don't increase this value due to bug in some EFI. */ disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS); @@ -524,15 +531,42 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector, { struct grub_efidisk_data *d; grub_efi_block_io_t *bio; + grub_efi_status_t status; + grub_size_t io_align, num_bytes; + char *aligned_buf; d = disk->data; bio = d->block_io; - return efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio, - bio->media->media_id, - (grub_efi_uint64_t) sector, - (grub_efi_uintn_t) size << disk->log_sector_size, - buf); + /* Set alignment to 1 if 0 specified */ + io_align = bio->media->io_align ? bio->media->io_align : 1; + num_bytes = size << disk->log_sector_size; + + if ((grub_addr_t) buf & (io_align - 1)) + { + aligned_buf = grub_memalign (io_align, num_bytes); + if (! aligned_buf) + return GRUB_EFI_OUT_OF_RESOURCES; + if (wr) + grub_memcpy (aligned_buf, buf, num_bytes); + } + else + { + aligned_buf = buf; + } + + status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio, + bio->media->media_id, (grub_efi_uint64_t) sector, + (grub_efi_uintn_t) num_bytes, aligned_buf); + + if ((grub_addr_t) buf & (io_align - 1)) + { + if (!wr) + grub_memcpy (buf, aligned_buf, num_bytes); + grub_free (aligned_buf); + } + + return status; } static grub_err_t From 102e435d818e3f9e1718326c3fe55e8459e924f3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 28 Feb 2016 03:07:27 +0100 Subject: [PATCH 0552/1167] grub_arch_sync_dma_caches: Accept volatile address --- include/grub/cache.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/grub/cache.h b/include/grub/cache.h index a9b3f529c..fc669dfd1 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -35,10 +35,11 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); #ifndef GRUB_MACHINE_EMU #ifdef _mips -void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len); +void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, + grub_size_t len); #else static inline void -grub_arch_sync_dma_caches (void *address __attribute__ ((unused)), +grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) { } From 8207874e5d0d05159fd8c531c87f0f6e4653b8a6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 28 Feb 2016 03:07:41 +0100 Subject: [PATCH 0553/1167] Release 2.02~beta3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 26d2f33c7..a85b134ec 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.02~beta3],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From d017ea8ede3f76aaf6b6c9dabe3e96af0eebd395 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 28 Feb 2016 21:52:08 +0300 Subject: [PATCH 0554/1167] NEWS update --- NEWS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index c9a975219..572eadb3e 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ New in 2.02: * ZFS features support. * ZFS LZ4 support. * XFS V5 format support. + * LVM RAID1 support. * New/improved terminal and video support: * Monochrome text (matching `hercules' in GRUB Legacy). @@ -49,6 +50,7 @@ New in 2.02: * Improve TFTP robustness. * Parse `nd' disk names in GRUB Legacy configuration files. * Issue separate DNS queries for IPv4 and IPv6. + * Support IPv6 Router Advertisement to configure default router. * Coreboot improvements: * CBFS support both in on-disk images (loopback) and flash. @@ -96,6 +98,8 @@ New in 2.02: EFI Stall. If everything fails, use hardcoded frequency 800MHz. * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration. * Map UEFI Persistent Memory to E820 persistent memory. + * New Xen loader on ARM64. + * Respect alignment requirement for block device IO buffers on EFI. * Security: * Add optional facility to enforce that all files read by the core image @@ -134,6 +138,11 @@ New in 2.02: menu entry immediately. * New `file' command and grub-file utility to check file types. * New syslinux configuration file parser. + * Set menu entry class to primary OS name returned by os-prober to display + OS specific icon. + * On Linux x86 detect EFI word size in grub-install and automatically select + correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel + 4.0 or higher. * Build system: * Remove all uses of nested functions; GRUB no longer requires an @@ -160,6 +169,8 @@ New in 2.02: * emu libusb support removed (was broken and unmaintained). * powerpc64le compile support. * Use fixed timestamp when generating GRUB image for reproducible builds. + * Verify at build time that modules contain only supported relocations and their + structure matches what boot-time module loader expects. * Revision control moved to git. From 082bc9f77b200eb48a5f1147163dea9c9d02d44c Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sat, 5 Mar 2016 17:30:48 -0500 Subject: [PATCH 0555/1167] 10_linux: Fix grouping of tests for GRUB_DEVICE Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to mixing of || and && operators. Add some parens to help with that. --- util/grub.d/10_linux.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 5a78513ae..de9044c7f 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -47,7 +47,7 @@ esac # and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then + || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} From 9545a8fd04ca33bcecc1907fec4d2354b02992ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 6 Mar 2016 08:54:19 +0300 Subject: [PATCH 0556/1167] 20_linux_xen: fix test for GRUB_DEVICE Same fix as in 082bc9f. --- util/grub.d/20_linux_xen.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 46045db1a..c48af948d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -47,7 +47,7 @@ esac # and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then + || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} From 7f2a856faec951b7ab816880bd26e1e10b17a596 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 10 Mar 2016 21:16:10 +0100 Subject: [PATCH 0557/1167] multiboot2: Remove useless GRUB_PACKED Reported by: Daniel Kiper --- include/multiboot2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/multiboot2.h b/include/multiboot2.h index 9d4862759..8b8c1568a 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -176,7 +176,7 @@ struct multiboot_mmap_entry #define MULTIBOOT_MEMORY_BADRAM 5 multiboot_uint32_t type; multiboot_uint32_t zero; -} GRUB_PACKED; +}; typedef struct multiboot_mmap_entry multiboot_memory_map_t; struct multiboot_tag From 15aee573d2312ebf4aab53d07d3d30eccf1484f9 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 11 Mar 2016 10:26:51 +0100 Subject: [PATCH 0558/1167] xen_file: Fix invalid payload size --- grub-core/loader/i386/xen_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 583621890..37f9ad8ac 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -55,11 +55,11 @@ grub_xen_file (grub_file_t file) grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", (unsigned long long) (lh.setup_sects + 1) * 512 + lh.payload_offset, - (unsigned long long) lh.payload_length - 4); + (unsigned long long) lh.payload_length); off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512 + lh.payload_offset, - lh.payload_length - 4); + lh.payload_length); if (!off_file) goto fail; From 3c3e96d0443e8de64ff29a6563fb69c8a37dd15a Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Fri, 29 Jan 2016 14:49:24 -0500 Subject: [PATCH 0559/1167] Failed config now returns exit code (#1252311) Grub would notify the user if the new config was invalid, however, it did not exit properly with exit code 1. Added the proper exit code. Resolves: rhbz#1252311 --- util/grub-mkconfig.in | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 203b07696..f8496d28b 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -273,6 +273,7 @@ Ensure that there are no errors in /etc/default/grub and /etc/grub.d/* files or please file a bug report with %s file attached." "${grub_cfg}.new" >&2 echo >&2 + exit 1 else # none of the children aborted with error, install the new grub.cfg mv -f ${grub_cfg}.new ${grub_cfg} From ee83919e938e7987c2753b3003a2074e92edf671 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 13 Mar 2016 08:11:58 +0300 Subject: [PATCH 0560/1167] Makefile.util.def: add $LIBINTL to grub-macbless flags Fixes compilation on OpenBSD 5.9. Reported by Jiri B --- Makefile.util.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.util.def b/Makefile.util.def index ed9b4c697..f9caccb97 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -416,7 +416,7 @@ program = { ldadd = libgrubgcry.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; data = { From 76eac44af37358fb14f437a7878119e6d34e8d7f Mon Sep 17 00:00:00 2001 From: Aaron Luft Date: Mon, 14 Mar 2016 16:48:33 -0400 Subject: [PATCH 0561/1167] Remove the variable oldname which is attempting to free stack space. Historically this variable hold previous value of filename that had to be freed if allocated previously. Currently this branch is entered only if filename was not allocated previously so it became redundant. It did not cause real problems because grub_free was not called, but code is confusing and causes compilation error in some cases. --- grub-core/fs/iso9660.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 67a67cf40..c9c8374bf 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -750,19 +750,15 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, if (dir->data->joliet && !ctx.filename) { - char *oldname, *semicolon; + char *semicolon; - oldname = name; ctx.filename = grub_iso9660_convert_string - ((grub_uint8_t *) oldname, dirent.namelen >> 1); + ((grub_uint8_t *) name, dirent.namelen >> 1); semicolon = grub_strrchr (ctx.filename, ';'); if (semicolon) *semicolon = '\0'; - if (ctx.filename_alloc) - grub_free (oldname); - ctx.filename_alloc = 1; } From 5b8ddf6e03bbc780d6902b1d9c1e3aa6361c9cc3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 19 Mar 2016 09:39:30 +0300 Subject: [PATCH 0562/1167] bootp: fix memory leak in grub_cmd_dhcpopt --- grub-core/net/bootp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index a088244b4..09c6f7606 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -368,6 +368,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), if (grub_strcmp (args[3], "string") == 0) { + grub_err_t err = GRUB_ERR_NONE; char *val = grub_malloc (taglength + 1); if (!val) return grub_errno; @@ -376,8 +377,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), if (args[0][0] == '-' && args[0][1] == 0) grub_printf ("%s\n", val); else - return grub_env_set (args[0], val); - return GRUB_ERR_NONE; + err = grub_env_set (args[0], val); + grub_free (val); + return err; } if (grub_strcmp (args[3], "number") == 0) @@ -399,6 +401,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), if (grub_strcmp (args[3], "hex") == 0) { + grub_err_t err = GRUB_ERR_NONE; char *val = grub_malloc (2 * taglength + 1); int i; if (!val) @@ -412,8 +415,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), if (args[0][0] == '-' && args[0][1] == 0) grub_printf ("%s\n", val); else - return grub_env_set (args[0], val); - return GRUB_ERR_NONE; + err = grub_env_set (args[0], val); + grub_free (val); + return err; } return grub_error (GRUB_ERR_BAD_ARGUMENT, From 6714d7ecffe58021760e4d1ebfa9cc3473f7fb24 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 20 Mar 2016 10:32:33 +0300 Subject: [PATCH 0563/1167] bootp: check that interface is not NULL in configure_by_dhcp_ack grub_net_add_addr may fail with OOM and we use returned interface later without any checks. --- grub-core/net/bootp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 09c6f7606..189551a48 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -157,6 +157,9 @@ grub_net_configure_by_dhcp_ack (const char *name, hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags); + if (!inter) + return 0; + #if 0 /* This is likely based on misunderstanding. gateway_ip refers to address of BOOTP relay and should not be used after BOOTP transaction From f4d35d49e32c29183b3492da18ea480d91716efe Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 22 Mar 2016 20:12:22 +0300 Subject: [PATCH 0564/1167] configure: set -fno-pie together with -fno-PIE OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate already, but that is not enough - it does not turn off -fpie. Actually check for -fPIE is not precise enough. __PIE__ is set for both -fpie and -fPIE but with different values. As far as I can tell, both options were introduced at the same time, so both should always be supported. This fixes compilation on OpenBSD 5.9 which otherwise created insanely big lzma_decompress.img. Reported, suggested and tested by: Jiri B --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a85b134ec..57e17138e 100644 --- a/configure.ac +++ b/configure.ac @@ -1185,9 +1185,9 @@ CFLAGS="$TARGET_CFLAGS" # Position independent executable. grub_CHECK_PIE [# Need that, because some distributions ship compilers that include -# `-fPIE' in the default specs. +# `-fPIE' or '-fpie' in the default specs. if [ x"$pie_possible" = xyes ]; then - TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie" fi] CFLAGS="$TARGET_CFLAGS" From abf9beb7d667d3604774753cf698c439c6fbc736 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Wed, 6 Apr 2016 18:19:14 +0800 Subject: [PATCH 0565/1167] http: fix superfluous null line in range request header At least the apache sever is very unhappy with that extra null line and will take more than ten seconds in responding to each range request, which slows down a lot the entire http file transfer process or even time out. --- grub-core/net/http.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c index 4684f8b33..a7c5101a1 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -381,9 +381,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) ptr = nb->tail; grub_snprintf ((char *) ptr, sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-" - "\r\n" "\r\n"), - "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n\r\n", + "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n", offset); grub_netbuff_put (nb, grub_strlen ((char *) ptr)); } From 7a5b301e3adb8e054288518a325135a1883c1c6c Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Tue, 19 Apr 2016 14:27:22 -0400 Subject: [PATCH 0566/1167] build: Use AC_HEADER_MAJOR to find device macros Depending on the OS/libc, device macros are defined in different headers. This change ensures we include the right one. sys/types.h - BSD sys/mkdev.h - Sun sys/sysmacros.h - glibc (Linux) glibc currently pulls sys/sysmacros.h into sys/types.h, but this may change in a future release. https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html --- configure.ac | 3 ++- grub-core/osdep/devmapper/getroot.c | 6 ++++++ grub-core/osdep/devmapper/hostdisk.c | 5 +++++ grub-core/osdep/linux/getroot.c | 6 ++++++ grub-core/osdep/unix/getroot.c | 4 +++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 57e17138e..9ddfc5323 100644 --- a/configure.ac +++ b/configure.ac @@ -388,7 +388,8 @@ fi # Check for functions and headers. AC_CHECK_FUNCS(posix_memalign memalign getextmntent) -AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) +AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) +AC_HEADER_MAJOR AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default #include diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 05eda500a..72e558275 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -40,6 +40,12 @@ #include #endif +#if defined(MAJOR_IN_MKDEV) +#include +#elif defined(MAJOR_IN_SYSMACROS) +#include +#endif + #include #include diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c index 19c1101fd..a697bcb4d 100644 --- a/grub-core/osdep/devmapper/hostdisk.c +++ b/grub-core/osdep/devmapper/hostdisk.c @@ -24,6 +24,11 @@ #include #include +#if defined(MAJOR_IN_MKDEV) +#include +#elif defined(MAJOR_IN_SYSMACROS) +#include +#endif #ifdef HAVE_DEVICE_MAPPER # include diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 10480b646..09e7e6e6d 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -35,6 +35,12 @@ #include #endif +#if defined(MAJOR_IN_MKDEV) +#include +#elif defined(MAJOR_IN_SYSMACROS) +#include +#endif + #include #include /* ioctl */ #include diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 1079a919d..4bf37b027 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -51,8 +51,10 @@ #endif #include -#if defined(HAVE_SYS_MKDEV_H) +#if defined(MAJOR_IN_MKDEV) #include +#elif defined(MAJOR_IN_SYSMACROS) +#include #endif #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) From 13f7ead3a17a5c2681b95c4bb4f40d8eb8648880 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sat, 30 Apr 2016 09:10:12 +0300 Subject: [PATCH 0567/1167] http: reset EOF indication in http_seek Otherwise next read will stop polling too early due to stale EOF indicator, returning incomplete data to caller. --- grub-core/net/http.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/net/http.c b/grub-core/net/http.c index a7c5101a1..5aa4ad3be 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -449,6 +449,7 @@ http_seek (struct grub_file *file, grub_off_t off) } file->device->net->stall = 0; + file->device->net->eof = 0; file->device->net->offset = off; data = grub_zalloc (sizeof (*data)); From e045af148a580203e47e47276e387fc3958391a5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 30 Apr 2016 09:15:36 +0300 Subject: [PATCH 0568/1167] net: reset net->stall in grub_net_seek_real If we open new connection, we need to reset stall indication, otherwise nothing will ever be polled (low level code rely on this field being zero when establishing connection). --- grub-core/net/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 942459527..26a1fc3fc 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1672,6 +1672,7 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset) file->device->net->packs.last = NULL; file->device->net->offset = 0; file->device->net->eof = 0; + file->device->net->stall = 0; err = file->device->net->protocol->open (file, file->device->net->name); if (err) return err; From b524fa27f56381bb0efa4944e36f50265113aee5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 3 May 2016 19:23:31 +0300 Subject: [PATCH 0569/1167] net: translate pxe prefix to tftp when checking for self-load Commit ba218c1 missed legacy pxe and pxe: prefixes which are translated to tftp, so comparison failed. --- grub-core/net/net.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 26a1fc3fc..10773fc34 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1346,6 +1346,15 @@ grub_net_open_real (const char *name) continue; } + if (grub_strncmp (prefdev, "pxe", sizeof ("pxe") - 1) == 0 && + (!prefdev[sizeof ("pxe") - 1] || (prefdev[sizeof("pxe") - 1] == ':'))) + { + grub_free (prefdev); + prefdev = grub_strdup ("tftp"); + if (!prefdev) + continue; + } + comma = grub_strchr (prefdev, ','); if (comma) *comma = '\0'; From 58590cb2ef48c6e85a8afeda01c385efc8c693bc Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 26 Jul 2016 20:29:26 +0300 Subject: [PATCH 0570/1167] xfs: accept filesystem with meta_uuid XFS V5 stores UUID in metadata and compares them with superblock UUID. To allow changing of user-visible UUID it stores original value in new superblock field (meta_uuid) and sets incompatible flag to indicate that new field must be used to verify metadata. Our driver currently does not check metadata UUID so simply accept such filesystem. Reported-By: Marcos Mello Reviewd by Jan Kara --- grub-core/fs/xfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index ca9c0c37a..9f66dd6e4 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -76,8 +76,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); /* incompat feature flags */ #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ +#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ + +/* We do not currently verify metadata UUID so it is safe to read such filesystem */ #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ - (XFS_SB_FEAT_INCOMPAT_FTYPE) + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_META_UUID) struct grub_xfs_sblock { From 52408aa94604466bdd80f48fa8d68378a1ffab31 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 26 Jul 2016 20:38:58 +0300 Subject: [PATCH 0571/1167] dns: fix buffer overflow for data->addresses in recv_hook We may get more than one response before exiting out of loop in grub_net_dns_lookup, but buffer was allocated for the first response only, so storing answers from subsequent replies wrote past allocated size. We never really use more than the very first address during lookup so there is little point in collecting all of them. Just quit early if we already have some reply. Code needs serious redesign to actually collect multiple answers and select the best fit according to requested type (IPv4 or IPv6). Reported and tested by Michael Chang --- grub-core/net/dns.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 89741dd7d..5d9afe093 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -238,6 +238,15 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), char *redirect_save = NULL; grub_uint32_t ttl_all = ~0U; + /* Code apparently assumed that only one packet is received as response. + We may get multiple responses due to network condition, so check here + and quit early. */ + if (*data->addresses) + { + grub_netbuff_free (nb); + return GRUB_ERR_NONE; + } + head = (struct dns_header *) nb->data; ptr = (grub_uint8_t *) (head + 1); if (ptr >= nb->tail) From c831d2073b9beda9dd94b74dd62d0f56c6168334 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 27 Jul 2016 08:33:12 +0300 Subject: [PATCH 0572/1167] at_keyboard: fix numpad "0" and "." mapping Reported for set 1 by fgndevelop . Apparently set 2 was reversed too. --- grub-core/term/at_keyboard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index c234e92f2..b4ea9ff7e 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -88,7 +88,7 @@ static const grub_uint8_t set1_mapping[128] = /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6, /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1, /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3, - /* 0x52 */ GRUB_KEYBOARD_KEY_NUMDOT, GRUB_KEYBOARD_KEY_NUMDOT, + /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, /* 0x54 */ 0, 0, /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11, /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0, @@ -193,7 +193,7 @@ static const grub_uint8_t set2_mapping[256] = /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4, /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA, /* 0x6e */ 0, 0, - /* 0x70 */ GRUB_KEYBOARD_KEY_NUMDOT, GRUB_KEYBOARD_KEY_NUM0, + /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5, /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8, /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK, From 4e0f8f66e321cf1051c0e01f6fbcc6fc35a807b6 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sat, 13 Aug 2016 10:51:34 +0200 Subject: [PATCH 0573/1167] Add missing va_end() to xasprintf() in grub-emu. --- grub-core/kern/emu/misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index d361feb00..76661337f 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -127,6 +127,7 @@ xasprintf (const char *fmt, ...) va_start (ap, fmt); result = grub_xvasprintf (fmt, ap); + va_end (ap); if (!result) grub_util_error ("%s", _("out of memory")); From a0bf403f66dbaca4edd8e667bfc397dd91c8d71c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 28 Sep 2016 20:31:04 +0300 Subject: [PATCH 0574/1167] asm-tests/i386-pc: Check that movl is 5 bytes. LLVM 3.9 now emits short form of jump instructions, but it is still using 32 bit addresses for some movl instructions. Fortunately it was caught early: clang ... boot/i386/pc/boot.S clang -cc1as: fatal error: error in backend: invalid .org offset '440' (at offset '441') Add additional check to catch it during configure run and force -no-integrated-as. Closes: 49200 More details in https://lists.gnu.org/archive/html/grub-devel/2015-02/msg00099.html https://llvm.org/bugs/show_bug.cgi?id=22662 --- asm-tests/i386-pc.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S index f6f9a88be..d037744f9 100644 --- a/asm-tests/i386-pc.S +++ b/asm-tests/i386-pc.S @@ -1,12 +1,16 @@ /* on x86 old clang doesn't support .code16 newer clang supports it but creates 6-byte jumps instead of 3-byte ones - which makes us go over boot sector size. */ + which makes us go over boot sector size. + Starting with 3.9 clang emits 3-byte jumps but still creates 8-bytes movl + instead of 5-bytes, so code overflows into data. */ .code16 jmp far .org 4 jmp nearer .org 6 + movl nearer, %ebx + .org 11 .space 100 nearer: .space 200 From e563928ba42ad400abd8d329a879a632abddcd0c Mon Sep 17 00:00:00 2001 From: Sakar Arora Date: Tue, 20 Sep 2016 01:01:17 +0530 Subject: [PATCH 0575/1167] net/ip: Fix limit_time calculation in freeing old fragments limit_time underflows when current time is less than 90000ms. This causes packet fragments received during this time, i.e., till 90000ms pass since timer init, to be rejected. Hence, set it to 0 if its less than 90000. Signed-off-by: Sakar Arora --- grub-core/net/ip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index 8c56baaf7..aba4f8908 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -363,7 +363,9 @@ static void free_old_fragments (void) { struct reassemble *rsm, **prev; - grub_uint64_t limit_time = grub_get_time_ms () - 90000; + grub_uint64_t limit_time = grub_get_time_ms (); + + limit_time = (limit_time > 90000) ? limit_time - 90000 : 0; for (prev = &reassembles, rsm = *prev; rsm; rsm = *prev) if (rsm->last_time < limit_time) From 9862b241212b25ee23f60f5bcc4277d2289eaaf9 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 17 Jul 2015 19:43:42 +0200 Subject: [PATCH 0576/1167] i386/relocator: Add grub_relocator64_efi relocator Add grub_relocator64_efi relocator. It will be used on EFI 64-bit platforms when multiboot2 compatible image requests MULTIBOOT_TAG_TYPE_EFI_BS. Relocator will set lower parts of %rax and %rbx accordingly to multiboot2 specification. On the other hand processor mode, just before jumping into loaded image, will be set accordingly to Unified Extensible Firmware Interface Specification, Version 2.4 Errata B, section 2.3.4, x64 Platforms, boot services. This way loaded image will be able to use EFI boot services without any issues. Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Vladimir Serbinenko --- grub-core/Makefile.core.def | 1 + grub-core/lib/i386/relocator64.S | 11 ++++ grub-core/lib/x86_64/efi/relocator.c | 80 ++++++++++++++++++++++++++++ grub-core/loader/multiboot.c | 51 ++++++++++++++++-- grub-core/loader/multiboot_mbi2.c | 19 +++++-- include/grub/i386/multiboot.h | 11 ++++ include/grub/i386/relocator.h | 21 ++++++++ include/multiboot2.h | 1 + 8 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 grub-core/lib/x86_64/efi/relocator.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 58b4208b0..21ad0dd7c 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1531,6 +1531,7 @@ module = { i386_xen = lib/i386/xen/relocator.S; x86_64_xen = lib/x86_64/xen/relocator.S; xen = lib/i386/relocator_common_c.c; + x86_64_efi = lib/x86_64/efi/relocator.c; extra_dist = lib/i386/relocator_common.S; extra_dist = kern/powerpc/cache_flush.S; diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S index e4648d818..75725cf75 100644 --- a/grub-core/lib/i386/relocator64.S +++ b/grub-core/lib/i386/relocator64.S @@ -73,6 +73,14 @@ VARIABLE(grub_relocator64_rsp) movq %rax, %rsp + /* + * Here is grub_relocator64_efi_start() entry point. + * Following code is shared between grub_relocator64_efi_start() + * and grub_relocator64_start(). + * + * Think twice before changing anything below!!! + */ +VARIABLE(grub_relocator64_efi_start) /* mov imm64, %rax */ .byte 0x48 .byte 0xb8 @@ -120,6 +128,9 @@ LOCAL(jump_addr): VARIABLE(grub_relocator64_rip) .quad 0 + /* Here grub_relocator64_efi_start() ends. Ufff... */ +VARIABLE(grub_relocator64_efi_end) + #ifndef __x86_64__ .p2align 4 LOCAL(gdt): diff --git a/grub-core/lib/x86_64/efi/relocator.c b/grub-core/lib/x86_64/efi/relocator.c new file mode 100644 index 000000000..3caef7a40 --- /dev/null +++ b/grub-core/lib/x86_64/efi/relocator.c @@ -0,0 +1,80 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2016 Oracle and/or its affiliates. All rights reserved. + * + * 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 . + */ + +#include +#include + +#include +#include + +#include +#include + +extern grub_uint64_t grub_relocator64_rax; +extern grub_uint64_t grub_relocator64_rbx; +extern grub_uint64_t grub_relocator64_rcx; +extern grub_uint64_t grub_relocator64_rdx; +extern grub_uint64_t grub_relocator64_rip; +extern grub_uint64_t grub_relocator64_rsi; + +extern grub_uint8_t grub_relocator64_efi_start; +extern grub_uint8_t grub_relocator64_efi_end; + +#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start) + +grub_err_t +grub_relocator64_efi_boot (struct grub_relocator *rel, + struct grub_relocator64_efi_state state) +{ + grub_err_t err; + void *relst; + grub_relocator_chunk_t ch; + + /* + * 64-bit relocator code may live above 4 GiB quite well. + * However, I do not want ask for problems. Just in case. + */ + err = grub_relocator_alloc_chunk_align (rel, &ch, 0, + 0x100000000 - RELOCATOR_SIZEOF (64_efi), + RELOCATOR_SIZEOF (64_efi), 16, + GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) + return err; + + /* Do not touch %rsp! It points to EFI created stack. */ + grub_relocator64_rax = state.rax; + grub_relocator64_rbx = state.rbx; + grub_relocator64_rcx = state.rcx; + grub_relocator64_rdx = state.rdx; + grub_relocator64_rip = state.rip; + grub_relocator64_rsi = state.rsi; + + grub_memmove (get_virtual_current_address (ch), &grub_relocator64_efi_start, + RELOCATOR_SIZEOF (64_efi)); + + err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch), + &relst, NULL); + if (err) + return err; + + ((void (*) (void)) relst) (); + + /* Not reached. */ + return GRUB_ERR_NONE; +} diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 73aa0aa12..18038fd31 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -118,6 +118,48 @@ grub_multiboot_set_video_mode (void) return err; } +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +#define grub_relocator_efi_boot grub_relocator64_efi_boot +#define grub_relocator_efi_state grub_relocator64_efi_state +#endif +#endif + +#ifdef grub_relocator_efi_boot +static void +efi_boot (struct grub_relocator *rel, + grub_uint32_t target) +{ + struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE; + + state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip; + state_efi.MULTIBOOT_EFI_MBI_REGISTER = target; + + grub_relocator_efi_boot (rel, state_efi); +} +#else +#define grub_efi_is_finished 1 +static void +efi_boot (struct grub_relocator *rel __attribute__ ((unused)), + grub_uint32_t target __attribute__ ((unused))) +{ +} +#endif + +#if defined (__i386__) || defined (__x86_64__) +static void +normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state) +{ + grub_relocator32_boot (rel, state, 0); +} +#else +static void +normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state) +{ + grub_relocator32_boot (rel, state); +} +#endif + static grub_err_t grub_multiboot_boot (void) { @@ -131,11 +173,10 @@ grub_multiboot_boot (void) if (err) return err; -#if defined (__i386__) || defined (__x86_64__) - grub_relocator32_boot (grub_multiboot_relocator, state, 0); -#else - grub_relocator32_boot (grub_multiboot_relocator, state); -#endif + if (grub_efi_is_finished) + normal_boot (grub_multiboot_relocator, state); + else + efi_boot (grub_multiboot_relocator, state.MULTIBOOT_MBI_REGISTER); /* Not reached. */ return GRUB_ERR_NONE; diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index f147d674d..a3dca9011 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -107,8 +107,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) grub_err_t err; struct multiboot_header_tag *tag; struct multiboot_header_tag_address *addr_tag = NULL; - int entry_specified = 0; - grub_addr_t entry = 0; + int entry_specified = 0, efi_entry_specified = 0; + grub_addr_t entry = 0, efi_entry = 0; grub_uint32_t console_required = 0; struct multiboot_header_tag_framebuffer *fbtag = NULL; int accepted_consoles = GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; @@ -192,6 +192,13 @@ grub_multiboot_load (grub_file_t file, const char *filename) entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr; break; + case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64: +#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__) + efi_entry_specified = 1; + efi_entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr; +#endif + break; + case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS: if (!(((struct multiboot_header_tag_console_flags *) tag)->console_flags & MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED)) @@ -211,7 +218,9 @@ grub_multiboot_load (grub_file_t file, const char *filename) break; case MULTIBOOT_HEADER_TAG_EFI_BS: +#ifdef GRUB_MACHINE_EFI keep_bs = 1; +#endif break; default: @@ -224,7 +233,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) break; } - if (addr_tag && !entry_specified) + if (addr_tag && !entry_specified && !(keep_bs && efi_entry_specified)) { grub_free (buffer); return grub_error (GRUB_ERR_UNKNOWN_OS, @@ -287,7 +296,9 @@ grub_multiboot_load (grub_file_t file, const char *filename) } } - if (entry_specified) + if (keep_bs && efi_entry_specified) + grub_multiboot_payload_eip = efi_entry; + else if (entry_specified) grub_multiboot_payload_eip = entry; if (fbtag) diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h index a1b94883d..807a1de27 100644 --- a/include/grub/i386/multiboot.h +++ b/include/grub/i386/multiboot.h @@ -30,6 +30,17 @@ #define MULTIBOOT_MBI_REGISTER ebx #define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386 +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +#define MULTIBOOT_EFI_INITIAL_STATE { .rax = MULTIBOOT_BOOTLOADER_MAGIC, \ + .rcx = 0, \ + .rdx = 0, \ + } +#define MULTIBOOT_EFI_ENTRY_REGISTER rip +#define MULTIBOOT_EFI_MBI_REGISTER rbx +#endif +#endif + #define MULTIBOOT_ELF32_MACHINE EM_386 #define MULTIBOOT_ELF64_MACHINE EM_X86_64 diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h index 5f89a7ec8..2a56c3b54 100644 --- a/include/grub/i386/relocator.h +++ b/include/grub/i386/relocator.h @@ -65,6 +65,20 @@ struct grub_relocator64_state grub_addr_t cr3; }; +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +struct grub_relocator64_efi_state +{ + grub_uint64_t rax; + grub_uint64_t rbx; + grub_uint64_t rcx; + grub_uint64_t rdx; + grub_uint64_t rip; + grub_uint64_t rsi; +}; +#endif +#endif + grub_err_t grub_relocator16_boot (struct grub_relocator *rel, struct grub_relocator16_state state); @@ -76,4 +90,11 @@ grub_err_t grub_relocator64_boot (struct grub_relocator *rel, struct grub_relocator64_state state, grub_addr_t min_addr, grub_addr_t max_addr); +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +grub_err_t grub_relocator64_efi_boot (struct grub_relocator *rel, + struct grub_relocator64_efi_state state); +#endif +#endif + #endif /* ! GRUB_RELOCATOR_CPU_HEADER */ diff --git a/include/multiboot2.h b/include/multiboot2.h index 8b8c1568a..46e7b7182 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -69,6 +69,7 @@ #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 #define MULTIBOOT_HEADER_TAG_EFI_BS 7 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 #define MULTIBOOT_ARCHITECTURE_I386 0 #define MULTIBOOT_ARCHITECTURE_MIPS32 4 From ba89c19f4995e01e3b84c6680f12f14bf0f6a38b Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 20 Nov 2014 00:09:54 +0100 Subject: [PATCH 0577/1167] multiboot2: Add tags used to pass ImageHandle to loaded image Add tags used to pass ImageHandle to loaded image if requested. It is used by at least ExitBootServices() function. Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Vladimir Serbinenko --- grub-core/loader/multiboot_mbi2.c | 42 +++++++++++++++++++++++++------ include/multiboot2.h | 16 ++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index a3dca9011..6c044024e 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -172,6 +172,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_TAG_TYPE_NETWORK: case MULTIBOOT_TAG_TYPE_EFI_MMAP: case MULTIBOOT_TAG_TYPE_EFI_BS: + case MULTIBOOT_TAG_TYPE_EFI32_IH: + case MULTIBOOT_TAG_TYPE_EFI64_IH: break; default: @@ -407,13 +409,15 @@ grub_multiboot_get_mbi_size (void) + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) - + ALIGN_UP (sizeof (struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN) - + ALIGN_UP (sizeof (struct multiboot_tag_efi64), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN) + acpiv2_size () + net_size () #ifdef GRUB_MACHINE_EFI + + ALIGN_UP (sizeof (struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN) + + ALIGN_UP (sizeof (struct multiboot_tag_efi32_ih), MULTIBOOT_TAG_ALIGN) + + ALIGN_UP (sizeof (struct multiboot_tag_efi64), MULTIBOOT_TAG_ALIGN) + + ALIGN_UP (sizeof (struct multiboot_tag_efi64_ih), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap) + efi_mmap_size, MULTIBOOT_TAG_ALIGN) #endif @@ -907,11 +911,35 @@ grub_multiboot_make_mbi (grub_uint32_t *target) if (keep_bs) { - struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig; - tag->type = MULTIBOOT_TAG_TYPE_EFI_BS; - tag->size = sizeof (struct multiboot_tag); - ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); + { + struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_EFI_BS; + tag->size = sizeof (struct multiboot_tag); + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } + +#ifdef __i386__ + { + struct multiboot_tag_efi32_ih *tag = (struct multiboot_tag_efi32_ih *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_EFI32_IH; + tag->size = sizeof (struct multiboot_tag_efi32_ih); + tag->pointer = (grub_addr_t) grub_efi_image_handle; + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } +#endif + +#ifdef __x86_64__ + { + struct multiboot_tag_efi64_ih *tag = (struct multiboot_tag_efi64_ih *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_EFI64_IH; + tag->size = sizeof (struct multiboot_tag_efi64_ih); + tag->pointer = (grub_addr_t) grub_efi_image_handle; + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } +#endif } #endif diff --git a/include/multiboot2.h b/include/multiboot2.h index 46e7b7182..f5bebe1e3 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -60,6 +60,8 @@ #define MULTIBOOT_TAG_TYPE_NETWORK 16 #define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 #define MULTIBOOT_TAG_TYPE_EFI_BS 18 +#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 +#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 #define MULTIBOOT_HEADER_TAG_END 0 #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 @@ -371,6 +373,20 @@ struct multiboot_tag_efi_mmap multiboot_uint8_t efi_mmap[0]; }; +struct multiboot_tag_efi32_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + #endif /* ! ASM_FILE */ #endif /* ! MULTIBOOT_HEADER */ From f2b6c20a258b328ae8717cd5624d7b039328bcc0 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Sat, 18 Jul 2015 00:09:31 +0200 Subject: [PATCH 0578/1167] multiboot2: Do not pass memory maps to image if EFI boot services are enabled If image requested EFI boot services then skip multiboot2 memory maps. Main reason for not providing maps is because they will likely be invalid. We do a few allocations after filling them, e.g. for relocator needs. Usually we do not care as we would have finished boot services. If we keep boot services then it is easier/safer to not provide maps. However, if image needs memory maps and they are not provided by bootloader then it should get itself just before ExitBootServices() call. Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Vladimir Serbinenko --- grub-core/loader/multiboot_mbi2.c | 71 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 6c044024e..ad1553ba7 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -390,7 +390,7 @@ static grub_size_t grub_multiboot_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI - if (!efi_mmap_size) + if (!keep_bs && !efi_mmap_size) find_efi_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) @@ -755,12 +755,13 @@ grub_multiboot_make_mbi (grub_uint32_t *target) } } - { - struct multiboot_tag_mmap *tag = (struct multiboot_tag_mmap *) ptrorig; - grub_fill_multiboot_mmap (tag); - ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + if (!keep_bs) + { + struct multiboot_tag_mmap *tag = (struct multiboot_tag_mmap *) ptrorig; + grub_fill_multiboot_mmap (tag); + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } { struct multiboot_tag_elf_sections *tag @@ -776,18 +777,19 @@ grub_multiboot_make_mbi (grub_uint32_t *target) / sizeof (grub_properly_aligned_t); } - { - struct multiboot_tag_basic_meminfo *tag - = (struct multiboot_tag_basic_meminfo *) ptrorig; - tag->type = MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; - tag->size = sizeof (struct multiboot_tag_basic_meminfo); + if (!keep_bs) + { + struct multiboot_tag_basic_meminfo *tag + = (struct multiboot_tag_basic_meminfo *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; + tag->size = sizeof (struct multiboot_tag_basic_meminfo); - /* Convert from bytes to kilobytes. */ - tag->mem_lower = grub_mmap_get_lower () / 1024; - tag->mem_upper = grub_mmap_get_upper () / 1024; - ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + /* Convert from bytes to kilobytes. */ + tag->mem_lower = grub_mmap_get_lower () / 1024; + tag->mem_upper = grub_mmap_get_upper () / 1024; + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } { struct grub_net_network_level_interface *net; @@ -886,27 +888,24 @@ grub_multiboot_make_mbi (grub_uint32_t *target) grub_efi_uintn_t efi_desc_size; grub_efi_uint32_t efi_desc_version; - tag->type = MULTIBOOT_TAG_TYPE_EFI_MMAP; - tag->size = sizeof (*tag) + efi_mmap_size; - if (!keep_bs) - err = grub_efi_finish_boot_services (&efi_mmap_size, tag->efi_mmap, NULL, - &efi_desc_size, &efi_desc_version); - else { - if (grub_efi_get_memory_map (&efi_mmap_size, (void *) tag->efi_mmap, - NULL, - &efi_desc_size, &efi_desc_version) <= 0) - err = grub_error (GRUB_ERR_IO, "couldn't retrieve memory map"); - } - if (err) - return err; - tag->descr_size = efi_desc_size; - tag->descr_vers = efi_desc_version; - tag->size = sizeof (*tag) + efi_mmap_size; + tag->type = MULTIBOOT_TAG_TYPE_EFI_MMAP; + tag->size = sizeof (*tag) + efi_mmap_size; - ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); + err = grub_efi_finish_boot_services (&efi_mmap_size, tag->efi_mmap, NULL, + &efi_desc_size, &efi_desc_version); + + if (err) + return err; + + tag->descr_size = efi_desc_size; + tag->descr_vers = efi_desc_version; + tag->size = sizeof (*tag) + efi_mmap_size; + + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } } if (keep_bs) From a620876e3b32e4ea0c9a7b3541fcb9a4dd4fb9eb Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 17 Jul 2015 21:02:09 +0200 Subject: [PATCH 0579/1167] multiboot2: Add support for relocatable images Currently multiboot2 protocol loads image exactly at address specified in ELF or multiboot2 header. This solution works quite well on legacy BIOS platforms. It is possible because memory regions are placed at predictable addresses (though I was not able to find any spec which says that it is strong requirement, so, it looks that it is just a goodwill of hardware designers). However, EFI platforms are more volatile. Even if required memory regions live at specific addresses then they are sometimes simply not free (e.g. used by boot/runtime services on Dell PowerEdge R820 and OVMF). This means that you are not able to just set up final image destination on build time. You have to provide method to relocate image contents to real load address which is usually different than load address specified in ELF and multiboot2 headers. This patch provides all needed machinery to do self relocation in image code. First of all GRUB2 reads min_addr (min. load addr), max_addr (max. load addr), align (required image alignment), preference (it says which memory regions are preferred by image, e.g. none, low, high) from multiboot_header_tag_relocatable header tag contained in binary (at this stage load addresses from multiboot2 and/or ELF headers are ignored). Later loader tries to fulfill request (not only that one) and if it succeeds then it informs image about real load address via multiboot_tag_load_base_addr tag. At this stage GRUB2 role is finished. Starting from now executable must cope with relocations itself using whole static and dynamic knowledge provided by boot loader. This patch does not provide functionality which could do relocations using ELF relocation data. However, I was asked by Konrad Rzeszutek Wilk and Vladimir 'phcoder' Serbinenko to investigate that thing. It looks that relevant machinery could be added to existing code (including this patch) without huge effort. Additionally, ELF relocation could live in parallel with self relocation provided by this patch. However, during research I realized that first of all we should establish the details how ELF relocatable image should look like and how it should be build. At least to build proper test/example files. So, this patch just provides support for self relocatable images. If ELF file with relocs is loaded then GRUB2 complains loudly and ignores it. Support for such files will be added later. This patch was tested with Xen image which uses that functionality. However, this Xen feature is still under development and new patchset will be released in about 2-3 weeks. Signed-off-by: Daniel Kiper Reviewed-by: Vladimir Serbinenko --- grub-core/loader/i386/multiboot_mbi.c | 13 ++- grub-core/loader/multiboot.c | 11 +-- grub-core/loader/multiboot_elfxx.c | 129 ++++++++++++++++---------- grub-core/loader/multiboot_mbi2.c | 122 ++++++++++++++++++++---- include/grub/multiboot.h | 22 ++++- include/multiboot2.h | 24 +++++ 6 files changed, 243 insertions(+), 78 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index f60b70234..fd7b41b0c 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -70,9 +70,18 @@ load_kernel (grub_file_t file, const char *filename, char *buffer, struct multiboot_header *header) { grub_err_t err; + mbi_load_data_t mld; + + mld.file = file; + mld.filename = filename; + mld.buffer = buffer; + mld.mbi_ver = 1; + mld.relocatable = 0; + mld.avoid_efi_boot_services = 0; + if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE) { - err = grub_multiboot_load_elf (file, filename, buffer); + err = grub_multiboot_load_elf (&mld); if (err == GRUB_ERR_NONE) { return GRUB_ERR_NONE; } @@ -121,7 +130,7 @@ load_kernel (grub_file_t file, const char *filename, return GRUB_ERR_NONE; } - return grub_multiboot_load_elf (file, filename, buffer); + return grub_multiboot_load_elf (&mld); } static struct multiboot_header * diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 18038fd31..bd9d5b3e6 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -207,13 +207,12 @@ static grub_uint64_t highest_load; /* Load ELF32 or ELF64. */ grub_err_t -grub_multiboot_load_elf (grub_file_t file, const char *filename, - void *buffer) +grub_multiboot_load_elf (mbi_load_data_t *mld) { - if (grub_multiboot_is_elf32 (buffer)) - return grub_multiboot_load_elf32 (file, filename, buffer); - else if (grub_multiboot_is_elf64 (buffer)) - return grub_multiboot_load_elf64 (file, filename, buffer); + if (grub_multiboot_is_elf32 (mld->buffer)) + return grub_multiboot_load_elf32 (mld); + else if (grub_multiboot_is_elf64 (mld->buffer)) + return grub_multiboot_load_elf64 (mld); return grub_error (GRUB_ERR_UNKNOWN_OS, N_("invalid arch-dependent ELF magic")); } diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index e3a39b609..5e649ed25 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -51,11 +51,15 @@ CONCAT(grub_multiboot_is_elf, XX) (void *buffer) } static grub_err_t -CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, void *buffer) +CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) { - Elf_Ehdr *ehdr = (Elf_Ehdr *) buffer; + Elf_Ehdr *ehdr = (Elf_Ehdr *) mld->buffer; char *phdr_base; + grub_err_t err; + grub_relocator_chunk_t ch; + grub_uint32_t load_offset, load_size; int i; + void *source; if (ehdr->e_ident[EI_MAG0] != ELFMAG0 || ehdr->e_ident[EI_MAG1] != ELFMAG1 @@ -75,54 +79,86 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset"); - phdr_base = (char *) buffer + ehdr->e_phoff; + phdr_base = (char *) mld->buffer + ehdr->e_phoff; #define phdr(i) ((Elf_Phdr *) (phdr_base + (i) * ehdr->e_phentsize)) + mld->link_base_addr = ~0; + + /* Calculate lowest and highest load address. */ + for (i = 0; i < ehdr->e_phnum; i++) + if (phdr(i)->p_type == PT_LOAD) + { + mld->link_base_addr = grub_min (mld->link_base_addr, phdr(i)->p_paddr); + highest_load = grub_max (highest_load, phdr(i)->p_paddr + phdr(i)->p_memsz); + } + +#ifdef MULTIBOOT_LOAD_ELF64 + if (highest_load >= 0x100000000) + return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border"); +#endif + + load_size = highest_load - mld->link_base_addr; + + if (mld->relocatable) + { + if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) + return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); + + err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + mld->min_addr, mld->max_addr - load_size, + load_size, mld->align ? mld->align : 1, + mld->preference, mld->avoid_efi_boot_services); + } + else + err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, &ch, + mld->link_base_addr, load_size); + + if (err) + { + grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); + return err; + } + + mld->load_base_addr = get_physical_target_address (ch); + source = get_virtual_current_address (ch); + + grub_dprintf ("multiboot_loader", "link_base_addr=0x%x, load_base_addr=0x%x, " + "load_size=0x%x, relocatable=%d\n", mld->link_base_addr, + mld->load_base_addr, load_size, mld->relocatable); + + if (mld->relocatable) + grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, avoid_efi_boot_services=%d\n", + (long) mld->align, mld->preference, mld->avoid_efi_boot_services); + /* Load every loadable segment in memory. */ for (i = 0; i < ehdr->e_phnum; i++) { if (phdr(i)->p_type == PT_LOAD) { - grub_err_t err; - void *source; - - if (phdr(i)->p_paddr + phdr(i)->p_memsz > highest_load) - highest_load = phdr(i)->p_paddr + phdr(i)->p_memsz; grub_dprintf ("multiboot_loader", "segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx\n", i, (long) phdr(i)->p_paddr, (long) phdr(i)->p_memsz, (long) phdr(i)->p_vaddr); - { - grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, - &ch, phdr(i)->p_paddr, - phdr(i)->p_memsz); - if (err) - { - grub_dprintf ("multiboot_loader", "Error loading phdr %d\n", i); - return err; - } - source = get_virtual_current_address (ch); - } + load_offset = phdr(i)->p_paddr - mld->link_base_addr; if (phdr(i)->p_filesz != 0) { - if (grub_file_seek (file, (grub_off_t) phdr(i)->p_offset) + if (grub_file_seek (mld->file, (grub_off_t) phdr(i)->p_offset) == (grub_off_t) -1) return grub_errno; - if (grub_file_read (file, source, phdr(i)->p_filesz) + if (grub_file_read (mld->file, (grub_uint8_t *) source + load_offset, phdr(i)->p_filesz) != (grub_ssize_t) phdr(i)->p_filesz) { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - filename); + mld->filename); return grub_errno; } } if (phdr(i)->p_filesz < phdr(i)->p_memsz) - grub_memset ((grub_uint8_t *) source + phdr(i)->p_filesz, 0, + grub_memset ((grub_uint8_t *) source + load_offset + phdr(i)->p_filesz, 0, phdr(i)->p_memsz - phdr(i)->p_filesz); } } @@ -168,18 +204,18 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi if (!shdr) return grub_errno; - if (grub_file_seek (file, ehdr->e_shoff) == (grub_off_t) -1) + if (grub_file_seek (mld->file, ehdr->e_shoff) == (grub_off_t) -1) { grub_free (shdr); return grub_errno; } - if (grub_file_read (file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize) + if (grub_file_read (mld->file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize) != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize) { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - filename); + mld->filename); return grub_errno; } @@ -189,7 +225,9 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi Elf_Shdr *sh = (Elf_Shdr *) shdrptr; void *src; grub_addr_t target; - grub_err_t err; + + if (mld->mbi_ver >= 2 && (sh->sh_type == SHT_REL || sh->sh_type == SHT_RELA)) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ELF files with relocs are not supported yet"); /* This section is a loaded section, so we don't care. */ @@ -200,33 +238,28 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi if (sh->sh_size == 0) continue; - { - grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, - &ch, 0, - (0xffffffff - sh->sh_size) - + 1, sh->sh_size, - sh->sh_addralign, - GRUB_RELOCATOR_PREFERENCE_NONE, - 0); - if (err) - { - grub_dprintf ("multiboot_loader", "Error loading shdr %d\n", i); - return err; - } - src = get_virtual_current_address (ch); - target = get_physical_target_address (ch); - } + err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, 0, + (0xffffffff - sh->sh_size) + 1, + sh->sh_size, sh->sh_addralign, + GRUB_RELOCATOR_PREFERENCE_NONE, + mld->avoid_efi_boot_services); + if (err) + { + grub_dprintf ("multiboot_loader", "Error loading shdr %d\n", i); + return err; + } + src = get_virtual_current_address (ch); + target = get_physical_target_address (ch); - if (grub_file_seek (file, sh->sh_offset) == (grub_off_t) -1) + if (grub_file_seek (mld->file, sh->sh_offset) == (grub_off_t) -1) return grub_errno; - if (grub_file_read (file, src, sh->sh_size) + if (grub_file_read (mld->file, src, sh->sh_size) != (grub_ssize_t) sh->sh_size) { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - filename); + mld->filename); return grub_errno; } sh->sh_addr = target; diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index ad1553ba7..b0679a9f6 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -68,6 +68,7 @@ static grub_size_t elf_sec_num, elf_sec_entsize; static unsigned elf_sec_shstrndx; static void *elf_sections; static int keep_bs = 0; +static grub_uint32_t load_base_addr; void grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, @@ -101,36 +102,40 @@ find_header (grub_properly_aligned_t *buffer, grub_ssize_t len) grub_err_t grub_multiboot_load (grub_file_t file, const char *filename) { - grub_properly_aligned_t *buffer; grub_ssize_t len; struct multiboot_header *header; grub_err_t err; struct multiboot_header_tag *tag; struct multiboot_header_tag_address *addr_tag = NULL; + struct multiboot_header_tag_relocatable *rel_tag; int entry_specified = 0, efi_entry_specified = 0; grub_addr_t entry = 0, efi_entry = 0; grub_uint32_t console_required = 0; struct multiboot_header_tag_framebuffer *fbtag = NULL; int accepted_consoles = GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; + mbi_load_data_t mld; - buffer = grub_malloc (MULTIBOOT_SEARCH); - if (!buffer) + mld.mbi_ver = 2; + mld.relocatable = 0; + + mld.buffer = grub_malloc (MULTIBOOT_SEARCH); + if (!mld.buffer) return grub_errno; - len = grub_file_read (file, buffer, MULTIBOOT_SEARCH); + len = grub_file_read (file, mld.buffer, MULTIBOOT_SEARCH); if (len < 32) { - grub_free (buffer); + grub_free (mld.buffer); return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), filename); } COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - header = find_header (buffer, len); + header = find_header (mld.buffer, len); if (header == 0) { - grub_free (buffer); + grub_free (mld.buffer); return grub_error (GRUB_ERR_BAD_ARGUMENT, "no multiboot header found"); } @@ -174,10 +179,11 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_TAG_TYPE_EFI_BS: case MULTIBOOT_TAG_TYPE_EFI32_IH: case MULTIBOOT_TAG_TYPE_EFI64_IH: + case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR: break; default: - grub_free (buffer); + grub_free (mld.buffer); return grub_error (GRUB_ERR_UNKNOWN_OS, "unsupported information tag: 0x%x", request_tag->requests[i]); @@ -215,6 +221,27 @@ grub_multiboot_load (grub_file_t file, const char *filename) accepted_consoles |= GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER; break; + case MULTIBOOT_HEADER_TAG_RELOCATABLE: + mld.relocatable = 1; + rel_tag = (struct multiboot_header_tag_relocatable *) tag; + mld.min_addr = rel_tag->min_addr; + mld.max_addr = rel_tag->max_addr; + mld.align = rel_tag->align; + switch (rel_tag->preference) + { + case MULTIBOOT_LOAD_PREFERENCE_LOW: + mld.preference = GRUB_RELOCATOR_PREFERENCE_LOW; + break; + + case MULTIBOOT_LOAD_PREFERENCE_HIGH: + mld.preference = GRUB_RELOCATOR_PREFERENCE_HIGH; + break; + + default: + mld.preference = GRUB_RELOCATOR_PREFERENCE_NONE; + } + break; + /* GRUB always page-aligns modules. */ case MULTIBOOT_HEADER_TAG_MODULE_ALIGN: break; @@ -228,7 +255,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) default: if (! (tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)) { - grub_free (buffer); + grub_free (mld.buffer); return grub_error (GRUB_ERR_UNKNOWN_OS, "unsupported tag: 0x%x", tag->type); } @@ -237,7 +264,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) if (addr_tag && !entry_specified && !(keep_bs && efi_entry_specified)) { - grub_free (buffer); + grub_free (mld.buffer); return grub_error (GRUB_ERR_UNKNOWN_OS, "load address tag without entry address tag"); } @@ -246,8 +273,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) { grub_uint64_t load_addr = (addr_tag->load_addr + 1) ? addr_tag->load_addr : (addr_tag->header_addr - - ((char *) header - (char *) buffer)); - int offset = ((char *) header - (char *) buffer - + - ((char *) header - (char *) mld.buffer)); + int offset = ((char *) header - (char *) mld.buffer - (addr_tag->header_addr - load_addr)); int load_size = ((addr_tag->load_end_addr == 0) ? file->size - offset : addr_tag->load_end_addr - addr_tag->load_addr); @@ -260,27 +287,50 @@ grub_multiboot_load (grub_file_t file, const char *filename) else code_size = load_size; - err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, - &ch, load_addr, - code_size); + if (mld.relocatable) + { + if (code_size > mld.max_addr || mld.min_addr > mld.max_addr - code_size) + { + grub_free (mld.buffer); + return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); + } + + err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + mld.min_addr, mld.max_addr - code_size, + code_size, mld.align ? mld.align : 1, + mld.preference, keep_bs); + } + else + err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, + &ch, load_addr, code_size); if (err) { grub_dprintf ("multiboot_loader", "Error loading aout kludge\n"); - grub_free (buffer); + grub_free (mld.buffer); return err; } + mld.link_base_addr = load_addr; + mld.load_base_addr = get_physical_target_address (ch); source = get_virtual_current_address (ch); + grub_dprintf ("multiboot_loader", "link_base_addr=0x%x, load_base_addr=0x%x, " + "load_size=0x%lx, relocatable=%d\n", mld.link_base_addr, + mld.load_base_addr, (long) code_size, mld.relocatable); + + if (mld.relocatable) + grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, avoid_efi_boot_services=%d\n", + (long) mld.align, mld.preference, keep_bs); + if ((grub_file_seek (file, offset)) == (grub_off_t) -1) { - grub_free (buffer); + grub_free (mld.buffer); return grub_errno; } grub_file_read (file, source, load_size); if (grub_errno) { - grub_free (buffer); + grub_free (mld.buffer); return grub_errno; } @@ -290,19 +340,41 @@ grub_multiboot_load (grub_file_t file, const char *filename) } else { - err = grub_multiboot_load_elf (file, filename, buffer); + mld.file = file; + mld.filename = filename; + mld.avoid_efi_boot_services = keep_bs; + err = grub_multiboot_load_elf (&mld); if (err) { - grub_free (buffer); + grub_free (mld.buffer); return err; } } + load_base_addr = mld.load_base_addr; + if (keep_bs && efi_entry_specified) grub_multiboot_payload_eip = efi_entry; else if (entry_specified) grub_multiboot_payload_eip = entry; + if (mld.relocatable) + { + /* + * Both branches are mathematically equivalent. However, it looks + * that real life (C?) is more complicated. I am trying to avoid + * wrap around here if mld.load_base_addr < mld.link_base_addr. + * If you look at C operator precedence then everything should work. + * However, I am not 100% sure that a given compiler will not + * optimize/break this stuff. So, maybe we should use signed + * 64-bit int here. + */ + if (mld.load_base_addr >= mld.link_base_addr) + grub_multiboot_payload_eip += mld.load_base_addr - mld.link_base_addr; + else + grub_multiboot_payload_eip -= mld.link_base_addr - mld.load_base_addr; + } + if (fbtag) err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER, accepted_consoles, @@ -411,6 +483,7 @@ grub_multiboot_get_mbi_size (void) + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN) + + ALIGN_UP (sizeof (struct multiboot_tag_load_base_addr), MULTIBOOT_TAG_ALIGN) + acpiv2_size () + net_size () #ifdef GRUB_MACHINE_EFI @@ -693,6 +766,15 @@ grub_multiboot_make_mbi (grub_uint32_t *target) % sizeof (grub_properly_aligned_t) == 0); ptrorig += (2 * sizeof (grub_uint32_t)) / sizeof (grub_properly_aligned_t); + { + struct multiboot_tag_load_base_addr *tag = (struct multiboot_tag_load_base_addr *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR; + tag->size = sizeof (struct multiboot_tag_load_base_addr); + tag->load_base_addr = load_base_addr; + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } + { struct multiboot_tag_string *tag = (struct multiboot_tag_string *) ptrorig; tag->type = MULTIBOOT_TAG_TYPE_CMDLINE; diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index e13c0843b..c96492bb5 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -91,10 +91,28 @@ grub_multiboot_set_console (int console_type, int accepted_consoles, int console_required); grub_err_t grub_multiboot_load (grub_file_t file, const char *filename); + +struct mbi_load_data +{ + grub_file_t file; + const char *filename; + void *buffer; + unsigned int mbi_ver; + int relocatable; + grub_uint32_t min_addr; + grub_uint32_t max_addr; + grub_size_t align; + grub_uint32_t preference; + grub_uint32_t link_base_addr; + grub_uint32_t load_base_addr; + int avoid_efi_boot_services; +}; +typedef struct mbi_load_data mbi_load_data_t; + /* Load ELF32 or ELF64. */ grub_err_t -grub_multiboot_load_elf (grub_file_t file, const char *filename, - void *buffer); +grub_multiboot_load_elf (mbi_load_data_t *mld); + extern grub_size_t grub_multiboot_pure_size; extern grub_size_t grub_multiboot_alloc_mbi; extern grub_uint32_t grub_multiboot_payload_eip; diff --git a/include/multiboot2.h b/include/multiboot2.h index f5bebe1e3..5a3db5a7c 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -62,6 +62,7 @@ #define MULTIBOOT_TAG_TYPE_EFI_BS 18 #define MULTIBOOT_TAG_TYPE_EFI32_IH 19 #define MULTIBOOT_TAG_TYPE_EFI64_IH 20 +#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 #define MULTIBOOT_HEADER_TAG_END 0 #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 @@ -72,11 +73,16 @@ #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 #define MULTIBOOT_HEADER_TAG_EFI_BS 7 #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 +#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 #define MULTIBOOT_ARCHITECTURE_I386 0 #define MULTIBOOT_ARCHITECTURE_MIPS32 4 #define MULTIBOOT_HEADER_TAG_OPTIONAL 1 +#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 +#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 +#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 + #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 #define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 @@ -161,6 +167,17 @@ struct multiboot_header_tag_module_align multiboot_uint32_t size; }; +struct multiboot_header_tag_relocatable +{ + multiboot_uint16_t type; + multiboot_uint16_t flags; + multiboot_uint32_t size; + multiboot_uint32_t min_addr; + multiboot_uint32_t max_addr; + multiboot_uint32_t align; + multiboot_uint32_t preference; +}; + struct multiboot_color { multiboot_uint8_t red; @@ -387,6 +404,13 @@ struct multiboot_tag_efi64_ih multiboot_uint64_t pointer; }; +struct multiboot_tag_load_base_addr +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t load_base_addr; +}; + #endif /* ! ASM_FILE */ #endif /* ! MULTIBOOT_HEADER */ From 4231927e449feeb8b1b39470a9b2288f2f773f25 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:06 +0100 Subject: [PATCH 0580/1167] xen: make xen loader callable multiple times The loader for xen paravirtualized environment isn't callable multiple times as it won't free any memory in case of failure. Call grub_relocator_unload() as other modules do it before allocating a new relocator or when unloading the module. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index c4d9689f7..179e89cb9 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -316,11 +316,23 @@ grub_xen_boot (void) xen_inf.virt_base); } +static void +grub_xen_reset (void) +{ + grub_memset (&next_start, 0, sizeof (next_start)); + xen_module_info_page = NULL; + n_modules = 0; + + grub_relocator_unload (relocator); + relocator = NULL; + loaded = 0; +} + static grub_err_t grub_xen_unload (void) { + grub_xen_reset (); grub_dl_unref (my_mod); - loaded = 0; return GRUB_ERR_NONE; } @@ -403,10 +415,7 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset (); - grub_memset (&next_start, 0, sizeof (next_start)); - - xen_module_info_page = NULL; - n_modules = 0; + grub_xen_reset (); grub_create_loader_cmdline (argc - 1, argv + 1, (char *) next_start.cmd_line, @@ -503,16 +512,18 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), goto fail; fail: + /* grub_errno might be clobbered by further calls, save the error reason. */ + err = grub_errno; if (elf) grub_elf_close (elf); else if (file) grub_file_close (file); - if (grub_errno != GRUB_ERR_NONE) - loaded = 0; + if (err != GRUB_ERR_NONE) + grub_xen_reset (); - return grub_errno; + return err; } static grub_err_t From c69d1858f1187b7d78cae33f213a946ec2e50e8b Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:07 +0100 Subject: [PATCH 0581/1167] xen: avoid memleaks on error When loading a Xen pv-kernel avoid memory leaks in case of errors. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 2 +- grub-core/loader/i386/xen_fileXX.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 179e89cb9..f45f70f1d 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -563,7 +563,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { err = grub_relocator_alloc_chunk_addr (relocator, &ch, max_addr, size); if (err) - return err; + goto fail; if (grub_initrd_load (&initrd_ctx, argv, get_virtual_current_address (ch))) diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 1ba5649e2..36b40e4b0 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -26,6 +26,8 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, char *buf; char *ptr; int has_paddr = 0; + + grub_errno = GRUB_ERR_NONE; if (grub_file_seek (elf->file, off) == (grub_off_t) -1) return grub_errno; buf = grub_malloc (sz); @@ -35,7 +37,8 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, if (grub_file_read (elf->file, buf, sz) != (grub_ssize_t) sz) { if (grub_errno) - return grub_errno; + goto out; + grub_free (buf); return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), elf->file->name); } @@ -123,14 +126,14 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, { xi->virt_base = grub_strtoull (ptr + sizeof ("VIRT_BASE=") - 1, &ptr, 16); if (grub_errno) - return grub_errno; + goto out; continue; } if (grub_strncmp (ptr, "VIRT_ENTRY=", sizeof ("VIRT_ENTRY=") - 1) == 0) { xi->entry_point = grub_strtoull (ptr + sizeof ("VIRT_ENTRY=") - 1, &ptr, 16); if (grub_errno) - return grub_errno; + goto out; continue; } if (grub_strncmp (ptr, "HYPERCALL_PAGE=", sizeof ("HYPERCALL_PAGE=") - 1) == 0) @@ -138,7 +141,7 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, xi->hypercall_page = grub_strtoull (ptr + sizeof ("HYPERCALL_PAGE=") - 1, &ptr, 16); xi->has_hypercall_page = 1; if (grub_errno) - return grub_errno; + goto out; continue; } if (grub_strncmp (ptr, "ELF_PADDR_OFFSET=", sizeof ("ELF_PADDR_OFFSET=") - 1) == 0) @@ -146,7 +149,7 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, xi->paddr_offset = grub_strtoull (ptr + sizeof ("ELF_PADDR_OFFSET=") - 1, &ptr, 16); has_paddr = 1; if (grub_errno) - return grub_errno; + goto out; continue; } } @@ -154,7 +157,11 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, xi->hypercall_page = (xi->hypercall_page << 12) + xi->virt_base; if (!has_paddr) xi->paddr_offset = xi->virt_base; - return GRUB_ERR_NONE; + +out: + grub_free (buf); + + return grub_errno; } #pragma GCC diagnostic ignored "-Wcast-align" From 6ae55ce1038425ca8811365725e939b47a99b33a Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:08 +0100 Subject: [PATCH 0582/1167] xen: reduce number of global variables in xen loader The loader for xen paravirtualized environment is using lots of global variables. Reduce the number by making them either local or by putting them into a single state structure. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 259 +++++++++++++++++++----------------- 1 file changed, 138 insertions(+), 121 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index f45f70f1d..691c22e8a 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -42,16 +42,20 @@ GRUB_MOD_LICENSE ("GPLv3+"); -static struct grub_relocator *relocator = NULL; -static grub_uint64_t max_addr; +struct xen_loader_state { + struct grub_relocator *relocator; + struct start_info next_start; + struct grub_xen_file_info xen_inf; + grub_uint64_t max_addr; + struct xen_multiboot_mod_list *module_info_page; + grub_uint64_t modules_target_start; + grub_size_t n_modules; + int loaded; +}; + +static struct xen_loader_state xen_state; + static grub_dl_t my_mod; -static int loaded = 0; -static struct start_info next_start; -static void *kern_chunk_src; -static struct grub_xen_file_info xen_inf; -static struct xen_multiboot_mod_list *xen_module_info_page; -static grub_uint64_t modules_target_start; -static grub_size_t n_modules; #define PAGE_SIZE 4096 #define MAX_MODULES (PAGE_SIZE / sizeof (struct xen_multiboot_mod_list)) @@ -225,50 +229,55 @@ grub_xen_boot (void) if (grub_xen_n_allocated_shared_pages) return grub_error (GRUB_ERR_BUG, "active grants"); - state.mfn_list = max_addr; - next_start.mfn_list = max_addr + xen_inf.virt_base; - next_start.first_p2m_pfn = max_addr >> PAGE_SHIFT; /* Is this right? */ + state.mfn_list = xen_state.max_addr; + xen_state.next_start.mfn_list = + xen_state.max_addr + xen_state.xen_inf.virt_base; + xen_state.next_start.first_p2m_pfn = xen_state.max_addr >> PAGE_SHIFT; pgtsize = sizeof (grub_xen_mfn_t) * grub_xen_start_page_addr->nr_pages; - err = grub_relocator_alloc_chunk_addr (relocator, &ch, max_addr, pgtsize); - next_start.nr_p2m_frames = (pgtsize + PAGE_SIZE - 1) >> PAGE_SHIFT; + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, pgtsize); + xen_state.next_start.nr_p2m_frames = (pgtsize + PAGE_SIZE - 1) >> PAGE_SHIFT; if (err) return err; new_mfn_list = get_virtual_current_address (ch); grub_memcpy (new_mfn_list, (void *) grub_xen_start_page_addr->mfn_list, pgtsize); - max_addr = ALIGN_UP (max_addr + pgtsize, PAGE_SIZE); + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + pgtsize, PAGE_SIZE); - err = grub_relocator_alloc_chunk_addr (relocator, &ch, - max_addr, sizeof (next_start)); + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, + sizeof (xen_state.next_start)); if (err) return err; - state.start_info = max_addr + xen_inf.virt_base; + state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base; nst = get_virtual_current_address (ch); - max_addr = ALIGN_UP (max_addr + sizeof (next_start), PAGE_SIZE); + xen_state.max_addr = + ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE); - next_start.nr_pages = grub_xen_start_page_addr->nr_pages; - grub_memcpy (next_start.magic, grub_xen_start_page_addr->magic, - sizeof (next_start.magic)); - next_start.store_mfn = grub_xen_start_page_addr->store_mfn; - next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn; - next_start.console.domU = grub_xen_start_page_addr->console.domU; - next_start.shared_info = grub_xen_start_page_addr->shared_info; + xen_state.next_start.nr_pages = grub_xen_start_page_addr->nr_pages; + grub_memcpy (xen_state.next_start.magic, grub_xen_start_page_addr->magic, + sizeof (xen_state.next_start.magic)); + xen_state.next_start.store_mfn = grub_xen_start_page_addr->store_mfn; + xen_state.next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn; + xen_state.next_start.console.domU = grub_xen_start_page_addr->console.domU; + xen_state.next_start.shared_info = grub_xen_start_page_addr->shared_info; - err = set_mfns (new_mfn_list, max_addr >> PAGE_SHIFT); + err = set_mfns (new_mfn_list, xen_state.max_addr >> PAGE_SHIFT); if (err) return err; - max_addr += 2 * PAGE_SIZE; + xen_state.max_addr += 2 * PAGE_SIZE; - next_start.pt_base = max_addr + xen_inf.virt_base; - state.paging_start = max_addr >> PAGE_SHIFT; + xen_state.next_start.pt_base = + xen_state.max_addr + xen_state.xen_inf.virt_base; + state.paging_start = xen_state.max_addr >> PAGE_SHIFT; - nr_info_pages = max_addr >> PAGE_SHIFT; + nr_info_pages = xen_state.max_addr >> PAGE_SHIFT; nr_pages = nr_info_pages; while (1) { nr_pages = ALIGN_UP (nr_pages, (ALIGN_SIZE >> PAGE_SHIFT)); - nr_pt_pages = get_pgtable_size (nr_pages, xen_inf.virt_base); + nr_pt_pages = get_pgtable_size (nr_pages, xen_state.xen_inf.virt_base); nr_need_pages = nr_info_pages + nr_pt_pages + ((ADDITIONAL_SIZE + STACK_SIZE) >> PAGE_SHIFT); @@ -278,27 +287,28 @@ grub_xen_boot (void) } grub_dprintf ("xen", "bootstrap domain %llx+%llx\n", - (unsigned long long) xen_inf.virt_base, + (unsigned long long) xen_state.xen_inf.virt_base, (unsigned long long) page2offset (nr_pages)); - err = grub_relocator_alloc_chunk_addr (relocator, &ch, - max_addr, page2offset (nr_pt_pages)); + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, + page2offset (nr_pt_pages)); if (err) return err; generate_page_table (get_virtual_current_address (ch), - max_addr >> PAGE_SHIFT, nr_pages, - xen_inf.virt_base, new_mfn_list); + xen_state.max_addr >> PAGE_SHIFT, nr_pages, + xen_state.xen_inf.virt_base, new_mfn_list); - max_addr += page2offset (nr_pt_pages); - state.stack = max_addr + STACK_SIZE + xen_inf.virt_base; - state.entry_point = xen_inf.entry_point; + xen_state.max_addr += page2offset (nr_pt_pages); + state.stack = xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; + state.entry_point = xen_state.xen_inf.entry_point; - next_start.nr_p2m_frames += nr_pt_pages; - next_start.nr_pt_frames = nr_pt_pages; + xen_state.next_start.nr_p2m_frames += nr_pt_pages; + xen_state.next_start.nr_pt_frames = nr_pt_pages; state.paging_size = nr_pt_pages; - *nst = next_start; + *nst = xen_state.next_start; grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); @@ -308,24 +318,20 @@ grub_xen_boot (void) for (i = 0; i < ARRAY_SIZE (grub_xen_shared_info->evtchn_pending); i++) grub_xen_shared_info->evtchn_pending[i] = 0; - return grub_relocator_xen_boot (relocator, state, nr_pages, - xen_inf.virt_base < + return grub_relocator_xen_boot (xen_state.relocator, state, nr_pages, + xen_state.xen_inf.virt_base < PAGE_SIZE ? page2offset (nr_pages) : 0, nr_pages - 1, page2offset (nr_pages - 1) + - xen_inf.virt_base); + xen_state.xen_inf.virt_base); } static void grub_xen_reset (void) { - grub_memset (&next_start, 0, sizeof (next_start)); - xen_module_info_page = NULL; - n_modules = 0; + grub_relocator_unload (xen_state.relocator); - grub_relocator_unload (relocator); - relocator = NULL; - loaded = 0; + grub_memset (&xen_state, 0, sizeof (xen_state)); } static grub_err_t @@ -409,17 +415,22 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), grub_file_t file; grub_elf_t elf; grub_err_t err; + void *kern_chunk_src; + grub_relocator_chunk_t ch; + grub_addr_t kern_start; + grub_addr_t kern_end; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + /* Call grub_loader_unset early to avoid it being called by grub_loader_set */ grub_loader_unset (); grub_xen_reset (); grub_create_loader_cmdline (argc - 1, argv + 1, - (char *) next_start.cmd_line, - sizeof (next_start.cmd_line) - 1); + (char *) xen_state.next_start.cmd_line, + sizeof (xen_state.next_start.cmd_line) - 1); file = grub_file_open (argv[0]); if (!file) @@ -429,85 +440,82 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), if (!elf) goto fail; - err = grub_xen_get_info (elf, &xen_inf); + err = grub_xen_get_info (elf, &xen_state.xen_inf); if (err) goto fail; #ifdef __x86_64__ - if (xen_inf.arch != GRUB_XEN_FILE_X86_64) + if (xen_state.xen_inf.arch != GRUB_XEN_FILE_X86_64) #else - if (xen_inf.arch != GRUB_XEN_FILE_I386_PAE - && xen_inf.arch != GRUB_XEN_FILE_I386_PAE_BIMODE) + if (xen_state.xen_inf.arch != GRUB_XEN_FILE_I386_PAE + && xen_state.xen_inf.arch != GRUB_XEN_FILE_I386_PAE_BIMODE) #endif { grub_error (GRUB_ERR_BAD_OS, "incompatible architecture: %d", - xen_inf.arch); + xen_state.xen_inf.arch); goto fail; } - if (xen_inf.virt_base & (PAGE_SIZE - 1)) + if (xen_state.xen_inf.virt_base & (PAGE_SIZE - 1)) { grub_error (GRUB_ERR_BAD_OS, "unaligned virt_base"); goto fail; } grub_dprintf ("xen", "virt_base = %llx, entry = %llx\n", - (unsigned long long) xen_inf.virt_base, - (unsigned long long) xen_inf.entry_point); + (unsigned long long) xen_state.xen_inf.virt_base, + (unsigned long long) xen_state.xen_inf.entry_point); - relocator = grub_relocator_new (); - if (!relocator) + xen_state.relocator = grub_relocator_new (); + if (!xen_state.relocator) goto fail; - grub_relocator_chunk_t ch; - grub_addr_t kern_start = xen_inf.kern_start - xen_inf.paddr_offset; - grub_addr_t kern_end = xen_inf.kern_end - xen_inf.paddr_offset; + kern_start = xen_state.xen_inf.kern_start - xen_state.xen_inf.paddr_offset; + kern_end = xen_state.xen_inf.kern_end - xen_state.xen_inf.paddr_offset; - if (xen_inf.has_hypercall_page) + if (xen_state.xen_inf.has_hypercall_page) { grub_dprintf ("xen", "hypercall page at 0x%llx\n", - (unsigned long long) xen_inf.hypercall_page); - if (xen_inf.hypercall_page - xen_inf.virt_base < kern_start) - kern_start = xen_inf.hypercall_page - xen_inf.virt_base; - - if (xen_inf.hypercall_page - xen_inf.virt_base + PAGE_SIZE > kern_end) - kern_end = xen_inf.hypercall_page - xen_inf.virt_base + PAGE_SIZE; + (unsigned long long) xen_state.xen_inf.hypercall_page); + kern_start = grub_min (kern_start, xen_state.xen_inf.hypercall_page - + xen_state.xen_inf.virt_base); + kern_end = grub_max (kern_end, xen_state.xen_inf.hypercall_page - + xen_state.xen_inf.virt_base + PAGE_SIZE); } - max_addr = ALIGN_UP (kern_end, PAGE_SIZE); + xen_state.max_addr = ALIGN_UP (kern_end, PAGE_SIZE); - err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start, + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, kern_end - kern_start); if (err) goto fail; kern_chunk_src = get_virtual_current_address (ch); grub_dprintf ("xen", "paddr_offset = 0x%llx\n", - (unsigned long long) xen_inf.paddr_offset); + (unsigned long long) xen_state.xen_inf.paddr_offset); grub_dprintf ("xen", "kern_start = 0x%llx, kern_end = 0x%llx\n", - (unsigned long long) xen_inf.kern_start, - (unsigned long long) xen_inf.kern_end); + (unsigned long long) xen_state.xen_inf.kern_start, + (unsigned long long) xen_state.xen_inf.kern_end); err = grub_elfXX_load (elf, argv[0], (grub_uint8_t *) kern_chunk_src - kern_start - - xen_inf.paddr_offset, 0, 0, 0); + - xen_state.xen_inf.paddr_offset, 0, 0, 0); - if (xen_inf.has_hypercall_page) + if (xen_state.xen_inf.has_hypercall_page) { unsigned i; for (i = 0; i < PAGE_SIZE / HYPERCALL_INTERFACE_SIZE; i++) set_hypercall_interface ((grub_uint8_t *) kern_chunk_src + i * HYPERCALL_INTERFACE_SIZE + - xen_inf.hypercall_page - xen_inf.virt_base - - kern_start, i); + xen_state.xen_inf.hypercall_page - + xen_state.xen_inf.virt_base - kern_start, i); } if (err) goto fail; grub_dl_ref (my_mod); - loaded = 1; + xen_state.loaded = 1; grub_loader_set (grub_xen_boot, grub_xen_unload, 0); - loaded = 1; goto fail; @@ -541,14 +549,14 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (!loaded) + if (!xen_state.loaded) { grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); goto fail; } - if (next_start.mod_start || next_start.mod_len) + if (xen_state.next_start.mod_start || xen_state.next_start.mod_len) { grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd already loaded")); goto fail; @@ -561,7 +569,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (size) { - err = grub_relocator_alloc_chunk_addr (relocator, &ch, max_addr, size); + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, size); if (err) goto fail; @@ -570,13 +579,14 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - next_start.mod_start = max_addr + xen_inf.virt_base; - next_start.mod_len = size; + xen_state.next_start.mod_start = + xen_state.max_addr + xen_state.xen_inf.virt_base; + xen_state.next_start.mod_len = size; - max_addr = ALIGN_UP (max_addr + size, PAGE_SIZE); + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE); grub_dprintf ("xen", "Initrd, addr=0x%x, size=0x%x\n", - (unsigned) next_start.mod_start, (unsigned) size); + (unsigned) xen_state.next_start.mod_start, (unsigned) size); fail: grub_initrd_close (&initrd_ctx); @@ -608,45 +618,48 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - if (!loaded) + if (!xen_state.loaded) { return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); } - if ((next_start.mod_start || next_start.mod_len) && !xen_module_info_page) + if ((xen_state.next_start.mod_start || xen_state.next_start.mod_len) && + !xen_state.module_info_page) { return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd already loaded")); } /* Leave one space for terminator. */ - if (n_modules >= MAX_MODULES - 1) + if (xen_state.n_modules >= MAX_MODULES - 1) { return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many modules"); } - if (!xen_module_info_page) + if (!xen_state.module_info_page) { - n_modules = 0; - max_addr = ALIGN_UP (max_addr, PAGE_SIZE); - modules_target_start = max_addr; - next_start.mod_start = max_addr + xen_inf.virt_base; - next_start.flags |= SIF_MULTIBOOT_MOD; + xen_state.n_modules = 0; + xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE); + xen_state.modules_target_start = xen_state.max_addr; + xen_state.next_start.mod_start = + xen_state.max_addr + xen_state.xen_inf.virt_base; + xen_state.next_start.flags |= SIF_MULTIBOOT_MOD; - err = grub_relocator_alloc_chunk_addr (relocator, &ch, - max_addr, MAX_MODULES + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, MAX_MODULES * - sizeof (xen_module_info_page + sizeof (xen_state.module_info_page [0])); if (err) return err; - xen_module_info_page = get_virtual_current_address (ch); - grub_memset (xen_module_info_page, 0, MAX_MODULES - * sizeof (xen_module_info_page[0])); - max_addr += MAX_MODULES * sizeof (xen_module_info_page[0]); + xen_state.module_info_page = get_virtual_current_address (ch); + grub_memset (xen_state.module_info_page, 0, MAX_MODULES + * sizeof (xen_state.module_info_page[0])); + xen_state.max_addr += + MAX_MODULES * sizeof (xen_state.module_info_page[0]); } - max_addr = ALIGN_UP (max_addr, PAGE_SIZE); + xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE); if (nounzip) grub_file_filter_disable_compression (); @@ -657,20 +670,22 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), cmdline_len = grub_loader_cmdline_size (argc - 1, argv + 1); - err = grub_relocator_alloc_chunk_addr (relocator, &ch, - max_addr, cmdline_len); + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, cmdline_len); if (err) goto fail; grub_create_loader_cmdline (argc - 1, argv + 1, get_virtual_current_address (ch), cmdline_len); - xen_module_info_page[n_modules].cmdline = max_addr - modules_target_start; - max_addr = ALIGN_UP (max_addr + cmdline_len, PAGE_SIZE); + xen_state.module_info_page[xen_state.n_modules].cmdline = + xen_state.max_addr - xen_state.modules_target_start; + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + cmdline_len, PAGE_SIZE); if (size) { - err = grub_relocator_alloc_chunk_addr (relocator, &ch, max_addr, size); + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, size); if (err) goto fail; if (grub_file_read (file, get_virtual_current_address (ch), size) @@ -682,15 +697,17 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), goto fail; } } - next_start.mod_len = max_addr + size - modules_target_start; - xen_module_info_page[n_modules].mod_start = max_addr - modules_target_start; - xen_module_info_page[n_modules].mod_end = - max_addr + size - modules_target_start; + xen_state.next_start.mod_len = + xen_state.max_addr + size - xen_state.modules_target_start; + xen_state.module_info_page[xen_state.n_modules].mod_start = + xen_state.max_addr - xen_state.modules_target_start; + xen_state.module_info_page[xen_state.n_modules].mod_end = + xen_state.max_addr + size - xen_state.modules_target_start; - n_modules++; + xen_state.n_modules++; grub_dprintf ("xen", "module, addr=0x%x, size=0x%x\n", - (unsigned) max_addr, (unsigned) size); - max_addr = ALIGN_UP (max_addr + size, PAGE_SIZE); + (unsigned) xen_state.max_addr, (unsigned) size); + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE); fail: From 7e5fcb0b346063e1c5af2353b82e74cf299b8b67 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:09 +0100 Subject: [PATCH 0583/1167] xen: add elfnote.h to avoid using numbers instead of constants Various features and parameters of a pv-kernel are specified via elf notes in the kernel image. Those notes are part of the interface between the Xen hypervisor and the kernel. Instead of using num,bers in the code when interpreting the elf notes make use of the header supplied by Xen for that purpose. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen_fileXX.c | 19 +- include/xen/elfnote.h | 281 +++++++++++++++++++++++++++++ 2 files changed, 291 insertions(+), 9 deletions(-) create mode 100644 include/xen/elfnote.h diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 36b40e4b0..03215cab2 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -18,6 +18,7 @@ #include #include +#include static grub_err_t parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, @@ -203,35 +204,35 @@ parse_note (grub_elf_t elf, struct grub_xen_file_info *xi, xi->has_note = 1; switch (nh->n_type) { - case 1: + case XEN_ELFNOTE_ENTRY: xi->entry_point = grub_le_to_cpu_addr (*(Elf_Addr *) desc); break; - case 2: + case XEN_ELFNOTE_HYPERCALL_PAGE: xi->hypercall_page = grub_le_to_cpu_addr (*(Elf_Addr *) desc); xi->has_hypercall_page = 1; break; - case 3: + case XEN_ELFNOTE_VIRT_BASE: xi->virt_base = grub_le_to_cpu_addr (*(Elf_Addr *) desc); break; - case 4: + case XEN_ELFNOTE_PADDR_OFFSET: xi->paddr_offset = grub_le_to_cpu_addr (*(Elf_Addr *) desc); break; - case 5: + case XEN_ELFNOTE_XEN_VERSION: grub_dprintf ("xen", "xenversion = `%s'\n", (char *) desc); break; - case 6: + case XEN_ELFNOTE_GUEST_OS: grub_dprintf ("xen", "name = `%s'\n", (char *) desc); break; - case 7: + case XEN_ELFNOTE_GUEST_VERSION: grub_dprintf ("xen", "version = `%s'\n", (char *) desc); break; - case 8: + case XEN_ELFNOTE_LOADER: if (descsz < 7 || grub_memcmp (desc, "generic", descsz == 7 ? 7 : 8) != 0) return grub_error (GRUB_ERR_BAD_OS, "invalid loader"); break; /* PAE */ - case 9: + case XEN_ELFNOTE_PAE_MODE: grub_dprintf ("xen", "pae = `%s', %d, %d\n", (char *) desc, xi->arch, descsz); if (xi->arch != GRUB_XEN_FILE_I386 diff --git a/include/xen/elfnote.h b/include/xen/elfnote.h new file mode 100644 index 000000000..71cd4ec52 --- /dev/null +++ b/include/xen/elfnote.h @@ -0,0 +1,281 @@ +/****************************************************************************** + * elfnote.h + * + * Definitions used for the Xen ELF notes. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2006, Ian Campbell, XenSource Ltd. + */ + +#ifndef __XEN_PUBLIC_ELFNOTE_H__ +#define __XEN_PUBLIC_ELFNOTE_H__ + +/* + * `incontents 200 elfnotes ELF notes + * + * The notes should live in a PT_NOTE segment and have "Xen" in the + * name field. + * + * Numeric types are either 4 or 8 bytes depending on the content of + * the desc field. + * + * LEGACY indicated the fields in the legacy __xen_guest string which + * this a note type replaces. + * + * String values (for non-legacy) are NULL terminated ASCII, also known + * as ASCIZ type. + */ + +/* + * NAME=VALUE pair (string). + */ +#define XEN_ELFNOTE_INFO 0 + +/* + * The virtual address of the entry point (numeric). + * + * LEGACY: VIRT_ENTRY + */ +#define XEN_ELFNOTE_ENTRY 1 + +/* The virtual address of the hypercall transfer page (numeric). + * + * LEGACY: HYPERCALL_PAGE. (n.b. legacy value is a physical page + * number not a virtual address) + */ +#define XEN_ELFNOTE_HYPERCALL_PAGE 2 + +/* The virtual address where the kernel image should be mapped (numeric). + * + * Defaults to 0. + * + * LEGACY: VIRT_BASE + */ +#define XEN_ELFNOTE_VIRT_BASE 3 + +/* + * The offset of the ELF paddr field from the actual required + * pseudo-physical address (numeric). + * + * This is used to maintain backwards compatibility with older kernels + * which wrote __PAGE_OFFSET into that field. This field defaults to 0 + * if not present. + * + * LEGACY: ELF_PADDR_OFFSET. (n.b. legacy default is VIRT_BASE) + */ +#define XEN_ELFNOTE_PADDR_OFFSET 4 + +/* + * The version of Xen that we work with (string). + * + * LEGACY: XEN_VER + */ +#define XEN_ELFNOTE_XEN_VERSION 5 + +/* + * The name of the guest operating system (string). + * + * LEGACY: GUEST_OS + */ +#define XEN_ELFNOTE_GUEST_OS 6 + +/* + * The version of the guest operating system (string). + * + * LEGACY: GUEST_VER + */ +#define XEN_ELFNOTE_GUEST_VERSION 7 + +/* + * The loader type (string). + * + * LEGACY: LOADER + */ +#define XEN_ELFNOTE_LOADER 8 + +/* + * The kernel supports PAE (x86/32 only, string = "yes", "no" or + * "bimodal"). + * + * For compatibility with Xen 3.0.3 and earlier the "bimodal" setting + * may be given as "yes,bimodal" which will cause older Xen to treat + * this kernel as PAE. + * + * LEGACY: PAE (n.b. The legacy interface included a provision to + * indicate 'extended-cr3' support allowing L3 page tables to be + * placed above 4G. It is assumed that any kernel new enough to use + * these ELF notes will include this and therefore "yes" here is + * equivalent to "yes[entended-cr3]" in the __xen_guest interface. + */ +#define XEN_ELFNOTE_PAE_MODE 9 + +/* + * The features supported/required by this kernel (string). + * + * The string must consist of a list of feature names (as given in + * features.h, without the "XENFEAT_" prefix) separated by '|' + * characters. If a feature is required for the kernel to function + * then the feature name must be preceded by a '!' character. + * + * LEGACY: FEATURES + */ +#define XEN_ELFNOTE_FEATURES 10 + +/* + * The kernel requires the symbol table to be loaded (string = "yes" or "no") + * LEGACY: BSD_SYMTAB (n.b. The legacy treated the presence or absence + * of this string as a boolean flag rather than requiring "yes" or + * "no". + */ +#define XEN_ELFNOTE_BSD_SYMTAB 11 + +/* + * The lowest address the hypervisor hole can begin at (numeric). + * + * This must not be set higher than HYPERVISOR_VIRT_START. Its presence + * also indicates to the hypervisor that the kernel can deal with the + * hole starting at a higher address. + */ +#define XEN_ELFNOTE_HV_START_LOW 12 + +/* + * List of maddr_t-sized mask/value pairs describing how to recognize + * (non-present) L1 page table entries carrying valid MFNs (numeric). + */ +#define XEN_ELFNOTE_L1_MFN_VALID 13 + +/* + * Whether or not the guest supports cooperative suspend cancellation. + * This is a numeric value. + * + * Default is 0 + */ +#define XEN_ELFNOTE_SUSPEND_CANCEL 14 + +/* + * The (non-default) location the initial phys-to-machine map should be + * placed at by the hypervisor (Dom0) or the tools (DomU). + * The kernel must be prepared for this mapping to be established using + * large pages, despite such otherwise not being available to guests. + * The kernel must also be able to handle the page table pages used for + * this mapping not being accessible through the initial mapping. + * (Only x86-64 supports this at present.) + */ +#define XEN_ELFNOTE_INIT_P2M 15 + +/* + * Whether or not the guest can deal with being passed an initrd not + * mapped through its initial page tables. + */ +#define XEN_ELFNOTE_MOD_START_PFN 16 + +/* + * The features supported by this kernel (numeric). + * + * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a + * kernel to specify support for features that older hypervisors don't + * know about. The set of features 4.2 and newer hypervisors will + * consider supported by the kernel is the combination of the sets + * specified through this and the string note. + * + * LEGACY: FEATURES + */ +#define XEN_ELFNOTE_SUPPORTED_FEATURES 17 + +/* + * Physical entry point into the kernel. + * + * 32bit entry point into the kernel. When requested to launch the + * guest kernel in a HVM container, Xen will use this entry point to + * launch the guest in 32bit protected mode with paging disabled. + * Ignored otherwise. + */ +#define XEN_ELFNOTE_PHYS32_ENTRY 18 + +/* + * The number of the highest elfnote defined. + */ +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_PHYS32_ENTRY + +/* + * System information exported through crash notes. + * + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO + * note in case of a system crash. This note will contain various + * information about the system, see xen/include/xen/elfcore.h. + */ +#define XEN_ELFNOTE_CRASH_INFO 0x1000001 + +/* + * System registers exported through crash notes. + * + * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_REGS + * note per cpu in case of a system crash. This note is architecture + * specific and will contain registers not saved in the "CORE" note. + * See xen/include/xen/elfcore.h for more information. + */ +#define XEN_ELFNOTE_CRASH_REGS 0x1000002 + + +/* + * xen dump-core none note. + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE + * in its dump file to indicate that the file is xen dump-core + * file. This note doesn't have any other information. + * See tools/libxc/xc_core.h for more information. + */ +#define XEN_ELFNOTE_DUMPCORE_NONE 0x2000000 + +/* + * xen dump-core header note. + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER + * in its dump file. + * See tools/libxc/xc_core.h for more information. + */ +#define XEN_ELFNOTE_DUMPCORE_HEADER 0x2000001 + +/* + * xen dump-core xen version note. + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION + * in its dump file. It contains the xen version obtained via the + * XENVER hypercall. + * See tools/libxc/xc_core.h for more information. + */ +#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION 0x2000002 + +/* + * xen dump-core format version note. + * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION + * in its dump file. It contains a format version identifier. + * See tools/libxc/xc_core.h for more information. + */ +#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION 0x2000003 + +#endif /* __XEN_PUBLIC_ELFNOTE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From 72c28509fa60289391b9a865507635a6d261c6b3 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:10 +0100 Subject: [PATCH 0584/1167] xen: synchronize xen header Get actual version of include/xen/xen.h from the Xen repository in order to be able to use constants defined there. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- include/xen/arch-x86/xen-x86_32.h | 22 +++--- include/xen/arch-x86/xen-x86_64.h | 8 +- include/xen/xen.h | 125 ++++++++++++++++++++++-------- 3 files changed, 105 insertions(+), 50 deletions(-) diff --git a/include/xen/arch-x86/xen-x86_32.h b/include/xen/arch-x86/xen-x86_32.h index 15041911e..7eca6cd41 100644 --- a/include/xen/arch-x86/xen-x86_32.h +++ b/include/xen/arch-x86/xen-x86_32.h @@ -58,34 +58,31 @@ #define __HYPERVISOR_VIRT_START_PAE 0xF5800000 #define __MACH2PHYS_VIRT_START_PAE 0xF5800000 #define __MACH2PHYS_VIRT_END_PAE 0xF6800000 -#define HYPERVISOR_VIRT_START_PAE \ - mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE) -#define MACH2PHYS_VIRT_START_PAE \ - mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE) -#define MACH2PHYS_VIRT_END_PAE \ - mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE) +#define HYPERVISOR_VIRT_START_PAE xen_mk_ulong(__HYPERVISOR_VIRT_START_PAE) +#define MACH2PHYS_VIRT_START_PAE xen_mk_ulong(__MACH2PHYS_VIRT_START_PAE) +#define MACH2PHYS_VIRT_END_PAE xen_mk_ulong(__MACH2PHYS_VIRT_END_PAE) /* Non-PAE bounds are obsolete. */ #define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000 #define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000 #define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000 #define HYPERVISOR_VIRT_START_NONPAE \ - mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE) + xen_mk_ulong(__HYPERVISOR_VIRT_START_NONPAE) #define MACH2PHYS_VIRT_START_NONPAE \ - mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE) + xen_mk_ulong(__MACH2PHYS_VIRT_START_NONPAE) #define MACH2PHYS_VIRT_END_NONPAE \ - mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE) + xen_mk_ulong(__MACH2PHYS_VIRT_END_NONPAE) #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE #ifndef HYPERVISOR_VIRT_START -#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) +#define HYPERVISOR_VIRT_START xen_mk_ulong(__HYPERVISOR_VIRT_START) #endif -#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) -#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_VIRT_START xen_mk_ulong(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END xen_mk_ulong(__MACH2PHYS_VIRT_END) #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2) #ifndef machine_to_phys_mapping #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START) @@ -104,6 +101,7 @@ do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \ (hnd).p = val; \ } while ( 0 ) +#define int64_aligned_t int64_t __attribute__((aligned(8))) #define uint64_aligned_t uint64_t __attribute__((aligned(8))) #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name) diff --git a/include/xen/arch-x86/xen-x86_64.h b/include/xen/arch-x86/xen-x86_64.h index 1c4e1590f..5e18613bd 100644 --- a/include/xen/arch-x86/xen-x86_64.h +++ b/include/xen/arch-x86/xen-x86_64.h @@ -76,12 +76,12 @@ #define __MACH2PHYS_VIRT_END 0xFFFF804000000000 #ifndef HYPERVISOR_VIRT_START -#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) -#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END) +#define HYPERVISOR_VIRT_START xen_mk_ulong(__HYPERVISOR_VIRT_START) +#define HYPERVISOR_VIRT_END xen_mk_ulong(__HYPERVISOR_VIRT_END) #endif -#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) -#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_VIRT_START xen_mk_ulong(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END xen_mk_ulong(__MACH2PHYS_VIRT_END) #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3) #ifndef machine_to_phys_mapping #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) diff --git a/include/xen/xen.h b/include/xen/xen.h index a6a20926a..6c9e42b2b 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -52,6 +52,19 @@ DEFINE_XEN_GUEST_HANDLE(void); DEFINE_XEN_GUEST_HANDLE(uint64_t); DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); + +/* Turn a plain number into a C unsigned (long) constant. */ +#define __xen_mk_uint(x) x ## U +#define __xen_mk_ulong(x) x ## UL +#define xen_mk_uint(x) __xen_mk_uint(x) +#define xen_mk_ulong(x) __xen_mk_ulong(x) + +#else + +/* In assembly code we cannot use C numeric constant suffixes. */ +#define xen_mk_uint(x) x +#define xen_mk_ulong(x) x + #endif /* @@ -101,6 +114,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_kexec_op 37 #define __HYPERVISOR_tmem_op 38 #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ +#define __HYPERVISOR_xenpmu_op 40 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 @@ -160,6 +174,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */ #define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */ #define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */ +#define VIRQ_XENPMU 13 /* V. PMC interrupt */ /* Architecture-specific VIRQ definitions. */ #define VIRQ_ARCH_0 16 @@ -449,13 +464,13 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); /* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */ /* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */ /* ` enum uvm_flags { */ -#define UVMF_NONE (0UL<<0) /* No flushing at all. */ -#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */ -#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */ -#define UVMF_FLUSHTYPE_MASK (3UL<<0) -#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */ -#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */ -#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */ +#define UVMF_NONE (xen_mk_ulong(0)<<0) /* No flushing at all. */ +#define UVMF_TLB_FLUSH (xen_mk_ulong(1)<<0) /* Flush entire TLB(s). */ +#define UVMF_INVLPG (xen_mk_ulong(2)<<0) /* Flush only one entry. */ +#define UVMF_FLUSHTYPE_MASK (xen_mk_ulong(3)<<0) +#define UVMF_MULTI (xen_mk_ulong(0)<<2) /* Flush subset of TLBs. */ +#define UVMF_LOCAL (xen_mk_ulong(0)<<2) /* Flush local TLB. */ +#define UVMF_ALL (xen_mk_ulong(1)<<2) /* Flush all TLBs. */ /* ` } */ /* @@ -486,17 +501,27 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); /* x86/PAE guests: support PDPTs above 4GB. */ #define VMASST_TYPE_pae_extended_cr3 3 +/* + * x86/64 guests: strictly hide M2P from user mode. + * This allows the guest to control respective hypervisor behavior: + * - when not set, L4 tables get created with the respective slot blank, + * and whenever the L4 table gets used as a kernel one the missing + * mapping gets inserted, + * - when set, L4 tables get created with the respective slot initialized + * as before, and whenever the L4 table gets used as a user one the + * mapping gets zapped. + */ +#define VMASST_TYPE_m2p_strict 32 + +#if __XEN_INTERFACE_VERSION__ < 0x00040600 #define MAX_VMASST_TYPE 3 - -#ifndef __ASSEMBLY__ - -typedef uint16_t domid_t; +#endif /* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ -#define DOMID_FIRST_RESERVED (0x7FF0U) +#define DOMID_FIRST_RESERVED xen_mk_uint(0x7FF0) /* DOMID_SELF is used in certain contexts to refer to oneself. */ -#define DOMID_SELF (0x7FF0U) +#define DOMID_SELF xen_mk_uint(0x7FF0) /* * DOMID_IO is used to restrict page-table updates to mapping I/O memory. @@ -507,7 +532,7 @@ typedef uint16_t domid_t; * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can * be specified by any calling domain. */ -#define DOMID_IO (0x7FF1U) +#define DOMID_IO xen_mk_uint(0x7FF1) /* * DOMID_XEN is used to allow privileged domains to map restricted parts of @@ -515,17 +540,21 @@ typedef uint16_t domid_t; * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if * the caller is privileged. */ -#define DOMID_XEN (0x7FF2U) +#define DOMID_XEN xen_mk_uint(0x7FF2) /* * DOMID_COW is used as the owner of sharable pages */ -#define DOMID_COW (0x7FF3U) +#define DOMID_COW xen_mk_uint(0x7FF3) /* DOMID_INVALID is used to identify pages with unknown owner. */ -#define DOMID_INVALID (0x7FF4U) +#define DOMID_INVALID xen_mk_uint(0x7FF4) /* Idle domain. */ -#define DOMID_IDLE (0x7FFFU) +#define DOMID_IDLE xen_mk_uint(0x7FFF) + +#ifndef __ASSEMBLY__ + +typedef uint16_t domid_t; /* * Send an array of these to HYPERVISOR_mmu_update(). @@ -682,6 +711,12 @@ struct shared_info { uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */ uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */ +#if !defined(__i386__) + uint32_t wc_sec_hi; +# define xen_wc_sec_hi wc_sec_hi +#elif !defined(__XEN__) && !defined(__XEN_TOOLS__) +# define xen_wc_sec_hi arch.wc_sec_hi +#endif struct arch_shared_info arch; @@ -698,24 +733,27 @@ typedef struct shared_info shared_info_t; * 3. This the order of bootstrap elements in the initial virtual region: * a. relocated kernel image * b. initial ram disk [mod_start, mod_len] + * (may be omitted) * c. list of allocated page frames [mfn_list, nr_pages] * (unless relocated due to XEN_ELFNOTE_INIT_P2M) * d. start_info_t structure [register ESI (x86)] - * e. bootstrap page tables [pt_base and CR3 (x86)] - * f. bootstrap stack [register ESP (x86)] + * in case of dom0 this page contains the console info, too + * e. unless dom0: xenstore ring page + * f. unless dom0: console ring page + * g. bootstrap page tables [pt_base and CR3 (x86)] + * h. bootstrap stack [register ESP (x86)] * 4. Bootstrap elements are packed together, but each is 4kB-aligned. - * 5. The initial ram disk may be omitted. - * 6. The list of page frames forms a contiguous 'pseudo-physical' memory + * 5. The list of page frames forms a contiguous 'pseudo-physical' memory * layout for the domain. In particular, the bootstrap virtual-memory * region is a 1:1 mapping to the first section of the pseudo-physical map. - * 7. All bootstrap elements are mapped read-writable for the guest OS. The + * 6. All bootstrap elements are mapped read-writable for the guest OS. The * only exception is the bootstrap page table, which is mapped read-only. - * 8. There is guaranteed to be at least 512kB padding after the final + * 7. There is guaranteed to be at least 512kB padding after the final * bootstrap element. If necessary, the bootstrap virtual region is * extended by an extra 4MB to ensure this. * * Note: Prior to 25833:bb85bbccb1c9. ("x86/32-on-64 adjust Dom0 initial page - * table layout") a bug caused the pt_base (3.e above) and cr3 to not point + * table layout") a bug caused the pt_base (3.g above) and cr3 to not point * to the start of the guest page tables (it was offset by two pages). * This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU * or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got @@ -759,6 +797,29 @@ struct start_info { }; typedef struct start_info start_info_t; +/* + * Start of day structure passed to PVH guests in %ebx. + * + * NOTE: nothing will be loaded at physical address 0, so + * a 0 value in any of the address fields should be treated + * as not present. + */ +struct hvm_start_info { +#define HVM_START_MAGIC_VALUE 0x336ec578 + uint32_t magic; /* Contains the magic value 0x336ec578 */ + /* ("xEn3" with the 0x80 bit of the "E" set).*/ + uint32_t flags; /* SIF_xxx flags. */ + uint32_t cmdline_paddr; /* Physical address of the command line. */ + uint32_t nr_modules; /* Number of modules passed to the kernel. */ + uint32_t modlist_paddr; /* Physical address of an array of */ + /* hvm_modlist_entry. */ +}; + +struct hvm_modlist_entry { + uint32_t paddr; /* Physical address of the module. */ + uint32_t size; /* Size of the module in bytes. */ +}; + /* New console union for dom0 introduced in 0x00030203. */ #if __XEN_INTERFACE_VERSION__ < 0x00030203 #define console_mfn console.domU.mfn @@ -771,6 +832,8 @@ typedef struct start_info start_info_t; #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */ #define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */ #define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */ +#define SIF_VIRT_P2M_4TOOLS (1<<4) /* Do Xen tools understand a virt. mapped */ + /* P->M making the 3 level tree obsolete? */ #define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */ /* @@ -851,25 +914,19 @@ typedef struct dom0_vga_console_info { typedef uint8_t xen_domain_handle_t[16]; -/* Turn a plain number into a C unsigned long constant. */ -#define __mk_unsigned_long(x) x ## UL -#define mk_unsigned_long(x) __mk_unsigned_long(x) - __DEFINE_XEN_GUEST_HANDLE(uint8, uint8_t); __DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t); __DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t); __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); -#else /* __ASSEMBLY__ */ - -/* In assembly code we cannot use C numeric constant suffixes. */ -#define mk_unsigned_long(x) x - #endif /* !__ASSEMBLY__ */ /* Default definitions for macros used by domctl/sysctl. */ #if defined(__XEN__) || defined(__XEN_TOOLS__) +#ifndef int64_aligned_t +#define int64_aligned_t int64_t +#endif #ifndef uint64_aligned_t #define uint64_aligned_t uint64_t #endif From c221ea06b5ed13b51dda8e32d620a7ca2d555a8f Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:11 +0100 Subject: [PATCH 0585/1167] xen: factor out p2m list allocation into separate function Do the p2m list allocation of the to be loaded kernel in a separate function. This will allow doing the p2m list allocation at different times of the boot preparations depending on the features the kernel is supporting. While at this remove superfluous setting of first_p2m_pfn and nr_p2m_frames as those are needed only in case of the p2m list not being mapped by the initial kernel mapping. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 87 +++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 691c22e8a..a2fd1f60a 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -44,8 +44,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct xen_loader_state { struct grub_relocator *relocator; + struct grub_relocator_xen_state state; struct start_info next_start; struct grub_xen_file_info xen_inf; + grub_xen_mfn_t *virt_mfn_list; grub_uint64_t max_addr; struct xen_multiboot_mod_list *module_info_page; grub_uint64_t modules_target_start; @@ -170,7 +172,7 @@ generate_page_table (grub_uint64_t *where, grub_uint64_t paging_start, } static grub_err_t -set_mfns (grub_xen_mfn_t * new_mfn_list, grub_xen_mfn_t pfn) +set_mfns (grub_xen_mfn_t pfn) { grub_xen_mfn_t i, t; grub_xen_mfn_t cn_pfn = -1, st_pfn = -1; @@ -179,32 +181,34 @@ set_mfns (grub_xen_mfn_t * new_mfn_list, grub_xen_mfn_t pfn) for (i = 0; i < grub_xen_start_page_addr->nr_pages; i++) { - if (new_mfn_list[i] == grub_xen_start_page_addr->console.domU.mfn) + if (xen_state.virt_mfn_list[i] == + grub_xen_start_page_addr->console.domU.mfn) cn_pfn = i; - if (new_mfn_list[i] == grub_xen_start_page_addr->store_mfn) + if (xen_state.virt_mfn_list[i] == grub_xen_start_page_addr->store_mfn) st_pfn = i; } if (cn_pfn == (grub_xen_mfn_t)-1) return grub_error (GRUB_ERR_BUG, "no console"); if (st_pfn == (grub_xen_mfn_t)-1) return grub_error (GRUB_ERR_BUG, "no store"); - t = new_mfn_list[pfn]; - new_mfn_list[pfn] = new_mfn_list[cn_pfn]; - new_mfn_list[cn_pfn] = t; - t = new_mfn_list[pfn + 1]; - new_mfn_list[pfn + 1] = new_mfn_list[st_pfn]; - new_mfn_list[st_pfn] = t; + t = xen_state.virt_mfn_list[pfn]; + xen_state.virt_mfn_list[pfn] = xen_state.virt_mfn_list[cn_pfn]; + xen_state.virt_mfn_list[cn_pfn] = t; + t = xen_state.virt_mfn_list[pfn + 1]; + xen_state.virt_mfn_list[pfn + 1] = xen_state.virt_mfn_list[st_pfn]; + xen_state.virt_mfn_list[st_pfn] = t; - m2p_updates[0].ptr = page2offset (new_mfn_list[pfn]) | MMU_MACHPHYS_UPDATE; + m2p_updates[0].ptr = + page2offset (xen_state.virt_mfn_list[pfn]) | MMU_MACHPHYS_UPDATE; m2p_updates[0].val = pfn; m2p_updates[1].ptr = - page2offset (new_mfn_list[pfn + 1]) | MMU_MACHPHYS_UPDATE; + page2offset (xen_state.virt_mfn_list[pfn + 1]) | MMU_MACHPHYS_UPDATE; m2p_updates[1].val = pfn + 1; m2p_updates[2].ptr = - page2offset (new_mfn_list[cn_pfn]) | MMU_MACHPHYS_UPDATE; + page2offset (xen_state.virt_mfn_list[cn_pfn]) | MMU_MACHPHYS_UPDATE; m2p_updates[2].val = cn_pfn; m2p_updates[3].ptr = - page2offset (new_mfn_list[st_pfn]) | MMU_MACHPHYS_UPDATE; + page2offset (xen_state.virt_mfn_list[st_pfn]) | MMU_MACHPHYS_UPDATE; m2p_updates[3].val = st_pfn; grub_xen_mmu_update (m2p_updates, 4, NULL, DOMID_SELF); @@ -212,44 +216,53 @@ set_mfns (grub_xen_mfn_t * new_mfn_list, grub_xen_mfn_t pfn) return GRUB_ERR_NONE; } +static grub_err_t +grub_xen_p2m_alloc (void) +{ + grub_relocator_chunk_t ch; + grub_size_t p2msize; + grub_err_t err; + + xen_state.state.mfn_list = xen_state.max_addr; + xen_state.next_start.mfn_list = + xen_state.max_addr + xen_state.xen_inf.virt_base; + p2msize = sizeof (grub_xen_mfn_t) * grub_xen_start_page_addr->nr_pages; + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, p2msize); + if (err) + return err; + xen_state.virt_mfn_list = get_virtual_current_address (ch); + grub_memcpy (xen_state.virt_mfn_list, + (void *) grub_xen_start_page_addr->mfn_list, p2msize); + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + p2msize, PAGE_SIZE); + + return GRUB_ERR_NONE; +} + static grub_err_t grub_xen_boot (void) { - struct grub_relocator_xen_state state; grub_relocator_chunk_t ch; grub_err_t err; - grub_size_t pgtsize; struct start_info *nst; grub_uint64_t nr_info_pages; grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages; struct gnttab_set_version gnttab_setver; - grub_xen_mfn_t *new_mfn_list; grub_size_t i; if (grub_xen_n_allocated_shared_pages) return grub_error (GRUB_ERR_BUG, "active grants"); - state.mfn_list = xen_state.max_addr; - xen_state.next_start.mfn_list = - xen_state.max_addr + xen_state.xen_inf.virt_base; - xen_state.next_start.first_p2m_pfn = xen_state.max_addr >> PAGE_SHIFT; - pgtsize = sizeof (grub_xen_mfn_t) * grub_xen_start_page_addr->nr_pages; - err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, - xen_state.max_addr, pgtsize); - xen_state.next_start.nr_p2m_frames = (pgtsize + PAGE_SIZE - 1) >> PAGE_SHIFT; + err = grub_xen_p2m_alloc (); if (err) return err; - new_mfn_list = get_virtual_current_address (ch); - grub_memcpy (new_mfn_list, - (void *) grub_xen_start_page_addr->mfn_list, pgtsize); - xen_state.max_addr = ALIGN_UP (xen_state.max_addr + pgtsize, PAGE_SIZE); err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, xen_state.max_addr, sizeof (xen_state.next_start)); if (err) return err; - state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base; + xen_state.state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base; nst = get_virtual_current_address (ch); xen_state.max_addr = ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE); @@ -262,14 +275,14 @@ grub_xen_boot (void) xen_state.next_start.console.domU = grub_xen_start_page_addr->console.domU; xen_state.next_start.shared_info = grub_xen_start_page_addr->shared_info; - err = set_mfns (new_mfn_list, xen_state.max_addr >> PAGE_SHIFT); + err = set_mfns (xen_state.max_addr >> PAGE_SHIFT); if (err) return err; xen_state.max_addr += 2 * PAGE_SIZE; xen_state.next_start.pt_base = xen_state.max_addr + xen_state.xen_inf.virt_base; - state.paging_start = xen_state.max_addr >> PAGE_SHIFT; + xen_state.state.paging_start = xen_state.max_addr >> PAGE_SHIFT; nr_info_pages = xen_state.max_addr >> PAGE_SHIFT; nr_pages = nr_info_pages; @@ -298,15 +311,15 @@ grub_xen_boot (void) generate_page_table (get_virtual_current_address (ch), xen_state.max_addr >> PAGE_SHIFT, nr_pages, - xen_state.xen_inf.virt_base, new_mfn_list); + xen_state.xen_inf.virt_base, xen_state.virt_mfn_list); xen_state.max_addr += page2offset (nr_pt_pages); - state.stack = xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; - state.entry_point = xen_state.xen_inf.entry_point; + xen_state.state.stack = + xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; + xen_state.state.entry_point = xen_state.xen_inf.entry_point; - xen_state.next_start.nr_p2m_frames += nr_pt_pages; xen_state.next_start.nr_pt_frames = nr_pt_pages; - state.paging_size = nr_pt_pages; + xen_state.state.paging_size = nr_pt_pages; *nst = xen_state.next_start; @@ -318,7 +331,7 @@ grub_xen_boot (void) for (i = 0; i < ARRAY_SIZE (grub_xen_shared_info->evtchn_pending); i++) grub_xen_shared_info->evtchn_pending[i] = 0; - return grub_relocator_xen_boot (xen_state.relocator, state, nr_pages, + return grub_relocator_xen_boot (xen_state.relocator, xen_state.state, nr_pages, xen_state.xen_inf.virt_base < PAGE_SIZE ? page2offset (nr_pages) : 0, nr_pages - 1, From 1fbb2b4b390dd33b808b119eaac35a38105b114a Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:12 +0100 Subject: [PATCH 0586/1167] xen: factor out allocation of special pages into separate function Do the allocation of special pages (start info, console and xenbus ring buffers) in a separate function. This will allow to do the allocation at different times of the boot preparations depending on the features the kernel is supporting. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 60 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index a2fd1f60a..a80c0f8b2 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -48,6 +48,8 @@ struct xen_loader_state { struct start_info next_start; struct grub_xen_file_info xen_inf; grub_xen_mfn_t *virt_mfn_list; + struct start_info *virt_start_info; + grub_xen_mfn_t console_pfn; grub_uint64_t max_addr; struct xen_multiboot_mod_list *module_info_page; grub_uint64_t modules_target_start; @@ -239,12 +241,40 @@ grub_xen_p2m_alloc (void) return GRUB_ERR_NONE; } +static grub_err_t +grub_xen_special_alloc (void) +{ + grub_relocator_chunk_t ch; + grub_err_t err; + + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, + xen_state.max_addr, + sizeof (xen_state.next_start)); + if (err) + return err; + xen_state.state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base; + xen_state.virt_start_info = get_virtual_current_address (ch); + xen_state.max_addr = + ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE); + xen_state.console_pfn = xen_state.max_addr >> PAGE_SHIFT; + xen_state.max_addr += 2 * PAGE_SIZE; + + xen_state.next_start.nr_pages = grub_xen_start_page_addr->nr_pages; + grub_memcpy (xen_state.next_start.magic, grub_xen_start_page_addr->magic, + sizeof (xen_state.next_start.magic)); + xen_state.next_start.store_mfn = grub_xen_start_page_addr->store_mfn; + xen_state.next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn; + xen_state.next_start.console.domU = grub_xen_start_page_addr->console.domU; + xen_state.next_start.shared_info = grub_xen_start_page_addr->shared_info; + + return GRUB_ERR_NONE; +} + static grub_err_t grub_xen_boot (void) { grub_relocator_chunk_t ch; grub_err_t err; - struct start_info *nst; grub_uint64_t nr_info_pages; grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages; struct gnttab_set_version gnttab_setver; @@ -256,29 +286,9 @@ grub_xen_boot (void) err = grub_xen_p2m_alloc (); if (err) return err; - - err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, - xen_state.max_addr, - sizeof (xen_state.next_start)); + err = grub_xen_special_alloc (); if (err) return err; - xen_state.state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base; - nst = get_virtual_current_address (ch); - xen_state.max_addr = - ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE); - - xen_state.next_start.nr_pages = grub_xen_start_page_addr->nr_pages; - grub_memcpy (xen_state.next_start.magic, grub_xen_start_page_addr->magic, - sizeof (xen_state.next_start.magic)); - xen_state.next_start.store_mfn = grub_xen_start_page_addr->store_mfn; - xen_state.next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn; - xen_state.next_start.console.domU = grub_xen_start_page_addr->console.domU; - xen_state.next_start.shared_info = grub_xen_start_page_addr->shared_info; - - err = set_mfns (xen_state.max_addr >> PAGE_SHIFT); - if (err) - return err; - xen_state.max_addr += 2 * PAGE_SIZE; xen_state.next_start.pt_base = xen_state.max_addr + xen_state.xen_inf.virt_base; @@ -309,6 +319,10 @@ grub_xen_boot (void) if (err) return err; + err = set_mfns (xen_state.console_pfn); + if (err) + return err; + generate_page_table (get_virtual_current_address (ch), xen_state.max_addr >> PAGE_SHIFT, nr_pages, xen_state.xen_inf.virt_base, xen_state.virt_mfn_list); @@ -321,7 +335,7 @@ grub_xen_boot (void) xen_state.next_start.nr_pt_frames = nr_pt_pages; xen_state.state.paging_size = nr_pt_pages; - *nst = xen_state.next_start; + *xen_state.virt_start_info = xen_state.next_start; grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); From d73976fdffe067262b0f7ca69010be13e4c9f638 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:13 +0100 Subject: [PATCH 0587/1167] xen: factor out allocation of page tables into separate function Do the allocation of page tables in a separate function. This will allow to do the allocation at different times of the boot preparations depending on the features the kernel is supporting. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 85 +++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 32 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index a80c0f8b2..2e127637a 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -51,6 +51,9 @@ struct xen_loader_state { struct start_info *virt_start_info; grub_xen_mfn_t console_pfn; grub_uint64_t max_addr; + grub_uint64_t *virt_pgtable; + grub_uint64_t pgtbl_start; + grub_uint64_t pgtbl_end; struct xen_multiboot_mod_list *module_info_page; grub_uint64_t modules_target_start; grub_size_t n_modules; @@ -110,17 +113,17 @@ get_pgtable_size (grub_uint64_t total_pages, grub_uint64_t virt_base) static void generate_page_table (grub_uint64_t *where, grub_uint64_t paging_start, - grub_uint64_t total_pages, grub_uint64_t virt_base, - grub_xen_mfn_t *mfn_list) + grub_uint64_t paging_end, grub_uint64_t total_pages, + grub_uint64_t virt_base, grub_xen_mfn_t *mfn_list) { if (!virt_base) - total_pages++; + paging_end++; grub_uint64_t lx[NUMBER_OF_LEVELS], lxs[NUMBER_OF_LEVELS]; grub_uint64_t nlx, nls, sz = 0; int l; - nlx = total_pages; + nlx = paging_end; nls = virt_base >> PAGE_SHIFT; for (l = 0; l < NUMBER_OF_LEVELS; l++) { @@ -164,7 +167,7 @@ generate_page_table (grub_uint64_t *where, grub_uint64_t paging_start, if (pr) pg += POINTERS_PER_PAGE; - for (j = 0; j < total_pages; j++) + for (j = 0; j < paging_end; j++) { if (j >= paging_start && j < lp) pg[j + lxs[0]] = page2offset (mfn_list[j]) | 5; @@ -271,24 +274,12 @@ grub_xen_special_alloc (void) } static grub_err_t -grub_xen_boot (void) +grub_xen_pt_alloc (void) { grub_relocator_chunk_t ch; grub_err_t err; grub_uint64_t nr_info_pages; grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages; - struct gnttab_set_version gnttab_setver; - grub_size_t i; - - if (grub_xen_n_allocated_shared_pages) - return grub_error (GRUB_ERR_BUG, "active grants"); - - err = grub_xen_p2m_alloc (); - if (err) - return err; - err = grub_xen_special_alloc (); - if (err) - return err; xen_state.next_start.pt_base = xen_state.max_addr + xen_state.xen_inf.virt_base; @@ -309,32 +300,62 @@ grub_xen_boot (void) nr_pages = nr_need_pages; } - grub_dprintf ("xen", "bootstrap domain %llx+%llx\n", - (unsigned long long) xen_state.xen_inf.virt_base, - (unsigned long long) page2offset (nr_pages)); - err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, xen_state.max_addr, page2offset (nr_pt_pages)); if (err) return err; + xen_state.virt_pgtable = get_virtual_current_address (ch); + xen_state.pgtbl_start = xen_state.max_addr >> PAGE_SHIFT; + xen_state.max_addr += page2offset (nr_pt_pages); + xen_state.state.stack = + xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; + xen_state.state.paging_size = nr_pt_pages; + xen_state.next_start.nr_pt_frames = nr_pt_pages; + xen_state.max_addr = page2offset (nr_pages); + xen_state.pgtbl_end = nr_pages; + + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_xen_boot (void) +{ + grub_err_t err; + grub_uint64_t nr_pages; + struct gnttab_set_version gnttab_setver; + grub_size_t i; + + if (grub_xen_n_allocated_shared_pages) + return grub_error (GRUB_ERR_BUG, "active grants"); + + err = grub_xen_p2m_alloc (); + if (err) + return err; + err = grub_xen_special_alloc (); + if (err) + return err; + err = grub_xen_pt_alloc (); + if (err) + return err; + err = set_mfns (xen_state.console_pfn); if (err) return err; - generate_page_table (get_virtual_current_address (ch), - xen_state.max_addr >> PAGE_SHIFT, nr_pages, + nr_pages = xen_state.max_addr >> PAGE_SHIFT; + + grub_dprintf ("xen", "bootstrap domain %llx+%llx\n", + (unsigned long long) xen_state.xen_inf.virt_base, + (unsigned long long) page2offset (nr_pages)); + + generate_page_table (xen_state.virt_pgtable, xen_state.pgtbl_start, + xen_state.pgtbl_end, nr_pages, xen_state.xen_inf.virt_base, xen_state.virt_mfn_list); - xen_state.max_addr += page2offset (nr_pt_pages); - xen_state.state.stack = - xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; xen_state.state.entry_point = xen_state.xen_inf.entry_point; - xen_state.next_start.nr_pt_frames = nr_pt_pages; - xen_state.state.paging_size = nr_pt_pages; - *xen_state.virt_start_info = xen_state.next_start; grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); @@ -348,8 +369,8 @@ grub_xen_boot (void) return grub_relocator_xen_boot (xen_state.relocator, xen_state.state, nr_pages, xen_state.xen_inf.virt_base < PAGE_SIZE ? page2offset (nr_pages) : 0, - nr_pages - 1, - page2offset (nr_pages - 1) + + xen_state.pgtbl_end - 1, + page2offset (xen_state.pgtbl_end - 1) + xen_state.xen_inf.virt_base); } From 5500cefccd6341d6bdaa800211582f2be8a85a26 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:14 +0100 Subject: [PATCH 0588/1167] xen: add capability to load initrd outside of initial mapping Modern pvops linux kernels support an initrd not covered by the initial mapping. This capability is flagged by an elf-note. In case the elf-note is set by the kernel don't place the initrd into the initial mapping. This will allow to load larger initrds and/or support domains with larger memory, as the initial mapping is limited to 2GB and it is containing the p2m list. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 60 ++++++++++++++++++++++++------ grub-core/loader/i386/xen_fileXX.c | 3 ++ include/grub/xen_file.h | 1 + 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 2e127637a..9639ca159 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -228,6 +228,9 @@ grub_xen_p2m_alloc (void) grub_size_t p2msize; grub_err_t err; + if (xen_state.virt_mfn_list) + return GRUB_ERR_NONE; + xen_state.state.mfn_list = xen_state.max_addr; xen_state.next_start.mfn_list = xen_state.max_addr + xen_state.xen_inf.virt_base; @@ -250,6 +253,9 @@ grub_xen_special_alloc (void) grub_relocator_chunk_t ch; grub_err_t err; + if (xen_state.virt_start_info) + return GRUB_ERR_NONE; + err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, xen_state.max_addr, sizeof (xen_state.next_start)); @@ -281,6 +287,9 @@ grub_xen_pt_alloc (void) grub_uint64_t nr_info_pages; grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages; + if (xen_state.virt_pgtable) + return GRUB_ERR_NONE; + xen_state.next_start.pt_base = xen_state.max_addr + xen_state.xen_inf.virt_base; xen_state.state.paging_start = xen_state.max_addr >> PAGE_SHIFT; @@ -319,6 +328,25 @@ grub_xen_pt_alloc (void) return GRUB_ERR_NONE; } +/* Allocate all not yet allocated areas mapped by initial page tables. */ +static grub_err_t +grub_xen_alloc_boot_data (void) +{ + grub_err_t err; + + err = grub_xen_p2m_alloc (); + if (err) + return err; + err = grub_xen_special_alloc (); + if (err) + return err; + err = grub_xen_pt_alloc (); + if (err) + return err; + + return GRUB_ERR_NONE; +} + static grub_err_t grub_xen_boot (void) { @@ -330,13 +358,7 @@ grub_xen_boot (void) if (grub_xen_n_allocated_shared_pages) return grub_error (GRUB_ERR_BUG, "active grants"); - err = grub_xen_p2m_alloc (); - if (err) - return err; - err = grub_xen_special_alloc (); - if (err) - return err; - err = grub_xen_pt_alloc (); + err = grub_xen_alloc_boot_data (); if (err) return err; @@ -610,6 +632,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } + if (xen_state.xen_inf.unmapped_initrd) + { + err = grub_xen_alloc_boot_data (); + if (err) + goto fail; + } + if (grub_initrd_init (argc, argv, &initrd_ctx)) goto fail; @@ -627,14 +656,22 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - xen_state.next_start.mod_start = - xen_state.max_addr + xen_state.xen_inf.virt_base; xen_state.next_start.mod_len = size; - xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE); + if (xen_state.xen_inf.unmapped_initrd) + { + xen_state.next_start.flags |= SIF_MOD_START_PFN; + xen_state.next_start.mod_start = xen_state.max_addr >> PAGE_SHIFT; + } + else + xen_state.next_start.mod_start = + xen_state.max_addr + xen_state.xen_inf.virt_base; grub_dprintf ("xen", "Initrd, addr=0x%x, size=0x%x\n", - (unsigned) xen_state.next_start.mod_start, (unsigned) size); + (unsigned) (xen_state.max_addr + xen_state.xen_inf.virt_base), + (unsigned) size); + + xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE); fail: grub_initrd_close (&initrd_ctx); @@ -686,6 +723,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), if (!xen_state.module_info_page) { + xen_state.xen_inf.unmapped_initrd = 0; xen_state.n_modules = 0; xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE); xen_state.modules_target_start = xen_state.max_addr; diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 03215cab2..8751174cf 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -261,6 +261,9 @@ parse_note (grub_elf_t elf, struct grub_xen_file_info *xi, descsz == 2 ? 2 : 3) == 0) xi->arch = GRUB_XEN_FILE_I386; break; + case XEN_ELFNOTE_MOD_START_PFN: + xi->unmapped_initrd = !!grub_le_to_cpu32(*(grub_uint32_t *) desc); + break; default: grub_dprintf ("xen", "unknown note type %d\n", nh->n_type); break; diff --git a/include/grub/xen_file.h b/include/grub/xen_file.h index 4b2ccba78..ed749fafe 100644 --- a/include/grub/xen_file.h +++ b/include/grub/xen_file.h @@ -36,6 +36,7 @@ struct grub_xen_file_info int has_note; int has_xen_guest; int extended_cr3; + int unmapped_initrd; enum { GRUB_XEN_FILE_I386 = 1, From b67a95ecad9fd815ac39a5cbade93358975aa0f1 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:15 +0100 Subject: [PATCH 0589/1167] xen: modify page table construction Modify the page table construction to allow multiple virtual regions to be mapped. This is done as preparation for removing the p2m list from the initial kernel mapping in order to support huge pv domains. This allows a cleaner approach for mapping the relocator page by using this capability. The interface to the assembler level of the relocator has to be changed in order to be able to process multiple page table areas. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/lib/i386/xen/relocator.S | 87 ++++--- grub-core/lib/x86_64/xen/relocator.S | 134 +++++------ grub-core/lib/xen/relocator.c | 28 ++- grub-core/loader/i386/xen.c | 329 ++++++++++++++++++--------- include/grub/i386/memory.h | 7 + include/grub/xen/relocator.h | 6 +- 6 files changed, 358 insertions(+), 233 deletions(-) diff --git a/grub-core/lib/i386/xen/relocator.S b/grub-core/lib/i386/xen/relocator.S index 694a54c85..f1c729e8c 100644 --- a/grub-core/lib/i386/xen/relocator.S +++ b/grub-core/lib/i386/xen/relocator.S @@ -16,6 +16,8 @@ * along with GRUB. If not, see . */ +#include +#include #include #include @@ -23,78 +25,86 @@ VARIABLE(grub_relocator_xen_remap_start) LOCAL(base): - /* mov imm32, %ebx */ + /* Remap the remapper to it's new address. */ + /* mov imm32, %ebx - %ebx: new virtual address of remapper */ .byte 0xbb VARIABLE(grub_relocator_xen_remapper_virt) .long 0 - /* mov imm32, %ecx */ + /* mov imm32, %ecx - %ecx: low part of page table entry */ .byte 0xb9 VARIABLE(grub_relocator_xen_remapper_map) .long 0 - /* mov imm32, %edx */ + /* mov imm32, %edx - %edx: high part of page table entry */ .byte 0xba VARIABLE(grub_relocator_xen_remapper_map_high) .long 0 - movl %ebx, %ebp + movl %ebx, %ebp /* %ebx is clobbered by hypercall */ - movl $2, %esi + movl $UVMF_INVLPG, %esi /* esi: flags (inv. single entry) */ movl $__HYPERVISOR_update_va_mapping, %eax int $0x82 movl %ebp, %ebx addl $(LOCAL(cont) - LOCAL(base)), %ebx - jmp *%ebx + jmp *%ebx /* Continue with new virtual address */ LOCAL(cont): - xorl %eax, %eax - movl %eax, %ebp + /* Modify mappings of new page tables to be read-only. */ + /* mov imm32, %eax */ + .byte 0xb8 +VARIABLE(grub_relocator_xen_paging_areas_addr) + .long 0 + movl %eax, %ebx 1: + movl 0(%ebx), %ebp /* Get start pfn of the current area */ + movl GRUB_TARGET_SIZEOF_LONG(%ebx), %ecx /* Get # of pg tables */ + testl %ecx, %ecx /* 0 -> last area reached */ + jz 3f + addl $(2 * GRUB_TARGET_SIZEOF_LONG), %ebx + movl %ebx, %esp /* Save current area pointer */ +2: + movl %ecx, %edi /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator_xen_mfn_list) .long 0 - movl %eax, %edi - movl %ebp, %eax - movl 0(%edi, %eax, 4), %ecx - - /* mov imm32, %ebx */ - .byte 0xbb -VARIABLE(grub_relocator_xen_paging_start) - .long 0 - shll $12, %eax - addl %eax, %ebx + movl 0(%eax, %ebp, 4), %ecx /* mfn */ + movl %ebp, %ebx + shll $PAGE_SHIFT, %ebx /* virtual address (1:1 mapping) */ movl %ecx, %edx - shll $12, %ecx - shrl $20, %edx - orl $5, %ecx - movl $2, %esi + shll $PAGE_SHIFT, %ecx /* prepare pte low part */ + shrl $(32 - PAGE_SHIFT), %edx /* pte high part */ + orl $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %ecx /* pte low */ + movl $UVMF_INVLPG, %esi movl $__HYPERVISOR_update_va_mapping, %eax - int $0x82 + int $0x82 /* parameters: eax, ebx, ecx, edx, esi */ - incl %ebp - /* mov imm32, %ecx */ - .byte 0xb9 -VARIABLE(grub_relocator_xen_paging_size) - .long 0 - cmpl %ebp, %ecx + incl %ebp /* next pfn */ + movl %edi, %ecx - ja 1b + loop 2b + mov %esp, %ebx /* restore area poniter */ + jmp 1b + +3: + /* Switch page tables: pin new L3 pt, load cr3, unpin old L3. */ /* mov imm32, %ebx */ .byte 0xbb VARIABLE(grub_relocator_xen_mmu_op_addr) .long 0 - movl $3, %ecx - movl $0, %edx - movl $0x7FF0, %esi + movl $3, %ecx /* 3 mmu ops */ + movl $0, %edx /* pdone (not used) */ + movl $DOMID_SELF, %esi movl $__HYPERVISOR_mmuext_op, %eax int $0x82 + /* Continue in virtual kernel mapping. */ /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator_xen_remap_continue) @@ -102,6 +112,9 @@ VARIABLE(grub_relocator_xen_remap_continue) jmp *%eax +VARIABLE(grub_relocator_xen_paging_areas) + .long 0, 0, 0, 0, 0, 0, 0, 0 + VARIABLE(grub_relocator_xen_mmu_op) .space 256 @@ -109,6 +122,7 @@ VARIABLE(grub_relocator_xen_remap_end) VARIABLE(grub_relocator_xen_start) + /* Unmap old remapper area. */ /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator_xen_remapper_virt2) @@ -116,14 +130,14 @@ VARIABLE(grub_relocator_xen_remapper_virt2) movl %eax, %edi - xorl %ecx, %ecx + xorl %ecx, %ecx /* Invalid pte */ xorl %edx, %edx - movl $2, %esi + movl $UVMF_INVLPG, %esi movl $__HYPERVISOR_update_va_mapping, %eax int $0x82 - + /* Prepare registers for starting kernel. */ /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator_xen_stack) @@ -145,6 +159,7 @@ VARIABLE(grub_relocator_xen_start_info) VARIABLE(grub_relocator_xen_entry_point) .long 0 + /* Now start the new kernel. */ jmp *%eax VARIABLE(grub_relocator_xen_end) diff --git a/grub-core/lib/x86_64/xen/relocator.S b/grub-core/lib/x86_64/xen/relocator.S index 92e9e72a9..f5364ed0f 100644 --- a/grub-core/lib/x86_64/xen/relocator.S +++ b/grub-core/lib/x86_64/xen/relocator.S @@ -16,95 +16,85 @@ * along with GRUB. If not, see . */ +#include +#include #include #include +/* Macro to load an imm64 value stored by the C-part into %rax: */ +#define MOV_IMM64_RAX(var) .byte 0x48, 0xb8; VARIABLE(var); .quad 0 + .p2align 4 /* force 16-byte alignment */ VARIABLE(grub_relocator_xen_remap_start) LOCAL(base): - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_remapper_virt) - .quad 0 + /* Remap the remapper to it's new address. */ + MOV_IMM64_RAX(grub_relocator_xen_remapper_virt) - movq %rax, %rdi - movq %rax, %rbx + movq %rax, %rdi /* %rdi: new virtual address of remapper */ + movq %rax, %rbx /* Remember new virtual address */ - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_remapper_map) - .quad 0 + MOV_IMM64_RAX(grub_relocator_xen_remapper_map) - movq %rax, %rsi + movq %rax, %rsi /* %rsi: page table entry */ - movq $2, %rdx + movq $UVMF_INVLPG, %rdx /* %rdx: flags (inv. single entry) */ movq $__HYPERVISOR_update_va_mapping, %rax - syscall + syscall /* Do the remap operation */ addq $(LOCAL(cont) - LOCAL(base)), %rbx - jmp *%rbx + jmp *%rbx /* Continue with new virtual address */ LOCAL(cont): - - /* mov imm64, %rcx */ - .byte 0x48 - .byte 0xb9 -VARIABLE(grub_relocator_xen_paging_size) - .quad 0 + /* Modify mappings of new page tables to be read-only. */ + MOV_IMM64_RAX(grub_relocator_xen_mfn_list) - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_paging_start) - .quad 0 + movq %rax, %rbx /* %rbx is the base of the p2m list */ + leaq EXT_C(grub_relocator_xen_paging_areas) (%rip), %r8 - movq %rax, %r12 - - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_mfn_list) - .quad 0 - - movq %rax, %rsi 1: + movq 0(%r8), %r12 /* Get start pfn of the current area */ + movq GRUB_TARGET_SIZEOF_LONG(%r8), %rcx /* Get # of pg tables */ + testq %rcx, %rcx /* 0 -> last area reached */ + jz 3f +2: movq %r12, %rdi - movq %rsi, %rbx - movq 0(%rsi), %rsi - shlq $12, %rsi - orq $5, %rsi - movq $2, %rdx - movq %rcx, %r9 + shlq $PAGE_SHIFT, %rdi /* virtual address (1:1 mapping) */ + movq (%rbx, %r12, 8), %rsi /* mfn */ + shlq $PAGE_SHIFT, %rsi + orq $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %rsi /* Build pte */ + movq $UVMF_INVLPG, %rdx + movq %rcx, %r9 /* %rcx clobbered by hypercall */ movq $__HYPERVISOR_update_va_mapping, %rax syscall movq %r9, %rcx - addq $8, %rbx - addq $4096, %r12 - movq %rbx, %rsi + incq %r12 /* next pfn */ - loop 1b + loop 2b - leaq LOCAL(mmu_op) (%rip), %rdi - movq $3, %rsi - movq $0, %rdx - movq $0x7FF0, %r10 + addq $(2 * GRUB_TARGET_SIZEOF_LONG), %r8 /* next pg table area */ + jmp 1b + +3: + /* Switch page tables: pin new L4 pt, load cr3, unpin old L4. */ + leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi + movq $3, %rsi /* 3 mmu ops */ + movq $0, %rdx /* pdone (not used) */ + movq $DOMID_SELF, %r10 movq $__HYPERVISOR_mmuext_op, %rax syscall - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_remap_continue) - .quad 0 + /* Continue in virtual kernel mapping. */ + MOV_IMM64_RAX(grub_relocator_xen_remap_continue) jmp *%rax -LOCAL(mmu_op): +VARIABLE(grub_relocator_xen_paging_areas) + /* array of start, size pairs, size 0 is end marker */ + .quad 0, 0, 0, 0, 0, 0, 0, 0 + VARIABLE(grub_relocator_xen_mmu_op) .space 256 @@ -112,46 +102,32 @@ VARIABLE(grub_relocator_xen_remap_end) VARIABLE(grub_relocator_xen_start) - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_remapper_virt2) - .quad 0 + /* Unmap old remapper area. */ + MOV_IMM64_RAX(grub_relocator_xen_remapper_virt2) movq %rax, %rdi - xorq %rax, %rax + xorq %rax, %rax /* Invalid pte */ movq %rax, %rsi - movq $2, %rdx + movq $UVMF_INVLPG, %rdx movq $__HYPERVISOR_update_va_mapping, %rax syscall - - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_stack) - .quad 0 + /* Prepare registers for starting kernel. */ + MOV_IMM64_RAX(grub_relocator_xen_stack) movq %rax, %rsp - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_start_info) - .quad 0 + MOV_IMM64_RAX(grub_relocator_xen_start_info) movq %rax, %rsi cld - /* mov imm64, %rax */ - .byte 0x48 - .byte 0xb8 -VARIABLE(grub_relocator_xen_entry_point) - .quad 0 + MOV_IMM64_RAX(grub_relocator_xen_entry_point) + /* Now start the new kernel. */ jmp *%rax VARIABLE(grub_relocator_xen_end) diff --git a/grub-core/lib/xen/relocator.c b/grub-core/lib/xen/relocator.c index 8f427d341..4d0cbcadb 100644 --- a/grub-core/lib/xen/relocator.c +++ b/grub-core/lib/xen/relocator.c @@ -29,6 +29,11 @@ typedef grub_addr_t grub_xen_reg_t; +struct grub_relocator_xen_paging_area { + grub_xen_reg_t start; + grub_xen_reg_t size; +} GRUB_PACKED; + extern grub_uint8_t grub_relocator_xen_start; extern grub_uint8_t grub_relocator_xen_end; extern grub_uint8_t grub_relocator_xen_remap_start; @@ -36,15 +41,16 @@ extern grub_uint8_t grub_relocator_xen_remap_end; extern grub_xen_reg_t grub_relocator_xen_stack; extern grub_xen_reg_t grub_relocator_xen_start_info; extern grub_xen_reg_t grub_relocator_xen_entry_point; -extern grub_xen_reg_t grub_relocator_xen_paging_start; -extern grub_xen_reg_t grub_relocator_xen_paging_size; extern grub_xen_reg_t grub_relocator_xen_remapper_virt; extern grub_xen_reg_t grub_relocator_xen_remapper_virt2; extern grub_xen_reg_t grub_relocator_xen_remapper_map; extern grub_xen_reg_t grub_relocator_xen_mfn_list; +extern struct grub_relocator_xen_paging_area + grub_relocator_xen_paging_areas[XEN_MAX_MAPPINGS]; extern grub_xen_reg_t grub_relocator_xen_remap_continue; #ifdef __i386__ extern grub_xen_reg_t grub_relocator_xen_mmu_op_addr; +extern grub_xen_reg_t grub_relocator_xen_paging_areas_addr; extern grub_xen_reg_t grub_relocator_xen_remapper_map_high; #endif extern mmuext_op_t grub_relocator_xen_mmu_op[3]; @@ -61,6 +67,7 @@ grub_relocator_xen_boot (struct grub_relocator *rel, { grub_err_t err; void *relst; + int i; grub_relocator_chunk_t ch, ch_tramp; grub_xen_mfn_t *mfn_list = (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; @@ -77,8 +84,11 @@ grub_relocator_xen_boot (struct grub_relocator *rel, grub_relocator_xen_stack = state.stack; grub_relocator_xen_start_info = state.start_info; grub_relocator_xen_entry_point = state.entry_point; - grub_relocator_xen_paging_start = state.paging_start << 12; - grub_relocator_xen_paging_size = state.paging_size; + for (i = 0; i < XEN_MAX_MAPPINGS; i++) + { + grub_relocator_xen_paging_areas[i].start = state.paging_start[i]; + grub_relocator_xen_paging_areas[i].size = state.paging_size[i]; + } grub_relocator_xen_remapper_virt = remapper_virt; grub_relocator_xen_remapper_virt2 = remapper_virt; grub_relocator_xen_remap_continue = trampoline_virt; @@ -88,10 +98,12 @@ grub_relocator_xen_boot (struct grub_relocator *rel, grub_relocator_xen_remapper_map_high = (mfn_list[remapper_pfn] >> 20); grub_relocator_xen_mmu_op_addr = (char *) &grub_relocator_xen_mmu_op - (char *) &grub_relocator_xen_remap_start + remapper_virt; + grub_relocator_xen_paging_areas_addr = + (char *) &grub_relocator_xen_paging_areas + - (char *) &grub_relocator_xen_remap_start + remapper_virt; #endif - grub_relocator_xen_mfn_list = state.mfn_list - + state.paging_start * sizeof (grub_addr_t); + grub_relocator_xen_mfn_list = state.mfn_list; grub_memset (grub_relocator_xen_mmu_op, 0, sizeof (grub_relocator_xen_mmu_op)); @@ -100,9 +112,9 @@ grub_relocator_xen_boot (struct grub_relocator *rel, #else grub_relocator_xen_mmu_op[0].cmd = MMUEXT_PIN_L4_TABLE; #endif - grub_relocator_xen_mmu_op[0].arg1.mfn = mfn_list[state.paging_start]; + grub_relocator_xen_mmu_op[0].arg1.mfn = mfn_list[state.paging_start[0]]; grub_relocator_xen_mmu_op[1].cmd = MMUEXT_NEW_BASEPTR; - grub_relocator_xen_mmu_op[1].arg1.mfn = mfn_list[state.paging_start]; + grub_relocator_xen_mmu_op[1].arg1.mfn = mfn_list[state.paging_start[0]]; grub_relocator_xen_mmu_op[2].cmd = MMUEXT_UNPIN_TABLE; grub_relocator_xen_mmu_op[2].arg1.mfn = mfn_list[grub_xen_start_page_addr->pt_base >> 12]; diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 9639ca159..a98badf44 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -39,9 +39,34 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); +#ifdef __x86_64__ +#define NUMBER_OF_LEVELS 4 +#define INTERMEDIATE_OR (GRUB_PAGE_PRESENT | GRUB_PAGE_RW | GRUB_PAGE_USER) +#define VIRT_MASK 0x0000ffffffffffffULL +#else +#define NUMBER_OF_LEVELS 3 +#define INTERMEDIATE_OR (GRUB_PAGE_PRESENT | GRUB_PAGE_RW) +#define VIRT_MASK 0x00000000ffffffffULL +#define HYPERVISOR_PUD_ADDRESS 0xc0000000ULL +#endif + +struct grub_xen_mapping_lvl { + grub_uint64_t virt_start; + grub_uint64_t virt_end; + grub_uint64_t pfn_start; + grub_uint64_t n_pt_pages; +}; + +struct grub_xen_mapping { + grub_uint64_t *where; + struct grub_xen_mapping_lvl area; + struct grub_xen_mapping_lvl lvls[NUMBER_OF_LEVELS]; +}; + struct xen_loader_state { struct grub_relocator *relocator; struct grub_relocator_xen_state state; @@ -51,12 +76,13 @@ struct xen_loader_state { struct start_info *virt_start_info; grub_xen_mfn_t console_pfn; grub_uint64_t max_addr; - grub_uint64_t *virt_pgtable; - grub_uint64_t pgtbl_start; grub_uint64_t pgtbl_end; struct xen_multiboot_mod_list *module_info_page; grub_uint64_t modules_target_start; grub_size_t n_modules; + struct grub_xen_mapping *map_reloc; + struct grub_xen_mapping mappings[XEN_MAX_MAPPINGS]; + int n_mappings; int loaded; }; @@ -64,9 +90,8 @@ static struct xen_loader_state xen_state; static grub_dl_t my_mod; -#define PAGE_SIZE 4096 +#define PAGE_SIZE (1UL << PAGE_SHIFT) #define MAX_MODULES (PAGE_SIZE / sizeof (struct xen_multiboot_mod_list)) -#define PAGE_SHIFT 12 #define STACK_SIZE 1048576 #define ADDITIONAL_SIZE (1 << 19) #define ALIGN_SIZE (1 << 22) @@ -79,100 +104,163 @@ page2offset (grub_uint64_t page) return page << PAGE_SHIFT; } -#ifdef __x86_64__ -#define NUMBER_OF_LEVELS 4 -#define INTERMEDIATE_OR 7 -#else -#define NUMBER_OF_LEVELS 3 -#define INTERMEDIATE_OR 3 +static grub_err_t +get_pgtable_size (grub_uint64_t from, grub_uint64_t to, grub_uint64_t pfn) +{ + struct grub_xen_mapping *map, *map_cmp; + grub_uint64_t mask, bits; + int i, m; + + if (xen_state.n_mappings == XEN_MAX_MAPPINGS) + return grub_error (GRUB_ERR_BUG, "too many mapped areas"); + + grub_dprintf ("xen", "get_pgtable_size %d from=%llx, to=%llx, pfn=%llx\n", + xen_state.n_mappings, (unsigned long long) from, + (unsigned long long) to, (unsigned long long) pfn); + + map = xen_state.mappings + xen_state.n_mappings; + grub_memset (map, 0, sizeof (*map)); + + map->area.virt_start = from & VIRT_MASK; + map->area.virt_end = (to - 1) & VIRT_MASK; + map->area.n_pt_pages = 0; + + for (i = NUMBER_OF_LEVELS - 1; i >= 0; i--) + { + map->lvls[i].pfn_start = pfn + map->area.n_pt_pages; + if (i == NUMBER_OF_LEVELS - 1) + { + if (xen_state.n_mappings == 0) + { + map->lvls[i].virt_start = 0; + map->lvls[i].virt_end = VIRT_MASK; + map->lvls[i].n_pt_pages = 1; + map->area.n_pt_pages++; + } + continue; + } + + bits = PAGE_SHIFT + (i + 1) * LOG_POINTERS_PER_PAGE; + mask = (1ULL << bits) - 1; + map->lvls[i].virt_start = map->area.virt_start & ~mask; + map->lvls[i].virt_end = map->area.virt_end | mask; +#ifdef __i386__ + /* PAE wants last root directory present. */ + if (i == 1 && to <= HYPERVISOR_PUD_ADDRESS && xen_state.n_mappings == 0) + map->lvls[i].virt_end = VIRT_MASK; #endif + for (m = 0; m < xen_state.n_mappings; m++) + { + map_cmp = xen_state.mappings + m; + if (map_cmp->lvls[i].virt_start == map_cmp->lvls[i].virt_end) + continue; + if (map->lvls[i].virt_start >= map_cmp->lvls[i].virt_start && + map->lvls[i].virt_end <= map_cmp->lvls[i].virt_end) + { + map->lvls[i].virt_start = 0; + map->lvls[i].virt_end = 0; + break; + } + if (map->lvls[i].virt_start >= map_cmp->lvls[i].virt_start && + map->lvls[i].virt_start <= map_cmp->lvls[i].virt_end) + map->lvls[i].virt_start = map_cmp->lvls[i].virt_end + 1; + if (map->lvls[i].virt_end >= map_cmp->lvls[i].virt_start && + map->lvls[i].virt_end <= map_cmp->lvls[i].virt_end) + map->lvls[i].virt_end = map_cmp->lvls[i].virt_start - 1; + } + if (map->lvls[i].virt_start < map->lvls[i].virt_end) + map->lvls[i].n_pt_pages = + ((map->lvls[i].virt_end - map->lvls[i].virt_start) >> bits) + 1; + map->area.n_pt_pages += map->lvls[i].n_pt_pages; + grub_dprintf ("xen", "get_pgtable_size level %d: virt %llx-%llx %d pts\n", + i, (unsigned long long) map->lvls[i].virt_start, + (unsigned long long) map->lvls[i].virt_end, + (int) map->lvls[i].n_pt_pages); + } + + grub_dprintf ("xen", "get_pgtable_size return: %d page tables\n", + (int) map->area.n_pt_pages); + + xen_state.state.paging_start[xen_state.n_mappings] = pfn; + xen_state.state.paging_size[xen_state.n_mappings] = map->area.n_pt_pages; + + return GRUB_ERR_NONE; +} + +static grub_uint64_t * +get_pg_table_virt (int mapping, int level) +{ + grub_uint64_t pfn; + struct grub_xen_mapping *map; + + map = xen_state.mappings + mapping; + pfn = map->lvls[level].pfn_start - map->lvls[NUMBER_OF_LEVELS - 1].pfn_start; + return map->where + pfn * POINTERS_PER_PAGE; +} static grub_uint64_t -get_pgtable_size (grub_uint64_t total_pages, grub_uint64_t virt_base) +get_pg_table_prot (int level, grub_uint64_t pfn) { - if (!virt_base) - total_pages++; - grub_uint64_t ret = 0; - grub_uint64_t ll = total_pages; - int i; - for (i = 0; i < NUMBER_OF_LEVELS; i++) + int m; + grub_uint64_t pfn_s, pfn_e; + + if (level > 0) + return INTERMEDIATE_OR; + for (m = 0; m < xen_state.n_mappings; m++) { - ll = (ll + POINTERS_PER_PAGE - 1) >> LOG_POINTERS_PER_PAGE; - /* PAE wants all 4 root directories present. */ -#ifdef __i386__ - if (i == 1) - ll = 4; -#endif - ret += ll; + pfn_s = xen_state.mappings[m].lvls[NUMBER_OF_LEVELS - 1].pfn_start; + pfn_e = xen_state.mappings[m].area.n_pt_pages + pfn_s; + if (pfn >= pfn_s && pfn < pfn_e) + return GRUB_PAGE_PRESENT | GRUB_PAGE_USER; } - for (i = 1; i < NUMBER_OF_LEVELS; i++) - if (virt_base >> (PAGE_SHIFT + i * LOG_POINTERS_PER_PAGE)) - ret++; - return ret; + return GRUB_PAGE_PRESENT | GRUB_PAGE_RW | GRUB_PAGE_USER; } static void -generate_page_table (grub_uint64_t *where, grub_uint64_t paging_start, - grub_uint64_t paging_end, grub_uint64_t total_pages, - grub_uint64_t virt_base, grub_xen_mfn_t *mfn_list) +generate_page_table (grub_xen_mfn_t *mfn_list) { - if (!virt_base) - paging_end++; + int l, m1, m2; + long p, p_s, p_e; + grub_uint64_t start, end, pfn; + grub_uint64_t *pg; + struct grub_xen_mapping_lvl *lvl; - grub_uint64_t lx[NUMBER_OF_LEVELS], lxs[NUMBER_OF_LEVELS]; - grub_uint64_t nlx, nls, sz = 0; - int l; + for (m1 = 0; m1 < xen_state.n_mappings; m1++) + grub_memset (xen_state.mappings[m1].where, 0, + xen_state.mappings[m1].area.n_pt_pages * PAGE_SIZE); - nlx = paging_end; - nls = virt_base >> PAGE_SHIFT; - for (l = 0; l < NUMBER_OF_LEVELS; l++) + for (l = NUMBER_OF_LEVELS - 1; l >= 0; l--) { - nlx = (nlx + POINTERS_PER_PAGE - 1) >> LOG_POINTERS_PER_PAGE; - /* PAE wants all 4 root directories present. */ -#ifdef __i386__ - if (l == 1) - nlx = 4; -#endif - lx[l] = nlx; - sz += lx[l]; - lxs[l] = nls & (POINTERS_PER_PAGE - 1); - if (nls && l != 0) - sz++; - nls >>= LOG_POINTERS_PER_PAGE; - } - - grub_uint64_t lp; - grub_uint64_t j; - grub_uint64_t *pg = (grub_uint64_t *) where; - int pr = 0; - - grub_memset (pg, 0, sz * PAGE_SIZE); - - lp = paging_start + lx[NUMBER_OF_LEVELS - 1]; - for (l = NUMBER_OF_LEVELS - 1; l >= 1; l--) - { - if (lxs[l] || pr) - pg[0] = page2offset (mfn_list[lp++]) | INTERMEDIATE_OR; - if (pr) - pg += POINTERS_PER_PAGE; - for (j = 0; j < lx[l - 1]; j++) - pg[j + lxs[l]] = page2offset (mfn_list[lp++]) | INTERMEDIATE_OR; - pg += lx[l] * POINTERS_PER_PAGE; - if (lxs[l]) - pr = 1; - } - - if (lxs[0] || pr) - pg[0] = page2offset (mfn_list[total_pages]) | 5; - if (pr) - pg += POINTERS_PER_PAGE; - - for (j = 0; j < paging_end; j++) - { - if (j >= paging_start && j < lp) - pg[j + lxs[0]] = page2offset (mfn_list[j]) | 5; - else - pg[j + lxs[0]] = page2offset (mfn_list[j]) | 7; + for (m1 = 0; m1 < xen_state.n_mappings; m1++) + { + start = xen_state.mappings[m1].lvls[l].virt_start; + end = xen_state.mappings[m1].lvls[l].virt_end; + pg = get_pg_table_virt(m1, l); + for (m2 = 0; m2 < xen_state.n_mappings; m2++) + { + lvl = (l > 0) ? xen_state.mappings[m2].lvls + l - 1 + : &xen_state.mappings[m2].area; + if (l > 0 && lvl->n_pt_pages == 0) + continue; + if (lvl->virt_start >= end || lvl->virt_end <= start) + continue; + p_s = (grub_max (start, lvl->virt_start) - start) >> + (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE); + p_e = (grub_min (end, lvl->virt_end) - start) >> + (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE); + pfn = ((grub_max (start, lvl->virt_start) - lvl->virt_start) >> + (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE)) + lvl->pfn_start; + grub_dprintf ("xen", "write page table entries level %d pg %p " + "mapping %d/%d index %lx-%lx pfn %llx\n", + l, pg, m1, m2, p_s, p_e, (unsigned long long) pfn); + for (p = p_s; p <= p_e; p++) + { + pg[p] = page2offset (mfn_list[pfn]) | + get_pg_table_prot (l, pfn); + pfn++; + } + } + } } } @@ -285,45 +373,71 @@ grub_xen_pt_alloc (void) grub_relocator_chunk_t ch; grub_err_t err; grub_uint64_t nr_info_pages; - grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages; + grub_uint64_t nr_need_pages; + grub_uint64_t try_virt_end; + struct grub_xen_mapping *map; - if (xen_state.virt_pgtable) + if (xen_state.pgtbl_end) return GRUB_ERR_NONE; + map = xen_state.mappings + xen_state.n_mappings; + xen_state.map_reloc = map + 1; + xen_state.next_start.pt_base = xen_state.max_addr + xen_state.xen_inf.virt_base; - xen_state.state.paging_start = xen_state.max_addr >> PAGE_SHIFT; - nr_info_pages = xen_state.max_addr >> PAGE_SHIFT; - nr_pages = nr_info_pages; + nr_need_pages = nr_info_pages; while (1) { - nr_pages = ALIGN_UP (nr_pages, (ALIGN_SIZE >> PAGE_SHIFT)); - nr_pt_pages = get_pgtable_size (nr_pages, xen_state.xen_inf.virt_base); - nr_need_pages = - nr_info_pages + nr_pt_pages + - ((ADDITIONAL_SIZE + STACK_SIZE) >> PAGE_SHIFT); - if (nr_pages >= nr_need_pages) + try_virt_end = ALIGN_UP (xen_state.xen_inf.virt_base + + page2offset (nr_need_pages) + + ADDITIONAL_SIZE + STACK_SIZE, ALIGN_SIZE); + if (!xen_state.xen_inf.virt_base) + try_virt_end += PAGE_SIZE; + + err = get_pgtable_size (xen_state.xen_inf.virt_base, try_virt_end, + nr_info_pages); + if (err) + return err; + xen_state.n_mappings++; + + /* Map the relocator page either at virtual 0 or after end of area. */ + nr_need_pages = nr_info_pages + map->area.n_pt_pages; + if (xen_state.xen_inf.virt_base) + err = get_pgtable_size (0, PAGE_SIZE, nr_need_pages); + else + err = get_pgtable_size (try_virt_end - PAGE_SIZE, try_virt_end, + nr_need_pages); + if (err) + return err; + nr_need_pages += xen_state.map_reloc->area.n_pt_pages; + + if (xen_state.xen_inf.virt_base + page2offset (nr_need_pages) <= + try_virt_end) break; - nr_pages = nr_need_pages; + + xen_state.n_mappings--; } + xen_state.n_mappings++; + nr_need_pages = map->area.n_pt_pages + xen_state.map_reloc->area.n_pt_pages; err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, xen_state.max_addr, - page2offset (nr_pt_pages)); + page2offset (nr_need_pages)); if (err) return err; - xen_state.virt_pgtable = get_virtual_current_address (ch); - xen_state.pgtbl_start = xen_state.max_addr >> PAGE_SHIFT; - xen_state.max_addr += page2offset (nr_pt_pages); + map->where = get_virtual_current_address (ch); + map->area.pfn_start = 0; + xen_state.max_addr += page2offset (nr_need_pages); xen_state.state.stack = xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base; - xen_state.state.paging_size = nr_pt_pages; - xen_state.next_start.nr_pt_frames = nr_pt_pages; - xen_state.max_addr = page2offset (nr_pages); - xen_state.pgtbl_end = nr_pages; + xen_state.next_start.nr_pt_frames = nr_need_pages; + xen_state.max_addr = try_virt_end - xen_state.xen_inf.virt_base; + xen_state.pgtbl_end = xen_state.max_addr >> PAGE_SHIFT; + xen_state.map_reloc->where = (grub_uint64_t *) ((char *) map->where + + page2offset (map->area.n_pt_pages)); return GRUB_ERR_NONE; } @@ -372,9 +486,8 @@ grub_xen_boot (void) (unsigned long long) xen_state.xen_inf.virt_base, (unsigned long long) page2offset (nr_pages)); - generate_page_table (xen_state.virt_pgtable, xen_state.pgtbl_start, - xen_state.pgtbl_end, nr_pages, - xen_state.xen_inf.virt_base, xen_state.virt_mfn_list); + xen_state.map_reloc->area.pfn_start = nr_pages; + generate_page_table (xen_state.virt_mfn_list); xen_state.state.entry_point = xen_state.xen_inf.entry_point; diff --git a/include/grub/i386/memory.h b/include/grub/i386/memory.h index c9b13288f..8bb6e1cbb 100644 --- a/include/grub/i386/memory.h +++ b/include/grub/i386/memory.h @@ -20,6 +20,8 @@ #ifndef GRUB_MEMORY_CPU_HEADER #define GRUB_MEMORY_CPU_HEADER 1 +#define PAGE_SHIFT 12 + /* The flag for protected mode. */ #define GRUB_MEMORY_CPU_CR0_PE_ON 0x1 #define GRUB_MEMORY_CPU_CR4_PAE_ON 0x00000020 @@ -31,6 +33,11 @@ #define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */ #define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START +/* Some PTE definitions. */ +#define GRUB_PAGE_PRESENT 0x00000001 +#define GRUB_PAGE_RW 0x00000002 +#define GRUB_PAGE_USER 0x00000004 + #ifndef ASM_FILE #define GRUB_MMAP_MALLOC_LOW 1 diff --git a/include/grub/xen/relocator.h b/include/grub/xen/relocator.h index ae45dce21..35a0ad9c7 100644 --- a/include/grub/xen/relocator.h +++ b/include/grub/xen/relocator.h @@ -23,11 +23,13 @@ #include #include +#define XEN_MAX_MAPPINGS 3 + struct grub_relocator_xen_state { grub_addr_t start_info; - grub_addr_t paging_start; - grub_addr_t paging_size; + grub_addr_t paging_start[XEN_MAX_MAPPINGS]; + grub_addr_t paging_size[XEN_MAX_MAPPINGS]; grub_addr_t mfn_list; grub_addr_t stack; grub_addr_t entry_point; From 0de3eeb6232db319812335ec02ea4cfb15aa2fef Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Thu, 3 Mar 2016 10:38:16 +0100 Subject: [PATCH 0590/1167] xen: add capability to load p2m list outside of kernel mapping Modern pvops linux kernels support a p2m list not covered by the kernel mapping. This capability is flagged by an elf-note specifying the virtual address the kernel is expecting the p2m list to be mapped to. In case the elf-note is set by the kernel don't place the p2m list into the kernel mapping, but map it to the given address. This will allow to support domains with larger memory, as the kernel mapping is limited to 2GB and a domain with huge memory in the TB range will have a p2m list larger than this. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen.c | 53 +++++++++++++++++++++++++----- grub-core/loader/i386/xen_fileXX.c | 4 +++ include/grub/xen_file.h | 2 ++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index a98badf44..51d1ddd37 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -313,24 +313,50 @@ static grub_err_t grub_xen_p2m_alloc (void) { grub_relocator_chunk_t ch; - grub_size_t p2msize; + grub_size_t p2msize, p2malloc; grub_err_t err; + struct grub_xen_mapping *map; if (xen_state.virt_mfn_list) return GRUB_ERR_NONE; + map = xen_state.mappings + xen_state.n_mappings; + p2msize = ALIGN_UP (sizeof (grub_xen_mfn_t) * + grub_xen_start_page_addr->nr_pages, PAGE_SIZE); + if (xen_state.xen_inf.has_p2m_base) + { + err = get_pgtable_size (xen_state.xen_inf.p2m_base, + xen_state.xen_inf.p2m_base + p2msize, + (xen_state.max_addr + p2msize) >> PAGE_SHIFT); + if (err) + return err; + + map->area.pfn_start = xen_state.max_addr >> PAGE_SHIFT; + p2malloc = p2msize + page2offset (map->area.n_pt_pages); + xen_state.n_mappings++; + xen_state.next_start.mfn_list = xen_state.xen_inf.p2m_base; + xen_state.next_start.first_p2m_pfn = map->area.pfn_start; + xen_state.next_start.nr_p2m_frames = p2malloc >> PAGE_SHIFT; + } + else + { + xen_state.next_start.mfn_list = + xen_state.max_addr + xen_state.xen_inf.virt_base; + p2malloc = p2msize; + } + xen_state.state.mfn_list = xen_state.max_addr; - xen_state.next_start.mfn_list = - xen_state.max_addr + xen_state.xen_inf.virt_base; - p2msize = sizeof (grub_xen_mfn_t) * grub_xen_start_page_addr->nr_pages; err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, - xen_state.max_addr, p2msize); + xen_state.max_addr, p2malloc); if (err) return err; xen_state.virt_mfn_list = get_virtual_current_address (ch); + if (xen_state.xen_inf.has_p2m_base) + map->where = (grub_uint64_t *) xen_state.virt_mfn_list + + p2msize / sizeof (grub_uint64_t); grub_memcpy (xen_state.virt_mfn_list, (void *) grub_xen_start_page_addr->mfn_list, p2msize); - xen_state.max_addr = ALIGN_UP (xen_state.max_addr + p2msize, PAGE_SIZE); + xen_state.max_addr += p2malloc; return GRUB_ERR_NONE; } @@ -448,9 +474,12 @@ grub_xen_alloc_boot_data (void) { grub_err_t err; - err = grub_xen_p2m_alloc (); - if (err) - return err; + if (!xen_state.xen_inf.has_p2m_base) + { + err = grub_xen_p2m_alloc (); + if (err) + return err; + } err = grub_xen_special_alloc (); if (err) return err; @@ -475,6 +504,12 @@ grub_xen_boot (void) err = grub_xen_alloc_boot_data (); if (err) return err; + if (xen_state.xen_inf.has_p2m_base) + { + err = grub_xen_p2m_alloc (); + if (err) + return err; + } err = set_mfns (xen_state.console_pfn); if (err) diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 8751174cf..fb66e66fe 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -261,6 +261,10 @@ parse_note (grub_elf_t elf, struct grub_xen_file_info *xi, descsz == 2 ? 2 : 3) == 0) xi->arch = GRUB_XEN_FILE_I386; break; + case XEN_ELFNOTE_INIT_P2M: + xi->p2m_base = grub_le_to_cpu_addr (*(Elf_Addr *) desc); + xi->has_p2m_base = 1; + break; case XEN_ELFNOTE_MOD_START_PFN: xi->unmapped_initrd = !!grub_le_to_cpu32(*(grub_uint32_t *) desc); break; diff --git a/include/grub/xen_file.h b/include/grub/xen_file.h index ed749fafe..658799952 100644 --- a/include/grub/xen_file.h +++ b/include/grub/xen_file.h @@ -32,9 +32,11 @@ struct grub_xen_file_info grub_uint64_t entry_point; grub_uint64_t hypercall_page; grub_uint64_t paddr_offset; + grub_uint64_t p2m_base; int has_hypercall_page; int has_note; int has_xen_guest; + int has_p2m_base; int extended_cr3; int unmapped_initrd; enum From 5f311e86d296fd8a7a16faa01bc87b26c1e5aa86 Mon Sep 17 00:00:00 2001 From: Corey Hickey Date: Fri, 4 Nov 2016 21:58:14 -0700 Subject: [PATCH 0591/1167] fix detection of non-LUKS CRYPT grub_util_get_dm_abstraction() does a string comparison of insufficient length. When using a UUID such as "CRYPT-PLAIN-sda6_crypt", the function returns GRUB_DEV_ABSTRACTION_LUKS. This results in the error: ./grub-probe: error: disk `cryptouuid/sda6_crypt' not found. This appears to be a copy/paste error introduced in: a10e7a5a8918bea6e2632055129fa9b516fe965a The bug was (apparently) latent until revealed by: 3bca85b4184f74995a7cc2791e432173fde26d34 Signed-off-by: Corey Hickey --- grub-core/osdep/devmapper/getroot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 72e558275..a13a39c96 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -143,7 +143,7 @@ grub_util_get_dm_abstraction (const char *os_dev) grub_free (uuid); return GRUB_DEV_ABSTRACTION_LVM; } - if (strncmp (uuid, "CRYPT-LUKS1-", 4) == 0) + if (strncmp (uuid, "CRYPT-LUKS1-", 12) == 0) { grub_free (uuid); return GRUB_DEV_ABSTRACTION_LUKS; From fbca3741052f4ee28a522cf0d778869623a8437d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 29 Feb 2016 00:22:23 +0100 Subject: [PATCH 0592/1167] arm64: Move firmware fdt search into global function Searching for a device tree that EFI passes to us via configuration tables is nothing architecture specific. Move it into generic code. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/kern/efi/init.c | 22 ++++++++++++++++++++++ grub-core/loader/arm64/fdt.c | 24 +----------------------- include/grub/efi/efi.h | 2 ++ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index e9c85de12..fb90ecd98 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -72,6 +72,28 @@ grub_machine_get_bootlocation (char **device, char **path) } } +void * +grub_efi_get_firmware_fdt (void) +{ + grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + void *firmware_fdt = NULL; + unsigned int i; + + /* Look for FDT in UEFI config tables. */ + tables = grub_efi_system_table->configuration_table; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) + { + firmware_fdt = tables[i].vendor_table; + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); + break; + } + + return firmware_fdt; +} + void grub_efi_fini (void) { diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index 5202c14e0..db49cf649 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -28,28 +28,6 @@ static void *loaded_fdt; static void *fdt; -static void * -get_firmware_fdt (void) -{ - grub_efi_configuration_table_t *tables; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - void *firmware_fdt = NULL; - unsigned int i; - - /* Look for FDT in UEFI config tables. */ - tables = grub_efi_system_table->configuration_table; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) - { - firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); - break; - } - - return firmware_fdt; -} - void * grub_fdt_load (grub_size_t additional_size) { @@ -65,7 +43,7 @@ grub_fdt_load (grub_size_t additional_size) if (loaded_fdt) raw_fdt = loaded_fdt; else - raw_fdt = get_firmware_fdt(); + raw_fdt = grub_efi_get_firmware_fdt(); size = raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 0e6fd86b0..2acf85ec1 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -81,6 +81,8 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, char **device, char **path); +void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); + grub_addr_t grub_efi_modules_addr (void); void grub_efi_mm_init (void); From e1b099fb69643afb5b215e8d74fc2175a9e4c7d3 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 29 Feb 2016 00:22:24 +0100 Subject: [PATCH 0593/1167] arm efi: Use fdt from firmware when available If EFI is nice enough to pass us an FDT using configuration tables on 32bit ARM, we should really try and make use of it. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- include/grub/arm/linux.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 059dbba42..a66caad13 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -40,11 +40,7 @@ # define LINUX_PHYS_OFFSET (0x00008000) # define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) # define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) -static inline grub_addr_t -grub_arm_firmware_get_boot_data (void) -{ - return 0; -} +# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt static inline grub_uint32_t grub_arm_firmware_get_machine_type (void) { From 28511b0da900876151c71b66885b89615c68cfa4 Mon Sep 17 00:00:00 2001 From: Joonas Lahtinen Date: Thu, 10 Nov 2016 15:45:38 +0200 Subject: [PATCH 0594/1167] .gitignore: Add grub-core/build-grub-module-verifier Signed-off-by: Joonas Lahtinen --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 18ab8e812..eca17bec9 100644 --- a/.gitignore +++ b/.gitignore @@ -246,3 +246,4 @@ build-aux/test-driver /garbage-gen /garbage-gen.exe /grub-fs-tester +grub-core/build-grub-module-verifier From 0d663b50b9abf830fd10de384606a0632a605b77 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 11 Oct 2016 22:19:02 +0200 Subject: [PATCH 0595/1167] grub-mknetdir: Add support for ARM64 EFI --- util/grub-mknetdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c index 3813e8bc0..82073d5cc 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -106,7 +106,8 @@ static const struct [GRUB_INSTALL_PLATFORM_I386_EFI] = { "i386-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_X86_64_EFI] = { "x86_64-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_IA64_EFI] = { "ia64-efi", "efinet", ".efi" }, - [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm-efi", "efinet", ".efi" } + [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm-efi", "efinet", ".efi" }, + [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64-efi", "efinet", ".efi" } }; static void From 0af7539bd297fb03da8166ba0c0c143cd2143fd2 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 9 Nov 2016 23:26:43 +0200 Subject: [PATCH 0596/1167] configure.ac: don't require build time grub-mkfont on powerpc-ieee1275 Don't require build time grub-mkfont on powerpc-ieee1275. Signed-off-by: Aaro Koskinen --- configure.ac | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 9ddfc5323..3d2551035 100644 --- a/configure.ac +++ b/configure.ac @@ -1555,11 +1555,11 @@ if test x"$grub_build_mkfont_excuse" = x ; then else enable_build_grub_mkfont=no fi -if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then +if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then if test x"$grub_build_mkfont_excuse" = x ; then - AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont]) + AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont]) else - AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont ($grub_build_mkfont_excuse)]) + AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)]) fi fi @@ -1629,11 +1629,11 @@ if test x"$enable_build_grub_mkfont" = xno ; then FONT_SOURCE= fi -if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then +if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then if test x"$grub_build_mkfont_excuse" = x ; then - AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont]) + AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont]) else - AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)]) + AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)]) fi fi From f8c3af3b613f9b1d5123f1ccad565950f82f6959 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 22 Nov 2016 20:42:23 +0300 Subject: [PATCH 0597/1167] bootp: export next server IP as environment variable Network boot autoconfiguration sets default server to next server IP (siaddr) from BOOTP/DHCP reply, but manual configuration using net_bootp exports only server name. Unfortunately semantic of server name is not clearly defined. BOOTP RFC 951 defines it only for client request, and DHCP RFC 1541 only mentions it, without any implied usage. It looks like this field is mostly empty in server replies. Export next server IP as net__next_server variable. This allows grub configuration script to set $root/$prefix based on information obtained by net_bootp. Reported and tested by: Nikunj A Dadhania Cc: nikunj@linux.vnet.ibm.com v2: change variable name to net__next_server as discussed on the list --- docs/grub.texi | 11 +++++++++++ grub-core/net/bootp.c | 24 ++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 82f6fa459..b9ddb9b8a 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2446,6 +2446,10 @@ The boot file name provided by DHCP. Read-only. The name of the DHCP server responsible for these boot parameters. Read-only. +@item net_@var{}_next_server +The IP address of the next (usually, TFTP) server provided by DHCP. +Read-only. + @item net_default_interface Initially set to name of network interface that was used to load grub. Read-write, although setting it affects only interpretation of @@ -3062,6 +3066,7 @@ These variables have special meaning to GRUB. * net_@var{}_hostname:: * net_@var{}_ip:: * net_@var{}_mac:: +* net_@var{}_next_server:: * net_@var{}_rootpath:: * net_default_interface:: * net_default_ip:: @@ -3422,6 +3427,12 @@ The default is the value of @samp{color_normal} (@pxref{color_normal}). @xref{Network}. +@node net_@var{}_next_server +@subsection net_@var{}_next_server + +@xref{Network}. + + @node net_@var{}_rootpath @subsection net_@var{}_rootpath diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 189551a48..9e2fdb795 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -142,6 +142,7 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_net_link_level_address_t hwaddr; struct grub_net_network_level_interface *inter; int mask = -1; + char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; addr.ipv4 = bp->your_ip; @@ -192,15 +193,22 @@ grub_net_configure_by_dhcp_ack (const char *name, if (size > OFFSET_OF (boot_file, bp)) grub_env_set_net_property (name, "boot_file", bp->boot_file, sizeof (bp->boot_file)); + if (bp->server_ip) + { + grub_snprintf (server_ip, sizeof (server_ip), "%d.%d.%d.%d", + ((grub_uint8_t *) &bp->server_ip)[0], + ((grub_uint8_t *) &bp->server_ip)[1], + ((grub_uint8_t *) &bp->server_ip)[2], + ((grub_uint8_t *) &bp->server_ip)[3]); + grub_env_set_net_property (name, "next_server", server_ip, sizeof (server_ip)); + grub_print_error (); + } + if (is_def) grub_net_default_server = 0; if (is_def && !grub_net_default_server && bp->server_ip) { - grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d", - ((grub_uint8_t *) &bp->server_ip)[0], - ((grub_uint8_t *) &bp->server_ip)[1], - ((grub_uint8_t *) &bp->server_ip)[2], - ((grub_uint8_t *) &bp->server_ip)[3]); + grub_net_default_server = grub_strdup (server_ip); grub_print_error (); } @@ -212,11 +220,7 @@ grub_net_configure_by_dhcp_ack (const char *name, if (device && !*device && bp->server_ip) { - *device = grub_xasprintf ("tftp,%d.%d.%d.%d", - ((grub_uint8_t *) &bp->server_ip)[0], - ((grub_uint8_t *) &bp->server_ip)[1], - ((grub_uint8_t *) &bp->server_ip)[2], - ((grub_uint8_t *) &bp->server_ip)[3]); + *device = grub_xasprintf ("tftp,%s", server_ip); grub_print_error (); } if (size > OFFSET_OF (server_name, bp) From c9a8d037a85fe439027e4dc294169e9d18757fcc Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 22 Nov 2016 20:51:54 +0300 Subject: [PATCH 0598/1167] NEWS updates --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 572eadb3e..2ebd54e78 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,8 @@ New in 2.02: * Parse `nd' disk names in GRUB Legacy configuration files. * Issue separate DNS queries for IPv4 and IPv6. * Support IPv6 Router Advertisement to configure default router. + * New variable net__next_server containing next server + from BOOTP reply. * Coreboot improvements: * CBFS support both in on-disk images (loopback) and flash. @@ -171,6 +173,7 @@ New in 2.02: * Use fixed timestamp when generating GRUB image for reproducible builds. * Verify at build time that modules contain only supported relocations and their structure matches what boot-time module loader expects. + * Do not require fonts on powerpc-ieee1275. * Revision control moved to git. From 0d2345774dddfb94d753a97db802d19494e31a82 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 21 Nov 2016 16:23:02 +0100 Subject: [PATCH 0599/1167] efi: Move fdt helper into own file We only support FDT files with EFI on arm and arm64 systems, not on x86. So move the helper that finds a prepopulated FDT UUID into its own file and only build it for architectures where it also gets called. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 2 ++ grub-core/kern/efi/fdt.c | 43 +++++++++++++++++++++++++++++++++++++ grub-core/kern/efi/init.c | 22 ------------------- include/grub/efi/efi.h | 2 ++ 4 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 grub-core/kern/efi/fdt.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 21ad0dd7c..2dfa22a92 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -212,8 +212,10 @@ kernel = { arm_efi = kern/arm/efi/init.c; arm_efi = kern/arm/efi/misc.c; + arm_efi = kern/efi/fdt.c; arm64_efi = kern/arm64/efi/init.c; + arm64_efi = kern/efi/fdt.c; i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/mmap.c; diff --git a/grub-core/kern/efi/fdt.c b/grub-core/kern/efi/fdt.c new file mode 100644 index 000000000..30100c61c --- /dev/null +++ b/grub-core/kern/efi/fdt.c @@ -0,0 +1,43 @@ +/* fdt.c - EFI Flattened Device Tree interaction */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2006,2007 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 . + */ + +#include +#include + +void * +grub_efi_get_firmware_fdt (void) +{ + grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + void *firmware_fdt = NULL; + unsigned int i; + + /* Look for FDT in UEFI config tables. */ + tables = grub_efi_system_table->configuration_table; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) + { + firmware_fdt = tables[i].vendor_table; + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); + break; + } + + return firmware_fdt; +} diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index fb90ecd98..e9c85de12 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -72,28 +72,6 @@ grub_machine_get_bootlocation (char **device, char **path) } } -void * -grub_efi_get_firmware_fdt (void) -{ - grub_efi_configuration_table_t *tables; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - void *firmware_fdt = NULL; - unsigned int i; - - /* Look for FDT in UEFI config tables. */ - tables = grub_efi_system_table->configuration_table; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) - { - firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); - break; - } - - return firmware_fdt; -} - void grub_efi_fini (void) { diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 2acf85ec1..e9c601f34 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -81,7 +81,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, char **device, char **path); +#if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); +#endif grub_addr_t grub_efi_modules_addr (void); From 7b4c54c4ad6a1c92228e1f05047bf820b3a6d36d Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Mon, 12 Dec 2016 18:03:38 +0300 Subject: [PATCH 0600/1167] ofnet: move the allocation of the transmit buffer into a function In the current code search_net_devices() uses the "alloc-mem" command from the IEEE1275 User Interface for allocation of the transmit buffer for the case when GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN is set. I don't have hardware where this flag is set to verify if this workaround is still needed. However, further changes to ofnet will require to execute this workaround one more time. Therefore, to avoid possible duplication of code I'm moving this piece of code into a function. Signed-off-by: Stanislav Kholmanskikh Reviewed-by: Daniel Kiper --- grub-core/net/drivers/ieee1275/ofnet.c | 69 ++++++++++++++++---------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 6bd3b922e..cec0ccc3c 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -294,6 +294,48 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path, } } +/* Allocate memory with alloc-mem */ +static void * +grub_ieee1275_alloc_mem (grub_size_t len) +{ + struct alloc_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t catch; + grub_ieee1275_cell_t result; + } + args; + + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET)) + { + grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("interpret is not supported")); + return NULL; + } + + INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2); + args.len = len; + args.method = (grub_ieee1275_cell_t) "alloc-mem"; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch) + { + grub_error (GRUB_ERR_INVALID_COMMAND, N_("alloc-mem failed")); + return NULL; + } + else + return (void *)args.result; +} + +static void * +ofnet_alloc_netbuf (grub_size_t len) +{ + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN)) + return grub_ieee1275_alloc_mem (len); + else + return grub_zalloc (len); +} + static int search_net_devices (struct grub_ieee1275_devalias *alias) { @@ -410,32 +452,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) card->txbufsize = ALIGN_UP (card->mtu, 64) + 256; - if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN)) - { - struct alloc_args - { - struct grub_ieee1275_common_hdr common; - grub_ieee1275_cell_t method; - grub_ieee1275_cell_t len; - grub_ieee1275_cell_t catch; - grub_ieee1275_cell_t result; - } - args; - INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2); - args.len = card->txbufsize; - args.method = (grub_ieee1275_cell_t) "alloc-mem"; - - if (IEEE1275_CALL_ENTRY_FN (&args) == -1 - || args.catch) - { - card->txbuf = 0; - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - } - else - card->txbuf = (void *) args.result; - } - else - card->txbuf = grub_zalloc (card->txbufsize); + card->txbuf = ofnet_alloc_netbuf (card->txbufsize); if (!card->txbuf) { grub_free (ofdata->path); From 130234bc782e1b36a6c55fcac31ff3208cc8807b Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Mon, 12 Dec 2016 18:03:39 +0300 Subject: [PATCH 0601/1167] ofnet: implement the receive buffer get_card_packet() from ofnet.c allocates a netbuff based on the device's MTU: nb = grub_netbuff_alloc (dev->mtu + 64 + 2); In the case when the MTU is large, and the received packet is relatively small, this leads to allocation of significantly more memory, than it's required. An example could be transmission of TFTP packets with 0x400 blksize via a network card with 0x10000 MTU. This patch implements a per-card receive buffer in a way similar to efinet.c, and makes get_card_packet() allocate a netbuff of the received data size. Signed-off-by: Stanislav Kholmanskikh Reviewed-by: Daniel Kiper --- grub-core/net/drivers/ieee1275/ofnet.c | 90 +++++++++++++++++++++----- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index cec0ccc3c..a78d164db 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -85,24 +85,30 @@ get_card_packet (struct grub_net_card *dev) grub_uint64_t start_time; struct grub_net_buff *nb; - nb = grub_netbuff_alloc (dev->mtu + 64 + 2); + start_time = grub_get_time_ms (); + do + rc = grub_ieee1275_read (data->handle, dev->rcvbuf, dev->rcvbufsize, &actual); + while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200)); + + if (actual <= 0) + return NULL; + + nb = grub_netbuff_alloc (actual + 2); if (!nb) return NULL; /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible by 4. So that IP header is aligned on 4 bytes. */ grub_netbuff_reserve (nb, 2); - start_time = grub_get_time_ms (); - do - rc = grub_ieee1275_read (data->handle, nb->data, dev->mtu + 64, &actual); - while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200)); - if (actual > 0) + grub_memcpy (nb->data, dev->rcvbuf, actual); + + if (grub_netbuff_put (nb, actual)) { - grub_netbuff_put (nb, actual); - return nb; + grub_netbuff_free (nb); + return NULL; } - grub_netbuff_free (nb); - return NULL; + + return nb; } static struct grub_net_card_driver ofdriver = @@ -327,6 +333,40 @@ grub_ieee1275_alloc_mem (grub_size_t len) return (void *)args.result; } +/* Free memory allocated by alloc-mem */ +static grub_err_t +grub_ieee1275_free_mem (void *addr, grub_size_t len) +{ + struct free_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t len; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t catch; + } + args; + + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET)) + { + grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("interpret is not supported")); + return grub_errno; + } + + INIT_IEEE1275_COMMON (&args.common, "interpret", 3, 1); + args.addr = (grub_ieee1275_cell_t)addr; + args.len = len; + args.method = (grub_ieee1275_cell_t) "free-mem"; + + if (IEEE1275_CALL_ENTRY_FN(&args) == -1 || args.catch) + { + grub_error (GRUB_ERR_INVALID_COMMAND, N_("free-mem failed")); + return grub_errno; + } + + return GRUB_ERR_NONE; +} + static void * ofnet_alloc_netbuf (grub_size_t len) { @@ -336,6 +376,15 @@ ofnet_alloc_netbuf (grub_size_t len) return grub_zalloc (len); } +static void +ofnet_free_netbuf (void *addr, grub_size_t len) +{ + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN)) + grub_ieee1275_free_mem (addr, len); + else + grub_free (addr); +} + static int search_net_devices (struct grub_ieee1275_devalias *alias) { @@ -451,15 +500,19 @@ search_net_devices (struct grub_ieee1275_devalias *alias) card->default_address = lla; card->txbufsize = ALIGN_UP (card->mtu, 64) + 256; + card->rcvbufsize = ALIGN_UP (card->mtu, 64) + 256; card->txbuf = ofnet_alloc_netbuf (card->txbufsize); if (!card->txbuf) + goto fail_netbuf; + + card->rcvbuf = ofnet_alloc_netbuf (card->rcvbufsize); + if (!card->rcvbuf) { - grub_free (ofdata->path); - grub_free (ofdata); - grub_free (card); - grub_print_error (); - return 0; + grub_error_push (); + ofnet_free_netbuf (card->txbuf, card->txbufsize); + grub_error_pop (); + goto fail_netbuf; } card->driver = NULL; card->data = ofdata; @@ -472,6 +525,13 @@ search_net_devices (struct grub_ieee1275_devalias *alias) card->driver = &ofdriver; grub_net_card_register (card); return 0; + +fail_netbuf: + grub_free (ofdata->path); + grub_free (ofdata); + grub_free (card); + grub_print_error (); + return 0; } static void From a3e9da054d00260f274cfd9d1b9611c32ecd437c Mon Sep 17 00:00:00 2001 From: Magnus Granberg Date: Wed, 14 Dec 2016 20:44:41 +0300 Subject: [PATCH 0602/1167] configure: add check for -no-pie if the compiler default to -fPIE When Grub is compile with gcc 6.1 that have --enable-defult-pie set. It fail with. -ffreestanding -m32 -Wl,-melf_i386 -Wl,--build-id=none -nostdlib -Wl,-N -Wl,-r,-d - o trig.module trig_module-trigtables.o grep 'MARKER' gcry_whirlpool.marker.new > gcry_whirlpool.marker; rm -f gcry_whirlpool.marker.new /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: -r and - shared may not be used together collect2: error: ld returned 1 exit status Makefile:26993: recipe for target 'trig.module' failed Check that compiler supports -no-pie and add it to linker flags. --- acinclude.m4 | 18 ++++++++++++++++++ configure.ac | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 526f97a3a..7884c1bb5 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -390,6 +390,24 @@ else [fi] ]) +dnl Check if the Linker supports `-no-pie'. +AC_DEFUN([grub_CHECK_NO_PIE], +[AC_MSG_CHECKING([whether linker accepts -no-pie]) +AC_CACHE_VAL(grub_cv_cc_ld_no_pie, +[save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -no-pie" +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_ld_no_pie=yes], + [grub_cv_cc_ld_no_pie=no]) +LDFLAGS="$save_LDFLAGS" +]) +AC_MSG_RESULT([$grub_cv_cc_ld_no_pie]) +nopie_possible=no +if test "x$grub_cv_cc_ld_no_pie" = xyes ; then + nopie_possible=yes +fi +]) + dnl Check if the C compiler supports `-fPIC'. AC_DEFUN([grub_CHECK_PIC],[ [# Position independent executable. diff --git a/configure.ac b/configure.ac index 3d2551035..dc56564d7 100644 --- a/configure.ac +++ b/configure.ac @@ -1185,13 +1185,18 @@ CFLAGS="$TARGET_CFLAGS" # Position independent executable. grub_CHECK_PIE +grub_CHECK_NO_PIE [# Need that, because some distributions ship compilers that include -# `-fPIE' or '-fpie' in the default specs. +# `-fPIE' or '-fpie' and '-pie' in the default specs. if [ x"$pie_possible" = xyes ]; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie" +fi +if [ x"$nopie_possible" = xyes ] && [ x"$pie_possible" = xyes ]; then + TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie" fi] CFLAGS="$TARGET_CFLAGS" +LDFLAGS="$TARGET_LDFLAGS" # Position independent executable. grub_CHECK_PIC From ce95549cc54b5d6f494608a7c390dba3aab4fba7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 15 Dec 2016 16:07:00 +0300 Subject: [PATCH 0603/1167] efi: properly terminate filepath with NULL in chainloader EFI File Path Media Device Path is defined as NULL terminated string; but chainloader built file paths without final NULL. This caused error with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS. Apparently firmware failed verification with EFI_INVALID_PARAMETER which is considered fatal error by PreLoader. Reported and tested by Giovanni Santini --- grub-core/loader/efi/chainloader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index 522a716e3..adc856366 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -122,6 +122,8 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, if (*p == '/') *p = '\\'; + /* File Path is NULL terminated */ + fp->path_name[size++] = '\0'; fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); } @@ -156,8 +158,10 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) d = GRUB_EFI_NEXT_DEVICE_PATH (d); } + /* File Path is NULL terminated. Allocate space for 2 extra characters */ + /* FIXME why we split path in two components? */ file_path = grub_malloc (size - + ((grub_strlen (dir_start) + 1) + + ((grub_strlen (dir_start) + 2) * GRUB_MAX_UTF16_PER_UTF8 * sizeof (grub_efi_char16_t)) + sizeof (grub_efi_file_path_device_path_t) * 2); From 562c406763d6c078ccf9fad1058e6d618b2456da Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 19 Dec 2016 17:09:04 +0800 Subject: [PATCH 0604/1167] Fix fwpath in efi netboot The path returned by grub_efi_net_config has already been stripped for the directory part extracted from cached bootp packet. We should just return the result to avoild it be stripped again. It fixed the problem that grub.efi as NBP image always looking for grub.cfg and platform directory in upper folder rather than current one it gets loaded while $prefix is empty. The behavior is inconsistent with other architecture and how we would expect empty $prefix going to be in general. The only exception to the general rule of empty $prefix is that when loaded from platform directory itself, the platform part is stripped thus upper folder is used for looking up files. It meets the case for how grub-mknetdir lay out the files under tftp root directory, but also hide away this issue to be identified as it appears to be just works. Also fix possible memory leak by moving grub_efi_get_filename() call after grub_efi_net_config(). --- grub-core/kern/efi/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index e9c85de12..2c31847bf 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -59,10 +59,13 @@ grub_machine_get_bootlocation (char **device, char **path) if (!image) return; *device = grub_efidisk_get_device_name (image->device_handle); - *path = grub_efi_get_filename (image->file_path); if (!*device && grub_efi_net_config) - grub_efi_net_config (image->device_handle, device, path); + { + grub_efi_net_config (image->device_handle, device, path); + return; + } + *path = grub_efi_get_filename (image->file_path); if (*path) { /* Get the directory. */ From 07662af7aed55bcec448bc2a6610de1f0cb62100 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 22 Dec 2016 22:48:25 +0300 Subject: [PATCH 0605/1167] configure: fix check for sys/sysmacros.h under glibc 2.25+ glibc 2.25 still includes sys/sysmacros.h in sys/types.h but also emits deprecation warning. So test for sys/types.h succeeds in configure but later compilation fails because we use -Werror by default. While this is fixed in current autoconf GIT, we really cannot force everyone to use bleeding edge (that is not even released right now). So run test under -Werror as well to force proper detection. This should have no impact on autoconf 2.70+ as AC_HEADER_MAJOR in this version simply checks for header existence. Reported and tested by Khem Raj --- configure.ac | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configure.ac b/configure.ac index dc56564d7..4e980c5fe 100644 --- a/configure.ac +++ b/configure.ac @@ -389,7 +389,14 @@ fi # Check for functions and headers. AC_CHECK_FUNCS(posix_memalign memalign getextmntent) AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) + +# glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation +# warning which causes compilation failure later with -Werror. So use -Werror here +# as well to force proper sys/sysmacros.h detection. +SAVED_CFLAGS="$CFLAGS" +CFLAGS="$HOST_CFLAGS -Werror" AC_HEADER_MAJOR +CFLAGS="$SAVED_CFLAGS" AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default #include From 972765fe8245cdf44d465329f33b5aa9ac6c2f47 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 8 Jan 2017 15:52:49 +0300 Subject: [PATCH 0606/1167] linux: fix "vga=XX deprecated" warning for text mode Arguments were in reverse order which resulted in text is deprecated. Use set gfxpayload=vga=0 before linux command instead. --- grub-core/loader/i386/linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index fddcc461d..b15b8cca5 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -915,8 +915,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_env_set ("gfxpayload", "text"); grub_printf_ (N_("%s is deprecated. " "Use set gfxpayload=%s before " - "linux command instead.\n"), "text", - argv[i]); + "linux command instead.\n"), + argv[i], "text"); break; case 1: @@ -925,8 +925,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_env_set ("gfxpayload", "text"); grub_printf_ (N_("%s is deprecated. " "Use set gfxpayload=%s before " - "linux command instead.\n"), "text", - argv[i]); + "linux command instead.\n"), + argv[i], "text"); break; default: /* Ignore invalid values. */ From a2932fbe8a602f3abd7c9b97004a31dc1a384639 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 24 Jan 2017 20:05:19 +0300 Subject: [PATCH 0607/1167] osdep/linux: handle autofs entries in /proc/self/mountinfo These entries have placeholder for device name and so are useless for our purpose. grub failed with something like grub-install: error: failed to get canonical path of `systemd-1'. When we see autofs entry, record it (to keep parent-child relationship) but continue to look for real mount. If it is found, we process it as usual. If only autofs entry exists, attempt to trigger mount by opening mount point and retry. Mount point itself is then kept open to avoid timeout. Recent systemd is by default using automount for /boot/efi so this should become more popular problem on EFI systems. Closes: 49942 --- grub-core/osdep/linux/getroot.c | 45 +++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 09e7e6e6d..90d92d3ad 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -380,24 +380,30 @@ get_btrfs_fs_prefix (const char *mount_path) char ** grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) { - FILE *fp; + FILE *fp = NULL; char *buf = NULL; size_t len = 0; - grub_size_t entry_len = 0, entry_max = 4; + grub_size_t entry_len, entry_max = 4; struct mountinfo_entry *entries; struct mountinfo_entry parent_entry = { 0, 0, 0, "", "", "", "" }; int i; + int retry = 0; + int dir_fd = -1; + char **ret = NULL; if (! *dir) dir = "/"; if (relroot) *relroot = NULL; + entries = xmalloc (entry_max * sizeof (*entries)); + +again: fp = grub_util_fopen ("/proc/self/mountinfo", "r"); if (! fp) - return NULL; /* fall through to other methods */ + goto out; /* fall through to other methods */ - entries = xmalloc (entry_max * sizeof (*entries)); + entry_len = 0; /* First, build a list of relevant visible mounts. */ while (getline (&buf, &len, fp) > 0) @@ -484,7 +490,6 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) /* Now scan visible mounts for the ones we're interested in. */ for (i = entry_len - 1; i >= 0; i--) { - char **ret = NULL; char *fs_prefix = NULL; if (!*entries[i].device) continue; @@ -515,6 +520,23 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) ret = grub_find_root_devices_from_btrfs (dir); fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path); } + else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0) + { + /* If the best match is automounted, try to trigger mount. We cannot + simply return here because stat() on automounted directory does not + trigger mount and returns bogus (pseudo)device number instead. + We keep mountpoint open until end of scan to prevent timeout. */ + + int flags = O_RDONLY|O_DIRECTORY; + + fclose (fp); +#ifdef O_LARGEFILE + flags |= O_LARGEFILE; +#endif + dir_fd = open (entries[i].enc_path, flags); + retry = 1; + goto again; + } if (!ret) { ret = xmalloc (2 * sizeof (ret[0])); @@ -544,16 +566,17 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) } if (fs_prefix != entries[i].enc_root) free (fs_prefix); - free (buf); - free (entries); - fclose (fp); - return ret; + break; } +out: free (buf); free (entries); - fclose (fp); - return NULL; + if (fp) + fclose (fp); + if (dir_fd != -1) + close (dir_fd); + return ret; } static char * From bf0e59cebff53b33674cb13cf18255686c288c57 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Jan 2017 17:46:47 +0000 Subject: [PATCH 0608/1167] grub-fs-tester: Accomodate for testing in proot containers. proot creates hidden files with .proot prefix and name derived from real file name. So decrease file name length and path depth. For some reason depth 85 also results in undeleteable directory, so use 84 instead of 85. --- tests/util/grub-fs-tester.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 424de2267..986f6677a 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -251,7 +251,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + CFILES[0]="american-english";; esac # OS LIMITATION: Limited by NAME_MAX (usually 255) in GNU/Linux - LONGNAME="qwertzuiopasdfghjklyxcvbnm1234567890qwertzuiopasdfghjklyxcvbnm1234567890oiewqfiewioqoiqoiurqruewqoiuwoieoiiuewqroreqiufieiuwrnureweriuvceoiroiewqoiricdsalkcndsakfirefoiwqeoircorejwoijfreoijojoiewjfwnfcoirenfoirefnreoifenoiwfnoirewoifoiwqwoieqfrqwioerijewr" + LONGNAME="qwertzuiopasdfghjklyxcvbnm1234567890qwertzuiopasdfghjklyxcvbnm1234567890oiewqfiewioqoiqoiurqruewqoiuwoieoiiuewqroreqiufieiuwrnureweriuvceoiroiewqoiricdsalkcndsakfirefoiwqeoircorejwoijfreoijojoiewjfwnfcoirenfoirefnreoifenoiwfnoi" rm -rf "$MASTER" case x"$fs" in @@ -498,8 +498,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + NOFSLABEL=y;; esac - PDIRCOMPNUM=220 - PDIR2COMPNUM=220 + PDIRCOMPNUM=210 + PDIR2COMPNUM=210 case x$fs in # OS LIMITATION: bfs_fuse bugs beyond that @@ -514,7 +514,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # FS LIMITATION: at most 255 on path length # FS LIMITATION: at most 100 on symlink length xcpio_ustar) - PDIRCOMPNUM=85 + PDIRCOMPNUM=84 PDIR2COMPNUM=30;; # OS LIMITATION: Linux supports only symlink at most one block long on reiserfs xreiserfs | xreiserfs_old) From cde63a3bb0e213386a5d836911f0e1d71b504620 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Jan 2017 17:58:15 +0000 Subject: [PATCH 0609/1167] grub-fs-tester: Accomodate for slower systems. fstime can be more different with xz squashfs. Allow difference up to 3 seconds. This code is ugly now but rewriting it now is not on the table. --- tests/util/grub-fs-tester.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 986f6677a..1111c4b7d 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1304,10 +1304,11 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # is not precise. Account for small difference here. FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")" FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")" + FSTIMEM3="$(date -d "$FSTIME UTC -3 second" -u "+%Y-%m-%d %H:%M:%S")" if [ x$NOFSTIME = xy ]; then : - elif echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" > /dev/null; then + elif echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then : else echo FSTIME FAIL From afa9dda37e9721e064e30e2c146654f5f4056c65 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Jan 2017 18:00:40 +0000 Subject: [PATCH 0610/1167] grub-fs-tester: Delete directory once we're done. --- tests/util/grub-fs-tester.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 1111c4b7d..d5c81a322 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1516,3 +1516,4 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + done done done +rmdir "${tempdir}" From bf9c5616708dcfd905acdd730e4d63b3be84dadd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 00:52:32 +0300 Subject: [PATCH 0611/1167] configure: Disable movw/movt with clang. Those relocations are not compatible with PE and also not compatible with custom uboot relocator. Disable them. --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 4e980c5fe..ab7fa92e0 100644 --- a/configure.ac +++ b/configure.ac @@ -1152,6 +1152,16 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then fi if test "x$target_cpu" = xarm; then + AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works], grub_cv_cc_mllvm_arm_use_movt, [ + CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_mllvm_arm_use_movt=yes], + [grub_cv_cc_mllvm_arm_use_movt=no]) + ]) + if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then + # A trick so that clang doesn't see it on link stage + TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0" + fi AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [ CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], From 79fc0089352fb0a7680fb661f6b759845c95e1fb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 23:57:23 +0300 Subject: [PATCH 0612/1167] Don't use -mlong-calls on arm. We don't really need it and it's flaky and creates bogus symbols with clang. --- configure.ac | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configure.ac b/configure.ac index ab7fa92e0..29d05c15d 100644 --- a/configure.ac +++ b/configure.ac @@ -1162,15 +1162,6 @@ if test "x$target_cpu" = xarm; then # A trick so that clang doesn't see it on link stage TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0" fi - AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [ - CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_mlong_calls=yes], - [grub_cv_cc_mlong_calls=no]) - ]) - if test "x$grub_cv_cc_mlong_calls" = xyes; then - TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls" - fi AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [ CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], From bec592aa872f7898e9665973b26156e46e73b29e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 21:25:25 +0300 Subject: [PATCH 0613/1167] grub-shell: skip font copying when no font is available. --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index ab19dbbf5..814f36c6b 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -481,7 +481,7 @@ elif [ x$boot = xemu ]; then mkdir -p "$grubdir/fonts" mkdir -p "$grubdir/themes" mkdir -p "$grubdir/locale" - cp "@builddir@/"unicode.pf2 "$grubdir/fonts/unicode.pf2" + test -f "@builddir@/"unicode.pf2 && cp "@builddir@/"unicode.pf2 "$grubdir/fonts/unicode.pf2" cp -R "@srcdir@/themes/starfield" "$grubdir/themes/starfield" for file in "@srcdir@/po/"*.gmo; do if [ -f "$file" ]; then From 43dbf83aa216ac9b92a98fdf9fa090192be65a6d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 23:32:25 +0300 Subject: [PATCH 0614/1167] Ensure that grub_reboot doesn't return on emu. Use grub_fatal if longjmp fails. grub_reboot is marked as noreturn so return would cause a crash. --- grub-core/kern/emu/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index f91280f68..425bb9603 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -63,6 +63,7 @@ void grub_reboot (void) { longjmp (main_env, 1); + grub_fatal ("longjmp failed"); } void From a0413e2677dd46a98b19bb2e9f3bd352383de2ad Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Fri, 27 Jan 2017 22:10:21 +0000 Subject: [PATCH 0615/1167] exfat: Support files over 4GiB file size in grub_fat_data was 32-bit on exfat. --- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 635c2c425..8d8dc35ce 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -189,7 +189,11 @@ struct grub_fshelp_node { struct grub_fat_data *data; grub_uint8_t attr; - grub_ssize_t file_size; +#ifndef MODE_EXFAT + grub_uint32_t file_size; +#else + grub_uint64_t file_size; +#endif grub_uint32_t file_cluster; grub_uint32_t cur_cluster_num; grub_uint32_t cur_cluster; From d15f17b2a03d9d25b547178a6413955468784d2e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Jan 2017 14:41:23 +0000 Subject: [PATCH 0616/1167] Support arm clang 3.8 amd later. clang 3.8 and later doesn't support -mllvm -use-arm-movt=0 whereas older clang doesn't know -mno-movt. So use -mno-movt whenever possible and fallback to mllvm variant. --- configure.ac | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 29d05c15d..33146b41a 100644 --- a/configure.ac +++ b/configure.ac @@ -1152,15 +1152,23 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then fi if test "x$target_cpu" = xarm; then - AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works], grub_cv_cc_mllvm_arm_use_movt, [ - CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_mllvm_arm_use_movt=yes], - [grub_cv_cc_mllvm_arm_use_movt=no]) + AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [ + grub_cv_target_cc_mno_movt=no + for cand in "-mno-movt" \ + "-mllvm -arm-use-movt=0"; do + if test x"$grub_cv_target_cc_mno_movt" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + CPPFLAGS="$TARGET_CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_mno_movt="$cand"], []) + done ]) - if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then + + if test x"$grub_cv_target_cc_mno_movt" != xno ; then # A trick so that clang doesn't see it on link stage - TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt" fi AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [ CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror" From 6371e9c10433578bb236a8284ddb9ce9e201eb59 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 30 Jan 2017 00:13:41 +0000 Subject: [PATCH 0617/1167] grub-module-verifier: Ignore all_video emptiness on xen. It's intentional that it's empty when no video modules are available. --- grub-core/genmod.sh.in | 2 +- include/grub/module_verifier.h | 4 ++-- util/grub-module-verifier.c | 29 +++++++++++++++++++++----- util/grub-module-verifierXX.c | 38 ++++++++++++++++++++++++++++++---- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 045817b15..03cc3b7f6 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -94,6 +94,6 @@ else rm -f $tmpfile.bin fi if test x@platform@ != xemu; then - ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@ + ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@ @platform@ fi mv $tmpfile $outfile diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h index 6cddff30f..f4870cb9c 100644 --- a/include/grub/module_verifier.h +++ b/include/grub/module_verifier.h @@ -16,5 +16,5 @@ struct grub_module_verifier_arch { const int *short_relocations; }; -void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); -void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); +void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); +void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 405c91170..de14c62e7 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -116,15 +116,27 @@ struct grub_module_verifier_arch archs[] = { }, }; +struct platform_whitelist { + const char *arch; + const char *platform; + const char **whitelist_empty; +}; + +static struct platform_whitelist whitelists[] = { + {"i386", "xen", (const char *[]) {"all_video", 0}}, + {"x86_64", "xen", (const char *[]) {"all_video", 0}} +}; + int main (int argc, char **argv) { size_t module_size; - unsigned arch; + unsigned arch, whitelist; + const char **whitelist_empty = 0; char *module_img; - if (argc != 3) { - fprintf (stderr, "usage: %s FILE ARCH\n", argv[0]); + if (argc != 4) { + fprintf (stderr, "usage: %s FILE ARCH PLATFORM\n", argv[0]); return 1; } @@ -134,11 +146,18 @@ main (int argc, char **argv) if (arch == ARRAY_SIZE(archs)) grub_util_error("unknown arch: %s", argv[2]); + for (whitelist = 0; whitelist < ARRAY_SIZE(whitelists); whitelist++) + if (strcmp(whitelists[whitelist].arch, argv[2]) == 0 + && strcmp(whitelists[whitelist].platform, argv[3]) == 0) + break; + if (whitelist != ARRAY_SIZE(whitelists)) + whitelist_empty = whitelists[whitelist].whitelist_empty; + module_size = grub_util_get_image_size (argv[1]); module_img = grub_util_read_image (argv[1]); if (archs[arch].voidp_sizeof == 8) - grub_module_verify64(module_img, module_size, &archs[arch]); + grub_module_verify64(module_img, module_size, &archs[arch], whitelist_empty); else - grub_module_verify32(module_img, module_size, &archs[arch]); + grub_module_verify32(module_img, module_size, &archs[arch], whitelist_empty); return 0; } diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 9c04caa63..2c0c690fa 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -184,8 +184,24 @@ get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word return sym; } +static int +is_whitelisted (const char *modname, const char **whitelist) +{ + const char **ptr; + if (!whitelist) + return 0; + if (!modname) + return 0; + for (ptr = whitelist; *ptr; ptr++) + if (strcmp (modname, *ptr) == 0) + return 1; + return 0; +} + static void -check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +check_symbols (const struct grub_module_verifier_arch *arch, + Elf_Ehdr *e, const char *modname, + const char **whitelist_empty) { Elf_Sym *sym; Elf_Word size, entsize; @@ -196,7 +212,16 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) sym = get_symtab (arch, e, &size, &entsize); if (!sym) { - Elf_Shdr *s = find_section (arch, e, ".moddeps"); + Elf_Shdr *s; + + /* However some modules are dependencies-only, + e.g. insmod all_video pulls in all video drivers. + Some platforms e.g. xen have no video drivers, so + the module does nothing. */ + if (is_whitelisted (modname, whitelist_empty)) + return; + + s = find_section (arch, e, ".moddeps"); if (!s) grub_util_error ("no symbol table and no .moddeps section"); @@ -324,7 +349,9 @@ check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) } void -SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_module_verifier_arch *arch) +SUFFIX(grub_module_verify) (void *module_img, size_t size, + const struct grub_module_verifier_arch *arch, + const char **whitelist_empty) { Elf_Ehdr *e = module_img; @@ -361,11 +388,14 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_mod check_license (arch, e); Elf_Shdr *s; + const char *modname; s = find_section (arch, e, ".modname"); if (!s) grub_util_error ("no module name found"); - check_symbols(arch, e); + modname = (const char *) e + grub_target_to_host (s->sh_offset); + + check_symbols(arch, e, modname, whitelist_empty); check_relocations(arch, e); } From b53f595b3ed989335d7cd1618a5502270cdb26de Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 30 Jan 2017 14:38:50 +0100 Subject: [PATCH 0618/1167] Fix -nopie/-nopie check. We don't use lgcc_s but missing lgcc_s or another library cause test to fail. So use -nostdlib. We need to use -Werror to avoid warning-generated case to be accepted. Clang uses -nopie rather than -no-pie. Check both and use whichever one works. Additionally android clang passes -pie to the linker even though it doesn't define __PIE__. So if compilation without no-pie logic fails add -nopie/-no-pie even if __PIE__ is not defined. --- acinclude.m4 | 36 +++++++++++++++++++++++++++++++++++- configure.ac | 12 ++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 7884c1bb5..78cdf6e1d 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -390,12 +390,29 @@ else [fi] ]) +AC_DEFUN([grub_CHECK_LINK_PIE],[ +[# Position independent executable. +link_nopie_needed=no] +AC_MSG_CHECKING([whether linker needs disabling of PIE to work]) +AC_LANG_CONFTEST([AC_LANG_SOURCE([[]])]) + +[if eval "$ac_compile -Wl,-r,-d -nostdlib -Werror -o conftest.o" 2> /dev/null; then] + AC_MSG_RESULT([no]) + [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? + rm -f conftest.o +else + link_nopie_needed=yes] + AC_MSG_RESULT([yes]) +[fi] +]) + + dnl Check if the Linker supports `-no-pie'. AC_DEFUN([grub_CHECK_NO_PIE], [AC_MSG_CHECKING([whether linker accepts -no-pie]) AC_CACHE_VAL(grub_cv_cc_ld_no_pie, [save_LDFLAGS="$LDFLAGS" -LDFLAGS="$LDFLAGS -no-pie" +LDFLAGS="$LDFLAGS -no-pie -nostdlib -Werror" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_ld_no_pie=yes], [grub_cv_cc_ld_no_pie=no]) @@ -408,6 +425,23 @@ if test "x$grub_cv_cc_ld_no_pie" = xyes ; then fi ]) +AC_DEFUN([grub_CHECK_NO_PIE_ONEWORD], +[AC_MSG_CHECKING([whether linker accepts -nopie]) +AC_CACHE_VAL(grub_cv_cc_ld_no_pie_oneword, +[save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -nopie -nostdlib -Werror" +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_ld_no_pie_oneword=yes], + [grub_cv_cc_ld_no_pie_oneword=no]) +LDFLAGS="$save_LDFLAGS" +]) +AC_MSG_RESULT([$grub_cv_cc_ld_no_pie_oneword]) +nopie_oneword_possible=no +if test "x$grub_cv_cc_ld_no_pie_oneword" = xyes ; then + nopie_oneword_possible=yes +fi +]) + dnl Check if the C compiler supports `-fPIC'. AC_DEFUN([grub_CHECK_PIC],[ [# Position independent executable. diff --git a/configure.ac b/configure.ac index 33146b41a..8f527544b 100644 --- a/configure.ac +++ b/configure.ac @@ -1202,13 +1202,21 @@ CFLAGS="$TARGET_CFLAGS" # Position independent executable. grub_CHECK_PIE grub_CHECK_NO_PIE +grub_CHECK_NO_PIE_ONEWORD +grub_CHECK_LINK_PIE [# Need that, because some distributions ship compilers that include # `-fPIE' or '-fpie' and '-pie' in the default specs. if [ x"$pie_possible" = xyes ]; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie" fi -if [ x"$nopie_possible" = xyes ] && [ x"$pie_possible" = xyes ]; then - TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie" + +if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then + if [ x"$nopie_possible" = xyes ]; then + TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie" + fi + if [ x"$nopie_oneword_possible" = xyes ]; then + TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie" + fi fi] CFLAGS="$TARGET_CFLAGS" From 255b9e0beaa3f4c939391d1e82f3ec2ba33b549b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 30 Jan 2017 19:52:58 +0100 Subject: [PATCH 0619/1167] grub-module-verifier: Add mips to all_video whitelist. On MIPS video is compiled-in. So all_video is empty. Whitelist it. --- util/grub-module-verifier.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index de14c62e7..4234cfdd4 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -124,7 +124,14 @@ struct platform_whitelist { static struct platform_whitelist whitelists[] = { {"i386", "xen", (const char *[]) {"all_video", 0}}, - {"x86_64", "xen", (const char *[]) {"all_video", 0}} + {"x86_64", "xen", (const char *[]) {"all_video", 0}}, + + /* video is compiled-in on MIPS. */ + {"mipsel", "loongson", (const char *[]) {"all_video", 0}}, + {"mipsel", "qemu_mips", (const char *[]) {"all_video", 0}}, + {"mipsel", "arc", (const char *[]) {"all_video", 0}}, + {"mips", "qemu_mips", (const char *[]) {"all_video", 0}}, + {"mips", "arc", (const char *[]) {"all_video", 0}}, }; From a134ef1ab92c0c0cd35d263301ef9acd77f3160f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 31 Jan 2017 12:39:01 +0100 Subject: [PATCH 0620/1167] ia64: Add support for R_IA64_GPREL64I. Recent GCC generates those relocations, so we need to support them. --- grub-core/kern/ia64/dl.c | 3 +++ grub-core/kern/ia64/dl_helper.c | 34 +++++++++++++++++++++++++++++++++ include/grub/ia64/reloc.h | 2 ++ util/grub-mkimagexx.c | 5 +++++ util/grub-module-verifier.c | 1 + 5 files changed, 45 insertions(+) diff --git a/grub-core/kern/ia64/dl.c b/grub-core/kern/ia64/dl.c index ad79eb525..082aebc3a 100644 --- a/grub-core/kern/ia64/dl.c +++ b/grub-core/kern/ia64/dl.c @@ -104,6 +104,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, case R_IA64_PCREL64LSB: *(grub_uint64_t *) addr += value - addr; break; + case R_IA64_GPREL64I: + grub_ia64_set_immu64 (addr, value - (grub_addr_t) mod->base); + break; case R_IA64_GPREL22: if ((value - (grub_addr_t) mod->base) & ~MASK20) return grub_error (GRUB_ERR_BAD_MODULE, diff --git a/grub-core/kern/ia64/dl_helper.c b/grub-core/kern/ia64/dl_helper.c index c7e53a679..2436b75fd 100644 --- a/grub-core/kern/ia64/dl_helper.c +++ b/grub-core/kern/ia64/dl_helper.c @@ -30,6 +30,40 @@ #define MASK20 ((1 << 20) - 1) #define MASK3 (~(grub_addr_t) 3) +void +grub_ia64_set_immu64 (grub_addr_t addr, grub_uint64_t val) +{ + /* Copied from binutils. */ + grub_uint64_t *ptr = ((grub_uint64_t *) (addr & MASK3)); + grub_uint64_t t0, t1; + + t0 = grub_le_to_cpu64 (ptr[0]); + t1 = grub_le_to_cpu64 (ptr[1]); + + /* tmpl/s: bits 0.. 5 in t0 + slot 0: bits 5..45 in t0 + slot 1: bits 46..63 in t0, bits 0..22 in t1 + slot 2: bits 23..63 in t1 */ + + /* First, clear the bits that form the 64 bit constant. */ + t0 &= ~(0x3ffffLL << 46); + t1 &= ~(0x7fffffLL + | (( (0x07fLL << 13) | (0x1ffLL << 27) + | (0x01fLL << 22) | (0x001LL << 21) + | (0x001LL << 36)) << 23)); + + t0 |= ((val >> 22) & 0x03ffffLL) << 46; /* 18 lsbs of imm41 */ + t1 |= ((val >> 40) & 0x7fffffLL) << 0; /* 23 msbs of imm41 */ + t1 |= ( (((val >> 0) & 0x07f) << 13) /* imm7b */ + | (((val >> 7) & 0x1ff) << 27) /* imm9d */ + | (((val >> 16) & 0x01f) << 22) /* imm5c */ + | (((val >> 21) & 0x001) << 21) /* ic */ + | (((val >> 63) & 0x001) << 36)) << 23; /* i */ + + ptr[0] = t0; + ptr[1] = t1; +} + void grub_ia64_add_value_to_slot_20b (grub_addr_t addr, grub_uint32_t value) { diff --git a/include/grub/ia64/reloc.h b/include/grub/ia64/reloc.h index 4c02ab2e6..45c8fba27 100644 --- a/include/grub/ia64/reloc.h +++ b/include/grub/ia64/reloc.h @@ -26,6 +26,8 @@ grub_ia64_add_value_to_slot_20b (grub_addr_t addr, grub_uint32_t value); void grub_ia64_add_value_to_slot_21 (grub_addr_t addr, grub_uint32_t value); void +grub_ia64_set_immu64 (grub_addr_t addr, grub_uint64_t value); +void grub_ia64_make_trampoline (struct grub_ia64_trampoline *tr, grub_uint64_t addr); struct grub_ia64_trampoline diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 353a9407a..aa20b9a87 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -920,6 +920,10 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_ia64_add_value_to_slot_21 ((grub_addr_t) target, addend + sym_addr); break; + case R_IA64_GPREL64I: + grub_ia64_set_immu64 ((grub_addr_t) target, + addend + sym_addr); + break; case R_IA64_PCREL64LSB: *target = grub_host_to_target64 (grub_target_to_host64 (*target) + addend + sym_addr @@ -1286,6 +1290,7 @@ translate_relocation_pe (struct translate_context *ctx, case R_IA64_LTOFF22X: case R_IA64_LTOFF22: case R_IA64_GPREL22: + case R_IA64_GPREL64I: case R_IA64_SEGREL64LSB: break; diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 4234cfdd4..dd72d7833 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -60,6 +60,7 @@ struct grub_module_verifier_arch archs[] = { R_IA64_PCREL64LSB, R_IA64_LTOFF22X, R_IA64_LTOFF22, + R_IA64_GPREL64I, R_IA64_LTOFF_FPTR22, R_IA64_LDXMOV, -1 From 6f5aa28bc239a35fc3dd64055179cf2993be2954 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 31 Jan 2017 18:49:37 +0100 Subject: [PATCH 0621/1167] gfxterm: Fix clearing of cursor. If ascent is bigger than height - 2, then we draw over character box but then to clear cursor we only draw over character box. So trim ascent if necessarry. --- grub-core/term/gfxterm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 70f10f19c..af7c090a3 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -668,6 +668,7 @@ draw_cursor (int show) unsigned int y; unsigned int width; unsigned int height; + unsigned int ascent; grub_video_color_t color; write_char (); @@ -679,13 +680,18 @@ draw_cursor (int show) >= virtual_screen.rows) return; + /* Ensure that cursor doesn't go outside of character box. */ + ascent = grub_font_get_ascent(virtual_screen.font); + if (ascent > virtual_screen.normal_char_height - 2) + ascent = virtual_screen.normal_char_height - 2; + /* Determine cursor properties and position on text layer. */ x = virtual_screen.cursor_x * virtual_screen.normal_char_width; width = virtual_screen.normal_char_width; color = virtual_screen.fg_color; y = ((virtual_screen.cursor_y + virtual_screen.total_scroll) * virtual_screen.normal_char_height - + grub_font_get_ascent (virtual_screen.font)); + + ascent); height = 2; /* Render cursor to text layer. */ From 0fd9fa565b874932c341daa4e418db8eb9b792bf Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 31 Jan 2017 19:29:31 +0100 Subject: [PATCH 0622/1167] charset: Trim away RLM and LRM. They are not visible but would otherwise end up as [LRM] or [RLM] squares with some fonts. --- grub-core/normal/charset.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c index eeb7ec18c..b0ab47d73 100644 --- a/grub-core/normal/charset.c +++ b/grub-core/normal/charset.c @@ -1144,6 +1144,16 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, } } +static int +is_visible (const struct grub_unicode_glyph *gl) +{ + if (gl->ncomb) + return 1; + if (gl->base == GRUB_UNICODE_LRM || gl->base == GRUB_UNICODE_RLM) + return 0; + return 1; +} + grub_ssize_t grub_bidi_logical_to_visual (const grub_uint32_t *logical, grub_size_t logical_len, @@ -1164,6 +1174,7 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical, if (ptr == logical + logical_len || *ptr == '\n') { grub_ssize_t ret; + grub_ssize_t i, j; ret = grub_bidi_line_logical_to_visual (line_start, ptr - line_start, visual_ptr, @@ -1182,7 +1193,10 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical, grub_free (*visual_out); return ret; } - visual_ptr += ret; + for (i = 0, j = 0; i < ret; i++) + if (is_visible(&visual_ptr[i])) + visual_ptr[j++] = visual_ptr[i]; + visual_ptr += j; line_start = ptr; if (ptr != logical + logical_len) { From f14c77f5013f3a882a90f77c4ace08c49d41bdc7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 31 Jan 2017 22:32:21 +0100 Subject: [PATCH 0623/1167] grub-mkfont: Remove leftover debug statement. --- util/grub-mkfont.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index a0cab3a93..0fe45a610 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -179,9 +179,6 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, if (font_info->flags & GRUB_FONT_FLAG_BOLD) FT_GlyphSlot_Embolden (glyph); - if (glyph->next) - printf ("%x\n", char_code); - if (nocut) cuttop = cutbottom = cutleft = cutright = 0; else From 0704e83a1b59d2a02f611fde1583f481d7a91e03 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 31 Jan 2017 22:36:11 +0100 Subject: [PATCH 0624/1167] Regenerate checksum.h. Screenshots checked. Using unifont from http://ftp.us.debian.org/debian/pool/main/u/unifont/xfonts-unifont_7.0.06-1_all.deb. --- grub-core/tests/checksums.h | 182 ++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index 2320158d4..76555c5eb 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -5,97 +5,97 @@ { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc52dc5f, 0xbc52dc5f, 0x4c895989, 0x4c895989, 0x59d180a4, 0x59d180a4, 0x50eb81b9, 0x50eb81b9, 0xae85d6c6, 0xae85d6c6, 0xf8354df6, 0xf8354df6, 0x83562153, 0x83562153, 0xd4caece2, 0xd4caece2, 0xb0b5612d, 0xb0b5612d, 0x123d360a, 0x123d360a, 0x70f62e8e, 0x70f62e8e, 0x6a82788f, 0x6a82788f, 0xb0a3ee68, 0xb0a3ee68, 0x604dd5b0, 0x604dd5b0, 0x20f7ea1, 0x20f7ea1, 0x3f6db6bf, 0x3f6db6bf, 0x4a762b9d, 0x4a762b9d, 0xea026ad4, 0xea026ad4, 0x8ba3d148, 0x8ba3d148, 0x434f2359, 0x434f2359, 0x4db299a1, 0x73536949, 0xf022eb4b, 0xf022eb4b, }, 45 }, { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7cfd676, 0x7cfd676, 0xaf7bcdc6, 0xaf7bcdc6, 0x7dc1f958, 0x7dc1f958, 0xc902ad3e, 0xc902ad3e, 0x5529ad04, 0x5529ad04, 0xa0a133b1, 0xa0a133b1, 0x72f927da, 0x72f927da, 0x28de6d8e, 0x28de6d8e, 0xa5eb10fc, 0xa5eb10fc, 0x2d7ba4f5, 0x2d7ba4f5, 0xd832b228, 0xd832b228, 0x56f0351, 0x56f0351, 0xc6556c2e, 0xc6556c2e, 0x2ceecfa4, 0x2ceecfa4, 0x3d765fbd, 0x3d765fbd, 0x8da7887e, 0x8da7887e, 0xfc8209ea, 0xfc8209ea, 0x6e822767, 0x6e822767, 0xba5c0adf, 0xba5c0adf, 0x8e2af81a, 0x8e2af81a, 0x62c25eb4, 0x2ba315e0, 0x349b7b7d, 0x349b7b7d, }, 45 }, { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x361fdea5, 0x361fdea5, 0x89a3b488, 0x89a3b488, 0x37302fbe, 0x37302fbe, 0x4b9f20b8, 0x4b9f20b8, 0xc60cf5fe, 0xc60cf5fe, 0xf7b755aa, 0xf7b755aa, 0xcaba5d52, 0xcaba5d52, 0x4f793adf, 0x4f793adf, 0x4cd60722, 0x4cd60722, 0x13adbeec, 0x13adbeec, 0xdc2c109f, 0xdc2c109f, 0x444e465a, 0x444e465a, 0x7baac5fa, 0x7baac5fa, 0x8e746e7f, 0x8e746e7f, 0x7fea6e68, 0x7fea6e68, 0x1f6edf48, 0x1f6edf48, 0x23322506, 0x23322506, 0xbccd38ef, 0xbccd38ef, 0x1b1f1dd3, 0x1b1f1dd3, 0x9c901775, 0x9c901775, 0x78b8e355, 0x95034aa2, 0x4f00ee83, 0x4f00ee83, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdf032925, 0xb9ccc5a6, 0xdf032925, 0x9cf5e462, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x9cf5e462, 0x9cf5e462, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa24e444d, 0x664c3f5, 0xa24e444d, 0x8c4bc132, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x8c4bc132, 0x8c4bc132, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6fa41086, 0xd5284f5e, 0x6fa41086, 0x32b37d02, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x32b37d02, 0x32b37d02, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd084e37c, 0x6324ea4b, 0xd084e37c, 0x7ed2aaa4, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x7ed2aaa4, 0x7ed2aaa4, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x451273fe, 0x55e4689f, 0x451273fe, 0x33b4464d, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x33b4464d, 0x33b4464d, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x93132338, 0xc76b87e6, 0x93132338, 0x8816f93f, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x8816f93f, 0x8816f93f, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6a4ef5, 0x5fb9948, 0xae6a4ef5, 0x51d55575, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x51d55575, 0x51d55575, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0x5fefa0d1, 0x5fefa0d1, 0x5fefa0d1, 0xde1c5600, 0xde1c5600, 0xde1c5600, 0x48b8ef6f, 0x48b8ef6f, 0x48b8ef6f, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x25ba43d4, 0x43fe620d, 0x25ba43d4, 0x664c8e93, 0x59c36f00, 0x59c36f00, 0xb2921a37, 0xb2921a37, 0xb2921a37, 0xcc127751, 0xcc127751, 0xcc127751, 0xaee46283, 0xaee46283, 0xaee46283, 0x59c36f00, 0x664c8e93, 0x664c8e93, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2aa2a72b, 0x6d6df6e1, 0x2aa2a72b, 0x4a72254, 0xaa4593fe, 0xaa4593fe, 0xa3be9127, 0xa3be9127, 0xa3be9127, 0x54b9c40, 0x54b9c40, 0x54b9c40, 0x28733738, 0x28733738, 0x28733738, 0xaa4593fe, 0x4a72254, 0x4a72254, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e799f98, 0xe21ad041, 0x9e799f98, 0xc36ef21c, 0xc9cbf769, 0xc9cbf769, 0x93d6c07d, 0x93d6c07d, 0x93d6c07d, 0x6d0e01b1, 0x6d0e01b1, 0x6d0e01b1, 0x8444beb9, 0x8444beb9, 0x8444beb9, 0xc9cbf769, 0xc36ef21c, 0xc36ef21c, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7ffc43fd, 0x64505961, 0x7ffc43fd, 0xd1aa0a25, 0x9813a416, 0x9813a416, 0x5b5f9bd5, 0x5b5f9bd5, 0x5b5f9bd5, 0xca841de6, 0xca841de6, 0xca841de6, 0xd33e2036, 0xd33e2036, 0xd33e2036, 0x9813a416, 0xd1aa0a25, 0xd1aa0a25, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x570ca3fc, 0x4f1cee0f, 0x570ca3fc, 0x21aa964f, 0x5fcf013d, 0x5fcf013d, 0xf2bc017e, 0xf2bc017e, 0xf2bc017e, 0x20ac1908, 0x20ac1908, 0x20ac1908, 0x36df2697, 0x36df2697, 0x36df2697, 0x5fcf013d, 0x21aa964f, 0x21aa964f, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcf9798d3, 0x5d39a7fa, 0xcf9798d3, 0xd49242d4, 0xdd28f52b, 0xdd28f52b, 0xe15747f0, 0xe15747f0, 0xe15747f0, 0xc06bbe14, 0xc06bbe14, 0xc06bbe14, 0xbdd37598, 0xbdd37598, 0xbdd37598, 0xdd28f52b, 0xd49242d4, 0xd49242d4, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6154e8, 0x59e627f7, 0xae6154e8, 0x51de4f68, 0x43d1f34, 0x43d1f34, 0x59a8eb9f, 0x59a8eb9f, 0x59a8eb9f, 0x26a24237, 0x26a24237, 0x26a24237, 0xbff347b1, 0xbff347b1, 0xbff347b1, 0x43d1f34, 0x51de4f68, 0x51de4f68, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2b04aa3, 0xca81b845, 0xb2b04aa3, 0xf14687e4, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xf14687e4, 0xf14687e4, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x19a66482, 0xba12148e, 0x19a66482, 0x37a3e1fd, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0x37a3e1fd, 0x37a3e1fd, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6a5ddfe7, 0xc898195a, 0x6a5ddfe7, 0x374ab263, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x374ab263, 0x374ab263, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb6ca222a, 0x98e6c241, 0xb6ca222a, 0x189c6bf2, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x189c6bf2, 0x189c6bf2, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x726d82d0, 0xe9c535bd, 0x726d82d0, 0x4cbb763, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x4cbb763, 0x4cbb763, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfe26fef7, 0x6031c462, 0xfe26fef7, 0xe52324f0, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0xe52324f0, 0xe52324f0, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x25e34f8a, 0x67935e5e, 0x25e34f8a, 0xda5c540a, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xda5c540a, 0xda5c540a, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67038f5e, 0x65d6007f, 0x67038f5e, 0x24f54219, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x24f54219, 0x24f54219, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944464c7, 0x27123864, 0x944464c7, 0xba41e1b8, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0xba41e1b8, 0xba41e1b8, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfe97adaf, 0x4f3307d4, 0xfe97adaf, 0xa380c02b, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xa380c02b, 0xa380c02b, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b32a9ba, 0xaf93fd91, 0x5b32a9ba, 0xf564e062, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf564e062, 0xf564e062, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e0e1ce8, 0x7ed1c9ee, 0x5e0e1ce8, 0x28a8295b, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x28a8295b, 0x28a8295b, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa473184a, 0x93eaf325, 0xa473184a, 0xbf76c24d, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0xbf76c24d, 0xbf76c24d, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa725578b, 0x81889cf9, 0xa725578b, 0x589a4c0b, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x589a4c0b, 0x589a4c0b, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd69cdcbf, 0x6ad9ce85, 0xd69cdcbf, 0x956a11f8, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0x956a11f8, 0x956a11f8, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1acffa1b, 0xecff2136, 0x1acffa1b, 0x34ca7f64, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0x34ca7f64, 0x34ca7f64, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1cf8992, 0xb2c51b4c, 0x1cf8992, 0x5cd8e416, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x5cd8e416, 0x5cd8e416, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1f39da0b, 0x6a7f5378, 0x1f39da0b, 0xb16f93d3, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb16f93d3, 0xb16f93d3, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x27394d6b, 0x459337bf, 0x27394d6b, 0x519f78d8, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x519f78d8, 0x519f78d8, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x624e1f92, 0x4be3bd84, 0x624e1f92, 0x794bc595, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x794bc595, 0x794bc595, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf5dab2e, 0x4747516, 0xbf5dab2e, 0x40e2b0ae, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x40e2b0ae, 0x40e2b0ae, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2e284303, 0x169e4b98, 0x2e284303, 0x6dde8e44, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x6dde8e44, 0x6dde8e44, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3a911f8f, 0xe5d171c6, 0x3a911f8f, 0x14949af0, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x14949af0, 0x14949af0, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa4645fb3, 0x8af97df0, 0xa4645fb3, 0xf9733237, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xf9733237, 0xf9733237, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c3a337b, 0xed3f1a6, 0x7c3a337b, 0xd26c7aa3, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd26c7aa3, 0xd26c7aa3, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9f31781b, 0xb6d3e547, 0x9f31781b, 0xe9974da8, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xe9974da8, 0xe9974da8, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfc18d24f, 0x70ed44c6, 0xfc18d24f, 0xe71d0848, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0xe71d0848, 0xe71d0848, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7bb91866, 0xc4777a1f, 0x7bb91866, 0x840603e6, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0x840603e6, 0x840603e6, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa0d0faff, 0x8b37dfcd, 0xa0d0faff, 0xe32637b8, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xe32637b8, 0xe32637b8, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4436bcdb, 0xb3a12b62, 0x4436bcdb, 0x6a3339a4, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0x6a3339a4, 0x6a3339a4, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8e59140, 0x2463e41f, 0xb8e59140, 0xe5f2fcc4, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xe5f2fcc4, 0xe5f2fcc4, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x438b3fcc, 0x7ebfbfd, 0x438b3fcc, 0xeddd7614, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xeddd7614, 0xeddd7614, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf9eea896, 0x25a51233, 0xf9eea896, 0x8f489d25, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0x8f489d25, 0x8f489d25, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9b617752, 0xb06817b5, 0x9b617752, 0x8064ad55, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x8064ad55, 0x8064ad55, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x595e29e, 0xc043d961, 0x595e29e, 0xfa2af91e, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xfa2af91e, 0xfa2af91e, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63e24d8a, 0x52da109, 0x63e24d8a, 0x201480cd, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x201480cd, 0x201480cd, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1b2e61c9, 0xbf04e671, 0x1b2e61c9, 0x352be4b6, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x352be4b6, 0x352be4b6, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefcce0d0, 0x5540bf08, 0xefcce0d0, 0xb2db8d54, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xb2db8d54, 0xb2db8d54, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x65a5505e, 0xd6055969, 0x65a5505e, 0xcbf31986, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcbf31986, 0xcbf31986, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7319d06, 0x17c78667, 0x7319d06, 0x7197a8b5, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x7197a8b5, 0x7197a8b5, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x723a247, 0x535b0699, 0x723a247, 0x1c267840, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x1c267840, 0x1c267840, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xe3a20cf8, 0x4833db45, 0xe3a20cf8, 0x1c1d1778, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x1c1d1778, 0x1c1d1778, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24b38cd5, 0x6b033831, 0x24b38cd5, 0x67454192, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x67454192, 0x67454192, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f09885, 0x5d94ace6, 0x54f09885, 0x7af51dfa, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0x7af51dfa, 0x7af51dfa, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x53c2ee74, 0x92931869, 0x53c2ee74, 0xed583f0, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0xed583f0, 0xed583f0, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e5ded6f, 0x12bf47c3, 0x4e5ded6f, 0xe00ba4b7, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe00ba4b7, 0xe00ba4b7, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3566adf6, 0x4c7649cf, 0x3566adf6, 0x43c09845, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x43c09845, 0x43c09845, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec1bda0d, 0x86636a33, 0xec1bda0d, 0xf71e000a, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0xf71e000a, 0xf71e000a, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x619415be, 0x92024b97, 0x619415be, 0x9e2b0e3e, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0x9e2b0e3e, 0x9e2b0e3e, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x200688e1, 0x1274a595, 0x200688e1, 0x63f045a6, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x63f045a6, 0x63f045a6, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa943b821, 0x8aa682a4, 0xa943b821, 0x87463d5e, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x87463d5e, 0x87463d5e, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x11b6367b, 0x27bbcfb4, 0x11b6367b, 0x4ca15bff, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x4ca15bff, 0x4ca15bff, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c16ec93, 0xe9d7d93f, 0x7c16ec93, 0xd240a54b, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd240a54b, 0xd240a54b, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe28608ec, 0x3575a25f, 0xe28608ec, 0x94203d5f, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0x94203d5f, 0x94203d5f, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb510e48, 0x9406b857, 0xb510e48, 0x1054d44f, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0x1054d44f, 0x1054d44f, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf256eb36, 0xaed7d845, 0xf256eb36, 0xde9f0b6, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0xde9f0b6, 0xde9f0b6, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe382dd9, 0x68f7c15a, 0xe382dd9, 0x59159307, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x59159307, 0x59159307, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c908c, 0xa4161734, 0x3c908c, 0xb09b4ada, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0xb09b4ada, 0xb09b4ada, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd2e9527, 0xb7a2caff, 0xd2e9527, 0x1d0b8b89, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x1d0b8b89, 0x1d0b8b89, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1639705d, 0xa599796a, 0x1639705d, 0x26488c72, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x26488c72, 0x26488c72, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x10d0c422, 0x26df43, 0x10d0c422, 0xbed72bd7, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0xbed72bd7, 0xbed72bd7, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd34e67a, 0x894c42a4, 0xdd34e67a, 0x53502da0, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x53502da0, 0x53502da0, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x410b50fc, 0xea9a8741, 0x410b50fc, 0xd653d65c, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xd653d65c, 0xd653d65c, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4c09d761, 0x2ac63be2, 0x4c09d761, 0xf44378ab, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xf44378ab, 0xf44378ab, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd3c0fce6, 0x77ea7b5e, 0xd3c0fce6, 0x10463469, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x10463469, 0x10463469, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xabafd82f, 0x112387f7, 0xabafd82f, 0xe9ca2412, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xe9ca2412, 0xe9ca2412, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2b138245, 0x98b38b72, 0x2b138245, 0x6500200c, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x6500200c, 0x6500200c, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x87f97368, 0x970f6809, 0x87f97368, 0x149f7c5f, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x149f7c5f, 0x149f7c5f, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x12986e14, 0x46e0caca, 0x12986e14, 0xf51eaa4a, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xf51eaa4a, 0xf51eaa4a, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf6aab2f6, 0x5d3b654b, 0xf6aab2f6, 0x8e22ec59, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x8e22ec59, 0x8e22ec59, 0x43d1f34, }, 20 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe9c994d6, 0x8f067855, 0xe9c994d6, 0xaa3f5991, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xaa3f5991, 0xaa3f5991, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2cc2fffd, 0x88e87845, 0x2cc2fffd, 0x2c77a82, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x2c77a82, 0x2c77a82, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x733b15c5, 0xc9b74a1d, 0x733b15c5, 0x2e2c7841, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x2e2c7841, 0x2e2c7841, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd703498e, 0x64a340b9, 0xd703498e, 0x79550056, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x79550056, 0x79550056, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7190a7ff, 0x6166bc9e, 0x7190a7ff, 0x736924c, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x736924c, 0x736924c, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x706487bc, 0x241c2362, 0x706487bc, 0x6b615dbb, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x6b615dbb, 0x6b615dbb, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x90994be3, 0x3b089c5e, 0x90994be3, 0x6f265063, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x6f265063, 0x6f265063, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x9b16e244, 0x9b16e244, 0x9b16e244, 0x1ae51495, 0x1ae51495, 0x1ae51495, 0x8c41adfa, 0x8c41adfa, 0x8c41adfa, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3eb350e7, 0x3053ed7f, 0x3eb350e7, 0x7d459da0, 0x59c36f00, 0x59c36f00, 0x7044c405, 0x7044c405, 0x7044c405, 0xec4a963, 0xec4a963, 0xec4a963, 0x6c32bcb1, 0x6c32bcb1, 0x6c32bcb1, 0x59c36f00, 0x7d459da0, 0x7d459da0, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x605b064a, 0x9446f166, 0x605b064a, 0x4e5e8335, 0xaa4593fe, 0xaa4593fe, 0x96342672, 0x96342672, 0x96342672, 0x30c12b15, 0x30c12b15, 0x30c12b15, 0x1df9806d, 0x1df9806d, 0x1df9806d, 0xaa4593fe, 0x4e5e8335, 0x4e5e8335, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x204c5494, 0x32c0ef19, 0x204c5494, 0x7d5b3910, 0xc9cbf769, 0xc9cbf769, 0x4c70c1a2, 0x4c70c1a2, 0x4c70c1a2, 0xb2a8006e, 0xb2a8006e, 0xb2a8006e, 0x5be2bf66, 0x5be2bf66, 0x5be2bf66, 0xc9cbf769, 0x7d5b3910, 0x7d5b3910, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x706dce4f, 0x6d5c7c0e, 0x706dce4f, 0xde3b8797, 0x9813a416, 0x9813a416, 0xb16f073b, 0xb16f073b, 0xb16f073b, 0x20b48108, 0x20b48108, 0x20b48108, 0x390ebcd8, 0x390ebcd8, 0x390ebcd8, 0x9813a416, 0xde3b8797, 0xde3b8797, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7d3ef313, 0xbc5bfdb2, 0x7d3ef313, 0xb98c6a0, 0x5fcf013d, 0x5fcf013d, 0x9495a31f, 0x9495a31f, 0x9495a31f, 0x4685bb69, 0x4685bb69, 0x4685bb69, 0x50f684f6, 0x50f684f6, 0x50f684f6, 0x5fcf013d, 0xb98c6a0, 0xb98c6a0, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x94568840, 0x5ba9e95d, 0x94568840, 0x8f535247, 0xdd28f52b, 0xdd28f52b, 0xda6ea802, 0xda6ea802, 0xda6ea802, 0xfb5251e6, 0xfb5251e6, 0xfb5251e6, 0x86ea9a6a, 0x86ea9a6a, 0x86ea9a6a, 0xdd28f52b, 0x8f535247, 0x8f535247, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcc418cc7, 0xbdfe0adb, 0xcc418cc7, 0x33fe9747, 0x43d1f34, 0x43d1f34, 0x9cb3f177, 0x9cb3f177, 0x9cb3f177, 0xe3b958df, 0xe3b958df, 0xe3b958df, 0x7ae85d59, 0x7ae85d59, 0x7ae85d59, 0x43d1f34, 0x33fe9747, 0x33fe9747, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x847af750, 0xfc4b05b6, 0x847af750, 0xc78c3a17, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xc78c3a17, 0xc78c3a17, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x972adf32, 0x349eaf3e, 0x972adf32, 0xb92f5a4d, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0xb92f5a4d, 0xb92f5a4d, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x76c2daa4, 0xd4071c19, 0x76c2daa4, 0x2bd5b720, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x2bd5b720, 0x2bd5b720, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb14d88d8, 0x9f6168b3, 0xb14d88d8, 0x1f1bc100, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x1f1bc100, 0x1f1bc100, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x46ef56d1, 0xdd47e1bc, 0x46ef56d1, 0x30496362, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x30496362, 0x30496362, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1d515a73, 0x834660e6, 0x1d515a73, 0x6548074, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0x6548074, 0x6548074, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x1b104a9c, 0x59605b48, 0x1b104a9c, 0xe4af511c, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xe4af511c, 0xe4af511c, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x51c932ad, 0x531cbd8c, 0x51c932ad, 0x123fffea, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x123fffea, 0x123fffea, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1ac8df77, 0xa99e83d4, 0x1ac8df77, 0x34cd5a08, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0x34cd5a08, 0x34cd5a08, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe208a8ec, 0x53ac0297, 0xe208a8ec, 0xbf1fc568, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xbf1fc568, 0xbf1fc568, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5cb50348, 0xa8145763, 0x5cb50348, 0xf2e34a90, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf2e34a90, 0xf2e34a90, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6a8cc8e9, 0x4a531def, 0x6a8cc8e9, 0x1c2afd5a, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x1c2afd5a, 0x1c2afd5a, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4704bcce, 0x709d57a1, 0x4704bcce, 0x5c0166c9, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0x5c0166c9, 0x5c0166c9, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x99d6529d, 0xbf7b99ef, 0x99d6529d, 0x6669491d, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x6669491d, 0x6669491d, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe056614c, 0x5c137376, 0xe056614c, 0xa3a0ac0b, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0xa3a0ac0b, 0xa3a0ac0b, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944341ab, 0x62739a86, 0x944341ab, 0xba46c4d4, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0xba46c4d4, 0xba46c4d4, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1d508cd1, 0xae5a1e0f, 0x1d508cd1, 0x4047e155, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x4047e155, 0x4047e155, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x18be70f9, 0x6df8f98a, 0x18be70f9, 0xb6e83921, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb6e83921, 0xb6e83921, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x13bb996a, 0x7111e3be, 0x13bb996a, 0x651dacd9, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x651dacd9, 0x651dacd9, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8139bb16, 0xa8941900, 0x8139bb16, 0x9a3c6111, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x9a3c6111, 0x9a3c6111, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x81aeae38, 0x3a877000, 0x81aeae38, 0x7e11b5b8, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x7e11b5b8, 0x7e11b5b8, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x18e2fef0, 0x2054f66b, 0x18e2fef0, 0x5b1433b7, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x5b1433b7, 0x5b1433b7, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb41da43f, 0x6b5dca76, 0xb41da43f, 0x9a182140, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x9a182140, 0x9a182140, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8fb5af0, 0x966678b3, 0xb8fb5af0, 0xe5ec3774, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xe5ec3774, 0xe5ec3774, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7bbd9989, 0x9545b54, 0x7bbd9989, 0xd5ebd051, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd5ebd051, 0xd5ebd051, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xabb3ac1a, 0x82513146, 0xabb3ac1a, 0xdd1599a9, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xdd1599a9, 0xdd1599a9, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1f6f76cb, 0x939ae042, 0x1f6f76cb, 0x46aaccc, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0x46aaccc, 0x46aaccc, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x454a1d70, 0xfa847f09, 0x454a1d70, 0xbaf506f0, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0xbaf506f0, 0xbaf506f0, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x961a470c, 0xbdfd623e, 0x961a470c, 0xd5ec8a4b, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xd5ec8a4b, 0xd5ec8a4b, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xcaba076b, 0x3d2d90d2, 0xcaba076b, 0xe4bf8214, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0xe4bf8214, 0xe4bf8214, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa47a9403, 0x38fce15c, 0xa47a9403, 0xf96df987, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xf96df987, 0xf96df987, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x440c953e, 0x6c510f, 0x440c953e, 0xea5adce6, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xea5adce6, 0xea5adce6, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xcd6c7c97, 0x1127c632, 0xcd6c7c97, 0xbbca4924, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0xbbca4924, 0xbbca4924, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7816d3d6, 0x531fb331, 0x7816d3d6, 0x631309d1, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x631309d1, 0x631309d1, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3b66e788, 0xfeb0dc77, 0x3b66e788, 0xc4d9fc08, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xc4d9fc08, 0xc4d9fc08, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5528f079, 0x33e71cfa, 0x5528f079, 0x16de3d3e, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x16de3d3e, 0x16de3d3e, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x95a2da79, 0x31885dc1, 0x95a2da79, 0xbba75f06, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0xbba75f06, 0xbba75f06, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf353e593, 0x49dfba4b, 0xf353e593, 0xae448817, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xae448817, 0xae448817, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6222faac, 0xd182f39b, 0x6222faac, 0xcc74b374, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcc74b374, 0xcc74b374, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x33b34907, 0x23455266, 0x33b34907, 0x45157cb4, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x45157cb4, 0x45157cb4, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe45406c3, 0xb02ca21d, 0xe45406c3, 0xff51dcc4, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xff51dcc4, 0xff51dcc4, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xdd5109ee, 0x76c0de53, 0xdd5109ee, 0x22ee126e, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x22ee126e, 0x22ee126e, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x12793126, 0x5dc985c2, 0x12793126, 0x518ffc61, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x518ffc61, 0x518ffc61, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xda7c2335, 0xd3181756, 0xda7c2335, 0xf479a64a, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0xf479a64a, 0xf479a64a, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4f5deb37, 0x8e0c1d2a, 0x4f5deb37, 0x124a86b3, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0x124a86b3, 0x124a86b3, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x49da479d, 0x1538ed31, 0x49da479d, 0xe78c0e45, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe78c0e45, 0xe78c0e45, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1e479f7, 0x78f49dce, 0x1e479f7, 0x77424c44, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x77424c44, 0x77424c44, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf6c7e89, 0x6514ceb7, 0xf6c7e89, 0x1469a48e, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0x1469a48e, 0x1469a48e, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5f6710a8, 0xacf14e81, 0x5f6710a8, 0xa0d80b28, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0xa0d80b28, 0xa0d80b28, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x16cc3512, 0x24be1866, 0x16cc3512, 0x553af855, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x553af855, 0x553af855, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x27cf0391, 0x42a3914, 0x27cf0391, 0x9ca86ee, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x9ca86ee, 0x9ca86ee, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd293338, 0x3b24caf7, 0xd293338, 0x503e5ebc, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x503e5ebc, 0x503e5ebc, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7b914661, 0xee5073cd, 0x7b914661, 0xd5c70fb9, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd5c70fb9, 0xd5c70fb9, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd604dced, 0x1f7765e, 0xd604dced, 0xa0a2e95e, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0xa0a2e95e, 0xa0a2e95e, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe826aacc, 0x77711cd3, 0xe826aacc, 0xf32370cb, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0xf32370cb, 0xf32370cb, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcca5ee20, 0x9024dd53, 0xcca5ee20, 0x331af5a0, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0x331af5a0, 0x331af5a0, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x40e1929b, 0x262e7e18, 0x40e1929b, 0x17cc2c45, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x17cc2c45, 0x17cc2c45, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3ff0750a, 0x9bdaf2b2, 0x3ff0750a, 0x8f57af5c, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0x8f57af5c, 0x8f57af5c, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x759a3475, 0xcf166bad, 0x759a3475, 0x65bf2adb, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x65bf2adb, 0x65bf2adb, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b955480, 0xe8355db7, 0x5b955480, 0x6be4a8af, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x6be4a8af, 0x6be4a8af, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xca9f82bf, 0xda6999de, 0xca9f82bf, 0x64986d4a, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0x64986d4a, 0x64986d4a, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec0810a9, 0xb870b477, 0xec0810a9, 0x626cdb73, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x626cdb73, 0x626cdb73, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6525b7b4, 0xceb46009, 0x6525b7b4, 0xf27d3114, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xf27d3114, 0xf27d3114, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7ac36a92, 0x1c0c8611, 0x7ac36a92, 0xc289c558, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xc289c558, 0xc289c558, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x5d4c4756, 0xf966c0ee, 0x5d4c4756, 0x9eca8fd9, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x9eca8fd9, 0x9eca8fd9, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb730dd6c, 0xdbc82b4, 0xb730dd6c, 0xf5552151, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xf5552151, 0xf5552151, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2c9428b7, 0x9f342180, 0x2c9428b7, 0x62878afe, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x62878afe, 0x62878afe, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb37ba769, 0xa38dbc08, 0xb37ba769, 0x201da85e, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x201da85e, 0x201da85e, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf1efca90, 0xa5976e4e, 0xf1efca90, 0x16690ece, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x16690ece, 0x16690ece, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc859b7e0, 0x63c8605d, 0xc859b7e0, 0xb0d1e94f, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0xb0d1e94f, 0xb0d1e94f, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From 68c6cec061d0a46adeafd7070d19d569ca051d67 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 15:57:08 +0100 Subject: [PATCH 0625/1167] Fix bootcheck-related files compilation. We need -static as otherwise linker will set interpreter field and ld.so is not available on our initrd's. Strip all sections we don't need on binary tests. --- Makefile.am | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Makefile.am b/Makefile.am index 00a9663b3..fa7146e83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -172,82 +172,82 @@ QEMU32=qemu-system-x86_64 endif linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -static -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -static -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux.init.mips: $(srcdir)/grub-core/tests/boot/linux.init-mips.S - $(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux.init.ppc: $(srcdir)/grub-core/tests/boot/linux.init-ppc.S - $(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux.init.mipsel: $(srcdir)/grub-core/tests/boot/linux.init-mips.S - $(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux.init.loongson: $(srcdir)/grub-core/tests/boot/linux.init-mips.S - $(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -DREBOOT=1 + $(TARGET_CC) -o $@ $< -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -DREBOOT=1 multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include + $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include + $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include kfreebsd.aout: kfreebsd.elf - $(TARGET_OBJCOPY) -O a.out-i386-linux $< $@ -R .note.gnu.build-id -R .note.gnu.gold-version + $(TARGET_OBJCOPY) -O a.out-i386-linux $< $@ -j .text pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32 + $(TARGET_CC) -o $@ $< -static -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32 pc-chainloader.bin: pc-chainloader.elf $(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32 + $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32 ntldr.bin: ntldr.elf - $(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; + $(TARGET_OBJCOPY) -O binary --strip-unneeded -j .text $< $@; multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1 + $(TARGET_CC) -static -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1 kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@ + $(TARGET_CC) -o $@ $< -m64 -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@ kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@ + $(TARGET_CC) -o $@ $< -m32 -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@ knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_NETBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -m32 -static -nostdlib -nostdinc -DTARGET_NETBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_OPENBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -m32 -static -nostdlib -nostdinc -DTARGET_OPENBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m64 -DTARGET_NETBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -m64 -DTARGET_NETBSD=1 -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" + $(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -static -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" linux-initramfs.mips: linux.init.mips Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR linux-initramfs.ppc: linux.init.ppc Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR linux-initramfs.mipsel: linux.init.mipsel Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR linux-initramfs.loongson: linux.init.loongson Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR linux-initramfs.i386: linux.init.i386 Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR linux-initramfs.x86_64: linux.init.x86_64 Makefile - TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR + TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio -R 0:0 --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR kfreebsd-mfsroot.i386.img: kfreebsd.init.i386 Makefile TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR From 3d173955f090b73ccd541dc7a0d7a9da70560442 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 15:58:36 +0100 Subject: [PATCH 0626/1167] arm: Fix trampoline generation. We used the wrong pointer in this case. It worked only by accident. --- grub-core/kern/arm/dl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index 24364e189..fe0abf997 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -232,8 +232,8 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, if (!grub_arm_thm_jump19_check_offset (offset) || !(sym_addr & 1)) { - struct trampoline_thumb *tp = mod->gotptr; - mod->gotptr = tp + 1; + struct trampoline_thumb *tp = mod->trampptr; + mod->trampptr = tp + 1; grub_memcpy (tp->template, thumb_template, sizeof (tp->template)); tp->neg_addr = -sym_addr - 4; offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1; From ea20dd2b2237c793066621c2dec453f05134d074 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 20:10:26 +0100 Subject: [PATCH 0627/1167] ia64: Fix iterator for relocation entries. Don't assume relocation entry size and use sh_entsize properly. --- grub-core/kern/ia64/dl_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/ia64/dl_helper.c b/grub-core/kern/ia64/dl_helper.c index 2436b75fd..f663a52d5 100644 --- a/grub-core/kern/ia64/dl_helper.c +++ b/grub-core/kern/ia64/dl_helper.c @@ -216,11 +216,11 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize))) if (s->sh_type == grub_cpu_to_le32_compile_time (SHT_RELA)) { - Elf64_Rela *rel, *max; + const Elf64_Rela *rel, *max; for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)), - max = rel + grub_le_to_cpu64 (s->sh_size) / grub_le_to_cpu64 (s->sh_entsize); - rel < max; rel++) + max = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_size)); + rel < max; rel = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_entsize))) switch (ELF64_R_TYPE (grub_le_to_cpu64 (rel->r_info))) { case R_IA64_PCREL21B: From 43b444e5939b9e9060cba545a1e28df619fe1a55 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 20:12:07 +0100 Subject: [PATCH 0628/1167] arm/arm64: Fix improper use of start address. It was used instead of loading address of current section or of entire buffer. --- util/grub-mkimagexx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index aa20b9a87..59b6bd232 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -50,8 +50,6 @@ #pragma GCC diagnostic ignored "-Wcast-align" -static Elf_Addr SUFFIX (entry_point); - /* These structures are defined according to the CHRP binding to IEEE1275, "Client Program Format" section. */ @@ -979,7 +977,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, case R_AARCH64_CALL26: { sym_addr -= offset; - sym_addr -= SUFFIX (entry_point); + sym_addr -= target_section_addr + image_target->vaddr_offset; if (!grub_arm_64_check_xxxx26_offset (sym_addr)) grub_util_error ("%s", "CALL26 Relocation out of range"); @@ -990,7 +988,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, case R_AARCH64_ADR_PREL_PG_HI21: { sym_addr &= ~0xfffULL; - sym_addr -= (offset + SUFFIX (entry_point)) & ~0xfffULL; + sym_addr -= (offset + target_section_addr + image_target->vaddr_offset) & ~0xfffULL; if (!grub_arm64_check_hi21_signed (sym_addr)) grub_util_error ("%s", "CALL26 Relocation out of range"); @@ -1010,7 +1008,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, case EM_ARM: { sym_addr += addend; - sym_addr -= SUFFIX (entry_point); + sym_addr -= image_target->vaddr_offset; switch (ELF_R_TYPE (info)) { case R_ARM_ABS32: @@ -1974,8 +1972,6 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); - SUFFIX (entry_point) = (Elf_Addr) layout->start_address; - /* Resolve addresses in the virtual address space. */ SUFFIX (relocate_addresses) (e, sections, section_addresses, section_entsize, From 377c121170f37107012a01382bb5da5198b87d72 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 21:21:17 +0100 Subject: [PATCH 0629/1167] mkimage: Fix memory leak. --- util/grub-mkimage.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 10375f4d2..aba19d21b 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -240,6 +240,7 @@ main (int argc, char *argv[]) { FILE *fp = stdout; struct arguments arguments; + unsigned i; grub_util_host_init (&argc, &argv); @@ -304,7 +305,12 @@ main (int argc, char *argv[]) grub_util_file_sync (fp); fclose (fp); + for (i = 0; i < arguments.nmodules; i++) + free (arguments.modules[i]); + free (arguments.dir); + free (arguments.prefix); + free (arguments.modules); if (arguments.output) free (arguments.output); From 34fe0b5901d51a64cf40e71cc804d47705e540d2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 21:46:19 +0100 Subject: [PATCH 0630/1167] arm64: Add support for GOT and PCREL32 relocations. --- grub-core/kern/arm64/dl.c | 96 ++++++++++++++++++-------------- grub-core/kern/arm64/dl_helper.c | 39 +++++++++++++ include/grub/arm64/reloc.h | 7 +++ include/grub/dl.h | 5 ++ include/grub/elf.h | 3 + include/grub/util/mkimage.h | 2 +- util/grub-mkimagexx.c | 91 ++++++++++++++++++++++++++---- util/grub-module-verifier.c | 3 + util/grub-module-verifierXX.c | 34 +++++++++++ 9 files changed, 226 insertions(+), 54 deletions(-) diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c index cf50d7250..fb0337319 100644 --- a/grub-core/kern/arm64/dl.c +++ b/grub-core/kern/arm64/dl.c @@ -25,14 +25,9 @@ #include #include -struct trampoline -{ #define LDR 0x58000050 #define BR 0xd61f0200 - grub_uint32_t ldr; /* ldr x16, 8 */ - grub_uint32_t br; /* br x16 */ - grub_uint64_t addr; -}; + /* * Check if EHDR is a valid ELF header. @@ -53,42 +48,6 @@ grub_arch_dl_check_header (void *ehdr) #pragma GCC diagnostic ignored "-Wcast-align" -grub_err_t -grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, - grub_size_t *got) -{ - const Elf_Ehdr *e = ehdr; - const Elf_Shdr *s; - unsigned i; - - *tramp = 0; - *got = 0; - - for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff); - i < e->e_shnum; - i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize)) - if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA) - { - const Elf_Rel *rel, *max; - - for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset), - max = rel + s->sh_size / s->sh_entsize; - rel < max; - rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize)) - switch (ELF_R_TYPE (rel->r_info)) - { - case R_AARCH64_CALL26: - case R_AARCH64_JUMP26: - { - *tramp += sizeof (struct trampoline); - break; - } - } - } - - return GRUB_ERR_NONE; -} - /* * Unified function for both REL and RELA */ @@ -97,6 +56,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, Elf_Shdr *s, grub_dl_segment_t seg) { Elf_Rel *rel, *max; + unsigned unmatched_adr_got_page = 0; for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset), max = (Elf_Rel *) ((char *) rel + s->sh_size); @@ -145,7 +105,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, if (!grub_arm_64_check_xxxx26_offset (offset)) { - struct trampoline *tp = mod->trampptr; + struct grub_arm64_trampoline *tp = mod->trampptr; mod->trampptr = tp + 1; tp->ldr = LDR; tp->br = BR; @@ -160,6 +120,56 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, grub_arm64_set_xxxx26_offset (place, offset); } break; + case R_AARCH64_PREL32: + { + grub_int64_t value; + Elf64_Word *addr32 = place; + value = ((grub_int32_t) *addr32) + sym_addr - + (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset; + if (value != (grub_int32_t) value) + return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range"); + grub_dprintf("dl", " reloc_prel32 %p => 0x%016llx\n", + place, (unsigned long long) sym_addr); + *addr32 = value; + } + break; + case R_AARCH64_ADR_GOT_PAGE: + { + grub_uint64_t *gp = mod->gotptr; + Elf_Rela *rel2; + grub_int64_t gpoffset = ((grub_uint64_t) gp & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL); + *gp = (grub_uint64_t) sym_addr; + mod->gotptr = gp + 1; + unmatched_adr_got_page++; + grub_dprintf("dl", " reloc_got %p => 0x%016llx (0x%016llx)\n", + place, (unsigned long long) sym_addr, (unsigned long long) gp); + if (!grub_arm64_check_hi21_signed (gpoffset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "HI21 out of range"); + grub_arm64_set_hi21(place, gpoffset); + for (rel2 = (Elf_Rela *) ((char *) rel + s->sh_entsize); + rel2 < (Elf_Rela *) max; + rel2 = (Elf_Rela *) ((char *) rel2 + s->sh_entsize)) + if (ELF_R_SYM (rel2->r_info) + == ELF_R_SYM (rel->r_info) + && ((Elf_Rela *) rel)->r_addend == rel2->r_addend + && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC) + { + grub_arm64_set_abs_lo12_ldst64 ((void *) ((grub_addr_t) seg->addr + rel2->r_offset), + (grub_uint64_t)gp); + break; + } + if (rel2 >= (Elf_Rela *) max) + return grub_error (GRUB_ERR_BAD_MODULE, + "ADR_GOT_PAGE without matching LD64_GOT_LO12_NC"); + } + break; + case R_AARCH64_LD64_GOT_LO12_NC: + if (unmatched_adr_got_page == 0) + return grub_error (GRUB_ERR_BAD_MODULE, + "LD64_GOT_LO12_NC without matching ADR_GOT_PAGE"); + unmatched_adr_got_page--; + break; case R_AARCH64_ADR_PREL_PG_HI21: { grub_int64_t offset = (sym_addr & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL); diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c index f031b1ae9..4af3c4a10 100644 --- a/grub-core/kern/arm64/dl_helper.c +++ b/grub-core/kern/arm64/dl_helper.c @@ -93,3 +93,42 @@ grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target) *place &= insmask; *place |= grub_cpu_to_le32 (target << 7) & ~insmask; } + +#pragma GCC diagnostic ignored "-Wcast-align" + +grub_err_t +grub_arm64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, + grub_size_t *got) +{ + const Elf64_Ehdr *e = ehdr; + const Elf64_Shdr *s; + unsigned i; + + *tramp = 0; + *got = 0; + + for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu64 (e->e_shoff)); + i < grub_le_to_cpu16 (e->e_shnum); + i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize))) + if (s->sh_type == grub_cpu_to_le32_compile_time (SHT_REL) + || s->sh_type == grub_cpu_to_le32_compile_time (SHT_RELA)) + { + const Elf64_Rela *rel, *max; + + for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)), + max = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_size)); + rel < max; rel = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_entsize))) + switch (ELF64_R_TYPE (rel->r_info)) + { + case R_AARCH64_CALL26: + case R_AARCH64_JUMP26: + *tramp += sizeof (struct grub_arm64_trampoline); + break; + case R_AARCH64_ADR_GOT_PAGE: + *got += 8; + break; + } + } + + return GRUB_ERR_NONE; +} diff --git a/include/grub/arm64/reloc.h b/include/grub/arm64/reloc.h index 452c14822..c8765de97 100644 --- a/include/grub/arm64/reloc.h +++ b/include/grub/arm64/reloc.h @@ -19,6 +19,13 @@ #ifndef GRUB_ARM64_RELOC_H #define GRUB_ARM64_RELOC_H 1 +struct grub_arm64_trampoline +{ + grub_uint32_t ldr; /* ldr x16, 8 */ + grub_uint32_t br; /* br x16 */ + grub_uint64_t addr; +}; + int grub_arm_64_check_xxxx26_offset (grub_int64_t offset); void grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset); diff --git a/include/grub/dl.h b/include/grub/dl.h index 9562fa663..2bca56ce0 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -263,11 +263,16 @@ void grub_arch_dl_init_linker (void); grub_err_t grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, grub_size_t *got); +grub_err_t +grub_arm64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, + grub_size_t *got); #if defined (__ia64__) #define GRUB_ARCH_DL_TRAMP_ALIGN GRUB_IA64_DL_TRAMP_ALIGN #define GRUB_ARCH_DL_GOT_ALIGN GRUB_IA64_DL_GOT_ALIGN #define grub_arch_dl_get_tramp_got_size grub_ia64_dl_get_tramp_got_size +#elif defined (__aarch64__) +#define grub_arch_dl_get_tramp_got_size grub_arm64_dl_get_tramp_got_size #else grub_err_t grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, diff --git a/include/grub/elf.h b/include/grub/elf.h index db15acecf..c8492f9dc 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -2068,11 +2068,14 @@ typedef Elf32_Addr Elf32_Conflict; #define R_AARCH64_NONE 0 /* No relocation. */ #define R_AARCH64_ABS64 257 /* Direct 64 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */ +#define R_AARCH64_PREL32 261 #define R_AARCH64_ADR_PREL_PG_HI21 275 #define R_AARCH64_ADD_ABS_LO12_NC 277 #define R_AARCH64_LDST64_ABS_LO12_NC 286 #define R_AARCH64_JUMP26 282 /* 26-bit relative. */ #define R_AARCH64_CALL26 283 /* 26-bit relative. */ +#define R_AARCH64_ADR_GOT_PAGE 311 +#define R_AARCH64_LD64_GOT_LO12_NC 312 #define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ #define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */ #define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */ diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 2a4894213..1a18708a8 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -30,7 +30,7 @@ struct grub_mkimage_layout size_t align; grub_size_t ia64jmp_off; grub_size_t tramp_off; - grub_size_t ia64_got_off; + grub_size_t got_off; grub_size_t got_size; unsigned ia64jmpnum; grub_uint32_t bss_start; diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 59b6bd232..32be4bfbc 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -717,6 +717,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, #ifdef MKIMAGE_ELF64 struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off); grub_uint64_t *gpptr = (void *) (pe_target + got_off); + unsigned unmatched_adr_got_page = 0; #define MASK19 ((1 << 19) - 1) #else grub_uint32_t *tr = (void *) (pe_target + tramp_off); @@ -965,6 +966,18 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, *target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr); } break; + case R_AARCH64_PREL32: + { + grub_uint32_t *t32 = (grub_uint32_t *) target; + *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) + + sym_addr + - target_section_addr - offset + - image_target->vaddr_offset); + grub_util_info ("relocating an R_AARCH64_PREL32 entry to 0x%x at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, + *t32, (unsigned long long) offset); + break; + } case R_AARCH64_ADD_ABS_LO12_NC: grub_arm64_set_abs_lo12 ((grub_uint32_t *) target, sym_addr); @@ -985,6 +998,41 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, sym_addr); } break; + case R_AARCH64_ADR_GOT_PAGE: + { + Elf64_Rela *rel2; + grub_int64_t gpoffset = (((char *) gpptr - (char *) pe_target + image_target->vaddr_offset) & ~0xfffULL) + - ((offset + target_section_addr + image_target->vaddr_offset) & ~0xfffULL); + unsigned k; + *gpptr = grub_host_to_target64 (sym_addr); + unmatched_adr_got_page++; + if (!grub_arm64_check_hi21_signed (gpoffset)) + grub_util_error ("HI21 out of range"); + grub_arm64_set_hi21((grub_uint32_t *)target, + gpoffset); + for (k = 0, rel2 = (Elf_Rela *) ((char *) r + r_size); + k < num_rs; + k++, rel2 = (Elf_Rela *) ((char *) rel2 + r_size)) + if (ELF_R_SYM (rel2->r_info) + == ELF_R_SYM (r->r_info) + && r->r_addend == rel2->r_addend + && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC) + { + grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) SUFFIX (get_target_address) (e, target_section, + grub_target_to_host (rel2->r_offset), image_target), + ((char *) gpptr - (char *) pe_target + image_target->vaddr_offset)); + break; + } + if (k >= num_rs) + grub_util_error ("ADR_GOT_PAGE without matching LD64_GOT_LO12_NC"); + gpptr++; + } + break; + case R_AARCH64_LD64_GOT_LO12_NC: + if (unmatched_adr_got_page == 0) + grub_util_error ("LD64_GOT_LO12_NC without matching ADR_GOT_PAGE"); + unmatched_adr_got_page--; + break; case R_AARCH64_ADR_PREL_PG_HI21: { sym_addr &= ~0xfffULL; @@ -1329,6 +1377,7 @@ translate_relocation_pe (struct translate_context *ctx, /* Relative relocations do not require fixup entries. */ case R_AARCH64_CALL26: case R_AARCH64_JUMP26: + case R_AARCH64_PREL32: break; /* Page-relative relocations do not require fixup entries. */ case R_AARCH64_ADR_PREL_PG_HI21: @@ -1339,6 +1388,11 @@ translate_relocation_pe (struct translate_context *ctx, case R_AARCH64_LDST64_ABS_LO12_NC: break; + /* GOT is relocated separately. */ + case R_AARCH64_ADR_GOT_PAGE: + case R_AARCH64_LD64_GOT_LO12_NC: + break; + default: grub_util_error (_("relocation 0x%x is not implemented yet"), (unsigned int) ELF_R_TYPE (info)); @@ -1547,9 +1601,9 @@ finish_reloc_translation (struct translate_context *ctx, struct grub_mkimage_lay static void -translate_reloc_jumpers (struct translate_context *ctx, - Elf_Addr jumpers, grub_size_t njumpers, - const struct grub_install_image_target_desc *image_target) +create_u64_fixups (struct translate_context *ctx, + Elf_Addr jumpers, grub_size_t njumpers, + const struct grub_install_image_target_desc *image_target) { unsigned i; assert (image_target->id == IMAGE_EFI); @@ -1614,11 +1668,17 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, } if (image_target->elf_target == EM_IA_64) - translate_reloc_jumpers (&ctx, - layout->ia64jmp_off - + image_target->vaddr_offset, - 2 * layout->ia64jmpnum + (layout->got_size / 8), - image_target); + create_u64_fixups (&ctx, + layout->ia64jmp_off + + image_target->vaddr_offset, + 2 * layout->ia64jmpnum, + image_target); + if (image_target->elf_target == EM_IA_64 || image_target->elf_target == EM_AARCH64) + create_u64_fixups (&ctx, + layout->got_off + + image_target->vaddr_offset, + (layout->got_size / 8), + image_target); finish_reloc_translation (&ctx, layout, image_target); } @@ -1944,7 +2004,18 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, image_target); layout->kernel_size += 16 * layout->ia64jmpnum; - layout->ia64_got_off = layout->kernel_size; + layout->got_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (layout->got_size, 16); + } + if (image_target->elf_target == EM_AARCH64) + { + grub_size_t tramp; + + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); + + grub_arm64_dl_get_tramp_got_size (e, &tramp, &layout->got_size); + + layout->got_off = layout->kernel_size; layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif @@ -1977,7 +2048,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, section_entsize, num_sections, strtab, out_img, layout->tramp_off, - layout->ia64_got_off, + layout->got_off, image_target); make_reloc_section (e, layout, diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index dd72d7833..d0cf8176f 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -107,11 +107,14 @@ struct grub_module_verifier_arch archs[] = { R_AARCH64_ABS64, R_AARCH64_CALL26, R_AARCH64_JUMP26, + R_AARCH64_ADR_GOT_PAGE, + R_AARCH64_LD64_GOT_LO12_NC, -1 }, (int[]){ R_AARCH64_ADR_PREL_PG_HI21, R_AARCH64_ADD_ABS_LO12_NC, R_AARCH64_LDST64_ABS_LO12_NC, + R_AARCH64_PREL32, -1 } }, diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 2c0c690fa..1feaafc9b 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -319,6 +319,40 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e continue; grub_util_error ("relocation 0x%x is not module-local", type); } +#if defined(MODULEVERIFIER_ELF64) + if (arch->machine == EM_AARCH64) + { + unsigned unmatched_adr_got_page = 0; + Elf_Rela *rel2; + for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), + max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); + rel < max; + rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize))) + { + switch (ELF_R_TYPE (grub_target_to_host (rel->r_info))) + { + case R_AARCH64_ADR_GOT_PAGE: + unmatched_adr_got_page++; + for (rel2 = (Elf_Rela *) ((char *) rel + grub_target_to_host (s->sh_entsize)); + rel2 < (Elf_Rela *) max; + rel2 = (Elf_Rela *) ((char *) rel2 + grub_target_to_host (s->sh_entsize))) + if (ELF_R_SYM (rel2->r_info) + == ELF_R_SYM (rel->r_info) + && ((Elf_Rela *) rel)->r_addend == rel2->r_addend + && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC) + break; + if (rel2 >= (Elf_Rela *) max) + grub_util_error ("ADR_GOT_PAGE without matching LD64_GOT_LO12_NC"); + break; + case R_AARCH64_LD64_GOT_LO12_NC: + if (unmatched_adr_got_page == 0) + grub_util_error ("LD64_GOT_LO12_NC without matching ADR_GOT_PAGE"); + unmatched_adr_got_page--; + break; + } + } + } +#endif } static void From 08438d783f3feb8e50c5e89a1654665acfeff912 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 1 Feb 2017 21:50:17 +0100 Subject: [PATCH 0631/1167] Add missing strtoull_test.c It was forgotten in my local directory. --- grub-core/tests/strtoull_test.c | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 grub-core/tests/strtoull_test.c diff --git a/grub-core/tests/strtoull_test.c b/grub-core/tests/strtoull_test.c new file mode 100644 index 000000000..7da615ff3 --- /dev/null +++ b/grub-core/tests/strtoull_test.c @@ -0,0 +1,63 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static void +strtoull_testcase (const char *input, int base, unsigned long long expected, + int num_digits, grub_err_t error) +{ + char *output; + unsigned long long value; + grub_errno = 0; + value = grub_strtoull(input, &output, base); + grub_test_assert (grub_errno == error, + "unexpected error. Expected %d, got %d. Input \"%s\"", + error, grub_errno, input); + if (grub_errno) + { + grub_errno = 0; + return; + } + grub_test_assert (input + num_digits == output, + "unexpected number of digits. Expected %d, got %d, input \"%s\"", + num_digits, (int) (output - input), input); + grub_test_assert (value == expected, + "unexpected return value. Expected %llu, got %llu, input \"\%s\"", + expected, value, input); +} + +static void +strtoull_test (void) +{ + strtoull_testcase ("9", 0, 9, 1, GRUB_ERR_NONE); + strtoull_testcase ("0xaa", 0, 0xaa, 4, GRUB_ERR_NONE); + strtoull_testcase ("0xff", 0, 0xff, 4, GRUB_ERR_NONE); + strtoull_testcase ("0", 10, 0, 1, GRUB_ERR_NONE); + strtoull_testcase ("8", 8, 0, 0, GRUB_ERR_BAD_NUMBER); + strtoull_testcase ("38", 8, 3, 1, GRUB_ERR_NONE); + strtoull_testcase ("7", 8, 7, 1, GRUB_ERR_NONE); + strtoull_testcase ("1]", 16, 1, 1, GRUB_ERR_NONE); + strtoull_testcase ("18446744073709551616", 10, 0, 0, GRUB_ERR_OUT_OF_RANGE); +} + + +GRUB_FUNCTIONAL_TEST (strtoull_test, strtoull_test); From 42e24b60066fb8d75653423324b0b9ac80be6096 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 00:59:49 +0100 Subject: [PATCH 0632/1167] Fix thumb compilation with clang. According to EABI only STT_FUNC has convention of lowest bit indicating execution mode. R_THM_{JUMP,CALL}* relocations are assumed to be pointing to thumb mode unless they use STT_FUNC. --- grub-core/kern/arm/dl.c | 5 +++++ util/grub-mkimagexx.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index fe0abf997..eab9d17ff 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -173,6 +173,8 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, sym_addr += grub_arm_thm_call_get_offset ((grub_uint16_t *) target); grub_dprintf ("dl", " sym_addr = 0x%08x\n", sym_addr); + if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) + sym_addr |= 1; offset = sym_addr - (grub_uint32_t) target; @@ -227,6 +229,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, sym_addr += grub_arm_thm_jump19_get_offset ((grub_uint16_t *) target); + if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) + sym_addr |= 1; + offset = sym_addr - (grub_uint32_t) target; if (!grub_arm_thm_jump19_check_offset (offset) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 32be4bfbc..f8faae878 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1079,10 +1079,16 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, case R_ARM_THM_JUMP19: { grub_err_t err; + Elf_Sym *sym; grub_util_info (" THM_JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) ((char *) target - (char *) e), sym_addr); + sym = (Elf_Sym *) ((char *) e + + grub_target_to_host (symtab_section->sh_offset) + + ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize)); + if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) + sym_addr |= 1; if (!(sym_addr & 1)) { grub_uint32_t tr_addr; From dac87d6032bdfacfa141d43330351c73115714fa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 01:11:52 +0100 Subject: [PATCH 0633/1167] INSTALL: Fix mention of thumb-clang. --- INSTALL | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index e5b081105..f3c20edc8 100644 --- a/INSTALL +++ b/INSTALL @@ -15,15 +15,14 @@ configuring the GRUB. Note: older versions may work but support is limited Experimental support for clang 3.3 or later (results in much bigger binaries) - for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64 + for i386, x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64 Note: clang 3.2 or later works for i386 and x86_64 targets but results in much bigger binaries. earlier versions not tested Note: clang 3.2 or later works for arm - None of tested clang versions generated usable thumb code earlier versions not tested - Note: clang 3.3 or later works for arm64 - earlier versions have no arm64 support + Note: clang on arm64 is not supported due to + https://llvm.org/bugs/show_bug.cgi?id=26030 Note: clang 3.3 or later works for mips(el) earlier versions fail to generate .reginfo and hence gprel relocations fail. From 393cc59195901ec58509973b8152fbfeb84d04bd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 01:24:11 +0100 Subject: [PATCH 0634/1167] Use -fPIC with arm64 with clang. Currently it doesn't work either way but with -fPIC it should work once clang bug is fixed. --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8f527544b..4f7765c2d 100644 --- a/configure.ac +++ b/configure.ac @@ -1229,9 +1229,12 @@ grub_CHECK_PIC # and reload $gp in every function. # GCC implements it using symbol __gnu_local_gp in non-PIC as well. # However with clang we need PIC for this reloading to happen. +# With arm64 we need relocations that are in some way representable in +# PE as we need to support arm64-efi. Without -fPIC clang generates +# movk's which aren't representable. # Since default varies across dictributions use either -fPIC or -fno-PIC # explicitly. -if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then +if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 ) && test "x$grub_cv_cc_target_clang" = xyes ; then TARGET_CFLAGS="$TARGET_CFLAGS -fPIC" elif [ x"$pic_possible" = xyes ]; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" From 31932a267ca67c39c51b5ffabb5c0ce572e39ea2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 21:41:18 +0100 Subject: [PATCH 0635/1167] bootcheck-linux-i386: Use -cpu pentium2. Most modern kernels are compiled for i686, so use -cpu pentium2 to avoid spurious failures. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index fa7146e83..2e9739f7b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -306,7 +306,7 @@ bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(GRUB_PAYLOADS_DIR)/ ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/grub-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null bootcheck-linux-i386: linux-initramfs.i386 $(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell - ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null + ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg --qemu-opts="-cpu pentium2" | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null bootcheck-linux-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null From 1402cdd96afd900fe47b1ae36f466177db4f0703 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 21:41:33 +0100 Subject: [PATCH 0636/1167] i386-ieee1275: Add missing bootcheck target. --- Makefile.am | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.am b/Makefile.am index 2e9739f7b..3c00f8539 100644 --- a/Makefile.am +++ b/Makefile.am @@ -369,6 +369,12 @@ if COND_i386_coreboot BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif +if COND_i386_ieee1275 +# *BSD requires ACPI +#legacy protocol (linux16) makes early BIOS calls. +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 +endif + if COND_i386_pc #pc chainloader by definition is only for i386-pc #ntldr and bootmgr require BIOS. From 4e5414b2a1fd84ac7b1b5c1e3e81de2412778b64 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 2 Feb 2017 15:19:18 +0100 Subject: [PATCH 0637/1167] i386/relocator: Align stack in grub_relocator64_efi relocator Unified Extensible Firmware Interface Specification, Version 2.6, section 2.3.4, x64 Platforms, boot services, says among others: The stack must be 16-byte aligned. So, do it. Otherwise OS may boot only by chance as it happens right now. Signed-off-by: Daniel Kiper --- grub-core/lib/i386/relocator64.S | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S index 75725cf75..148f38adb 100644 --- a/grub-core/lib/i386/relocator64.S +++ b/grub-core/lib/i386/relocator64.S @@ -73,14 +73,22 @@ VARIABLE(grub_relocator64_rsp) movq %rax, %rsp +#ifdef GRUB_MACHINE_EFI + jmp LOCAL(skip_efi_stack_align) + /* - * Here is grub_relocator64_efi_start() entry point. - * Following code is shared between grub_relocator64_efi_start() + * Here is grub_relocator64_efi_start() entry point. Most of the + * code below is shared between grub_relocator64_efi_start() * and grub_relocator64_start(). * - * Think twice before changing anything below!!! + * Think twice before changing anything there!!! */ VARIABLE(grub_relocator64_efi_start) + /* Align the stack as UEFI spec requires. */ + andq $~15, %rsp + +LOCAL(skip_efi_stack_align): +#endif /* mov imm64, %rax */ .byte 0x48 .byte 0xb8 @@ -128,8 +136,10 @@ LOCAL(jump_addr): VARIABLE(grub_relocator64_rip) .quad 0 +#ifdef GRUB_MACHINE_EFI /* Here grub_relocator64_efi_start() ends. Ufff... */ VARIABLE(grub_relocator64_efi_end) +#endif #ifndef __x86_64__ .p2align 4 From 1d4e3db907e780d3183ae336e509ca12bd4560d5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 23:19:00 +0100 Subject: [PATCH 0638/1167] grub-fs-tester: Fix fat test. mkfs.vfat ignores -S when invoked on a disk, including loopback device, so do an mkfs on underlying image. --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index d5c81a322..ad65e81c8 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -640,7 +640,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else A= fi - "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${LODEVICES[0]}" + "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${FSIMAGES[0]}" MOUNTOPTS="iocharset=utf8,codepage=437," MOUNTFS="$(echo "$fs"|sed 's,[0-9]*a\?$,,')";; x"minix2") From a5bd52990e4ecda96cedd8a7c44d1ec566f91479 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 2 Feb 2017 23:32:38 +0100 Subject: [PATCH 0639/1167] grub-fs-tester: Fix mkudffs invocation. With current invocation order of arguments is wrong and path is hardcoded. --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index ad65e81c8..9fa9ce02e 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -654,7 +654,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MOUNTOPTS="iocharset=utf8,compression," MOUNTFS="ntfs-3g";; x"udf") - "/usr/bin/mkudffs" -b $BLKSIZE --utf8 --lvid="$FSLABEL" "${LODEVICES[0]}" + "mkudffs" --utf8 -b $BLKSIZE --lvid="$FSLABEL" "${LODEVICES[0]}" MOUNTOPTS="iocharset=utf8,bs=$BLKSIZE,";; x"ufs2") "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 2 "${LODEVICES[0]}" From c65d35b08b6e9ec68a0a2139dc17fb1aaea90504 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 00:30:29 +0100 Subject: [PATCH 0640/1167] btrfs: Shorten label by one character. mkfs.btrfs imposes a slightly lower limit than would be possible in btrfs. --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 9fa9ce02e..0ad66569d 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -263,7 +263,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + ;; # FS LIMITATION: btrfs label is at most 255 UTF-8 chars x"btrfs"*) - FSLABEL="grub_;/testé莭ð¯¦ðŸ˜ÐºÐ¸Ñ€Ð¸Ñ‚i urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoif";; + FSLABEL="grub_;/testé莭ð¯¦ðŸ˜ÐºÐ¸Ñ€Ð¸Ñ‚i urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoi";; # FS LIMITATION: exfat is at most 15 UTF-16 chars x"exfat") From 5412028d19915311c0b44bdd6a3e46bbc343c373 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 00:34:07 +0100 Subject: [PATCH 0641/1167] Avoid causing kernel oops in nilfs2 test. 1024-byte and 2048-byte blocks don't really work with some kernels, skip them as we don't want any oops'es. --- tests/util/grub-fs-tester.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 0ad66569d..f363d6f6e 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -85,7 +85,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MAXBLKSIZE=1048576 ;; xnilfs2) - MINBLKSIZE=1024 + # nilfs2 supports blocksizes from 1024 to 4096 + # but non-4096 results in kernel oops in some cases, + # avoid it. + MINBLKSIZE=4096 MAXBLKSIZE=4096 ;; xsfs*) From bf94ef7fbdc22e24c3da63f63a1eb6975bab2b40 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 3 Feb 2017 12:32:25 +0100 Subject: [PATCH 0642/1167] documentation: Clarify documentation for special environment variable "default". The current documentation for the special environment variable "default" is confusing and unclear. This patch attempts to clean it up. In particular, the current documentation refers to the "number or title", but then in the example it gives, the menu entries and submenus all have numbers *in* their title; furthermore, there is no example given about how to choose the number, or any indication about whether counting is zero-indexed or 1-indexed. Having a cleaner example and presenting all variants (numeric, title, and id) should make it clearer to the user. Signed-off-by: Daniel Kahn Gillmor --- docs/grub.texi | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index b9ddb9b8a..e935af33e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3218,9 +3218,10 @@ source for more details. @node default @subsection default -If this variable is set, it identifies a menu entry that should be selected -by default, possibly after a timeout (@pxref{timeout}). The entry may be -identified by number or by id. +If this variable is set, it identifies a menu entry that should be +selected by default, possibly after a timeout (@pxref{timeout}). The +entry may be identified by number (starting from 0 at each level of +the hierarchy), by title, or by id. For example, if you have: @@ -3236,24 +3237,26 @@ then you can make this the default using: default=example-gnu-linux @end example -If the entry is in a submenu, then it must be identified using the titles of -each of the submenus starting from the top level followed by the number or -title of the menu entry itself, separated by @samp{>}. For example, take -the following menu structure: +If the entry is in a submenu, then it must be identified using the +number, title, or id of each of the submenus starting from the top +level, followed by the number, title, or id of the menu entry itself, +with each element separated by @samp{>}. For example, take the +following menu structure: @example -Submenu 1 - Menu Entry 1 - Menu Entry 2 -Submenu 2 - Submenu 3 - Menu Entry 3 - Menu Entry 4 - Menu Entry 5 +GNU/Hurd --id gnu-hurd + Standard Boot --id=gnu-hurd-std + Rescue shell --id=gnu-hurd-rescue +Other platforms --id=other + Minix --id=minix + Version 3.4.0 --id=minix-3.4.0 + Version 3.3.0 --id=minix-3.3.0 + GRUB Invaders --id=grub-invaders @end example -``Menu Entry 3'' would then be identified as -@samp{Submenu 2>Submenu 3>Menu Entry 3}. +The more recent release of Minix would then be identified as +@samp{Other platforms>Minix>Version 3.4.0}, or as @samp{1>0>0}, or as +@samp{other>minix>minix-3.4.0}. This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple configuration}), @command{grub-set-default}, or @command{grub-reboot}. From c96cfac167fedf60e54308dc67a5f0277c315027 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 12:59:50 +0100 Subject: [PATCH 0643/1167] Fix mingw compilation. --- grub-core/kern/arm64/dl_helper.c | 4 ++-- grub-core/kern/ia64/dl_helper.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c index 4af3c4a10..e00c198db 100644 --- a/grub-core/kern/arm64/dl_helper.c +++ b/grub-core/kern/arm64/dl_helper.c @@ -116,8 +116,8 @@ grub_arm64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, const Elf64_Rela *rel, *max; for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)), - max = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_size)); - rel < max; rel = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_entsize))) + max = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_size)); + rel < max; rel = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_entsize))) switch (ELF64_R_TYPE (rel->r_info)) { case R_AARCH64_CALL26: diff --git a/grub-core/kern/ia64/dl_helper.c b/grub-core/kern/ia64/dl_helper.c index f663a52d5..c60159573 100644 --- a/grub-core/kern/ia64/dl_helper.c +++ b/grub-core/kern/ia64/dl_helper.c @@ -219,8 +219,8 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, const Elf64_Rela *rel, *max; for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)), - max = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_size)); - rel < max; rel = (const Elf64_Rela *) ((grub_addr_t) rel + grub_le_to_cpu64 (s->sh_entsize))) + max = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_size)); + rel < max; rel = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_entsize))) switch (ELF64_R_TYPE (grub_le_to_cpu64 (rel->r_info))) { case R_IA64_PCREL21B: From c36c0e05f107565d67197660868004abe9c811fd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 12:34:21 +0100 Subject: [PATCH 0644/1167] Release 2.02-rc1. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4f7765c2d..0893ad60c 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02~beta3],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.02~rc1],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From fcb1528d932367d0f738606a85356fa3be477c58 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 13:41:13 +0100 Subject: [PATCH 0645/1167] Regenerate checksums.h Screenshots contain version, so we need new checksums. --- grub-core/tests/checksums.h | 192 ++++++++++++------------------------ 1 file changed, 63 insertions(+), 129 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index 76555c5eb..258a6e7d8 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,129 +1,63 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24285504, 0x24285504, 0x3cc7ae1, 0x3cc7ae1, 0x20e2971b, 0x20e2971b, 0xc295b4fc, 0xc295b4fc, 0x1fbe0d4, 0x1fbe0d4, 0x82930744, 0x82930744, 0xf4b66805, 0xf4b66805, 0x3e16a8c5, 0x3e16a8c5, 0x1165d7dc, 0x1165d7dc, 0xfa78cf7f, 0xfa78cf7f, 0xc105a544, 0xc105a544, 0x430cee22, 0x430cee22, 0xbcf938a0, 0xbcf938a0, 0x7b800045, 0x7b800045, 0x2cc85143, 0x2cc85143, 0x80e0a4b4, 0x80e0a4b4, 0x212e8415, 0x212e8415, 0x151d5163, 0x151d5163, 0x24dcfa9e, 0x24dcfa9e, 0xb1df21b2, 0xb1df21b2, 0x2990a5cf, 0x8c1740a5, 0xd29f2d17, 0xd29f2d17, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b224886, 0x2b224886, 0x4fa52ab9, 0x4fa52ab9, 0xad8716fa, 0xad8716fa, 0x97a64f1, 0x97a64f1, 0x5fa72700, 0x5fa72700, 0x41913bce, 0x41913bce, 0xe3e6af02, 0xe3e6af02, 0x978a4f3c, 0x978a4f3c, 0xfdedd645, 0xfdedd645, 0x4700a76, 0x4700a76, 0x28761dd2, 0x28761dd2, 0x255a96e8, 0x255a96e8, 0x6eb066fa, 0x6eb066fa, 0x5948e6c4, 0x5948e6c4, 0xc2d83034, 0xc2d83034, 0xe9cc8934, 0xe9cc8934, 0x406490d, 0x406490d, 0x2287423f, 0x2287423f, 0x565ef88b, 0x565ef88b, 0x31af9b10, 0x31af9b10, 0xfbd17ce0, 0xdb686c61, 0xd2731a72, 0xd2731a72, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x999febcd, 0x999febcd, 0x4be4a5e6, 0x4be4a5e6, 0xaa36e979, 0xaa36e979, 0x27ebab0f, 0x27ebab0f, 0x6fa8606c, 0x6fa8606c, 0xd3f60410, 0xd3f60410, 0xa3aea110, 0xa3aea110, 0x5b352e4b, 0x5b352e4b, 0xad22636f, 0xad22636f, 0x54333936, 0x54333936, 0x73d67c9f, 0x73d67c9f, 0xb4462f4a, 0xb4462f4a, 0x1dffdbca, 0x1dffdbca, 0x7095a788, 0x7095a788, 0xc71aa28, 0xc71aa28, 0x215e8dfc, 0x215e8dfc, 0x388d3494, 0x388d3494, 0x5804733d, 0x5804733d, 0x98ef7a83, 0x98ef7a83, 0xc986bddb, 0xc986bddb, 0x183599ab, 0xf4204ada, 0x6562dd40, 0x6562dd40, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xea25e7f1, 0xea25e7f1, 0xf959b605, 0xf959b605, 0x5650ee99, 0x5650ee99, 0xbf3bec3c, 0xbf3bec3c, 0x8d04d782, 0x8d04d782, 0xddbcf5be, 0xddbcf5be, 0x7ee1adaf, 0x7ee1adaf, 0x2fbaff58, 0x2fbaff58, 0x42b24add, 0x42b24add, 0x47483eb4, 0x47483eb4, 0x78962528, 0x78962528, 0x847ee9b7, 0x847ee9b7, 0xc826c0f, 0xc826c0f, 0x82b1bf51, 0x82b1bf51, 0x13ccc821, 0x13ccc821, 0x7d783b1e, 0x7d783b1e, 0xdd2c0bbc, 0xdd2c0bbc, 0x7b71ebd7, 0x7b71ebd7, 0x7381f4c5, 0x7381f4c5, 0xfe20bc9c, 0xfe20bc9c, 0x85dee923, 0x85611b00, 0x723c0ec4, 0x723c0ec4, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc52dc5f, 0xbc52dc5f, 0x4c895989, 0x4c895989, 0x59d180a4, 0x59d180a4, 0x50eb81b9, 0x50eb81b9, 0xae85d6c6, 0xae85d6c6, 0xf8354df6, 0xf8354df6, 0x83562153, 0x83562153, 0xd4caece2, 0xd4caece2, 0xb0b5612d, 0xb0b5612d, 0x123d360a, 0x123d360a, 0x70f62e8e, 0x70f62e8e, 0x6a82788f, 0x6a82788f, 0xb0a3ee68, 0xb0a3ee68, 0x604dd5b0, 0x604dd5b0, 0x20f7ea1, 0x20f7ea1, 0x3f6db6bf, 0x3f6db6bf, 0x4a762b9d, 0x4a762b9d, 0xea026ad4, 0xea026ad4, 0x8ba3d148, 0x8ba3d148, 0x434f2359, 0x434f2359, 0x4db299a1, 0x73536949, 0xf022eb4b, 0xf022eb4b, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7cfd676, 0x7cfd676, 0xaf7bcdc6, 0xaf7bcdc6, 0x7dc1f958, 0x7dc1f958, 0xc902ad3e, 0xc902ad3e, 0x5529ad04, 0x5529ad04, 0xa0a133b1, 0xa0a133b1, 0x72f927da, 0x72f927da, 0x28de6d8e, 0x28de6d8e, 0xa5eb10fc, 0xa5eb10fc, 0x2d7ba4f5, 0x2d7ba4f5, 0xd832b228, 0xd832b228, 0x56f0351, 0x56f0351, 0xc6556c2e, 0xc6556c2e, 0x2ceecfa4, 0x2ceecfa4, 0x3d765fbd, 0x3d765fbd, 0x8da7887e, 0x8da7887e, 0xfc8209ea, 0xfc8209ea, 0x6e822767, 0x6e822767, 0xba5c0adf, 0xba5c0adf, 0x8e2af81a, 0x8e2af81a, 0x62c25eb4, 0x2ba315e0, 0x349b7b7d, 0x349b7b7d, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x361fdea5, 0x361fdea5, 0x89a3b488, 0x89a3b488, 0x37302fbe, 0x37302fbe, 0x4b9f20b8, 0x4b9f20b8, 0xc60cf5fe, 0xc60cf5fe, 0xf7b755aa, 0xf7b755aa, 0xcaba5d52, 0xcaba5d52, 0x4f793adf, 0x4f793adf, 0x4cd60722, 0x4cd60722, 0x13adbeec, 0x13adbeec, 0xdc2c109f, 0xdc2c109f, 0x444e465a, 0x444e465a, 0x7baac5fa, 0x7baac5fa, 0x8e746e7f, 0x8e746e7f, 0x7fea6e68, 0x7fea6e68, 0x1f6edf48, 0x1f6edf48, 0x23322506, 0x23322506, 0xbccd38ef, 0xbccd38ef, 0x1b1f1dd3, 0x1b1f1dd3, 0x9c901775, 0x9c901775, 0x78b8e355, 0x95034aa2, 0x4f00ee83, 0x4f00ee83, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe9c994d6, 0x8f067855, 0xe9c994d6, 0xaa3f5991, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xaa3f5991, 0xaa3f5991, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2cc2fffd, 0x88e87845, 0x2cc2fffd, 0x2c77a82, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x2c77a82, 0x2c77a82, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x733b15c5, 0xc9b74a1d, 0x733b15c5, 0x2e2c7841, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x2e2c7841, 0x2e2c7841, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd703498e, 0x64a340b9, 0xd703498e, 0x79550056, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x79550056, 0x79550056, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7190a7ff, 0x6166bc9e, 0x7190a7ff, 0x736924c, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x736924c, 0x736924c, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x706487bc, 0x241c2362, 0x706487bc, 0x6b615dbb, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x6b615dbb, 0x6b615dbb, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x90994be3, 0x3b089c5e, 0x90994be3, 0x6f265063, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x6f265063, 0x6f265063, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x9b16e244, 0x9b16e244, 0x9b16e244, 0x1ae51495, 0x1ae51495, 0x1ae51495, 0x8c41adfa, 0x8c41adfa, 0x8c41adfa, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3eb350e7, 0x3053ed7f, 0x3eb350e7, 0x7d459da0, 0x59c36f00, 0x59c36f00, 0x7044c405, 0x7044c405, 0x7044c405, 0xec4a963, 0xec4a963, 0xec4a963, 0x6c32bcb1, 0x6c32bcb1, 0x6c32bcb1, 0x59c36f00, 0x7d459da0, 0x7d459da0, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x605b064a, 0x9446f166, 0x605b064a, 0x4e5e8335, 0xaa4593fe, 0xaa4593fe, 0x96342672, 0x96342672, 0x96342672, 0x30c12b15, 0x30c12b15, 0x30c12b15, 0x1df9806d, 0x1df9806d, 0x1df9806d, 0xaa4593fe, 0x4e5e8335, 0x4e5e8335, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x204c5494, 0x32c0ef19, 0x204c5494, 0x7d5b3910, 0xc9cbf769, 0xc9cbf769, 0x4c70c1a2, 0x4c70c1a2, 0x4c70c1a2, 0xb2a8006e, 0xb2a8006e, 0xb2a8006e, 0x5be2bf66, 0x5be2bf66, 0x5be2bf66, 0xc9cbf769, 0x7d5b3910, 0x7d5b3910, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x706dce4f, 0x6d5c7c0e, 0x706dce4f, 0xde3b8797, 0x9813a416, 0x9813a416, 0xb16f073b, 0xb16f073b, 0xb16f073b, 0x20b48108, 0x20b48108, 0x20b48108, 0x390ebcd8, 0x390ebcd8, 0x390ebcd8, 0x9813a416, 0xde3b8797, 0xde3b8797, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7d3ef313, 0xbc5bfdb2, 0x7d3ef313, 0xb98c6a0, 0x5fcf013d, 0x5fcf013d, 0x9495a31f, 0x9495a31f, 0x9495a31f, 0x4685bb69, 0x4685bb69, 0x4685bb69, 0x50f684f6, 0x50f684f6, 0x50f684f6, 0x5fcf013d, 0xb98c6a0, 0xb98c6a0, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x94568840, 0x5ba9e95d, 0x94568840, 0x8f535247, 0xdd28f52b, 0xdd28f52b, 0xda6ea802, 0xda6ea802, 0xda6ea802, 0xfb5251e6, 0xfb5251e6, 0xfb5251e6, 0x86ea9a6a, 0x86ea9a6a, 0x86ea9a6a, 0xdd28f52b, 0x8f535247, 0x8f535247, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcc418cc7, 0xbdfe0adb, 0xcc418cc7, 0x33fe9747, 0x43d1f34, 0x43d1f34, 0x9cb3f177, 0x9cb3f177, 0x9cb3f177, 0xe3b958df, 0xe3b958df, 0xe3b958df, 0x7ae85d59, 0x7ae85d59, 0x7ae85d59, 0x43d1f34, 0x33fe9747, 0x33fe9747, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x847af750, 0xfc4b05b6, 0x847af750, 0xc78c3a17, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xc78c3a17, 0xc78c3a17, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x972adf32, 0x349eaf3e, 0x972adf32, 0xb92f5a4d, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0xb92f5a4d, 0xb92f5a4d, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x76c2daa4, 0xd4071c19, 0x76c2daa4, 0x2bd5b720, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x2bd5b720, 0x2bd5b720, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb14d88d8, 0x9f6168b3, 0xb14d88d8, 0x1f1bc100, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x1f1bc100, 0x1f1bc100, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x46ef56d1, 0xdd47e1bc, 0x46ef56d1, 0x30496362, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x30496362, 0x30496362, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1d515a73, 0x834660e6, 0x1d515a73, 0x6548074, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0x6548074, 0x6548074, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x1b104a9c, 0x59605b48, 0x1b104a9c, 0xe4af511c, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xe4af511c, 0xe4af511c, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x51c932ad, 0x531cbd8c, 0x51c932ad, 0x123fffea, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x123fffea, 0x123fffea, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1ac8df77, 0xa99e83d4, 0x1ac8df77, 0x34cd5a08, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0x34cd5a08, 0x34cd5a08, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe208a8ec, 0x53ac0297, 0xe208a8ec, 0xbf1fc568, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xbf1fc568, 0xbf1fc568, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5cb50348, 0xa8145763, 0x5cb50348, 0xf2e34a90, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf2e34a90, 0xf2e34a90, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6a8cc8e9, 0x4a531def, 0x6a8cc8e9, 0x1c2afd5a, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x1c2afd5a, 0x1c2afd5a, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4704bcce, 0x709d57a1, 0x4704bcce, 0x5c0166c9, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0x5c0166c9, 0x5c0166c9, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x99d6529d, 0xbf7b99ef, 0x99d6529d, 0x6669491d, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x6669491d, 0x6669491d, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe056614c, 0x5c137376, 0xe056614c, 0xa3a0ac0b, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0xa3a0ac0b, 0xa3a0ac0b, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944341ab, 0x62739a86, 0x944341ab, 0xba46c4d4, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0xba46c4d4, 0xba46c4d4, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1d508cd1, 0xae5a1e0f, 0x1d508cd1, 0x4047e155, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x4047e155, 0x4047e155, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x18be70f9, 0x6df8f98a, 0x18be70f9, 0xb6e83921, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb6e83921, 0xb6e83921, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x13bb996a, 0x7111e3be, 0x13bb996a, 0x651dacd9, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x651dacd9, 0x651dacd9, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8139bb16, 0xa8941900, 0x8139bb16, 0x9a3c6111, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x9a3c6111, 0x9a3c6111, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x81aeae38, 0x3a877000, 0x81aeae38, 0x7e11b5b8, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x7e11b5b8, 0x7e11b5b8, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x18e2fef0, 0x2054f66b, 0x18e2fef0, 0x5b1433b7, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x5b1433b7, 0x5b1433b7, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb41da43f, 0x6b5dca76, 0xb41da43f, 0x9a182140, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x9a182140, 0x9a182140, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8fb5af0, 0x966678b3, 0xb8fb5af0, 0xe5ec3774, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xe5ec3774, 0xe5ec3774, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7bbd9989, 0x9545b54, 0x7bbd9989, 0xd5ebd051, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd5ebd051, 0xd5ebd051, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xabb3ac1a, 0x82513146, 0xabb3ac1a, 0xdd1599a9, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xdd1599a9, 0xdd1599a9, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1f6f76cb, 0x939ae042, 0x1f6f76cb, 0x46aaccc, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0x46aaccc, 0x46aaccc, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x454a1d70, 0xfa847f09, 0x454a1d70, 0xbaf506f0, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0xbaf506f0, 0xbaf506f0, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x961a470c, 0xbdfd623e, 0x961a470c, 0xd5ec8a4b, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xd5ec8a4b, 0xd5ec8a4b, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xcaba076b, 0x3d2d90d2, 0xcaba076b, 0xe4bf8214, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0xe4bf8214, 0xe4bf8214, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa47a9403, 0x38fce15c, 0xa47a9403, 0xf96df987, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xf96df987, 0xf96df987, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x440c953e, 0x6c510f, 0x440c953e, 0xea5adce6, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xea5adce6, 0xea5adce6, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xcd6c7c97, 0x1127c632, 0xcd6c7c97, 0xbbca4924, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0xbbca4924, 0xbbca4924, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7816d3d6, 0x531fb331, 0x7816d3d6, 0x631309d1, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x631309d1, 0x631309d1, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3b66e788, 0xfeb0dc77, 0x3b66e788, 0xc4d9fc08, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xc4d9fc08, 0xc4d9fc08, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5528f079, 0x33e71cfa, 0x5528f079, 0x16de3d3e, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x16de3d3e, 0x16de3d3e, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x95a2da79, 0x31885dc1, 0x95a2da79, 0xbba75f06, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0xbba75f06, 0xbba75f06, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf353e593, 0x49dfba4b, 0xf353e593, 0xae448817, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xae448817, 0xae448817, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6222faac, 0xd182f39b, 0x6222faac, 0xcc74b374, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcc74b374, 0xcc74b374, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x33b34907, 0x23455266, 0x33b34907, 0x45157cb4, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x45157cb4, 0x45157cb4, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe45406c3, 0xb02ca21d, 0xe45406c3, 0xff51dcc4, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xff51dcc4, 0xff51dcc4, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xdd5109ee, 0x76c0de53, 0xdd5109ee, 0x22ee126e, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x22ee126e, 0x22ee126e, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x12793126, 0x5dc985c2, 0x12793126, 0x518ffc61, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x518ffc61, 0x518ffc61, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xda7c2335, 0xd3181756, 0xda7c2335, 0xf479a64a, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0xf479a64a, 0xf479a64a, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4f5deb37, 0x8e0c1d2a, 0x4f5deb37, 0x124a86b3, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0x124a86b3, 0x124a86b3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x49da479d, 0x1538ed31, 0x49da479d, 0xe78c0e45, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe78c0e45, 0xe78c0e45, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1e479f7, 0x78f49dce, 0x1e479f7, 0x77424c44, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x77424c44, 0x77424c44, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf6c7e89, 0x6514ceb7, 0xf6c7e89, 0x1469a48e, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0x1469a48e, 0x1469a48e, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5f6710a8, 0xacf14e81, 0x5f6710a8, 0xa0d80b28, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0xa0d80b28, 0xa0d80b28, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x16cc3512, 0x24be1866, 0x16cc3512, 0x553af855, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x553af855, 0x553af855, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x27cf0391, 0x42a3914, 0x27cf0391, 0x9ca86ee, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x9ca86ee, 0x9ca86ee, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd293338, 0x3b24caf7, 0xd293338, 0x503e5ebc, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x503e5ebc, 0x503e5ebc, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7b914661, 0xee5073cd, 0x7b914661, 0xd5c70fb9, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd5c70fb9, 0xd5c70fb9, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd604dced, 0x1f7765e, 0xd604dced, 0xa0a2e95e, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0xa0a2e95e, 0xa0a2e95e, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe826aacc, 0x77711cd3, 0xe826aacc, 0xf32370cb, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0xf32370cb, 0xf32370cb, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcca5ee20, 0x9024dd53, 0xcca5ee20, 0x331af5a0, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0x331af5a0, 0x331af5a0, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x40e1929b, 0x262e7e18, 0x40e1929b, 0x17cc2c45, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x17cc2c45, 0x17cc2c45, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3ff0750a, 0x9bdaf2b2, 0x3ff0750a, 0x8f57af5c, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0x8f57af5c, 0x8f57af5c, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x759a3475, 0xcf166bad, 0x759a3475, 0x65bf2adb, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x65bf2adb, 0x65bf2adb, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b955480, 0xe8355db7, 0x5b955480, 0x6be4a8af, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x6be4a8af, 0x6be4a8af, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xca9f82bf, 0xda6999de, 0xca9f82bf, 0x64986d4a, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0x64986d4a, 0x64986d4a, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec0810a9, 0xb870b477, 0xec0810a9, 0x626cdb73, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x626cdb73, 0x626cdb73, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6525b7b4, 0xceb46009, 0x6525b7b4, 0xf27d3114, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xf27d3114, 0xf27d3114, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7ac36a92, 0x1c0c8611, 0x7ac36a92, 0xc289c558, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xc289c558, 0xc289c558, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x5d4c4756, 0xf966c0ee, 0x5d4c4756, 0x9eca8fd9, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x9eca8fd9, 0x9eca8fd9, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb730dd6c, 0xdbc82b4, 0xb730dd6c, 0xf5552151, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xf5552151, 0xf5552151, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2c9428b7, 0x9f342180, 0x2c9428b7, 0x62878afe, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x62878afe, 0x62878afe, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb37ba769, 0xa38dbc08, 0xb37ba769, 0x201da85e, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x201da85e, 0x201da85e, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf1efca90, 0xa5976e4e, 0xf1efca90, 0x16690ece, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x16690ece, 0x16690ece, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc859b7e0, 0x63c8605d, 0xc859b7e0, 0xb0d1e94f, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0xb0d1e94f, 0xb0d1e94f, 0x43d1f34, }, 20 }, - { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, - { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, - { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, - { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, - { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, - { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, - { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x68f4102c, 0x68f4102c, 0x4f103fc9, 0x4f103fc9, 0x6c3ed233, 0x6c3ed233, 0x8e49f1d4, 0x8e49f1d4, 0x4d27a5fc, 0x4d27a5fc, 0xce4f426c, 0xce4f426c, 0xb86a2d2d, 0xb86a2d2d, 0x72caeded, 0x72caeded, 0x5db992f4, 0x5db992f4, 0xb6a48a57, 0xb6a48a57, 0x8dd9e06c, 0x8dd9e06c, 0xfd0ab0a, 0xfd0ab0a, 0xf0257d88, 0xf0257d88, 0x375c456d, 0x375c456d, 0x6014146b, 0x6014146b, 0xcc3ce19c, 0xcc3ce19c, 0x6df2c13d, 0x6df2c13d, 0x59c1144b, 0x59c1144b, 0x6800bfb6, 0x6800bfb6, 0xfd03649a, 0xfd03649a, 0x654ce0e7, 0xc0cb058d, 0x9e43683f, 0x9e43683f, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c2c3e3f, 0x3c2c3e3f, 0x58ab5c00, 0x58ab5c00, 0xba896043, 0xba896043, 0x1e741248, 0x1e741248, 0x48a951b9, 0x48a951b9, 0x569f4d77, 0x569f4d77, 0xf4e8d9bb, 0xf4e8d9bb, 0x80843985, 0x80843985, 0xeae3a0fc, 0xeae3a0fc, 0x137e7ccf, 0x137e7ccf, 0x3f786b6b, 0x3f786b6b, 0x3254e051, 0x3254e051, 0x79be1043, 0x79be1043, 0x4e46907d, 0x4e46907d, 0xd5d6468d, 0xd5d6468d, 0xfec2ff8d, 0xfec2ff8d, 0x13083fb4, 0x13083fb4, 0x35893486, 0x35893486, 0x41508e32, 0x41508e32, 0x26a1eda9, 0x26a1eda9, 0xecdf0a59, 0xcc661ad8, 0xc57d6ccb, 0xc57d6ccb, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xeed4e023, 0xeed4e023, 0x3cafae08, 0x3cafae08, 0xdd7de297, 0xdd7de297, 0x50a0a0e1, 0x50a0a0e1, 0x18e36b82, 0x18e36b82, 0xa4bd0ffe, 0xa4bd0ffe, 0xd4e5aafe, 0xd4e5aafe, 0x2c7e25a5, 0x2c7e25a5, 0xda696881, 0xda696881, 0x237832d8, 0x237832d8, 0x49d7771, 0x49d7771, 0xc30d24a4, 0xc30d24a4, 0x6ab4d024, 0x6ab4d024, 0x7deac66, 0x7deac66, 0x7b3aa1c6, 0x7b3aa1c6, 0x56158612, 0x56158612, 0x4fc63f7a, 0x4fc63f7a, 0x2f4f78d3, 0x2f4f78d3, 0xefa4716d, 0xefa4716d, 0xbecdb635, 0xbecdb635, 0x6f7e9245, 0x836b4134, 0x1229d6ae, 0x1229d6ae, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xddd2650a, 0xddd2650a, 0xceae34fe, 0xceae34fe, 0x61a76c62, 0x61a76c62, 0x88cc6ec7, 0x88cc6ec7, 0xbaf35579, 0xbaf35579, 0xea4b7745, 0xea4b7745, 0x49162f54, 0x49162f54, 0x184d7da3, 0x184d7da3, 0x7545c826, 0x7545c826, 0x70bfbc4f, 0x70bfbc4f, 0x4f61a7d3, 0x4f61a7d3, 0xb3896b4c, 0xb3896b4c, 0x3b75eef4, 0x3b75eef4, 0xb5463daa, 0xb5463daa, 0x243b4ada, 0x243b4ada, 0x4a8fb9e5, 0x4a8fb9e5, 0xeadb8947, 0xeadb8947, 0x4c86692c, 0x4c86692c, 0x4476763e, 0x4476763e, 0xc9d73e67, 0xc9d73e67, 0xb2296bd8, 0xb29699fb, 0x45cb8c3f, 0x45cb8c3f, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xca59adfd, 0xca59adfd, 0x3a82282b, 0x3a82282b, 0x2fdaf106, 0x2fdaf106, 0x26e0f01b, 0x26e0f01b, 0xd88ea764, 0xd88ea764, 0x8e3e3c54, 0x8e3e3c54, 0xf55d50f1, 0xf55d50f1, 0xa2c19d40, 0xa2c19d40, 0xc6be108f, 0xc6be108f, 0x643647a8, 0x643647a8, 0x6fd5f2c, 0x6fd5f2c, 0x1c89092d, 0x1c89092d, 0xc6a89fca, 0xc6a89fca, 0x1646a412, 0x1646a412, 0x74040f03, 0x74040f03, 0x4966c71d, 0x4966c71d, 0x3c7d5a3f, 0x3c7d5a3f, 0x9c091b76, 0x9c091b76, 0xfda8a0ea, 0xfda8a0ea, 0x354452fb, 0x354452fb, 0x3bb9e803, 0x55818eb, 0x86299ae9, 0x86299ae9, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xad0b91c2, 0xad0b91c2, 0x5bf8a72, 0x5bf8a72, 0xd705beec, 0xd705beec, 0x63c6ea8a, 0x63c6ea8a, 0xffedeab0, 0xffedeab0, 0xa657405, 0xa657405, 0xd83d606e, 0xd83d606e, 0x821a2a3a, 0x821a2a3a, 0xf2f5748, 0xf2f5748, 0x87bfe341, 0x87bfe341, 0x72f6f59c, 0x72f6f59c, 0xafab44e5, 0xafab44e5, 0x6c912b9a, 0x6c912b9a, 0x862a8810, 0x862a8810, 0x97b21809, 0x97b21809, 0x2763cfca, 0x2763cfca, 0x56464e5e, 0x56464e5e, 0xc44660d3, 0xc44660d3, 0x10984d6b, 0x10984d6b, 0x24eebfae, 0x24eebfae, 0xc8061900, 0x81675254, 0x9e5f3cc9, 0x9e5f3cc9, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x68ab9311, 0x68ab9311, 0xd717f93c, 0xd717f93c, 0x6984620a, 0x6984620a, 0x152b6d0c, 0x152b6d0c, 0x98b8b84a, 0x98b8b84a, 0xa903181e, 0xa903181e, 0x940e10e6, 0x940e10e6, 0x11cd776b, 0x11cd776b, 0x12624a96, 0x12624a96, 0x4d19f358, 0x4d19f358, 0x82985d2b, 0x82985d2b, 0x1afa0bee, 0x1afa0bee, 0x251e884e, 0x251e884e, 0xd0c023cb, 0xd0c023cb, 0x215e23dc, 0x215e23dc, 0x41da92fc, 0x41da92fc, 0x7d8668b2, 0x7d8668b2, 0xe279755b, 0xe279755b, 0x45ab5067, 0x45ab5067, 0xc2245ac1, 0xc2245ac1, 0x260caee1, 0xcbb70716, 0x11b4a337, 0x11b4a337, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa515d1fe, 0xc3da3d7d, 0xa515d1fe, 0xe6e31cb9, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0xe6e31cb9, 0xe6e31cb9, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3bcc8944, 0x9fe60efc, 0x3bcc8944, 0x15c90c3b, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0x15c90c3b, 0x15c90c3b, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4701e2b, 0xbefc41f3, 0x4701e2b, 0x596773af, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0x596773af, 0x596773af, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe0f4cb75, 0x5354c242, 0xe0f4cb75, 0x4ea282ad, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0x4ea282ad, 0x4ea282ad, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x79bd65d, 0x176dcd3c, 0x79bd65d, 0x713de3ee, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x713de3ee, 0x713de3ee, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdaa0c008, 0x8ed864d6, 0xdaa0c008, 0xc1a51a0f, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0xc1a51a0f, 0xc1a51a0f, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xce2d0657, 0x65bcd1ea, 0xce2d0657, 0x31921dd7, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0x31921dd7, 0x31921dd7, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xde5d5c76, 0xde5d5c76, 0xde5d5c76, 0x8285aab6, 0x8285aab6, 0x8285aab6, 0xab1d6424, 0xab1d6424, 0xab1d6424, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xebc08e8, 0xebc08e8, 0xebc08e8, 0x5be3a2e2, 0x5be3a2e2, 0x5be3a2e2, 0x32d06aab, 0x32d06aab, 0x32d06aab, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xb1733229, 0xb1733229, 0xb1733229, 0xcecd94bd, 0xcecd94bd, 0xcecd94bd, 0x8cb9f4c5, 0x8cb9f4c5, 0x8cb9f4c5, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x7400503e, 0x7400503e, 0x7400503e, 0x9fa5ba42, 0x9fa5ba42, 0x9fa5ba42, 0x99eebab2, 0x99eebab2, 0x99eebab2, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x46a2d276, 0x46a2d276, 0x46a2d276, 0x29eb0e67, 0x29eb0e67, 0x29eb0e67, 0x241d9064, 0x241d9064, 0x241d9064, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0xfe89652d, 0xfe89652d, 0xfe89652d, 0x383b2133, 0x383b2133, 0x383b2133, 0x2c5ef18c, 0x2c5ef18c, 0x2c5ef18c, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0xb646d62d, 0xb646d62d, 0xb646d62d, 0x37b520fc, 0x37b520fc, 0x37b520fc, 0xa1119993, 0xa1119993, 0xa1119993, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb59af897, 0xbb7a450f, 0xb59af897, 0xf66c35d0, 0x59c36f00, 0x59c36f00, 0xfb6d6c75, 0xfb6d6c75, 0xfb6d6c75, 0x85ed0113, 0x85ed0113, 0x85ed0113, 0xe71b14c1, 0xe71b14c1, 0xe71b14c1, 0x59c36f00, 0xf66c35d0, 0xf66c35d0, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xcdeaad5f, 0x39f75a73, 0xcdeaad5f, 0xe3ef2820, 0xaa4593fe, 0xaa4593fe, 0x3b858d67, 0x3b858d67, 0x3b858d67, 0x9d708000, 0x9d708000, 0x9d708000, 0xb0482b78, 0xb0482b78, 0xb0482b78, 0xaa4593fe, 0xe3ef2820, 0xe3ef2820, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xbfc1cc02, 0xad4d778f, 0xbfc1cc02, 0xe2d6a186, 0xc9cbf769, 0xc9cbf769, 0xd3fd5934, 0xd3fd5934, 0xd3fd5934, 0x2d2598f8, 0x2d2598f8, 0x2d2598f8, 0xc46f27f0, 0xc46f27f0, 0xc46f27f0, 0xc9cbf769, 0xe2d6a186, 0xe2d6a186, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb4e8961f, 0xa9d9245e, 0xb4e8961f, 0x1abedfc7, 0x9813a416, 0x9813a416, 0x75ea5f6b, 0x75ea5f6b, 0x75ea5f6b, 0xe431d958, 0xe431d958, 0xe431d958, 0xfd8be488, 0xfd8be488, 0xfd8be488, 0x9813a416, 0x1abedfc7, 0x1abedfc7, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xfba9cd4c, 0x3accc3ed, 0xfba9cd4c, 0x8d0ff8ff, 0x5fcf013d, 0x5fcf013d, 0x12029d40, 0x12029d40, 0x12029d40, 0xc0128536, 0xc0128536, 0xc0128536, 0xd661baa9, 0xd661baa9, 0xd661baa9, 0x5fcf013d, 0x8d0ff8ff, 0x8d0ff8ff, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9afaa18d, 0x5505c090, 0x9afaa18d, 0x81ff7b8a, 0xdd28f52b, 0xdd28f52b, 0xd4c281cf, 0xd4c281cf, 0xd4c281cf, 0xf5fe782b, 0xf5fe782b, 0xf5fe782b, 0x8846b3a7, 0x8846b3a7, 0x8846b3a7, 0xdd28f52b, 0x81ff7b8a, 0x81ff7b8a, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3af16e43, 0x4b4ee85f, 0x3af16e43, 0xc54e75c3, 0x43d1f34, 0x43d1f34, 0x6a0313f3, 0x6a0313f3, 0x6a0313f3, 0x1509ba5b, 0x1509ba5b, 0x1509ba5b, 0x8c58bfdd, 0x8c58bfdd, 0x8c58bfdd, 0x43d1f34, 0xc54e75c3, 0xc54e75c3, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x49a25e74, 0x3193ac92, 0x49a25e74, 0xa549333, 0x59c36f00, 0x59c36f00, 0xdc6419f, 0xdc6419f, 0xdc6419f, 0x73462cf9, 0x73462cf9, 0x73462cf9, 0x11b0392b, 0x11b0392b, 0x11b0392b, 0x59c36f00, 0xa549333, 0xa549333, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x6485919, 0xa5fc2915, 0x6485919, 0x284ddc66, 0xaa4593fe, 0xaa4593fe, 0x6b2dd2e2, 0x6b2dd2e2, 0x6b2dd2e2, 0xcdd8df85, 0xcdd8df85, 0xcdd8df85, 0xe0e074fd, 0xe0e074fd, 0xe0e074fd, 0xaa4593fe, 0x284ddc66, 0x284ddc66, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5b7d7c45, 0xf9b8baf8, 0x5b7d7c45, 0x66a11c1, 0xc9cbf769, 0xc9cbf769, 0x57d5ac1f, 0x57d5ac1f, 0x57d5ac1f, 0xa90d6dd3, 0xa90d6dd3, 0xa90d6dd3, 0x4047d2db, 0x4047d2db, 0x4047d2db, 0xc9cbf769, 0x66a11c1, 0x66a11c1, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6fd2a74d, 0x41fe4726, 0x6fd2a74d, 0xc184ee95, 0x9813a416, 0x9813a416, 0xa132a122, 0xa132a122, 0xa132a122, 0x30e92711, 0x30e92711, 0x30e92711, 0x29531ac1, 0x29531ac1, 0x29531ac1, 0x9813a416, 0xc184ee95, 0xc184ee95, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x69685505, 0xf2c0e268, 0x69685505, 0x1fce60b6, 0x5fcf013d, 0x5fcf013d, 0xd61aeb01, 0xd61aeb01, 0xd61aeb01, 0x40af377, 0x40af377, 0x40af377, 0x1279cce8, 0x1279cce8, 0x1279cce8, 0x5fcf013d, 0x1fce60b6, 0x1fce60b6, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xee7e1be9, 0x7069217c, 0xee7e1be9, 0xf57bc1ee, 0xdd28f52b, 0xdd28f52b, 0x77d02fa2, 0x77d02fa2, 0x77d02fa2, 0x56ecd646, 0x56ecd646, 0x56ecd646, 0x2b541dca, 0x2b541dca, 0x2b541dca, 0xdd28f52b, 0xf57bc1ee, 0xf57bc1ee, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb5b4521a, 0xf7c443ce, 0xb5b4521a, 0x4a0b499a, 0x43d1f34, 0x43d1f34, 0xd019cfce, 0xd019cfce, 0xd019cfce, 0xaf136666, 0xaf136666, 0xaf136666, 0x364263e0, 0x364263e0, 0x364263e0, 0x43d1f34, 0x4a0b499a, 0x4a0b499a, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x9bdad73f, 0x990f581e, 0x9bdad73f, 0xd82c1a78, 0x59c36f00, 0x59c36f00, 0x663aaa6f, 0x663aaa6f, 0x663aaa6f, 0x18bac709, 0x18bac709, 0x18bac709, 0x7a4cd2db, 0x7a4cd2db, 0x7a4cd2db, 0x59c36f00, 0xd82c1a78, 0xd82c1a78, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf835ac2, 0xbcd50661, 0xf835ac2, 0x2186dfbd, 0xaa4593fe, 0xaa4593fe, 0x1f1997c1, 0x1f1997c1, 0x1f1997c1, 0xb9ec9aa6, 0xb9ec9aa6, 0xb9ec9aa6, 0x94d431de, 0x94d431de, 0x94d431de, 0xaa4593fe, 0x2186dfbd, 0x2186dfbd, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa3d7300f, 0x12739a74, 0xa3d7300f, 0xfec05d8b, 0xc9cbf769, 0xc9cbf769, 0x93dd5635, 0x93dd5635, 0x93dd5635, 0x6d0597f9, 0x6d0597f9, 0x6d0597f9, 0x844f28f1, 0x844f28f1, 0x844f28f1, 0xc9cbf769, 0xfec05d8b, 0xfec05d8b, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x32d637b0, 0xc677639b, 0x32d637b0, 0x9c807e68, 0x9813a416, 0x9813a416, 0xa1b8fcf1, 0xa1b8fcf1, 0xa1b8fcf1, 0x30637ac2, 0x30637ac2, 0x30637ac2, 0x29d94712, 0x29d94712, 0x29d94712, 0x9813a416, 0x9c807e68, 0x9c807e68, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3ec3528b, 0x1e1c878d, 0x3ec3528b, 0x48656738, 0x5fcf013d, 0x5fcf013d, 0x3510cd00, 0x3510cd00, 0x3510cd00, 0xe700d576, 0xe700d576, 0xe700d576, 0xf173eae9, 0xf173eae9, 0xf173eae9, 0x5fcf013d, 0x48656738, 0x48656738, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x50bc4d38, 0x6725a657, 0x50bc4d38, 0x4bb9973f, 0xdd28f52b, 0xdd28f52b, 0x66f52001, 0x66f52001, 0x66f52001, 0x47c9d9e5, 0x47c9d9e5, 0x47c9d9e5, 0x3a711269, 0x3a711269, 0x3a711269, 0xdd28f52b, 0x4bb9973f, 0x4bb9973f, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc481102d, 0xe22cdb5f, 0xc481102d, 0x3b3e0bad, 0x43d1f34, 0x43d1f34, 0xaf0df118, 0xaf0df118, 0xaf0df118, 0xd00758b0, 0xd00758b0, 0xd00758b0, 0x49565d36, 0x49565d36, 0x49565d36, 0x43d1f34, 0x3b3e0bad, 0x3b3e0bad, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd24e2c02, 0x6e0b3e38, 0xd24e2c02, 0x91b8e145, 0x59c36f00, 0x59c36f00, 0xf6d94324, 0xf6d94324, 0xf6d94324, 0x88592e42, 0x88592e42, 0x88592e42, 0xeaaf3b90, 0xeaaf3b90, 0xeaaf3b90, 0x59c36f00, 0x91b8e145, 0x91b8e145, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x48c95a99, 0xbef981b4, 0x48c95a99, 0x66ccdfe6, 0xaa4593fe, 0xaa4593fe, 0x69f632fe, 0x69f632fe, 0x69f632fe, 0xcf033f99, 0xcf033f99, 0xcf033f99, 0xe23b94e1, 0xe23b94e1, 0xe23b94e1, 0xaa4593fe, 0x66ccdfe6, 0x66ccdfe6, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdf5958ac, 0x6c53ca72, 0xdf5958ac, 0x824e3528, 0xc9cbf769, 0xc9cbf769, 0x7872f95f, 0x7872f95f, 0x7872f95f, 0x86aa3893, 0x86aa3893, 0x86aa3893, 0x6fe0879b, 0x6fe0879b, 0x6fe0879b, 0xc9cbf769, 0x824e3528, 0x824e3528, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e4e65e4, 0x3b08ec97, 0x4e4e65e4, 0xe0182c3c, 0x9813a416, 0x9813a416, 0xd87a3bca, 0xd87a3bca, 0xd87a3bca, 0x49a1bdf9, 0x49a1bdf9, 0x49a1bdf9, 0x501b8029, 0x501b8029, 0x501b8029, 0x9813a416, 0xe0182c3c, 0xe0182c3c, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa9051255, 0xcbaf6881, 0xa9051255, 0xdfa327e6, 0x5fcf013d, 0x5fcf013d, 0xdc53ce4e, 0xdc53ce4e, 0xdc53ce4e, 0xe43d638, 0xe43d638, 0xe43d638, 0x1830e9a7, 0x1830e9a7, 0x1830e9a7, 0x5fcf013d, 0xdfa327e6, 0xdfa327e6, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc3280b45, 0xea85a953, 0xc3280b45, 0xd82dd142, 0xdd28f52b, 0xdd28f52b, 0x4f22c62f, 0x4f22c62f, 0x4f22c62f, 0x6e1e3fcb, 0x6e1e3fcb, 0x6e1e3fcb, 0x13a6f447, 0x13a6f447, 0x13a6f447, 0xdd28f52b, 0xd82dd142, 0xd82dd142, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x93f5ee2e, 0x28dc3016, 0x93f5ee2e, 0x6c4af5ae, 0x43d1f34, 0x43d1f34, 0x2e9a92cb, 0x2e9a92cb, 0x2e9a92cb, 0x51903b63, 0x51903b63, 0x51903b63, 0xc8c13ee5, 0xc8c13ee5, 0xc8c13ee5, 0x43d1f34, 0x6c4af5ae, 0x6c4af5ae, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24539267, 0x1ce59afc, 0x24539267, 0x67a55f20, 0x59c36f00, 0x59c36f00, 0xee51a3ff, 0xee51a3ff, 0xee51a3ff, 0x90d1ce99, 0x90d1ce99, 0x90d1ce99, 0xf227db4b, 0xf227db4b, 0xf227db4b, 0x59c36f00, 0x67a55f20, 0x67a55f20, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7cb69e26, 0xa3f6f06f, 0x7cb69e26, 0x52b31b59, 0xaa4593fe, 0xaa4593fe, 0x2f6d12b5, 0x2f6d12b5, 0x2f6d12b5, 0x89981fd2, 0x89981fd2, 0x89981fd2, 0xa4a0b4aa, 0xa4a0b4aa, 0xa4a0b4aa, 0xaa4593fe, 0x52b31b59, 0x52b31b59, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e0eb3da, 0xb0939199, 0x9e0eb3da, 0xc319de5e, 0xc9cbf769, 0xc9cbf769, 0xc9c28f3b, 0xc9c28f3b, 0xc9c28f3b, 0x371a4ef7, 0x371a4ef7, 0x371a4ef7, 0xde50f1ff, 0xde50f1ff, 0xde50f1ff, 0xc9cbf769, 0xc319de5e, 0xc319de5e, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2bd305d0, 0x593ac70d, 0x2bd305d0, 0x85854c08, 0x9813a416, 0x9813a416, 0xd6c41d1f, 0xd6c41d1f, 0xd6c41d1f, 0x471f9b2c, 0x471f9b2c, 0x471f9b2c, 0x5ea5a6fc, 0x5ea5a6fc, 0x5ea5a6fc, 0x9813a416, 0x85854c08, 0x85854c08, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd554b2a6, 0xfcb62ffa, 0xd554b2a6, 0xa3f28715, 0x5fcf013d, 0x5fcf013d, 0x49663ae2, 0x49663ae2, 0x49663ae2, 0x9b762294, 0x9b762294, 0x9b762294, 0x8d051d0b, 0x8d051d0b, 0x8d051d0b, 0x5fcf013d, 0xa3f28715, 0xa3f28715, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcb4a441b, 0x47bfd292, 0xcb4a441b, 0xd04f9e1c, 0xdd28f52b, 0xdd28f52b, 0x1c62c4cf, 0x1c62c4cf, 0x1c62c4cf, 0x3d5e3d2b, 0x3d5e3d2b, 0x3d5e3d2b, 0x40e6f6a7, 0x40e6f6a7, 0x40e6f6a7, 0xdd28f52b, 0xd04f9e1c, 0xd04f9e1c, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84489cd2, 0x3b86feab, 0x84489cd2, 0x7bf78752, 0x43d1f34, 0x43d1f34, 0xeb4b4093, 0xeb4b4093, 0xeb4b4093, 0x9441e93b, 0x9441e93b, 0x9441e93b, 0xd10ecbd, 0xd10ecbd, 0xd10ecbd, 0x43d1f34, 0x7bf78752, 0x7bf78752, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdac60224, 0xf1212716, 0xdac60224, 0x9930cf63, 0x59c36f00, 0x59c36f00, 0xd83aedef, 0xd83aedef, 0xd83aedef, 0xa6ba8089, 0xa6ba8089, 0xa6ba8089, 0xc44c955b, 0xc44c955b, 0xc44c955b, 0x59c36f00, 0x9930cf63, 0x9930cf63, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xddb471d2, 0x2a23e66b, 0xddb471d2, 0xf3b1f4ad, 0xaa4593fe, 0xaa4593fe, 0x44e1ed3b, 0x44e1ed3b, 0x44e1ed3b, 0xe214e05c, 0xe214e05c, 0xe214e05c, 0xcf2c4b24, 0xcf2c4b24, 0xcf2c4b24, 0xaa4593fe, 0xf3b1f4ad, 0xf3b1f4ad, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd3319fed, 0x4fb7eab2, 0xd3319fed, 0x8e26f269, 0xc9cbf769, 0xc9cbf769, 0xb45d8a1a, 0xb45d8a1a, 0xb45d8a1a, 0x4a854bd6, 0x4a854bd6, 0x4a854bd6, 0xa3cff4de, 0xa3cff4de, 0xa3cff4de, 0xc9cbf769, 0x8e26f269, 0x8e26f269, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x73fb17c5, 0x379bd3f4, 0x73fb17c5, 0xddad5e1d, 0x9813a416, 0x9813a416, 0xbd332cdb, 0xbd332cdb, 0xbd332cdb, 0x2ce8aae8, 0x2ce8aae8, 0x2ce8aae8, 0x35529738, 0x35529738, 0x35529738, 0x9813a416, 0xddad5e1d, 0xddad5e1d, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbb670d35, 0x672cb790, 0xbb670d35, 0xcdc13886, 0x5fcf013d, 0x5fcf013d, 0x14e80d5a, 0x14e80d5a, 0x14e80d5a, 0xc6f8152c, 0xc6f8152c, 0xc6f8152c, 0xd08b2ab3, 0xd08b2ab3, 0xd08b2ab3, 0x5fcf013d, 0xcdc13886, 0xcdc13886, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd2d29462, 0xf9dbf485, 0xd2d29462, 0xc9d74e65, 0xdd28f52b, 0xdd28f52b, 0x92d1dcce, 0x92d1dcce, 0x92d1dcce, 0xb3ed252a, 0xb3ed252a, 0xb3ed252a, 0xce55eea6, 0xce55eea6, 0xce55eea6, 0xdd28f52b, 0xc9d74e65, 0xc9d74e65, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x65d2aa3c, 0xa00491c3, 0x65d2aa3c, 0x9a6db1bc, 0x43d1f34, 0x43d1f34, 0x33df64a1, 0x33df64a1, 0x33df64a1, 0x4cd5cd09, 0x4cd5cd09, 0x4cd5cd09, 0xd584c88f, 0xd584c88f, 0xd584c88f, 0x43d1 \ No newline at end of file From ec4aca088a04fce6c7d97c733ec272c63b0a1231 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 3 Feb 2017 20:17:48 +0100 Subject: [PATCH 0646/1167] Fix truncated checksum.h. --- grub-core/tests/checksums.h | 68 ++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index 258a6e7d8..bbbd3a59f 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -60,4 +60,70 @@ { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x73fb17c5, 0x379bd3f4, 0x73fb17c5, 0xddad5e1d, 0x9813a416, 0x9813a416, 0xbd332cdb, 0xbd332cdb, 0xbd332cdb, 0x2ce8aae8, 0x2ce8aae8, 0x2ce8aae8, 0x35529738, 0x35529738, 0x35529738, 0x9813a416, 0xddad5e1d, 0xddad5e1d, 0x9813a416, }, 20 }, { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbb670d35, 0x672cb790, 0xbb670d35, 0xcdc13886, 0x5fcf013d, 0x5fcf013d, 0x14e80d5a, 0x14e80d5a, 0x14e80d5a, 0xc6f8152c, 0xc6f8152c, 0xc6f8152c, 0xd08b2ab3, 0xd08b2ab3, 0xd08b2ab3, 0x5fcf013d, 0xcdc13886, 0xcdc13886, 0x5fcf013d, }, 20 }, { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd2d29462, 0xf9dbf485, 0xd2d29462, 0xc9d74e65, 0xdd28f52b, 0xdd28f52b, 0x92d1dcce, 0x92d1dcce, 0x92d1dcce, 0xb3ed252a, 0xb3ed252a, 0xb3ed252a, 0xce55eea6, 0xce55eea6, 0xce55eea6, 0xdd28f52b, 0xc9d74e65, 0xc9d74e65, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x65d2aa3c, 0xa00491c3, 0x65d2aa3c, 0x9a6db1bc, 0x43d1f34, 0x43d1f34, 0x33df64a1, 0x33df64a1, 0x33df64a1, 0x4cd5cd09, 0x4cd5cd09, 0x4cd5cd09, 0xd584c88f, 0xd584c88f, 0xd584c88f, 0x43d1 \ No newline at end of file + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x65d2aa3c, 0xa00491c3, 0x65d2aa3c, 0x9a6db1bc, 0x43d1f34, 0x43d1f34, 0x33df64a1, 0x33df64a1, 0x33df64a1, 0x4cd5cd09, 0x4cd5cd09, 0x4cd5cd09, 0xd584c88f, 0xd584c88f, 0xd584c88f, 0x43d1f34, 0x9a6db1bc, 0x9a6db1bc, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x19f4b551, 0x7f3b59d2, 0x19f4b551, 0x5a027816, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0x5a027816, 0x5a027816, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x82acacc0, 0x26862b78, 0x82acacc0, 0xaca929bf, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0xaca929bf, 0xaca929bf, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8418ee7d, 0x3e94b1a5, 0x8418ee7d, 0xd90f83f9, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0xd90f83f9, 0xd90f83f9, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x55d57857, 0xe6757160, 0x55d57857, 0xfb83318f, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0xfb83318f, 0xfb83318f, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x45b838a5, 0x554e23c4, 0x45b838a5, 0x331e0d16, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x331e0d16, 0x331e0d16, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4e904177, 0x1ae8e5a9, 0x4e904177, 0x55959b70, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0x55959b70, 0x55959b70, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x83e5445a, 0x287493e7, 0x83e5445a, 0x7c5a5fda, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0x7c5a5fda, 0x7c5a5fda, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x43eebd9e, 0xc5e097a, 0x43eebd9e, 0x1870d9, 0x59c36f00, 0x59c36f00, 0x90b8be2f, 0x90b8be2f, 0x90b8be2f, 0xee38d349, 0xee38d349, 0xee38d349, 0x8ccec69b, 0x8ccec69b, 0x8ccec69b, 0x59c36f00, 0x1870d9, 0x1870d9, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd16e76b1, 0xd80a42d2, 0xd16e76b1, 0xff6bf3ce, 0xaa4593fe, 0xaa4593fe, 0xe8b201a3, 0xe8b201a3, 0xe8b201a3, 0x4e470cc4, 0x4e470cc4, 0x4e470cc4, 0x637fa7bc, 0x637fa7bc, 0x637fa7bc, 0xaa4593fe, 0xff6bf3ce, 0xff6bf3ce, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x46c9c0b6, 0x879836ab, 0x46c9c0b6, 0x1bdead32, 0xc9cbf769, 0xc9cbf769, 0x7f3bf79a, 0x7f3bf79a, 0x7f3bf79a, 0x81e33656, 0x81e33656, 0x81e33656, 0x68a9895e, 0x68a9895e, 0x68a9895e, 0xc9cbf769, 0x1bdead32, 0x1bdead32, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbedd413, 0x570f7ebf, 0xbedd413, 0xa5bb9dcb, 0x9813a416, 0x9813a416, 0x30f35812, 0x30f35812, 0x30f35812, 0xa128de21, 0xa128de21, 0xa128de21, 0xb892e3f1, 0xb892e3f1, 0xb892e3f1, 0x9813a416, 0xa5bb9dcb, 0xa5bb9dcb, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x76ec4315, 0xffca72c, 0x76ec4315, 0x4a76a6, 0x5fcf013d, 0x5fcf013d, 0x7b237d7d, 0x7b237d7d, 0x7b237d7d, 0xa933650b, 0xa933650b, 0xa933650b, 0xbf405a94, 0xbf405a94, 0xbf405a94, 0x5fcf013d, 0x4a76a6, 0x4a76a6, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x75cfd768, 0x1fb76756, 0x75cfd768, 0x6eca0d6f, 0xdd28f52b, 0xdd28f52b, 0xa0ff4b91, 0xa0ff4b91, 0xa0ff4b91, 0x81c3b275, 0x81c3b275, 0x81c3b275, 0xfc7b79f9, 0xfc7b79f9, 0xfc7b79f9, 0xdd28f52b, 0x6eca0d6f, 0x6eca0d6f, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd5cf1813, 0x2659463a, 0xd5cf1813, 0x2a700393, 0x43d1f34, 0x43d1f34, 0x850afb92, 0x850afb92, 0x850afb92, 0xfa00523a, 0xfa00523a, 0xfa00523a, 0x635157bc, 0x635157bc, 0x635157bc, 0x43d1f34, 0x2a700393, 0x2a700393, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5d323c44, 0x6f401130, 0x5d323c44, 0x1ec4f103, 0x59c36f00, 0x59c36f00, 0x68eced5a, 0x68eced5a, 0x68eced5a, 0x166c803c, 0x166c803c, 0x166c803c, 0x749a95ee, 0x749a95ee, 0x749a95ee, 0x59c36f00, 0x1ec4f103, 0x1ec4f103, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x984941ed, 0xbbac7b68, 0x984941ed, 0xb64cc492, 0xaa4593fe, 0xaa4593fe, 0x4082ddcb, 0x4082ddcb, 0x4082ddcb, 0xe677d0ac, 0xe677d0ac, 0xe677d0ac, 0xcb4f7bd4, 0xcb4f7bd4, 0xcb4f7bd4, 0xaa4593fe, 0xb64cc492, 0xb64cc492, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb6d3d3b9, 0x80de2a76, 0xb6d3d3b9, 0xebc4be3d, 0xc9cbf769, 0xc9cbf769, 0xea0ec457, 0xea0ec457, 0xea0ec457, 0x14d6059b, 0x14d6059b, 0x14d6059b, 0xfd9cba93, 0xfd9cba93, 0xfd9cba93, 0xc9cbf769, 0xebc4be3d, 0xebc4be3d, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4733985d, 0xd2f2adf1, 0x4733985d, 0xe965d185, 0x9813a416, 0x9813a416, 0xa2feabe5, 0xa2feabe5, 0xa2feabe5, 0x33252dd6, 0x33252dd6, 0x33252dd6, 0x2a9f1006, 0x2a9f1006, 0x2a9f1006, 0x9813a416, 0xe965d185, 0xe965d185, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x939ea364, 0x446d09d7, 0x939ea364, 0xe53896d7, 0x5fcf013d, 0x5fcf013d, 0x39f5030f, 0x39f5030f, 0x39f5030f, 0xebe51b79, 0xebe51b79, 0xebe51b79, 0xfd9624e6, 0xfd9624e6, 0xfd9624e6, 0x5fcf013d, 0xe53896d7, 0xe53896d7, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x63d43704, 0xfc83811b, 0x63d43704, 0x78d1ed03, 0xdd28f52b, 0xdd28f52b, 0x9835fc4a, 0x9835fc4a, 0x9835fc4a, 0xb90905ae, 0xb90905ae, 0xb90905ae, 0xc4b1ce22, 0xc4b1ce22, 0xc4b1ce22, 0xdd28f52b, 0x78d1ed03, 0x78d1ed03, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfc47195d, 0xa0c62a2e, 0xfc47195d, 0x3f802dd, 0x43d1f34, 0x43d1f34, 0x8e86b971, 0x8e86b971, 0x8e86b971, 0xf18c10d9, 0xf18c10d9, 0xf18c10d9, 0x68dd155f, 0x68dd155f, 0x68dd155f, 0x43d1f34, 0x3f802dd, 0x3f802dd, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc3dd7b3, 0x6af23b30, 0xc3dd7b3, 0x5b10696d, 0x59c36f00, 0x59c36f00, 0xf6ddaf81, 0xf6ddaf81, 0xf6ddaf81, 0x885dc2e7, 0x885dc2e7, 0x885dc2e7, 0xeaabd735, 0xeaabd735, 0xeaabd735, 0x59c36f00, 0x5b10696d, 0x5b10696d, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x28fe03b3, 0x8cd4840b, 0x28fe03b3, 0x9859d9e5, 0xaa4593fe, 0xaa4593fe, 0x1af5874a, 0x1af5874a, 0x1af5874a, 0xbc008a2d, 0xbc008a2d, 0xbc008a2d, 0x91382155, 0x91382155, 0x91382155, 0xaa4593fe, 0x9859d9e5, 0x9859d9e5, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2d13f9b, 0xb85d6043, 0x2d13f9b, 0x12f42135, 0xc9cbf769, 0xc9cbf769, 0x11cfa191, 0x11cfa191, 0x11cfa191, 0xef17605d, 0xef17605d, 0xef17605d, 0x65ddf55, 0x65ddf55, 0x65ddf55, 0xc9cbf769, 0x12f42135, 0x12f42135, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6c62d67b, 0xdfc2df4c, 0x6c62d67b, 0x5c132a54, 0x9813a416, 0x9813a416, 0x7e455ca7, 0x7e455ca7, 0x7e455ca7, 0xef9eda94, 0xef9eda94, 0xef9eda94, 0xf624e744, 0xf624e744, 0xf624e744, 0x9813a416, 0x5c132a54, 0x5c132a54, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc94f31d, 0xac62e87c, 0xbc94f31d, 0x12931ce8, 0x5fcf013d, 0x5fcf013d, 0x11dc48b3, 0x11dc48b3, 0x11dc48b3, 0xc3cc50c5, 0xc3cc50c5, 0xc3cc50c5, 0xd5bf6f5a, 0xd5bf6f5a, 0xd5bf6f5a, 0x5fcf013d, 0x12931ce8, 0x12931ce8, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46cc571d, 0x12b4f3c3, 0x46cc571d, 0xc8a89cc7, 0xdd28f52b, 0xdd28f52b, 0xa242e6a5, 0xa242e6a5, 0xa242e6a5, 0x837e1f41, 0x837e1f41, 0x837e1f41, 0xfec6d4cd, 0xfec6d4cd, 0xfec6d4cd, 0xdd28f52b, 0xc8a89cc7, 0xc8a89cc7, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3b91fa00, 0x90002dbd, 0x3b91fa00, 0xacc97ca0, 0x43d1f34, 0x43d1f34, 0x935e0051, 0x935e0051, 0x935e0051, 0xec54a9f9, 0xec54a9f9, 0xec54a9f9, 0x7505ac7f, 0x7505ac7f, 0x7505ac7f, 0x43d1f34, 0xacc97ca0, 0xacc97ca0, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x361f2fba, 0x50d0c339, 0x361f2fba, 0x8e558070, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0x8e558070, 0x8e558070, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4a4231ef, 0xee68b657, 0x4a4231ef, 0x89c4f960, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0x89c4f960, 0x89c4f960, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc07bd682, 0x7af7895a, 0xc07bd682, 0x821e2abf, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0x821e2abf, 0x821e2abf, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1b63aa4c, 0xa8c3a37b, 0x1b63aa4c, 0x55700805, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0x55700805, 0x55700805, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc570d6cb, 0xd586cdaa, 0xc570d6cb, 0x5616d9fc, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x5616d9fc, 0x5616d9fc, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5b2b8d24, 0xf5329fa, 0x5b2b8d24, 0xbcad497a, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0xbcad497a, 0xbcad497a, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x96edfa54, 0x3d7c2de9, 0x96edfa54, 0xee65a4fb, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0xee65a4fb, 0xee65a4fb, 0x43d1f34, }, 20 }, + { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, + { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, + { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, + { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, + { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, + { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, + { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, From f3df8f961f19fa8ecfb463b1559ba2ae68b53c5d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 4 Feb 2017 00:06:57 +0100 Subject: [PATCH 0647/1167] linguas: Don't skip ko.po. Translation project doesn't require copyright disclaimers. They're independant from us. They're responsible for their copyright story. --- linguas.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linguas.sh b/linguas.sh index e57f50dc6..b95ad4f7d 100755 --- a/linguas.sh +++ b/linguas.sh @@ -1,6 +1,6 @@ #!/bin/sh -rsync -Lrtvz --exclude=ko.po translationproject.org::tp/latest/grub/ po +rsync -Lrtvz translationproject.org::tp/latest/grub/ po autogenerated="en@quot en@hebrew de@hebrew en@cyrillic en@greek en@arabic en@piglatin de_CH" From 8a96fc409373fffda99e18a8438ddfc6bb787bc8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 7 Feb 2017 00:42:43 +0100 Subject: [PATCH 0648/1167] xen: Fix handling of GRUB chainloading. In case of GRUB we put remapper after domain pages and not at 0x0. In this case we use max_addr to put remapper. Unfortunately we increment max_addr as well in this case resulting in virt mapping mapping page at old max_addr and trying to boot using new max_addr. Closes 46014. --- grub-core/loader/i386/xen.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 51d1ddd37..3073f64d5 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -419,8 +419,6 @@ grub_xen_pt_alloc (void) try_virt_end = ALIGN_UP (xen_state.xen_inf.virt_base + page2offset (nr_need_pages) + ADDITIONAL_SIZE + STACK_SIZE, ALIGN_SIZE); - if (!xen_state.xen_inf.virt_base) - try_virt_end += PAGE_SIZE; err = get_pgtable_size (xen_state.xen_inf.virt_base, try_virt_end, nr_info_pages); @@ -433,7 +431,7 @@ grub_xen_pt_alloc (void) if (xen_state.xen_inf.virt_base) err = get_pgtable_size (0, PAGE_SIZE, nr_need_pages); else - err = get_pgtable_size (try_virt_end - PAGE_SIZE, try_virt_end, + err = get_pgtable_size (try_virt_end, try_virt_end + PAGE_SIZE, nr_need_pages); if (err) return err; From 529818738fb2aafb05721830dc99cc6c8736a048 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 7 Feb 2017 00:47:23 +0100 Subject: [PATCH 0649/1167] xen: Fix parsing of XZ kernel. In case of xz, the uncompressed size is appended to xz data which confuses our xz decompressor. Trim it. --- grub-core/loader/i386/xen_file.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 37f9ad8ac..99fad4cad 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -20,12 +20,16 @@ #include #include +#define XZ_MAGIC "\3757zXZ\0" + grub_elf_t grub_xen_file (grub_file_t file) { grub_elf_t elf; struct linux_kernel_header lh; grub_file_t off_file; + grub_uint32_t payload_offset, payload_length; + grub_uint8_t magic[6]; elf = grub_elf_file (file, file->name); if (elf) @@ -46,20 +50,36 @@ grub_xen_file (grub_file_t file) return NULL; } - if (lh.payload_length < 4) + payload_length = lh.payload_length; + payload_offset = (lh.setup_sects + 1) * 512 + + lh.payload_offset; + + if (payload_length < sizeof (magic)) { grub_error (GRUB_ERR_BAD_OS, "payload too short"); return NULL; } grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", - (unsigned long long) (lh.setup_sects + 1) * 512 - + lh.payload_offset, + (unsigned long long) payload_offset, (unsigned long long) lh.payload_length); - off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512 - + lh.payload_offset, - lh.payload_length); + grub_file_seek (file, payload_offset); + + if (grub_file_read (file, &magic, sizeof (magic)) != sizeof (magic)) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + file->name); + goto fail; + } + + /* Kernel suffixes xz payload with their uncompressed size. + Trim it. */ + if (grub_memcmp (magic, XZ_MAGIC, sizeof (XZ_MAGIC) - 1) == 0) + payload_length -= 4; + off_file = grub_file_offset_open (file, payload_offset, + payload_length); if (!off_file) goto fail; From 2fb8cd26a90be74643bcb4bc39da01f84fecb1a9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 12 Feb 2017 09:23:34 +0300 Subject: [PATCH 0650/1167] script: fix double free in lexer yylex_destroy() already frees scanner. Found by: Coverity scan. CID: 176636 --- grub-core/script/lexer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c index 89cf67706..c6bd3172f 100644 --- a/grub-core/script/lexer.c +++ b/grub-core/script/lexer.c @@ -251,7 +251,6 @@ grub_script_lexer_init (struct grub_parser_param *parser, char *script, { parser->lexerstate = 0; yylex_destroy (lexerstate->yyscanner); - grub_free (lexerstate->yyscanner); grub_free (lexerstate->text); grub_free (lexerstate); return 0; From 512bb31cbc80db22d6071b72a645e75f81c70291 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Feb 2017 09:55:51 +0100 Subject: [PATCH 0651/1167] Whitelist sparc64-ieee1275 as having no video modules. ieee1275_fb is not built on sparc64 due to virtual address issues. --- util/grub-module-verifier.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index d0cf8176f..9179285a5 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -129,6 +129,7 @@ struct platform_whitelist { static struct platform_whitelist whitelists[] = { {"i386", "xen", (const char *[]) {"all_video", 0}}, {"x86_64", "xen", (const char *[]) {"all_video", 0}}, + {"sparc64", "ieee1275", (const char *[]) {"all_video", 0}}, /* video is compiled-in on MIPS. */ {"mipsel", "loongson", (const char *[]) {"all_video", 0}}, From 951306c5094d2bfb46d5baedfde84a2015c4a3fa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 24 Feb 2017 19:10:43 +0300 Subject: [PATCH 0652/1167] squash4: fix handling of fragments and sparse files 1. Do not assume block list and fragment are mutually exclusive. Squash can pack file tail as fragment (unless -no-fragments is specified); so check read offset and read either from block list or from fragments as appropriate. 2. Support sparse files with zero blocks. 3. Fix fragment read - frag.offset is absolute fragment position, not offset relative to ino.chunk. Reported and tested by Carlo Caione --- grub-core/fs/squash4.c | 57 +++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c index b97b34440..2c967c65a 100644 --- a/grub-core/fs/squash4.c +++ b/grub-core/fs/squash4.c @@ -823,7 +823,12 @@ direct_read (struct grub_squash_data *data, curread = data->blksz - boff; if (curread > len) curread = len; - if (!(ino->block_sizes[i] + if (!ino->block_sizes[i]) + { + /* Sparse block */ + grub_memset (buf, '\0', curread); + } + else if (!(ino->block_sizes[i] & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED))) { char *block; @@ -873,36 +878,57 @@ direct_read (struct grub_squash_data *data, static grub_ssize_t -grub_squash_read_data (struct grub_squash_data *data, - struct grub_squash_cache_inode *ino, - grub_off_t off, char *buf, grub_size_t len) +grub_squash_read (grub_file_t file, char *buf, grub_size_t len) { + struct grub_squash_data *data = file->data; + struct grub_squash_cache_inode *ino = &data->ino; + grub_off_t off = file->offset; grub_err_t err; - grub_uint64_t a = 0, b; + grub_uint64_t a, b; grub_uint32_t fragment = 0; int compressed = 0; struct grub_squash_frag_desc frag; + grub_off_t direct_len; + grub_uint64_t mask = grub_le_to_cpu32 (data->sb.block_size) - 1; + grub_size_t orig_len = len; switch (ino->ino.type) { case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR): - a = grub_le_to_cpu64 (ino->ino.long_file.chunk); fragment = grub_le_to_cpu32 (ino->ino.long_file.fragment); break; case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR): - a = grub_le_to_cpu32 (ino->ino.file.chunk); fragment = grub_le_to_cpu32 (ino->ino.file.fragment); break; } - if (fragment == 0xffffffff) - return direct_read (data, ino, off, buf, len); + /* Squash may pack file tail as fragment. So read initial part directly and + get tail from fragments */ + direct_len = fragment == 0xffffffff ? file->size : file->size & ~mask; + if (off < direct_len) + { + grub_size_t read_len = direct_len - off; + grub_ssize_t res; + + if (read_len > len) + read_len = len; + res = direct_read (data, ino, off, buf, read_len); + if ((grub_size_t) res != read_len) + return -1; /* FIXME: is short read possible here? */ + len -= read_len; + if (!len) + return read_len; + buf += read_len; + off = 0; + } + else + off -= direct_len; err = read_chunk (data, &frag, sizeof (frag), data->fragments, sizeof (frag) * fragment); if (err) return -1; - a += grub_le_to_cpu64 (frag.offset); + a = grub_le_to_cpu64 (frag.offset); compressed = !(frag.size & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED)); if (ino->ino.type == grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR)) b = grub_le_to_cpu32 (ino->ino.long_file.offset) + off; @@ -943,16 +969,7 @@ grub_squash_read_data (struct grub_squash_data *data, if (err) return -1; } - return len; -} - -static grub_ssize_t -grub_squash_read (grub_file_t file, char *buf, grub_size_t len) -{ - struct grub_squash_data *data = file->data; - - return grub_squash_read_data (data, &data->ino, - file->offset, buf, len); + return orig_len; } static grub_err_t From 892dfbe113d08c18e51d7c27eee5094f3da530ec Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 25 Feb 2017 08:39:38 +0300 Subject: [PATCH 0653/1167] efi: strip off final NULL from File Path in grub_efi_get_filename UEFI 2.6 9.3.6.4 File Path Media Device Path says that Path Name is "A NULL-terminated Path string including directory and file names". Strip final NULL from Path Name in each File Path node when constructing full path. To be on safe side, strip all of them. Fixes failure chainloading grub from grub, when loaded grub truncates image path and does not find its grub.cfg. https://bugzilla.opensuse.org/show_bug.cgi?id=1026344 This was triggered by commit ce95549cc54b5d6f494608a7c390dba3aab4fba7; before it we built Path Name without trailing NULL, and apparently all other bootloaders use single File Path node, thus not exposing this bug. --- grub-core/kern/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index caf9bcc41..d467785fc 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -366,6 +366,9 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) / sizeof (grub_efi_char16_t)); fp = (grub_efi_file_path_device_path_t *) dp; + /* According to EFI spec Path Name is NULL terminated */ + while (len > 0 && fp->path_name[len - 1] == 0) + len--; p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len); } From f34ed1f53c2927fb97799db00c0b732bbcf79e43 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 26 Feb 2017 14:38:04 +0300 Subject: [PATCH 0654/1167] grub-fs-tester: improve squash4 tests 1. Make sure files are not multiple of block size. This will ensure tail packing for squash4 and may also trigger more codes paths in other filesystems. 2. Call mksquashfs with -always-use-fragments to force tail packing. --- tests/util/grub-fs-tester.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index f363d6f6e..2337771a1 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -913,6 +913,9 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + *) BLOCKCNT=5242880;; esac + # Make sure file is not exact multiple of block size. This helps to force + # tail packing in case of squash4. + : $((BLOCKCNT--)) case x"$fs" in x"ntfscomp") setfattr -h -v 0x00000800 -n system.ntfs_attrib_be "$MNTPOINTRW/$OSDIR";; @@ -998,8 +1001,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + x"romfs") genromfs -V "$FSLABEL" -f "${FSIMAGES[0]}" -d "$MASTER" ;; xsquash4_*) - echo mksquashfs "$MASTER" "${FSIMAGES[0]}" -comp "${fs/squash4_/}" -b $BLKSIZE - mksquashfs "$MASTER" "${FSIMAGES[0]}" -comp "${fs/squash4_/}" -b $BLKSIZE ;; + echo mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE + mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE ;; x"bfs") sleep 1 fusermount -u "$MNTPOINTRW" From 641bb15fa4b9fd3a3948d8dcd4d28b5a35258828 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Feb 2017 21:23:09 +0000 Subject: [PATCH 0655/1167] legacy_initrd: Strip any additional arguments to initrd. --- grub-core/commands/legacycfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index dd9d9f18f..b32f3c74c 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)), #endif ); - return cmd->func (cmd, argc, args); + return cmd->func (cmd, argc ? 1 : 0, args); } if (kernel_type == MULTIBOOT) { From fb93c75bdd10c0791522baa0cfff1bed9edc8745 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 9 Feb 2017 02:22:24 +0100 Subject: [PATCH 0656/1167] video_fb: Fix blue collor if using unoptimized blitter. when unmapping the color what matters is the mode of source, not target. --- grub-core/video/fb/video_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c index 722bb3bb4..1a602c8b2 100644 --- a/grub-core/video/fb/video_fb.c +++ b/grub-core/video/fb/video_fb.c @@ -743,7 +743,7 @@ grub_video_fb_unmap_color_int (struct grub_video_fbblit_info * source, if ((mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) { - if ((framebuffer.render_target->mode_info.mode_type + if ((mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_ALPHA) != 0 && color == 0xf0) { From bcf3c55531349dfec135cad9bf359960214dd0f6 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 5 Mar 2017 10:04:07 +0100 Subject: [PATCH 0657/1167] xen: Fix wrong register in relocator. This fixes chainloading of some GRUB variants. --- grub-core/lib/i386/xen/relocator.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/i386/xen/relocator.S b/grub-core/lib/i386/xen/relocator.S index f1c729e8c..96e51b59a 100644 --- a/grub-core/lib/i386/xen/relocator.S +++ b/grub-core/lib/i386/xen/relocator.S @@ -128,7 +128,7 @@ VARIABLE(grub_relocator_xen_start) VARIABLE(grub_relocator_xen_remapper_virt2) .long 0 - movl %eax, %edi + movl %eax, %ebx xorl %ecx, %ecx /* Invalid pte */ xorl %edx, %edx From c42cb97f0881a927b5039d830d1d007f2eaa5b50 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 14 Mar 2017 04:12:32 +0000 Subject: [PATCH 0658/1167] efi: skip iPXE block device. iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices. We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ... Closes: 50518 --- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b79f7bbc..e66b35d87 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -80,6 +80,15 @@ make_devices (void) /* This should not happen... Why? */ continue; + /* iPXE adds stub Block IO protocol to loaded image device handle. It is + completely non-functional and simply returns an error for every method. + So attempt to detect and skip it. Magic number is literal "iPXE" and + check block size as well */ + /* FIXME: shoud we close it? We do not do it elsewhere */ + if (bio->media && bio->media->media_id == 0x69505845U && + bio->media->block_size == 1) + continue; + d = grub_malloc (sizeof (*d)); if (! d) { From fcea891e17dc8b14887aa2a08fe735128243faf9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 15 Mar 2017 09:20:14 +0100 Subject: [PATCH 0659/1167] Use core2duo for bootcheck test on 64-bit EFI. Obviously pentium2 can't run efi64. --- Makefile.am | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 3c00f8539..7795baeb6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -145,30 +145,37 @@ if COND_real_platform if COND_i386_coreboot QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_i386_multiboot QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_i386_ieee1275 QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_i386_qemu QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_i386_pc QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_i386_efi QEMU32=qemu-system-i386 +MINIMUM_CPU_LINUX=pentium2 endif if COND_x86_64_efi QEMU32=qemu-system-x86_64 +MINIMUM_CPU_LINUX=core2duo endif linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S @@ -306,7 +313,7 @@ bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(GRUB_PAYLOADS_DIR)/ ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/grub-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null bootcheck-linux-i386: linux-initramfs.i386 $(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell - ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg --qemu-opts="-cpu pentium2" | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null + ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg --qemu-opts="-cpu $(MINIMUM_CPU_LINUX)" | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null bootcheck-linux-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null From 8014b7b337b708a4599f9e8fc883ad0150cf5c9c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 15 Mar 2017 09:20:29 +0100 Subject: [PATCH 0660/1167] Increment version to GRUB 2.02~rc2. --- configure.ac | 2 +- grub-core/tests/checksums.h | 196 ++++++++++++++++++------------------ 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/configure.ac b/configure.ac index 0893ad60c..acf94b056 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02~rc1],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.02~rc2],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index bbbd3a59f..efa1adb3f 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,101 +1,101 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x68f4102c, 0x68f4102c, 0x4f103fc9, 0x4f103fc9, 0x6c3ed233, 0x6c3ed233, 0x8e49f1d4, 0x8e49f1d4, 0x4d27a5fc, 0x4d27a5fc, 0xce4f426c, 0xce4f426c, 0xb86a2d2d, 0xb86a2d2d, 0x72caeded, 0x72caeded, 0x5db992f4, 0x5db992f4, 0xb6a48a57, 0xb6a48a57, 0x8dd9e06c, 0x8dd9e06c, 0xfd0ab0a, 0xfd0ab0a, 0xf0257d88, 0xf0257d88, 0x375c456d, 0x375c456d, 0x6014146b, 0x6014146b, 0xcc3ce19c, 0xcc3ce19c, 0x6df2c13d, 0x6df2c13d, 0x59c1144b, 0x59c1144b, 0x6800bfb6, 0x6800bfb6, 0xfd03649a, 0xfd03649a, 0x654ce0e7, 0xc0cb058d, 0x9e43683f, 0x9e43683f, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c2c3e3f, 0x3c2c3e3f, 0x58ab5c00, 0x58ab5c00, 0xba896043, 0xba896043, 0x1e741248, 0x1e741248, 0x48a951b9, 0x48a951b9, 0x569f4d77, 0x569f4d77, 0xf4e8d9bb, 0xf4e8d9bb, 0x80843985, 0x80843985, 0xeae3a0fc, 0xeae3a0fc, 0x137e7ccf, 0x137e7ccf, 0x3f786b6b, 0x3f786b6b, 0x3254e051, 0x3254e051, 0x79be1043, 0x79be1043, 0x4e46907d, 0x4e46907d, 0xd5d6468d, 0xd5d6468d, 0xfec2ff8d, 0xfec2ff8d, 0x13083fb4, 0x13083fb4, 0x35893486, 0x35893486, 0x41508e32, 0x41508e32, 0x26a1eda9, 0x26a1eda9, 0xecdf0a59, 0xcc661ad8, 0xc57d6ccb, 0xc57d6ccb, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xeed4e023, 0xeed4e023, 0x3cafae08, 0x3cafae08, 0xdd7de297, 0xdd7de297, 0x50a0a0e1, 0x50a0a0e1, 0x18e36b82, 0x18e36b82, 0xa4bd0ffe, 0xa4bd0ffe, 0xd4e5aafe, 0xd4e5aafe, 0x2c7e25a5, 0x2c7e25a5, 0xda696881, 0xda696881, 0x237832d8, 0x237832d8, 0x49d7771, 0x49d7771, 0xc30d24a4, 0xc30d24a4, 0x6ab4d024, 0x6ab4d024, 0x7deac66, 0x7deac66, 0x7b3aa1c6, 0x7b3aa1c6, 0x56158612, 0x56158612, 0x4fc63f7a, 0x4fc63f7a, 0x2f4f78d3, 0x2f4f78d3, 0xefa4716d, 0xefa4716d, 0xbecdb635, 0xbecdb635, 0x6f7e9245, 0x836b4134, 0x1229d6ae, 0x1229d6ae, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xddd2650a, 0xddd2650a, 0xceae34fe, 0xceae34fe, 0x61a76c62, 0x61a76c62, 0x88cc6ec7, 0x88cc6ec7, 0xbaf35579, 0xbaf35579, 0xea4b7745, 0xea4b7745, 0x49162f54, 0x49162f54, 0x184d7da3, 0x184d7da3, 0x7545c826, 0x7545c826, 0x70bfbc4f, 0x70bfbc4f, 0x4f61a7d3, 0x4f61a7d3, 0xb3896b4c, 0xb3896b4c, 0x3b75eef4, 0x3b75eef4, 0xb5463daa, 0xb5463daa, 0x243b4ada, 0x243b4ada, 0x4a8fb9e5, 0x4a8fb9e5, 0xeadb8947, 0xeadb8947, 0x4c86692c, 0x4c86692c, 0x4476763e, 0x4476763e, 0xc9d73e67, 0xc9d73e67, 0xb2296bd8, 0xb29699fb, 0x45cb8c3f, 0x45cb8c3f, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xca59adfd, 0xca59adfd, 0x3a82282b, 0x3a82282b, 0x2fdaf106, 0x2fdaf106, 0x26e0f01b, 0x26e0f01b, 0xd88ea764, 0xd88ea764, 0x8e3e3c54, 0x8e3e3c54, 0xf55d50f1, 0xf55d50f1, 0xa2c19d40, 0xa2c19d40, 0xc6be108f, 0xc6be108f, 0x643647a8, 0x643647a8, 0x6fd5f2c, 0x6fd5f2c, 0x1c89092d, 0x1c89092d, 0xc6a89fca, 0xc6a89fca, 0x1646a412, 0x1646a412, 0x74040f03, 0x74040f03, 0x4966c71d, 0x4966c71d, 0x3c7d5a3f, 0x3c7d5a3f, 0x9c091b76, 0x9c091b76, 0xfda8a0ea, 0xfda8a0ea, 0x354452fb, 0x354452fb, 0x3bb9e803, 0x55818eb, 0x86299ae9, 0x86299ae9, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xad0b91c2, 0xad0b91c2, 0x5bf8a72, 0x5bf8a72, 0xd705beec, 0xd705beec, 0x63c6ea8a, 0x63c6ea8a, 0xffedeab0, 0xffedeab0, 0xa657405, 0xa657405, 0xd83d606e, 0xd83d606e, 0x821a2a3a, 0x821a2a3a, 0xf2f5748, 0xf2f5748, 0x87bfe341, 0x87bfe341, 0x72f6f59c, 0x72f6f59c, 0xafab44e5, 0xafab44e5, 0x6c912b9a, 0x6c912b9a, 0x862a8810, 0x862a8810, 0x97b21809, 0x97b21809, 0x2763cfca, 0x2763cfca, 0x56464e5e, 0x56464e5e, 0xc44660d3, 0xc44660d3, 0x10984d6b, 0x10984d6b, 0x24eebfae, 0x24eebfae, 0xc8061900, 0x81675254, 0x9e5f3cc9, 0x9e5f3cc9, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x68ab9311, 0x68ab9311, 0xd717f93c, 0xd717f93c, 0x6984620a, 0x6984620a, 0x152b6d0c, 0x152b6d0c, 0x98b8b84a, 0x98b8b84a, 0xa903181e, 0xa903181e, 0x940e10e6, 0x940e10e6, 0x11cd776b, 0x11cd776b, 0x12624a96, 0x12624a96, 0x4d19f358, 0x4d19f358, 0x82985d2b, 0x82985d2b, 0x1afa0bee, 0x1afa0bee, 0x251e884e, 0x251e884e, 0xd0c023cb, 0xd0c023cb, 0x215e23dc, 0x215e23dc, 0x41da92fc, 0x41da92fc, 0x7d8668b2, 0x7d8668b2, 0xe279755b, 0xe279755b, 0x45ab5067, 0x45ab5067, 0xc2245ac1, 0xc2245ac1, 0x260caee1, 0xcbb70716, 0x11b4a337, 0x11b4a337, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa515d1fe, 0xc3da3d7d, 0xa515d1fe, 0xe6e31cb9, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0xe6e31cb9, 0xe6e31cb9, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3bcc8944, 0x9fe60efc, 0x3bcc8944, 0x15c90c3b, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0x15c90c3b, 0x15c90c3b, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4701e2b, 0xbefc41f3, 0x4701e2b, 0x596773af, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0x596773af, 0x596773af, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe0f4cb75, 0x5354c242, 0xe0f4cb75, 0x4ea282ad, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0x4ea282ad, 0x4ea282ad, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x79bd65d, 0x176dcd3c, 0x79bd65d, 0x713de3ee, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x713de3ee, 0x713de3ee, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdaa0c008, 0x8ed864d6, 0xdaa0c008, 0xc1a51a0f, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0xc1a51a0f, 0xc1a51a0f, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xce2d0657, 0x65bcd1ea, 0xce2d0657, 0x31921dd7, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0x31921dd7, 0x31921dd7, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xde5d5c76, 0xde5d5c76, 0xde5d5c76, 0x8285aab6, 0x8285aab6, 0x8285aab6, 0xab1d6424, 0xab1d6424, 0xab1d6424, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xebc08e8, 0xebc08e8, 0xebc08e8, 0x5be3a2e2, 0x5be3a2e2, 0x5be3a2e2, 0x32d06aab, 0x32d06aab, 0x32d06aab, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xb1733229, 0xb1733229, 0xb1733229, 0xcecd94bd, 0xcecd94bd, 0xcecd94bd, 0x8cb9f4c5, 0x8cb9f4c5, 0x8cb9f4c5, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x7400503e, 0x7400503e, 0x7400503e, 0x9fa5ba42, 0x9fa5ba42, 0x9fa5ba42, 0x99eebab2, 0x99eebab2, 0x99eebab2, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x46a2d276, 0x46a2d276, 0x46a2d276, 0x29eb0e67, 0x29eb0e67, 0x29eb0e67, 0x241d9064, 0x241d9064, 0x241d9064, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0xfe89652d, 0xfe89652d, 0xfe89652d, 0x383b2133, 0x383b2133, 0x383b2133, 0x2c5ef18c, 0x2c5ef18c, 0x2c5ef18c, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0xb646d62d, 0xb646d62d, 0xb646d62d, 0x37b520fc, 0x37b520fc, 0x37b520fc, 0xa1119993, 0xa1119993, 0xa1119993, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb59af897, 0xbb7a450f, 0xb59af897, 0xf66c35d0, 0x59c36f00, 0x59c36f00, 0xfb6d6c75, 0xfb6d6c75, 0xfb6d6c75, 0x85ed0113, 0x85ed0113, 0x85ed0113, 0xe71b14c1, 0xe71b14c1, 0xe71b14c1, 0x59c36f00, 0xf66c35d0, 0xf66c35d0, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xcdeaad5f, 0x39f75a73, 0xcdeaad5f, 0xe3ef2820, 0xaa4593fe, 0xaa4593fe, 0x3b858d67, 0x3b858d67, 0x3b858d67, 0x9d708000, 0x9d708000, 0x9d708000, 0xb0482b78, 0xb0482b78, 0xb0482b78, 0xaa4593fe, 0xe3ef2820, 0xe3ef2820, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xbfc1cc02, 0xad4d778f, 0xbfc1cc02, 0xe2d6a186, 0xc9cbf769, 0xc9cbf769, 0xd3fd5934, 0xd3fd5934, 0xd3fd5934, 0x2d2598f8, 0x2d2598f8, 0x2d2598f8, 0xc46f27f0, 0xc46f27f0, 0xc46f27f0, 0xc9cbf769, 0xe2d6a186, 0xe2d6a186, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb4e8961f, 0xa9d9245e, 0xb4e8961f, 0x1abedfc7, 0x9813a416, 0x9813a416, 0x75ea5f6b, 0x75ea5f6b, 0x75ea5f6b, 0xe431d958, 0xe431d958, 0xe431d958, 0xfd8be488, 0xfd8be488, 0xfd8be488, 0x9813a416, 0x1abedfc7, 0x1abedfc7, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xfba9cd4c, 0x3accc3ed, 0xfba9cd4c, 0x8d0ff8ff, 0x5fcf013d, 0x5fcf013d, 0x12029d40, 0x12029d40, 0x12029d40, 0xc0128536, 0xc0128536, 0xc0128536, 0xd661baa9, 0xd661baa9, 0xd661baa9, 0x5fcf013d, 0x8d0ff8ff, 0x8d0ff8ff, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9afaa18d, 0x5505c090, 0x9afaa18d, 0x81ff7b8a, 0xdd28f52b, 0xdd28f52b, 0xd4c281cf, 0xd4c281cf, 0xd4c281cf, 0xf5fe782b, 0xf5fe782b, 0xf5fe782b, 0x8846b3a7, 0x8846b3a7, 0x8846b3a7, 0xdd28f52b, 0x81ff7b8a, 0x81ff7b8a, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3af16e43, 0x4b4ee85f, 0x3af16e43, 0xc54e75c3, 0x43d1f34, 0x43d1f34, 0x6a0313f3, 0x6a0313f3, 0x6a0313f3, 0x1509ba5b, 0x1509ba5b, 0x1509ba5b, 0x8c58bfdd, 0x8c58bfdd, 0x8c58bfdd, 0x43d1f34, 0xc54e75c3, 0xc54e75c3, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x49a25e74, 0x3193ac92, 0x49a25e74, 0xa549333, 0x59c36f00, 0x59c36f00, 0xdc6419f, 0xdc6419f, 0xdc6419f, 0x73462cf9, 0x73462cf9, 0x73462cf9, 0x11b0392b, 0x11b0392b, 0x11b0392b, 0x59c36f00, 0xa549333, 0xa549333, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x6485919, 0xa5fc2915, 0x6485919, 0x284ddc66, 0xaa4593fe, 0xaa4593fe, 0x6b2dd2e2, 0x6b2dd2e2, 0x6b2dd2e2, 0xcdd8df85, 0xcdd8df85, 0xcdd8df85, 0xe0e074fd, 0xe0e074fd, 0xe0e074fd, 0xaa4593fe, 0x284ddc66, 0x284ddc66, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5b7d7c45, 0xf9b8baf8, 0x5b7d7c45, 0x66a11c1, 0xc9cbf769, 0xc9cbf769, 0x57d5ac1f, 0x57d5ac1f, 0x57d5ac1f, 0xa90d6dd3, 0xa90d6dd3, 0xa90d6dd3, 0x4047d2db, 0x4047d2db, 0x4047d2db, 0xc9cbf769, 0x66a11c1, 0x66a11c1, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6fd2a74d, 0x41fe4726, 0x6fd2a74d, 0xc184ee95, 0x9813a416, 0x9813a416, 0xa132a122, 0xa132a122, 0xa132a122, 0x30e92711, 0x30e92711, 0x30e92711, 0x29531ac1, 0x29531ac1, 0x29531ac1, 0x9813a416, 0xc184ee95, 0xc184ee95, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x69685505, 0xf2c0e268, 0x69685505, 0x1fce60b6, 0x5fcf013d, 0x5fcf013d, 0xd61aeb01, 0xd61aeb01, 0xd61aeb01, 0x40af377, 0x40af377, 0x40af377, 0x1279cce8, 0x1279cce8, 0x1279cce8, 0x5fcf013d, 0x1fce60b6, 0x1fce60b6, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xee7e1be9, 0x7069217c, 0xee7e1be9, 0xf57bc1ee, 0xdd28f52b, 0xdd28f52b, 0x77d02fa2, 0x77d02fa2, 0x77d02fa2, 0x56ecd646, 0x56ecd646, 0x56ecd646, 0x2b541dca, 0x2b541dca, 0x2b541dca, 0xdd28f52b, 0xf57bc1ee, 0xf57bc1ee, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb5b4521a, 0xf7c443ce, 0xb5b4521a, 0x4a0b499a, 0x43d1f34, 0x43d1f34, 0xd019cfce, 0xd019cfce, 0xd019cfce, 0xaf136666, 0xaf136666, 0xaf136666, 0x364263e0, 0x364263e0, 0x364263e0, 0x43d1f34, 0x4a0b499a, 0x4a0b499a, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x9bdad73f, 0x990f581e, 0x9bdad73f, 0xd82c1a78, 0x59c36f00, 0x59c36f00, 0x663aaa6f, 0x663aaa6f, 0x663aaa6f, 0x18bac709, 0x18bac709, 0x18bac709, 0x7a4cd2db, 0x7a4cd2db, 0x7a4cd2db, 0x59c36f00, 0xd82c1a78, 0xd82c1a78, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf835ac2, 0xbcd50661, 0xf835ac2, 0x2186dfbd, 0xaa4593fe, 0xaa4593fe, 0x1f1997c1, 0x1f1997c1, 0x1f1997c1, 0xb9ec9aa6, 0xb9ec9aa6, 0xb9ec9aa6, 0x94d431de, 0x94d431de, 0x94d431de, 0xaa4593fe, 0x2186dfbd, 0x2186dfbd, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa3d7300f, 0x12739a74, 0xa3d7300f, 0xfec05d8b, 0xc9cbf769, 0xc9cbf769, 0x93dd5635, 0x93dd5635, 0x93dd5635, 0x6d0597f9, 0x6d0597f9, 0x6d0597f9, 0x844f28f1, 0x844f28f1, 0x844f28f1, 0xc9cbf769, 0xfec05d8b, 0xfec05d8b, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x32d637b0, 0xc677639b, 0x32d637b0, 0x9c807e68, 0x9813a416, 0x9813a416, 0xa1b8fcf1, 0xa1b8fcf1, 0xa1b8fcf1, 0x30637ac2, 0x30637ac2, 0x30637ac2, 0x29d94712, 0x29d94712, 0x29d94712, 0x9813a416, 0x9c807e68, 0x9c807e68, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3ec3528b, 0x1e1c878d, 0x3ec3528b, 0x48656738, 0x5fcf013d, 0x5fcf013d, 0x3510cd00, 0x3510cd00, 0x3510cd00, 0xe700d576, 0xe700d576, 0xe700d576, 0xf173eae9, 0xf173eae9, 0xf173eae9, 0x5fcf013d, 0x48656738, 0x48656738, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x50bc4d38, 0x6725a657, 0x50bc4d38, 0x4bb9973f, 0xdd28f52b, 0xdd28f52b, 0x66f52001, 0x66f52001, 0x66f52001, 0x47c9d9e5, 0x47c9d9e5, 0x47c9d9e5, 0x3a711269, 0x3a711269, 0x3a711269, 0xdd28f52b, 0x4bb9973f, 0x4bb9973f, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc481102d, 0xe22cdb5f, 0xc481102d, 0x3b3e0bad, 0x43d1f34, 0x43d1f34, 0xaf0df118, 0xaf0df118, 0xaf0df118, 0xd00758b0, 0xd00758b0, 0xd00758b0, 0x49565d36, 0x49565d36, 0x49565d36, 0x43d1f34, 0x3b3e0bad, 0x3b3e0bad, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd24e2c02, 0x6e0b3e38, 0xd24e2c02, 0x91b8e145, 0x59c36f00, 0x59c36f00, 0xf6d94324, 0xf6d94324, 0xf6d94324, 0x88592e42, 0x88592e42, 0x88592e42, 0xeaaf3b90, 0xeaaf3b90, 0xeaaf3b90, 0x59c36f00, 0x91b8e145, 0x91b8e145, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x48c95a99, 0xbef981b4, 0x48c95a99, 0x66ccdfe6, 0xaa4593fe, 0xaa4593fe, 0x69f632fe, 0x69f632fe, 0x69f632fe, 0xcf033f99, 0xcf033f99, 0xcf033f99, 0xe23b94e1, 0xe23b94e1, 0xe23b94e1, 0xaa4593fe, 0x66ccdfe6, 0x66ccdfe6, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdf5958ac, 0x6c53ca72, 0xdf5958ac, 0x824e3528, 0xc9cbf769, 0xc9cbf769, 0x7872f95f, 0x7872f95f, 0x7872f95f, 0x86aa3893, 0x86aa3893, 0x86aa3893, 0x6fe0879b, 0x6fe0879b, 0x6fe0879b, 0xc9cbf769, 0x824e3528, 0x824e3528, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e4e65e4, 0x3b08ec97, 0x4e4e65e4, 0xe0182c3c, 0x9813a416, 0x9813a416, 0xd87a3bca, 0xd87a3bca, 0xd87a3bca, 0x49a1bdf9, 0x49a1bdf9, 0x49a1bdf9, 0x501b8029, 0x501b8029, 0x501b8029, 0x9813a416, 0xe0182c3c, 0xe0182c3c, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa9051255, 0xcbaf6881, 0xa9051255, 0xdfa327e6, 0x5fcf013d, 0x5fcf013d, 0xdc53ce4e, 0xdc53ce4e, 0xdc53ce4e, 0xe43d638, 0xe43d638, 0xe43d638, 0x1830e9a7, 0x1830e9a7, 0x1830e9a7, 0x5fcf013d, 0xdfa327e6, 0xdfa327e6, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc3280b45, 0xea85a953, 0xc3280b45, 0xd82dd142, 0xdd28f52b, 0xdd28f52b, 0x4f22c62f, 0x4f22c62f, 0x4f22c62f, 0x6e1e3fcb, 0x6e1e3fcb, 0x6e1e3fcb, 0x13a6f447, 0x13a6f447, 0x13a6f447, 0xdd28f52b, 0xd82dd142, 0xd82dd142, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x93f5ee2e, 0x28dc3016, 0x93f5ee2e, 0x6c4af5ae, 0x43d1f34, 0x43d1f34, 0x2e9a92cb, 0x2e9a92cb, 0x2e9a92cb, 0x51903b63, 0x51903b63, 0x51903b63, 0xc8c13ee5, 0xc8c13ee5, 0xc8c13ee5, 0x43d1f34, 0x6c4af5ae, 0x6c4af5ae, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24539267, 0x1ce59afc, 0x24539267, 0x67a55f20, 0x59c36f00, 0x59c36f00, 0xee51a3ff, 0xee51a3ff, 0xee51a3ff, 0x90d1ce99, 0x90d1ce99, 0x90d1ce99, 0xf227db4b, 0xf227db4b, 0xf227db4b, 0x59c36f00, 0x67a55f20, 0x67a55f20, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7cb69e26, 0xa3f6f06f, 0x7cb69e26, 0x52b31b59, 0xaa4593fe, 0xaa4593fe, 0x2f6d12b5, 0x2f6d12b5, 0x2f6d12b5, 0x89981fd2, 0x89981fd2, 0x89981fd2, 0xa4a0b4aa, 0xa4a0b4aa, 0xa4a0b4aa, 0xaa4593fe, 0x52b31b59, 0x52b31b59, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e0eb3da, 0xb0939199, 0x9e0eb3da, 0xc319de5e, 0xc9cbf769, 0xc9cbf769, 0xc9c28f3b, 0xc9c28f3b, 0xc9c28f3b, 0x371a4ef7, 0x371a4ef7, 0x371a4ef7, 0xde50f1ff, 0xde50f1ff, 0xde50f1ff, 0xc9cbf769, 0xc319de5e, 0xc319de5e, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2bd305d0, 0x593ac70d, 0x2bd305d0, 0x85854c08, 0x9813a416, 0x9813a416, 0xd6c41d1f, 0xd6c41d1f, 0xd6c41d1f, 0x471f9b2c, 0x471f9b2c, 0x471f9b2c, 0x5ea5a6fc, 0x5ea5a6fc, 0x5ea5a6fc, 0x9813a416, 0x85854c08, 0x85854c08, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd554b2a6, 0xfcb62ffa, 0xd554b2a6, 0xa3f28715, 0x5fcf013d, 0x5fcf013d, 0x49663ae2, 0x49663ae2, 0x49663ae2, 0x9b762294, 0x9b762294, 0x9b762294, 0x8d051d0b, 0x8d051d0b, 0x8d051d0b, 0x5fcf013d, 0xa3f28715, 0xa3f28715, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcb4a441b, 0x47bfd292, 0xcb4a441b, 0xd04f9e1c, 0xdd28f52b, 0xdd28f52b, 0x1c62c4cf, 0x1c62c4cf, 0x1c62c4cf, 0x3d5e3d2b, 0x3d5e3d2b, 0x3d5e3d2b, 0x40e6f6a7, 0x40e6f6a7, 0x40e6f6a7, 0xdd28f52b, 0xd04f9e1c, 0xd04f9e1c, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84489cd2, 0x3b86feab, 0x84489cd2, 0x7bf78752, 0x43d1f34, 0x43d1f34, 0xeb4b4093, 0xeb4b4093, 0xeb4b4093, 0x9441e93b, 0x9441e93b, 0x9441e93b, 0xd10ecbd, 0xd10ecbd, 0xd10ecbd, 0x43d1f34, 0x7bf78752, 0x7bf78752, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdac60224, 0xf1212716, 0xdac60224, 0x9930cf63, 0x59c36f00, 0x59c36f00, 0xd83aedef, 0xd83aedef, 0xd83aedef, 0xa6ba8089, 0xa6ba8089, 0xa6ba8089, 0xc44c955b, 0xc44c955b, 0xc44c955b, 0x59c36f00, 0x9930cf63, 0x9930cf63, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xddb471d2, 0x2a23e66b, 0xddb471d2, 0xf3b1f4ad, 0xaa4593fe, 0xaa4593fe, 0x44e1ed3b, 0x44e1ed3b, 0x44e1ed3b, 0xe214e05c, 0xe214e05c, 0xe214e05c, 0xcf2c4b24, 0xcf2c4b24, 0xcf2c4b24, 0xaa4593fe, 0xf3b1f4ad, 0xf3b1f4ad, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd3319fed, 0x4fb7eab2, 0xd3319fed, 0x8e26f269, 0xc9cbf769, 0xc9cbf769, 0xb45d8a1a, 0xb45d8a1a, 0xb45d8a1a, 0x4a854bd6, 0x4a854bd6, 0x4a854bd6, 0xa3cff4de, 0xa3cff4de, 0xa3cff4de, 0xc9cbf769, 0x8e26f269, 0x8e26f269, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x73fb17c5, 0x379bd3f4, 0x73fb17c5, 0xddad5e1d, 0x9813a416, 0x9813a416, 0xbd332cdb, 0xbd332cdb, 0xbd332cdb, 0x2ce8aae8, 0x2ce8aae8, 0x2ce8aae8, 0x35529738, 0x35529738, 0x35529738, 0x9813a416, 0xddad5e1d, 0xddad5e1d, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbb670d35, 0x672cb790, 0xbb670d35, 0xcdc13886, 0x5fcf013d, 0x5fcf013d, 0x14e80d5a, 0x14e80d5a, 0x14e80d5a, 0xc6f8152c, 0xc6f8152c, 0xc6f8152c, 0xd08b2ab3, 0xd08b2ab3, 0xd08b2ab3, 0x5fcf013d, 0xcdc13886, 0xcdc13886, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd2d29462, 0xf9dbf485, 0xd2d29462, 0xc9d74e65, 0xdd28f52b, 0xdd28f52b, 0x92d1dcce, 0x92d1dcce, 0x92d1dcce, 0xb3ed252a, 0xb3ed252a, 0xb3ed252a, 0xce55eea6, 0xce55eea6, 0xce55eea6, 0xdd28f52b, 0xc9d74e65, 0xc9d74e65, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x65d2aa3c, 0xa00491c3, 0x65d2aa3c, 0x9a6db1bc, 0x43d1f34, 0x43d1f34, 0x33df64a1, 0x33df64a1, 0x33df64a1, 0x4cd5cd09, 0x4cd5cd09, 0x4cd5cd09, 0xd584c88f, 0xd584c88f, 0xd584c88f, 0x43d1f34, 0x9a6db1bc, 0x9a6db1bc, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x19f4b551, 0x7f3b59d2, 0x19f4b551, 0x5a027816, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0x5a027816, 0x5a027816, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x82acacc0, 0x26862b78, 0x82acacc0, 0xaca929bf, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0xaca929bf, 0xaca929bf, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8418ee7d, 0x3e94b1a5, 0x8418ee7d, 0xd90f83f9, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0xd90f83f9, 0xd90f83f9, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x55d57857, 0xe6757160, 0x55d57857, 0xfb83318f, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0xfb83318f, 0xfb83318f, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x45b838a5, 0x554e23c4, 0x45b838a5, 0x331e0d16, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x331e0d16, 0x331e0d16, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4e904177, 0x1ae8e5a9, 0x4e904177, 0x55959b70, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0x55959b70, 0x55959b70, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x83e5445a, 0x287493e7, 0x83e5445a, 0x7c5a5fda, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0x7c5a5fda, 0x7c5a5fda, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x43eebd9e, 0xc5e097a, 0x43eebd9e, 0x1870d9, 0x59c36f00, 0x59c36f00, 0x90b8be2f, 0x90b8be2f, 0x90b8be2f, 0xee38d349, 0xee38d349, 0xee38d349, 0x8ccec69b, 0x8ccec69b, 0x8ccec69b, 0x59c36f00, 0x1870d9, 0x1870d9, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd16e76b1, 0xd80a42d2, 0xd16e76b1, 0xff6bf3ce, 0xaa4593fe, 0xaa4593fe, 0xe8b201a3, 0xe8b201a3, 0xe8b201a3, 0x4e470cc4, 0x4e470cc4, 0x4e470cc4, 0x637fa7bc, 0x637fa7bc, 0x637fa7bc, 0xaa4593fe, 0xff6bf3ce, 0xff6bf3ce, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x46c9c0b6, 0x879836ab, 0x46c9c0b6, 0x1bdead32, 0xc9cbf769, 0xc9cbf769, 0x7f3bf79a, 0x7f3bf79a, 0x7f3bf79a, 0x81e33656, 0x81e33656, 0x81e33656, 0x68a9895e, 0x68a9895e, 0x68a9895e, 0xc9cbf769, 0x1bdead32, 0x1bdead32, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbedd413, 0x570f7ebf, 0xbedd413, 0xa5bb9dcb, 0x9813a416, 0x9813a416, 0x30f35812, 0x30f35812, 0x30f35812, 0xa128de21, 0xa128de21, 0xa128de21, 0xb892e3f1, 0xb892e3f1, 0xb892e3f1, 0x9813a416, 0xa5bb9dcb, 0xa5bb9dcb, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x76ec4315, 0xffca72c, 0x76ec4315, 0x4a76a6, 0x5fcf013d, 0x5fcf013d, 0x7b237d7d, 0x7b237d7d, 0x7b237d7d, 0xa933650b, 0xa933650b, 0xa933650b, 0xbf405a94, 0xbf405a94, 0xbf405a94, 0x5fcf013d, 0x4a76a6, 0x4a76a6, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x75cfd768, 0x1fb76756, 0x75cfd768, 0x6eca0d6f, 0xdd28f52b, 0xdd28f52b, 0xa0ff4b91, 0xa0ff4b91, 0xa0ff4b91, 0x81c3b275, 0x81c3b275, 0x81c3b275, 0xfc7b79f9, 0xfc7b79f9, 0xfc7b79f9, 0xdd28f52b, 0x6eca0d6f, 0x6eca0d6f, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd5cf1813, 0x2659463a, 0xd5cf1813, 0x2a700393, 0x43d1f34, 0x43d1f34, 0x850afb92, 0x850afb92, 0x850afb92, 0xfa00523a, 0xfa00523a, 0xfa00523a, 0x635157bc, 0x635157bc, 0x635157bc, 0x43d1f34, 0x2a700393, 0x2a700393, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5d323c44, 0x6f401130, 0x5d323c44, 0x1ec4f103, 0x59c36f00, 0x59c36f00, 0x68eced5a, 0x68eced5a, 0x68eced5a, 0x166c803c, 0x166c803c, 0x166c803c, 0x749a95ee, 0x749a95ee, 0x749a95ee, 0x59c36f00, 0x1ec4f103, 0x1ec4f103, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x984941ed, 0xbbac7b68, 0x984941ed, 0xb64cc492, 0xaa4593fe, 0xaa4593fe, 0x4082ddcb, 0x4082ddcb, 0x4082ddcb, 0xe677d0ac, 0xe677d0ac, 0xe677d0ac, 0xcb4f7bd4, 0xcb4f7bd4, 0xcb4f7bd4, 0xaa4593fe, 0xb64cc492, 0xb64cc492, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb6d3d3b9, 0x80de2a76, 0xb6d3d3b9, 0xebc4be3d, 0xc9cbf769, 0xc9cbf769, 0xea0ec457, 0xea0ec457, 0xea0ec457, 0x14d6059b, 0x14d6059b, 0x14d6059b, 0xfd9cba93, 0xfd9cba93, 0xfd9cba93, 0xc9cbf769, 0xebc4be3d, 0xebc4be3d, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4733985d, 0xd2f2adf1, 0x4733985d, 0xe965d185, 0x9813a416, 0x9813a416, 0xa2feabe5, 0xa2feabe5, 0xa2feabe5, 0x33252dd6, 0x33252dd6, 0x33252dd6, 0x2a9f1006, 0x2a9f1006, 0x2a9f1006, 0x9813a416, 0xe965d185, 0xe965d185, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x939ea364, 0x446d09d7, 0x939ea364, 0xe53896d7, 0x5fcf013d, 0x5fcf013d, 0x39f5030f, 0x39f5030f, 0x39f5030f, 0xebe51b79, 0xebe51b79, 0xebe51b79, 0xfd9624e6, 0xfd9624e6, 0xfd9624e6, 0x5fcf013d, 0xe53896d7, 0xe53896d7, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x63d43704, 0xfc83811b, 0x63d43704, 0x78d1ed03, 0xdd28f52b, 0xdd28f52b, 0x9835fc4a, 0x9835fc4a, 0x9835fc4a, 0xb90905ae, 0xb90905ae, 0xb90905ae, 0xc4b1ce22, 0xc4b1ce22, 0xc4b1ce22, 0xdd28f52b, 0x78d1ed03, 0x78d1ed03, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfc47195d, 0xa0c62a2e, 0xfc47195d, 0x3f802dd, 0x43d1f34, 0x43d1f34, 0x8e86b971, 0x8e86b971, 0x8e86b971, 0xf18c10d9, 0xf18c10d9, 0xf18c10d9, 0x68dd155f, 0x68dd155f, 0x68dd155f, 0x43d1f34, 0x3f802dd, 0x3f802dd, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc3dd7b3, 0x6af23b30, 0xc3dd7b3, 0x5b10696d, 0x59c36f00, 0x59c36f00, 0xf6ddaf81, 0xf6ddaf81, 0xf6ddaf81, 0x885dc2e7, 0x885dc2e7, 0x885dc2e7, 0xeaabd735, 0xeaabd735, 0xeaabd735, 0x59c36f00, 0x5b10696d, 0x5b10696d, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x28fe03b3, 0x8cd4840b, 0x28fe03b3, 0x9859d9e5, 0xaa4593fe, 0xaa4593fe, 0x1af5874a, 0x1af5874a, 0x1af5874a, 0xbc008a2d, 0xbc008a2d, 0xbc008a2d, 0x91382155, 0x91382155, 0x91382155, 0xaa4593fe, 0x9859d9e5, 0x9859d9e5, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2d13f9b, 0xb85d6043, 0x2d13f9b, 0x12f42135, 0xc9cbf769, 0xc9cbf769, 0x11cfa191, 0x11cfa191, 0x11cfa191, 0xef17605d, 0xef17605d, 0xef17605d, 0x65ddf55, 0x65ddf55, 0x65ddf55, 0xc9cbf769, 0x12f42135, 0x12f42135, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6c62d67b, 0xdfc2df4c, 0x6c62d67b, 0x5c132a54, 0x9813a416, 0x9813a416, 0x7e455ca7, 0x7e455ca7, 0x7e455ca7, 0xef9eda94, 0xef9eda94, 0xef9eda94, 0xf624e744, 0xf624e744, 0xf624e744, 0x9813a416, 0x5c132a54, 0x5c132a54, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc94f31d, 0xac62e87c, 0xbc94f31d, 0x12931ce8, 0x5fcf013d, 0x5fcf013d, 0x11dc48b3, 0x11dc48b3, 0x11dc48b3, 0xc3cc50c5, 0xc3cc50c5, 0xc3cc50c5, 0xd5bf6f5a, 0xd5bf6f5a, 0xd5bf6f5a, 0x5fcf013d, 0x12931ce8, 0x12931ce8, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46cc571d, 0x12b4f3c3, 0x46cc571d, 0xc8a89cc7, 0xdd28f52b, 0xdd28f52b, 0xa242e6a5, 0xa242e6a5, 0xa242e6a5, 0x837e1f41, 0x837e1f41, 0x837e1f41, 0xfec6d4cd, 0xfec6d4cd, 0xfec6d4cd, 0xdd28f52b, 0xc8a89cc7, 0xc8a89cc7, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3b91fa00, 0x90002dbd, 0x3b91fa00, 0xacc97ca0, 0x43d1f34, 0x43d1f34, 0x935e0051, 0x935e0051, 0x935e0051, 0xec54a9f9, 0xec54a9f9, 0xec54a9f9, 0x7505ac7f, 0x7505ac7f, 0x7505ac7f, 0x43d1f34, 0xacc97ca0, 0xacc97ca0, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x361f2fba, 0x50d0c339, 0x361f2fba, 0x8e558070, 0x59c36f00, 0x59c36f00, 0x9f7ce1f7, 0x9f7ce1f7, 0x9f7ce1f7, 0xe1fc8c91, 0xe1fc8c91, 0xe1fc8c91, 0x830a9943, 0x830a9943, 0x830a9943, 0x59c36f00, 0x8e558070, 0x8e558070, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4a4231ef, 0xee68b657, 0x4a4231ef, 0x89c4f960, 0xaa4593fe, 0xaa4593fe, 0x91ef3db0, 0x91ef3db0, 0x91ef3db0, 0x371a30d7, 0x371a30d7, 0x371a30d7, 0x1a229baf, 0x1a229baf, 0x1a229baf, 0xaa4593fe, 0x89c4f960, 0x89c4f960, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc07bd682, 0x7af7895a, 0xc07bd682, 0x821e2abf, 0xc9cbf769, 0xc9cbf769, 0x85e9b626, 0x85e9b626, 0x85e9b626, 0x7b3177ea, 0x7b3177ea, 0x7b3177ea, 0x927bc8e2, 0x927bc8e2, 0x927bc8e2, 0xc9cbf769, 0x821e2abf, 0x821e2abf, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1b63aa4c, 0xa8c3a37b, 0x1b63aa4c, 0x55700805, 0x9813a416, 0x9813a416, 0x8acc5af7, 0x8acc5af7, 0x8acc5af7, 0x1b17dcc4, 0x1b17dcc4, 0x1b17dcc4, 0x2ade114, 0x2ade114, 0x2ade114, 0x9813a416, 0x55700805, 0x55700805, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc570d6cb, 0xd586cdaa, 0xc570d6cb, 0x5616d9fc, 0x5fcf013d, 0x5fcf013d, 0xc848cef3, 0xc848cef3, 0xc848cef3, 0x1a58d685, 0x1a58d685, 0x1a58d685, 0xc2be91a, 0xc2be91a, 0xc2be91a, 0x5fcf013d, 0x5616d9fc, 0x5616d9fc, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5b2b8d24, 0xf5329fa, 0x5b2b8d24, 0xbcad497a, 0xdd28f52b, 0xdd28f52b, 0x673783b0, 0x673783b0, 0x673783b0, 0x460b7a54, 0x460b7a54, 0x460b7a54, 0x3bb3b1d8, 0x3bb3b1d8, 0x3bb3b1d8, 0xdd28f52b, 0xbcad497a, 0xbcad497a, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x96edfa54, 0x3d7c2de9, 0x96edfa54, 0xee65a4fb, 0x43d1f34, 0x43d1f34, 0x7b987b91, 0x7b987b91, 0x7b987b91, 0x492d239, 0x492d239, 0x492d239, 0x9dc3d7bf, 0x9dc3d7bf, 0x9dc3d7bf, 0x43d1f34, 0xee65a4fb, 0xee65a4fb, 0x43d1f34, }, 20 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x64d48e11, 0x64d48e11, 0x4330a1f4, 0x4330a1f4, 0x601e4c0e, 0x601e4c0e, 0x82696fe9, 0x82696fe9, 0x41073bc1, 0x41073bc1, 0xc26fdc51, 0xc26fdc51, 0xb44ab310, 0xb44ab310, 0x7eea73d0, 0x7eea73d0, 0x51990cc9, 0x51990cc9, 0xba84146a, 0xba84146a, 0x81f97e51, 0x81f97e51, 0x3f03537, 0x3f03537, 0xfc05e3b5, 0xfc05e3b5, 0x3b7cdb50, 0x3b7cdb50, 0x6c348a56, 0x6c348a56, 0xc01c7fa1, 0xc01c7fa1, 0x61d25f00, 0x61d25f00, 0x55e18a76, 0x55e18a76, 0x6420218b, 0x6420218b, 0xf123faa7, 0xf123faa7, 0x696c7eda, 0xcceb9bb0, 0x9263f602, 0x9263f602, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe6e8acc3, 0xe6e8acc3, 0x826fcefc, 0x826fcefc, 0x604df2bf, 0x604df2bf, 0xc4b080b4, 0xc4b080b4, 0x926dc345, 0x926dc345, 0x8c5bdf8b, 0x8c5bdf8b, 0x2e2c4b47, 0x2e2c4b47, 0x5a40ab79, 0x5a40ab79, 0x30273200, 0x30273200, 0xc9baee33, 0xc9baee33, 0xe5bcf997, 0xe5bcf997, 0xe89072ad, 0xe89072ad, 0xa37a82bf, 0xa37a82bf, 0x94820281, 0x94820281, 0xf12d471, 0xf12d471, 0x24066d71, 0x24066d71, 0xc9ccad48, 0xc9ccad48, 0xef4da67a, 0xef4da67a, 0x9b941cce, 0x9b941cce, 0xfc657f55, 0xfc657f55, 0x361b98a5, 0x16a28824, 0x1fb9fe37, 0x1fb9fe37, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f1b6349, 0x9f1b6349, 0x4d602d62, 0x4d602d62, 0xacb261fd, 0xacb261fd, 0x216f238b, 0x216f238b, 0x692ce8e8, 0x692ce8e8, 0xd5728c94, 0xd5728c94, 0xa52a2994, 0xa52a2994, 0x5db1a6cf, 0x5db1a6cf, 0xaba6ebeb, 0xaba6ebeb, 0x52b7b1b2, 0x52b7b1b2, 0x7552f41b, 0x7552f41b, 0xb2c2a7ce, 0xb2c2a7ce, 0x1b7b534e, 0x1b7b534e, 0x76112f0c, 0x76112f0c, 0xaf522ac, 0xaf522ac, 0x27da0578, 0x27da0578, 0x3e09bc10, 0x3e09bc10, 0x5e80fbb9, 0x5e80fbb9, 0x9e6bf207, 0x9e6bf207, 0xcf02355f, 0xcf02355f, 0x1eb1112f, 0xf2a4c25e, 0x63e655c4, 0x63e655c4, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xfb375a6d, 0xfb375a6d, 0xe84b0b99, 0xe84b0b99, 0x47425305, 0x47425305, 0xae2951a0, 0xae2951a0, 0x9c166a1e, 0x9c166a1e, 0xccae4822, 0xccae4822, 0x6ff31033, 0x6ff31033, 0x3ea842c4, 0x3ea842c4, 0x53a0f741, 0x53a0f741, 0x565a8328, 0x565a8328, 0x698498b4, 0x698498b4, 0x956c542b, 0x956c542b, 0x1d90d193, 0x1d90d193, 0x93a302cd, 0x93a302cd, 0x2de75bd, 0x2de75bd, 0x6c6a8682, 0x6c6a8682, 0xcc3eb620, 0xcc3eb620, 0x6a63564b, 0x6a63564b, 0x62934959, 0x62934959, 0xef320100, 0xef320100, 0x94cc54bf, 0x9473a69c, 0x632eb358, 0x632eb358, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f56a4, 0xc24f56a4, 0x3294d372, 0x3294d372, 0x27cc0a5f, 0x27cc0a5f, 0x2ef60b42, 0x2ef60b42, 0xd0985c3d, 0xd0985c3d, 0x8628c70d, 0x8628c70d, 0xfd4baba8, 0xfd4baba8, 0xaad76619, 0xaad76619, 0xcea8ebd6, 0xcea8ebd6, 0x6c20bcf1, 0x6c20bcf1, 0xeeba475, 0xeeba475, 0x149ff274, 0x149ff274, 0xcebe6493, 0xcebe6493, 0x1e505f4b, 0x1e505f4b, 0x7c12f45a, 0x7c12f45a, 0x41703c44, 0x41703c44, 0x346ba166, 0x346ba166, 0x941fe02f, 0x941fe02f, 0xf5be5bb3, 0xf5be5bb3, 0x3d52a9a2, 0x3d52a9a2, 0x33af135a, 0xd4ee3b2, 0x8e3f61b0, 0x8e3f61b0, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb96e28e9, 0xb96e28e9, 0x11da3359, 0x11da3359, 0xc36007c7, 0xc36007c7, 0x77a353a1, 0x77a353a1, 0xeb88539b, 0xeb88539b, 0x1e00cd2e, 0x1e00cd2e, 0xcc58d945, 0xcc58d945, 0x967f9311, 0x967f9311, 0x1b4aee63, 0x1b4aee63, 0x93da5a6a, 0x93da5a6a, 0x66934cb7, 0x66934cb7, 0xbbcefdce, 0xbbcefdce, 0x78f492b1, 0x78f492b1, 0x924f313b, 0x924f313b, 0x83d7a122, 0x83d7a122, 0x330676e1, 0x330676e1, 0x4223f775, 0x4223f775, 0xd023d9f8, 0xd023d9f8, 0x4fdf440, 0x4fdf440, 0x308b0685, 0x308b0685, 0xdc63a02b, 0x9502eb7f, 0x8a3a85e2, 0x8a3a85e2, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x53572ec9, 0x53572ec9, 0xeceb44e4, 0xeceb44e4, 0x5278dfd2, 0x5278dfd2, 0x2ed7d0d4, 0x2ed7d0d4, 0xa3440592, 0xa3440592, 0x92ffa5c6, 0x92ffa5c6, 0xaff2ad3e, 0xaff2ad3e, 0x2a31cab3, 0x2a31cab3, 0x299ef74e, 0x299ef74e, 0x76e54e80, 0x76e54e80, 0xb964e0f3, 0xb964e0f3, 0x2106b636, 0x2106b636, 0x1ee23596, 0x1ee23596, 0xeb3c9e13, 0xeb3c9e13, 0x1aa29e04, 0x1aa29e04, 0x7a262f24, 0x7a262f24, 0x467ad56a, 0x467ad56a, 0xd985c883, 0xd985c883, 0x7e57edbf, 0x7e57edbf, 0xf9d8e719, 0xf9d8e719, 0x1df01339, 0xf04bbace, 0x2a481eef, 0x2a481eef, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa9354fc3, 0xcffaa340, 0xa9354fc3, 0xeac38284, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0xeac38284, 0xeac38284, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe1081bb8, 0x45229c00, 0xe1081bb8, 0xcf0d9ec7, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0xcf0d9ec7, 0xcf0d9ec7, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x75bf9d41, 0xcf33c299, 0x75bf9d41, 0x28a8f0c5, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0x28a8f0c5, 0x28a8f0c5, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc611f412, 0x75b1fd25, 0xc611f412, 0x6847bdca, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0x6847bdca, 0x6847bdca, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf8d2d04, 0x1f7b3665, 0xf8d2d04, 0x792b18b7, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x792b18b7, 0x792b18b7, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcec57923, 0x9abdddfd, 0xcec57923, 0xd5c0a324, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0xd5c0a324, 0xd5c0a324, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf5d1bb8f, 0x5e406c32, 0xf5d1bb8f, 0xa6ea00f, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0xa6ea00f, 0xa6ea00f, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xa90b01bc, 0xa90b01bc, 0xa90b01bc, 0xf5d3f77c, 0xf5d3f77c, 0xf5d3f77c, 0xdc4b39ee, 0xdc4b39ee, 0xdc4b39ee, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0x11c82fe4, 0x11c82fe4, 0x11c82fe4, 0x449785ee, 0x449785ee, 0x449785ee, 0x2da44da7, 0x2da44da7, 0x2da44da7, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xc52df491, 0xc52df491, 0xc52df491, 0xba935205, 0xba935205, 0xba935205, 0xf8e7327d, 0xf8e7327d, 0xf8e7327d, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x6a50b915, 0x6a50b915, 0x6a50b915, 0x81f55369, 0x81f55369, 0x81f55369, 0x87be5399, 0x87be5399, 0x87be5399, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0xf841f7f, 0xf841f7f, 0xf841f7f, 0x60cdc36e, 0x60cdc36e, 0x60cdc36e, 0x6d3b5d6d, 0x6d3b5d6d, 0x6d3b5d6d, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x5b2ee37, 0x5b2ee37, 0x5b2ee37, 0xc300aa29, 0xc300aa29, 0xc300aa29, 0xd7657a96, 0xd7657a96, 0xd7657a96, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x8001ca17, 0x8001ca17, 0x8001ca17, 0x1f23cc6, 0x1f23cc6, 0x1f23cc6, 0x975685a9, 0x975685a9, 0x975685a9, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x82d8a3c, 0x6cd37a4, 0x82d8a3c, 0x4bdb477b, 0x59c36f00, 0x59c36f00, 0x46da1ede, 0x46da1ede, 0x46da1ede, 0x385a73b8, 0x385a73b8, 0x385a73b8, 0x5aac666a, 0x5aac666a, 0x5aac666a, 0x59c36f00, 0x4bdb477b, 0x4bdb477b, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x78e61710, 0x8cfbe03c, 0x78e61710, 0x56e3926f, 0xaa4593fe, 0xaa4593fe, 0x8e893728, 0x8e893728, 0x8e893728, 0x287c3a4f, 0x287c3a4f, 0x287c3a4f, 0x5449137, 0x5449137, 0x5449137, 0xaa4593fe, 0x56e3926f, 0x56e3926f, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8616c425, 0x949a7fa8, 0x8616c425, 0xdb01a9a1, 0xc9cbf769, 0xc9cbf769, 0xea2a5113, 0xea2a5113, 0xea2a5113, 0x14f290df, 0x14f290df, 0x14f290df, 0xfdb82fd7, 0xfdb82fd7, 0xfdb82fd7, 0xc9cbf769, 0xdb01a9a1, 0xdb01a9a1, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7b96f2e, 0x1a88dd6f, 0x7b96f2e, 0xa9ef26f6, 0x9813a416, 0x9813a416, 0xc6bba65a, 0xc6bba65a, 0xc6bba65a, 0x57602069, 0x57602069, 0x57602069, 0x4eda1db9, 0x4eda1db9, 0x4eda1db9, 0x9813a416, 0xa9ef26f6, 0xa9ef26f6, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x95679383, 0x54029d22, 0x95679383, 0xe3c1a630, 0x5fcf013d, 0x5fcf013d, 0x7cccc38f, 0x7cccc38f, 0x7cccc38f, 0xaedcdbf9, 0xaedcdbf9, 0xaedcdbf9, 0xb8afe466, 0xb8afe466, 0xb8afe466, 0x5fcf013d, 0xe3c1a630, 0xe3c1a630, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdc1ff783, 0x13e0969e, 0xdc1ff783, 0xc71a2d84, 0xdd28f52b, 0xdd28f52b, 0x9227d7c1, 0x9227d7c1, 0x9227d7c1, 0xb31b2e25, 0xb31b2e25, 0xb31b2e25, 0xcea3e5a9, 0xcea3e5a9, 0xcea3e5a9, 0xdd28f52b, 0xc71a2d84, 0xc71a2d84, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x23cfa079, 0x52702665, 0x23cfa079, 0xdc70bbf9, 0x43d1f34, 0x43d1f34, 0x733dddc9, 0x733dddc9, 0x733dddc9, 0xc377461, 0xc377461, 0xc377461, 0x956671e7, 0x956671e7, 0x956671e7, 0x43d1f34, 0xdc70bbf9, 0xdc70bbf9, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4582c049, 0x3db332af, 0x4582c049, 0x6740d0e, 0x59c36f00, 0x59c36f00, 0x1e6dfa2, 0x1e6dfa2, 0x1e6dfa2, 0x7f66b2c4, 0x7f66b2c4, 0x7f66b2c4, 0x1d90a716, 0x1d90a716, 0x1d90a716, 0x59c36f00, 0x6740d0e, 0x6740d0e, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xdc8ccbe5, 0x7f38bbe9, 0xdc8ccbe5, 0xf2894e9a, 0xaa4593fe, 0xaa4593fe, 0xb1e9401e, 0xb1e9401e, 0xb1e9401e, 0x171c4d79, 0x171c4d79, 0x171c4d79, 0x3a24e601, 0x3a24e601, 0x3a24e601, 0xaa4593fe, 0xf2894e9a, 0xf2894e9a, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2ab2ff2f, 0x88773992, 0x2ab2ff2f, 0x77a592ab, 0xc9cbf769, 0xc9cbf769, 0x261a2f75, 0x261a2f75, 0x261a2f75, 0xd8c2eeb9, 0xd8c2eeb9, 0xd8c2eeb9, 0x318851b1, 0x318851b1, 0x318851b1, 0xc9cbf769, 0x77a592ab, 0x77a592ab, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4937982a, 0x671b7841, 0x4937982a, 0xe761d1f2, 0x9813a416, 0x9813a416, 0x87d79e45, 0x87d79e45, 0x87d79e45, 0x160c1876, 0x160c1876, 0x160c1876, 0xfb625a6, 0xfb625a6, 0xfb625a6, 0x9813a416, 0xe761d1f2, 0xe761d1f2, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x617eae5c, 0xfad61931, 0x617eae5c, 0x17d89bef, 0x5fcf013d, 0x5fcf013d, 0xde0c1058, 0xde0c1058, 0xde0c1058, 0xc1c082e, 0xc1c082e, 0xc1c082e, 0x1a6f37b1, 0x1a6f37b1, 0x1a6f37b1, 0x5fcf013d, 0x17d89bef, 0x17d89bef, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfa1ba2c2, 0x640c9857, 0xfa1ba2c2, 0xe11e78c5, 0xdd28f52b, 0xdd28f52b, 0x63b59689, 0x63b59689, 0x63b59689, 0x42896f6d, 0x42896f6d, 0x42896f6d, 0x3f31a4e1, 0x3f31a4e1, 0x3f31a4e1, 0xdd28f52b, 0xe11e78c5, 0xe11e78c5, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8e48efc2, 0xcc38fe16, 0x8e48efc2, 0x71f7f442, 0x43d1f34, 0x43d1f34, 0xebe57216, 0xebe57216, 0xebe57216, 0x94efdbbe, 0x94efdbbe, 0x94efdbbe, 0xdbede38, 0xdbede38, 0xdbede38, 0x43d1f34, 0x71f7f442, 0x71f7f442, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x266da594, 0x24b82ab5, 0x266da594, 0x659b68d3, 0x59c36f00, 0x59c36f00, 0xdb8dd8c4, 0xdb8dd8c4, 0xdb8dd8c4, 0xa50db5a2, 0xa50db5a2, 0xa50db5a2, 0xc7fba070, 0xc7fba070, 0xc7fba070, 0x59c36f00, 0x659b68d3, 0x659b68d3, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xba8fe08d, 0x9d9bc2e, 0xba8fe08d, 0x948a65f2, 0xaa4593fe, 0xaa4593fe, 0xaa152d8e, 0xaa152d8e, 0xaa152d8e, 0xce020e9, 0xce020e9, 0xce020e9, 0x21d88b91, 0x21d88b91, 0x21d88b91, 0xaa4593fe, 0x948a65f2, 0x948a65f2, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9a003828, 0x2ba49253, 0x9a003828, 0xc71755ac, 0xc9cbf769, 0xc9cbf769, 0xaa0a5e12, 0xaa0a5e12, 0xaa0a5e12, 0x54d29fde, 0x54d29fde, 0x54d29fde, 0xbd9820d6, 0xbd9820d6, 0xbd9820d6, 0xc9cbf769, 0xc71755ac, 0xc71755ac, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8187ce81, 0x75269aaa, 0x8187ce81, 0x2fd18759, 0x9813a416, 0x9813a416, 0x12e905c0, 0x12e905c0, 0x12e905c0, 0x833283f3, 0x833283f3, 0x833283f3, 0x9a88be23, 0x9a88be23, 0x9a88be23, 0x9813a416, 0x2fd18759, 0x2fd18759, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x500d0c44, 0x70d2d942, 0x500d0c44, 0x26ab39f7, 0x5fcf013d, 0x5fcf013d, 0x5bde93cf, 0x5bde93cf, 0x5bde93cf, 0x89ce8bb9, 0x89ce8bb9, 0x89ce8bb9, 0x9fbdb426, 0x9fbdb426, 0x9fbdb426, 0x5fcf013d, 0x26ab39f7, 0x26ab39f7, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x16591b36, 0x21c0f059, 0x16591b36, 0xd5cc131, 0xdd28f52b, 0xdd28f52b, 0x2010760f, 0x2010760f, 0x2010760f, 0x12c8feb, 0x12c8feb, 0x12c8feb, 0x7c944467, 0x7c944467, 0x7c944467, 0xdd28f52b, 0xd5cc131, 0xd5cc131, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xddbfde17, 0xfb121565, 0xddbfde17, 0x2200c597, 0x43d1f34, 0x43d1f34, 0xb6333f22, 0xb6333f22, 0xb6333f22, 0xc939968a, 0xc939968a, 0xc939968a, 0x5068930c, 0x5068930c, 0x5068930c, 0x43d1f34, 0x2200c597, 0x2200c597, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xde6eb23f, 0x622ba005, 0xde6eb23f, 0x9d987f78, 0x59c36f00, 0x59c36f00, 0xfaf9dd19, 0xfaf9dd19, 0xfaf9dd19, 0x8479b07f, 0x8479b07f, 0x8479b07f, 0xe68fa5ad, 0xe68fa5ad, 0xe68fa5ad, 0x59c36f00, 0x9d987f78, 0x9d987f78, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x920dc865, 0x643d1348, 0x920dc865, 0xbc084d1a, 0xaa4593fe, 0xaa4593fe, 0xb332a002, 0xb332a002, 0xb332a002, 0x15c7ad65, 0x15c7ad65, 0x15c7ad65, 0x38ff061d, 0x38ff061d, 0x38ff061d, 0xaa4593fe, 0xbc084d1a, 0xbc084d1a, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xae96dbc6, 0x1d9c4918, 0xae96dbc6, 0xf381b642, 0xc9cbf769, 0xc9cbf769, 0x9bd7a35, 0x9bd7a35, 0x9bd7a35, 0xf765bbf9, 0xf765bbf9, 0xf765bbf9, 0x1e2f04f1, 0x1e2f04f1, 0x1e2f04f1, 0xc9cbf769, 0xf381b642, 0xf381b642, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x68ab5a83, 0x1dedd3f0, 0x68ab5a83, 0xc6fd135b, 0x9813a416, 0x9813a416, 0xfe9f04ad, 0xfe9f04ad, 0xfe9f04ad, 0x6f44829e, 0x6f44829e, 0x6f44829e, 0x76febf4e, 0x76febf4e, 0x76febf4e, 0x9813a416, 0xc6fd135b, 0xc6fd135b, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa113e90c, 0xc3b993d8, 0xa113e90c, 0xd7b5dcbf, 0x5fcf013d, 0x5fcf013d, 0xd4453517, 0xd4453517, 0xd4453517, 0x6552d61, 0x6552d61, 0x6552d61, 0x102612fe, 0x102612fe, 0x102612fe, 0x5fcf013d, 0xd7b5dcbf, 0xd7b5dcbf, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd74db26e, 0xfee01078, 0xd74db26e, 0xcc486869, 0xdd28f52b, 0xdd28f52b, 0x5b477f04, 0x5b477f04, 0x5b477f04, 0x7a7b86e0, 0x7a7b86e0, 0x7a7b86e0, 0x7c34d6c, 0x7c34d6c, 0x7c34d6c, 0xdd28f52b, 0xcc486869, 0xcc486869, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa80953f6, 0x13208dce, 0xa80953f6, 0x57b64876, 0x43d1f34, 0x43d1f34, 0x15662f13, 0x15662f13, 0x15662f13, 0x6a6c86bb, 0x6a6c86bb, 0x6a6c86bb, 0xf33d833d, 0xf33d833d, 0xf33d833d, 0x43d1f34, 0x57b64876, 0x57b64876, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x28730c5a, 0x10c504c1, 0x28730c5a, 0x6b85c11d, 0x59c36f00, 0x59c36f00, 0xe2713dc2, 0xe2713dc2, 0xe2713dc2, 0x9cf150a4, 0x9cf150a4, 0x9cf150a4, 0xfe074576, 0xfe074576, 0xfe074576, 0x59c36f00, 0x6b85c11d, 0x6b85c11d, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa6720cda, 0x79326293, 0xa6720cda, 0x887789a5, 0xaa4593fe, 0xaa4593fe, 0xf5a98049, 0xf5a98049, 0xf5a98049, 0x535c8d2e, 0x535c8d2e, 0x535c8d2e, 0x7e642656, 0x7e642656, 0x7e642656, 0xaa4593fe, 0x887789a5, 0x887789a5, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefc130b0, 0xc15c12f3, 0xefc130b0, 0xb2d65d34, 0xc9cbf769, 0xc9cbf769, 0xb80d0c51, 0xb80d0c51, 0xb80d0c51, 0x46d5cd9d, 0x46d5cd9d, 0x46d5cd9d, 0xaf9f7295, 0xaf9f7295, 0xaf9f7295, 0xc9cbf769, 0xb2d65d34, 0xb2d65d34, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd363ab7, 0x7fdff86a, 0xd363ab7, 0xa360736f, 0x9813a416, 0x9813a416, 0xf0212278, 0xf0212278, 0xf0212278, 0x61faa44b, 0x61faa44b, 0x61faa44b, 0x7840999b, 0x7840999b, 0x7840999b, 0x9813a416, 0xa360736f, 0xa360736f, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xdd4249ff, 0xf4a0d4a3, 0xdd4249ff, 0xabe47c4c, 0x5fcf013d, 0x5fcf013d, 0x4170c1bb, 0x4170c1bb, 0x4170c1bb, 0x9360d9cd, 0x9360d9cd, 0x9360d9cd, 0x8513e652, 0x8513e652, 0x8513e652, 0x5fcf013d, 0xabe47c4c, 0xabe47c4c, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdf2ffd30, 0x53da6bb9, 0xdf2ffd30, 0xc42a2737, 0xdd28f52b, 0xdd28f52b, 0x8077de4, 0x8077de4, 0x8077de4, 0x293b8400, 0x293b8400, 0x293b8400, 0x54834f8c, 0x54834f8c, 0x54834f8c, 0xdd28f52b, 0xc42a2737, 0xc42a2737, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbfb4210a, 0x7a4373, 0xbfb4210a, 0x400b3a8a, 0x43d1f34, 0x43d1f34, 0xd0b7fd4b, 0xd0b7fd4b, 0xd0b7fd4b, 0xafbd54e3, 0xafbd54e3, 0xafbd54e3, 0x36ec5165, 0x36ec5165, 0x36ec5165, 0x43d1f34, 0x400b3a8a, 0x400b3a8a, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd6e69c19, 0xfd01b92b, 0xd6e69c19, 0x9510515e, 0x59c36f00, 0x59c36f00, 0xd41a73d2, 0xd41a73d2, 0xd41a73d2, 0xaa9a1eb4, 0xaa9a1eb4, 0xaa9a1eb4, 0xc86c0b66, 0xc86c0b66, 0xc86c0b66, 0x59c36f00, 0x9510515e, 0x9510515e, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x770e32e, 0xf0e77497, 0x770e32e, 0x29756651, 0xaa4593fe, 0xaa4593fe, 0x9e257fc7, 0x9e257fc7, 0x9e257fc7, 0x38d072a0, 0x38d072a0, 0x38d072a0, 0x15e8d9d8, 0x15e8d9d8, 0x15e8d9d8, 0xaa4593fe, 0x29756651, 0x29756651, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa2fe1c87, 0x3e7869d8, 0xa2fe1c87, 0xffe97103, 0xc9cbf769, 0xc9cbf769, 0xc5920970, 0xc5920970, 0xc5920970, 0x3b4ac8bc, 0x3b4ac8bc, 0x3b4ac8bc, 0xd20077b4, 0xd20077b4, 0xd20077b4, 0xc9cbf769, 0xffe97103, 0xffe97103, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x551e28a2, 0x117eec93, 0x551e28a2, 0xfb48617a, 0x9813a416, 0x9813a416, 0x9bd613bc, 0x9bd613bc, 0x9bd613bc, 0xa0d958f, 0xa0d958f, 0xa0d958f, 0x13b7a85f, 0x13b7a85f, 0x13b7a85f, 0x9813a416, 0xfb48617a, 0xfb48617a, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb371f66c, 0x6f3a4cc9, 0xb371f66c, 0xc5d7c3df, 0x5fcf013d, 0x5fcf013d, 0x1cfef603, 0x1cfef603, 0x1cfef603, 0xceeeee75, 0xceeeee75, 0xceeeee75, 0xd89dd1ea, 0xd89dd1ea, 0xd89dd1ea, 0x5fcf013d, 0xc5d7c3df, 0xc5d7c3df, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc6b72d49, 0xedbe4dae, 0xc6b72d49, 0xddb2f74e, 0xdd28f52b, 0xdd28f52b, 0x86b465e5, 0x86b465e5, 0x86b465e5, 0xa7889c01, 0xa7889c01, 0xa7889c01, 0xda30578d, 0xda30578d, 0xda30578d, 0xdd28f52b, 0xddb2f74e, 0xddb2f74e, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5e2e17e4, 0x9bf82c1b, 0x5e2e17e4, 0xa1910c64, 0x43d1f34, 0x43d1f34, 0x823d979, 0x823d979, 0x823d979, 0x772970d1, 0x772970d1, 0x772970d1, 0xee787557, 0xee787557, 0xee787557, 0x43d1f34, 0xa1910c64, 0xa1910c64, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x15d42b6c, 0x731bc7ef, 0x15d42b6c, 0x5622e62b, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0x5622e62b, 0x5622e62b, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x58683e3c, 0xfc42b984, 0x58683e3c, 0x766dbb43, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0x766dbb43, 0x766dbb43, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf5d76d17, 0x4f5b32cf, 0xf5d76d17, 0xa8c00093, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0xa8c00093, 0xa8c00093, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x73304730, 0xc0904e07, 0x73304730, 0xdd660ee8, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0xdd660ee8, 0xdd660ee8, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4daec3fc, 0x5d58d89d, 0x4daec3fc, 0x3b08f64f, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x3b08f64f, 0x3b08f64f, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5af5f85c, 0xe8d5c82, 0x5af5f85c, 0x41f0225b, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0x41f0225b, 0x41f0225b, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb819f982, 0x13882e3f, 0xb819f982, 0x47a6e202, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0x47a6e202, 0x47a6e202, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4e09ed16, 0x1b959f2, 0x4e09ed16, 0xdff2051, 0x59c36f00, 0x59c36f00, 0x9d5feea7, 0x9d5feea7, 0x9d5feea7, 0xe3df83c1, 0xe3df83c1, 0xe3df83c1, 0x81299613, 0x81299613, 0x81299613, 0x59c36f00, 0xdff2051, 0xdff2051, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb4fe3633, 0xbd9a0250, 0xb4fe3633, 0x9afbb34c, 0xaa4593fe, 0xaa4593fe, 0x8d224121, 0x8d224121, 0x8d224121, 0x2bd74c46, 0x2bd74c46, 0x2bd74c46, 0x6efe73e, 0x6efe73e, 0x6efe73e, 0xaa4593fe, 0x9afbb34c, 0x9afbb34c, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x19cdf337, 0xd89c052a, 0x19cdf337, 0x44da9eb3, 0xc9cbf769, 0xc9cbf769, 0x203fc41b, 0x203fc41b, 0x203fc41b, 0xdee705d7, 0xdee705d7, 0xdee705d7, 0x37adbadf, 0x37adbadf, 0x37adbadf, 0xc9cbf769, 0x44da9eb3, 0x44da9eb3, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5bd9226d, 0x73b88c1, 0x5bd9226d, 0xf58f6bb5, 0x9813a416, 0x9813a416, 0x60c7ae6c, 0x60c7ae6c, 0x60c7ae6c, 0xf11c285f, 0xf11c285f, 0xf11c285f, 0xe8a6158f, 0xe8a6158f, 0xe8a6158f, 0x9813a416, 0xf58f6bb5, 0xf58f6bb5, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5bee0c71, 0x22fee848, 0x5bee0c71, 0x2d4839c2, 0x5fcf013d, 0x5fcf013d, 0x56213219, 0x56213219, 0x56213219, 0x84312a6f, 0x84312a6f, 0x84312a6f, 0x924215f0, 0x924215f0, 0x924215f0, 0x5fcf013d, 0x2d4839c2, 0x2d4839c2, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x56e6fad4, 0x3c9e4aea, 0x56e6fad4, 0x4de320d3, 0xdd28f52b, 0xdd28f52b, 0x83d6662d, 0x83d6662d, 0x83d6662d, 0xa2ea9fc9, 0xa2ea9fc9, 0xa2ea9fc9, 0xdf525445, 0xdf525445, 0xdf525445, 0xdd28f52b, 0x4de320d3, 0x4de320d3, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfde17453, 0xe772a7a, 0xfde17453, 0x25e6fd3, 0x43d1f34, 0x43d1f34, 0xad2497d2, 0xad2497d2, 0xad2497d2, 0xd22e3e7a, 0xd22e3e7a, 0xd22e3e7a, 0x4b7f3bfc, 0x4b7f3bfc, 0x4b7f3bfc, 0x43d1f34, 0x25e6fd3, 0x25e6fd3, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5112a279, 0x63608f0d, 0x5112a279, 0x12e46f3e, 0x59c36f00, 0x59c36f00, 0x64cc7367, 0x64cc7367, 0x64cc7367, 0x1a4c1e01, 0x1a4c1e01, 0x1a4c1e01, 0x78ba0bd3, 0x78ba0bd3, 0x78ba0bd3, 0x59c36f00, 0x12e46f3e, 0x12e46f3e, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x428dd311, 0x6168e994, 0x428dd311, 0x6c88566e, 0xaa4593fe, 0xaa4593fe, 0x9a464f37, 0x9a464f37, 0x9a464f37, 0x3cb34250, 0x3cb34250, 0x3cb34250, 0x118be928, 0x118be928, 0x118be928, 0xaa4593fe, 0x6c88566e, 0x6c88566e, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc71c50d3, 0xf111a91c, 0xc71c50d3, 0x9a0b3d57, 0xc9cbf769, 0xc9cbf769, 0x9bc1473d, 0x9bc1473d, 0x9bc1473d, 0x651986f1, 0x651986f1, 0x651986f1, 0x8c5339f9, 0x8c5339f9, 0x8c5339f9, 0xc9cbf769, 0x9a0b3d57, 0x9a0b3d57, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x61d6a73a, 0xf4179296, 0x61d6a73a, 0xcf80eee2, 0x9813a416, 0x9813a416, 0x841b9482, 0x841b9482, 0x841b9482, 0x15c012b1, 0x15c012b1, 0x15c012b1, 0xc7a2f61, 0xc7a2f61, 0xc7a2f61, 0x9813a416, 0xcf80eee2, 0xcf80eee2, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9b88583d, 0x4c7bf28e, 0x9b88583d, 0xed2e6d8e, 0x5fcf013d, 0x5fcf013d, 0x31e3f856, 0x31e3f856, 0x31e3f856, 0xe3f3e020, 0xe3f3e020, 0xe3f3e020, 0xf580dfbf, 0xf580dfbf, 0xf580dfbf, 0x5fcf013d, 0xed2e6d8e, 0xed2e6d8e, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x77b18e2f, 0xe8e63830, 0x77b18e2f, 0x6cb45428, 0xdd28f52b, 0xdd28f52b, 0x8c504561, 0x8c504561, 0x8c504561, 0xad6cbc85, 0xad6cbc85, 0xad6cbc85, 0xd0d47709, 0xd0d47709, 0xd0d47709, 0xdd28f52b, 0x6cb45428, 0x6cb45428, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc7bba485, 0x9b3a97f6, 0xc7bba485, 0x3804bf05, 0x43d1f34, 0x43d1f34, 0xb57a04a9, 0xb57a04a9, 0xb57a04a9, 0xca70ad01, 0xca70ad01, 0xca70ad01, 0x5321a887, 0x5321a887, 0x5321a887, 0x43d1f34, 0x3804bf05, 0x3804bf05, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1d498e, 0x66d2a50d, 0x1d498e, 0x5730f750, 0x59c36f00, 0x59c36f00, 0xfafd31bc, 0xfafd31bc, 0xfafd31bc, 0x847d5cda, 0x847d5cda, 0x847d5cda, 0xe68b4908, 0xe68b4908, 0xe68b4908, 0x59c36f00, 0x5730f750, 0x5730f750, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf23a914f, 0x561016f7, 0xf23a914f, 0x429d4b19, 0xaa4593fe, 0xaa4593fe, 0xc03115b6, 0xc03115b6, 0xc03115b6, 0x66c418d1, 0x66c418d1, 0x66c418d1, 0x4bfcb3a9, 0x4bfcb3a9, 0x4bfcb3a9, 0xaa4593fe, 0x429d4b19, 0x429d4b19, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x731ebcf1, 0xc992e329, 0x731ebcf1, 0x633ba25f, 0xc9cbf769, 0xc9cbf769, 0x600022fb, 0x600022fb, 0x600022fb, 0x9ed8e337, 0x9ed8e337, 0x9ed8e337, 0x77925c3f, 0x77925c3f, 0x77925c3f, 0xc9cbf769, 0x633ba25f, 0x633ba25f, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4a87e91c, 0xf927e02b, 0x4a87e91c, 0x7af61533, 0x9813a416, 0x9813a416, 0x58a063c0, 0x58a063c0, 0x58a063c0, 0xc97be5f3, 0xc97be5f3, 0xc97be5f3, 0xd0c1d823, 0xd0c1d823, 0xd0c1d823, 0x9813a416, 0x7af61533, 0x7af61533, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb4820844, 0xa4741325, 0xb4820844, 0x1a85e7b1, 0x5fcf013d, 0x5fcf013d, 0x19cab3ea, 0x19cab3ea, 0x19cab3ea, 0xcbdaab9c, 0xcbdaab9c, 0xcbdaab9c, 0xdda99403, 0xdda99403, 0xdda99403, 0x5fcf013d, 0x1a85e7b1, 0x1a85e7b1, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x52a9ee36, 0x6d14ae8, 0x52a9ee36, 0xdccd25ec, 0xdd28f52b, 0xdd28f52b, 0xb6275f8e, 0xb6275f8e, 0xb6275f8e, 0x971ba66a, 0x971ba66a, 0x971ba66a, 0xeaa36de6, 0xeaa36de6, 0xeaa36de6, 0xdd28f52b, 0xdccd25ec, 0xdccd25ec, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6d47d8, 0xabfc9065, 0x6d47d8, 0x9735c178, 0x43d1f34, 0x43d1f34, 0xa8a2bd89, 0xa8a2bd89, 0xa8a2bd89, 0xd7a81421, 0xd7a81421, 0xd7a81421, 0x4ef911a7, 0x4ef911a7, 0x4ef911a7, 0x43d1f34, 0x9735c178, 0x9735c178, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3a3fb187, 0x5cf05d04, 0x3a3fb187, 0x82751e4d, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0x82751e4d, 0x82751e4d, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9086a313, 0x34ac24ab, 0x9086a313, 0x53006b9c, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0x53006b9c, 0x53006b9c, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb1b455e8, 0xb380a30, 0xb1b455e8, 0xf3d1a9d5, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0xf3d1a9d5, 0xf3d1a9d5, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x3d86952b, 0x8e269c1c, 0x3d86952b, 0x73953762, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0x73953762, 0x73953762, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xcd662d92, 0xdd9036f3, 0xcd662d92, 0x5e0022a5, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x5e0022a5, 0x5e0022a5, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4f4e340f, 0x1b3690d1, 0x4f4e340f, 0xa8c8f051, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0xa8c8f051, 0xa8c8f051, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xad11478c, 0x6809031, 0xad11478c, 0xd5991923, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0xd5991923, 0xd5991923, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From ec4af117c6e16d0ef9b2792827c5dd619342f787 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 2 Apr 2017 14:47:20 +0300 Subject: [PATCH 0661/1167] acpi: add missing efi_call wrapper to acpi command Fixed loading of ACPI tables on EFI (side effect was apparent memory corruption ranging from unpredictable behavior to system reset). Reported by Nando Eva --- grub-core/commands/acpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index b5c2f27c1..9f02f2201 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -761,10 +761,10 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) struct grub_efi_guid acpi = GRUB_EFI_ACPI_TABLE_GUID; struct grub_efi_guid acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID; - grub_efi_system_table->boot_services->install_configuration_table - (&acpi20, grub_acpi_get_rsdpv2 ()); - grub_efi_system_table->boot_services->install_configuration_table - (&acpi, grub_acpi_get_rsdpv1 ()); + efi_call_2 (grub_efi_system_table->boot_services->install_configuration_table, + &acpi20, grub_acpi_get_rsdpv2 ()); + efi_call_2 (grub_efi_system_table->boot_services->install_configuration_table, + &acpi, grub_acpi_get_rsdpv1 ()); } #endif From 6cef7f6079550af3bf91dbff824398eaef08c3c5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 4 Apr 2017 19:22:32 +0300 Subject: [PATCH 0662/1167] btrfs: avoid "used uninitialized" error with GCC7 sblock was local and so considered new variable on every loop iteration. Closes: 50597 --- grub-core/fs/btrfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 9cffa91fa..4849c1ceb 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -227,11 +227,11 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, static grub_err_t read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) { + struct grub_btrfs_superblock sblock; unsigned i; grub_err_t err = GRUB_ERR_NONE; for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++) { - struct grub_btrfs_superblock sblock; /* Don't try additional superblocks beyond device size. */ if (i && (grub_le_to_cpu64 (sblock.this_device.size) >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i]) From 4bd4a88725604471fdbd86316c91967a7f4dba5a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 4 Apr 2017 19:23:55 +0300 Subject: [PATCH 0663/1167] i386, x86_64, ppc: fix switch fallthrough cases with GCC7 In util/getroot and efidisk slightly modify exitsing comment to mostly retain it but still make GCC7 compliant with respect to fall through annotation. In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as upstream. In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to suppress GCC7 warning. In grub-core/gnulib/regexec.c use new __attribute__, because existing annotation is not recognized by GCC7 parser (which requires that comment immediately precedes case statement). Otherwise add FALLTHROUGH comment. Closes: 50598 --- grub-core/commands/hdparm.c | 1 + grub-core/commands/nativedisk.c | 1 + grub-core/disk/cryptodisk.c | 1 + grub-core/disk/efi/efidisk.c | 2 +- grub-core/efiemu/mm.c | 1 + grub-core/gdb/cstub.c | 1 + grub-core/gnulib/regexec.c | 3 +++ grub-core/lib/xzembed/xz_dec_lzma2.c | 4 ++++ grub-core/lib/xzembed/xz_dec_stream.c | 6 ++++++ grub-core/loader/i386/linux.c | 3 +++ grub-core/tests/setjmp_test.c | 5 ++++- grub-core/video/ieee1275.c | 1 + grub-core/video/readers/jpeg.c | 1 + util/getroot.c | 2 +- util/grub-install.c | 1 + util/grub-mkimagexx.c | 1 + util/grub-mount.c | 1 + 17 files changed, 32 insertions(+), 3 deletions(-) diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c index f6b178eae..d3fa9661e 100644 --- a/grub-core/commands/hdparm.c +++ b/grub-core/commands/hdparm.c @@ -328,6 +328,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) ata = ((struct grub_scsi *) disk->data)->data; break; } + /* FALLTHROUGH */ default: grub_disk_close (disk); return grub_error (GRUB_ERR_IO, "not an ATA device"); diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index 345f97c4d..2f56a870e 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -79,6 +79,7 @@ get_uuid (const char *name, char **uuid, int getnative) case GRUB_DISK_DEVICE_XEN: if (getnative) break; + /* FALLTHROUGH */ /* Virtual disks. */ /* GRUB dynamically generated files. */ diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 1e03a091c..bd60a66b3 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -282,6 +282,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev, break; case GRUB_CRYPTODISK_MODE_IV_PLAIN64: iv[1] = grub_cpu_to_le32 (sector >> 32); + /* FALLTHROUGH */ case GRUB_CRYPTODISK_MODE_IV_PLAIN: iv[0] = grub_cpu_to_le32 (sector & 0xFFFFFFFF); break; diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index e66b35d87..5d2400f66 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -224,7 +224,7 @@ name_devices (struct grub_efidisk_data *devices) { case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE: is_hard_drive = 1; - /* Fall through by intention. */ + /* Intentionally fall through. */ case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE: { struct grub_efidisk_data *parent, *parent2; diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index e606dbffc..52a032f7b 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -417,6 +417,7 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, default: grub_dprintf ("efiemu", "Unknown memory type %d. Assuming unusable\n", type); + /* FALLTHROUGH */ case GRUB_MEMORY_RESERVED: return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_UNUSABLE_MEMORY); diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c index c94411b10..b64acd70f 100644 --- a/grub-core/gdb/cstub.c +++ b/grub-core/gdb/cstub.c @@ -336,6 +336,7 @@ grub_gdb_trap (int trap_no) /* sAA..AA: Step one instruction from AA..AA(optional). */ case 's': stepping = 1; + /* FALLTHROUGH */ /* cAA..AA: Continue at address AA..AA(optional). */ case 'c': diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c index f632cd47b..a7776f088 100644 --- a/grub-core/gnulib/regexec.c +++ b/grub-core/gnulib/regexec.c @@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, case OP_UTF8_PERIOD: if (ch >= ASCII_CHARS) return false; +#if defined __GNUC__ && __GNUC__ >= 7 + __attribute__ ((fallthrough)); +#endif /* FALLTHROUGH */ #endif case OP_PERIOD: diff --git a/grub-core/lib/xzembed/xz_dec_lzma2.c b/grub-core/lib/xzembed/xz_dec_lzma2.c index 8a2a1183d..af7b77079 100644 --- a/grub-core/lib/xzembed/xz_dec_lzma2.c +++ b/grub-core/lib/xzembed/xz_dec_lzma2.c @@ -1044,6 +1044,8 @@ enum xz_ret xz_dec_lzma2_run( s->lzma2.sequence = SEQ_LZMA_PREPARE; + /* Fall through */ + case SEQ_LZMA_PREPARE: if (s->lzma2.compressed < RC_INIT_BYTES) return XZ_DATA_ERROR; @@ -1054,6 +1056,8 @@ enum xz_ret xz_dec_lzma2_run( s->lzma2.compressed -= RC_INIT_BYTES; s->lzma2.sequence = SEQ_LZMA_RUN; + /* Fall through */ + case SEQ_LZMA_RUN: /* * Set dictionary limit to indicate how much we want diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c index c16b13060..a29751e14 100644 --- a/grub-core/lib/xzembed/xz_dec_stream.c +++ b/grub-core/lib/xzembed/xz_dec_stream.c @@ -750,6 +750,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->sequence = SEQ_BLOCK_START; + /* FALLTHROUGH */ case SEQ_BLOCK_START: /* We need one byte of input to continue. */ if (b->in_pos == b->in_size) @@ -773,6 +774,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->temp.pos = 0; s->sequence = SEQ_BLOCK_HEADER; + /* FALLTHROUGH */ case SEQ_BLOCK_HEADER: if (!fill_temp(s, b)) return XZ_OK; @@ -783,6 +785,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->sequence = SEQ_BLOCK_UNCOMPRESS; + /* FALLTHROUGH */ case SEQ_BLOCK_UNCOMPRESS: ret = dec_block(s, b); if (ret != XZ_STREAM_END) @@ -810,6 +813,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->sequence = SEQ_BLOCK_CHECK; + /* FALLTHROUGH */ case SEQ_BLOCK_CHECK: ret = hash_validate(s, b, 0); if (ret != XZ_STREAM_END) @@ -858,6 +862,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->sequence = SEQ_INDEX_CRC32; + /* FALLTHROUGH */ case SEQ_INDEX_CRC32: ret = hash_validate(s, b, 1); if (ret != XZ_STREAM_END) @@ -866,6 +871,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) s->temp.size = STREAM_HEADER_SIZE; s->sequence = SEQ_STREAM_FOOTER; + /* FALLTHROUGH */ case SEQ_STREAM_FOOTER: if (!fill_temp(s, b)) return XZ_OK; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index b15b8cca5..083f9417c 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -984,10 +984,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { case 'g': shift += 10; + /* FALLTHROUGH */ case 'm': shift += 10; + /* FALLTHROUGH */ case 'k': shift += 10; + /* FALLTHROUGH */ default: break; } diff --git a/grub-core/tests/setjmp_test.c b/grub-core/tests/setjmp_test.c index 390cb26eb..604a6ce8f 100644 --- a/grub-core/tests/setjmp_test.c +++ b/grub-core/tests/setjmp_test.c @@ -25,7 +25,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_jmp_buf jmp_point; static int expected, ctr; -#pragma GCC diagnostic ignored "-Wmissing-noreturn" +/* This fixes GCC7 "unintentional fallthrough" warning */ +static void jmp0 (void) __attribute__ ((noreturn)); +static void jmp1 (void) __attribute__ ((noreturn)); +static void jmp2 (void) __attribute__ ((noreturn)); static void jmp0 (void) diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c index 0b150ec24..17a3dbbb5 100644 --- a/grub-core/video/ieee1275.c +++ b/grub-core/video/ieee1275.c @@ -181,6 +181,7 @@ grub_video_ieee1275_fill_mode_info (grub_ieee1275_phandle_t dev, case 32: out->reserved_mask_size = 8; out->reserved_field_pos = 24; + /* FALLTHROUGH */ case 24: out->red_mask_size = 8; diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index c3e0df240..21b0d9ded 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -736,6 +736,7 @@ grub_jpeg_decode_jpeg (struct grub_jpeg_data *data) case JPEG_MARKER_SOS: /* Start Of Scan. */ if (grub_jpeg_decode_sos (data)) break; + /* FALLTHROUGH */ case JPEG_MARKER_RST0: /* Restart. */ case JPEG_MARKER_RST1: case JPEG_MARKER_RST2: diff --git a/util/getroot.c b/util/getroot.c index 92c0d709b..847406fba 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -99,7 +99,7 @@ grub_util_pull_device (const char *os_dev) { case GRUB_DEV_ABSTRACTION_LVM: grub_util_pull_lvm_by_command (os_dev); - /* Fallthrough in case that lvm-tools are unavailable. */ + /* Fallthrough - in case that lvm-tools are unavailable. */ case GRUB_DEV_ABSTRACTION_LUKS: grub_util_pull_devmapper (os_dev); return; diff --git a/util/grub-install.c b/util/grub-install.c index 6c89c2b0c..9074d3e9e 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1851,6 +1851,7 @@ main (int argc, char *argv[]) free (mach_kernel); break; } + /* FALLTHROUGH */ case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index f8faae878..e63f148e4 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -907,6 +907,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, + sym->st_value - image_target->vaddr_offset)); } + /* FALLTHROUGH */ case R_IA64_LTOFF_FPTR22: *gpptr = grub_host_to_target64 (addend + sym_addr); grub_ia64_add_value_to_slot_21 ((grub_addr_t) target, diff --git a/util/grub-mount.c b/util/grub-mount.c index aca5f82e3..a25db8a71 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -530,6 +530,7 @@ argp_parser (int key, char *arg, struct argp_state *state) if (arg[0] != '-') break; + /* FALLTHROUGH */ default: if (!arg) return 0; From 007f0b407f72314ec832d77e15b83ea40b160037 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 4 Apr 2017 19:37:47 +0300 Subject: [PATCH 0664/1167] Add gnulib-fix-gcc7-fallthrough.diff As long as the code is not upstream, add it as explicit patch for the case of gnulib refresh. --- grub-core/gnulib-fix-gcc7-fallthrough.diff | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 grub-core/gnulib-fix-gcc7-fallthrough.diff diff --git a/grub-core/gnulib-fix-gcc7-fallthrough.diff b/grub-core/gnulib-fix-gcc7-fallthrough.diff new file mode 100644 index 000000000..9802e2d24 --- /dev/null +++ b/grub-core/gnulib-fix-gcc7-fallthrough.diff @@ -0,0 +1,14 @@ +diff --git grub-core/gnulib/regexec.c grub-core/gnulib/regexec.c +index f632cd4..a7776f0 100644 +--- grub-core/gnulib/regexec.c ++++ grub-core/gnulib/regexec.c +@@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, + case OP_UTF8_PERIOD: + if (ch >= ASCII_CHARS) + return false; ++#if defined __GNUC__ && __GNUC__ >= 7 ++ __attribute__ ((fallthrough)); ++#endif + /* FALLTHROUGH */ + #endif + case OP_PERIOD: From d454509bb866d4eaefbb558d94dd0ef0228830eb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 12 Apr 2017 01:42:38 +0000 Subject: [PATCH 0665/1167] Fix remaining cases of gcc 7 fallthrough warning. They are all intended, so just add the relevant comment. --- grub-core/kern/ia64/dl.c | 1 + grub-core/kern/mips/dl.c | 1 + grub-core/kern/sparc64/dl.c | 1 + grub-core/loader/i386/coreboot/chainloader.c | 1 + 4 files changed, 4 insertions(+) diff --git a/grub-core/kern/ia64/dl.c b/grub-core/kern/ia64/dl.c index 082aebc3a..ebcf31629 100644 --- a/grub-core/kern/ia64/dl.c +++ b/grub-core/kern/ia64/dl.c @@ -119,6 +119,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, case R_IA64_LTOFF22: if (ELF_ST_TYPE (sym->st_info) == STT_FUNC) value = *(grub_uint64_t *) sym->st_value + rel->r_addend; + /* Fallthrough. */ case R_IA64_LTOFF_FPTR22: { grub_uint64_t *gpptr = mod->gotptr; diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c index e320a4ee7..5d7d299c7 100644 --- a/grub-core/kern/mips/dl.c +++ b/grub-core/kern/mips/dl.c @@ -236,6 +236,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, sym_value &= 0xffff0000; *(grub_uint16_t *) addr = 0; } + /* Fallthrough. */ case R_MIPS_CALL16: { grub_uint32_t *gpptr = mod->gotptr; diff --git a/grub-core/kern/sparc64/dl.c b/grub-core/kern/sparc64/dl.c index d25c15e10..739be4717 100644 --- a/grub-core/kern/sparc64/dl.c +++ b/grub-core/kern/sparc64/dl.c @@ -159,6 +159,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, if (value >> 32) return grub_error (GRUB_ERR_BAD_MODULE, "address out of 32 bits range"); + /* Fallthrough. */ case R_SPARC_LM22: *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF); break; diff --git a/grub-core/loader/i386/coreboot/chainloader.c b/grub-core/loader/i386/coreboot/chainloader.c index d4cc40b7f..2cb78eee0 100644 --- a/grub-core/loader/i386/coreboot/chainloader.c +++ b/grub-core/loader/i386/coreboot/chainloader.c @@ -384,6 +384,7 @@ load_chewed (grub_file_t file, const char *filename) segment.len = 0; segment.offset = 0; segment.len = 0; + /* Fallthrough. */ case PAYLOAD_SEGMENT_CODE: case PAYLOAD_SEGMENT_DATA: { From e54c99aaff5e5f6f5d3b06028506c57e66d8ef77 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 25 Apr 2017 16:23:16 +0200 Subject: [PATCH 0666/1167] Increase version to 2.02. --- configure.ac | 2 +- grub-core/tests/checksums.h | 196 ++++++++++++++++++------------------ 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/configure.ac b/configure.ac index acf94b056..edd184154 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02~rc2],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.02],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index efa1adb3f..68d8ce7c7 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,101 +1,101 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x64d48e11, 0x64d48e11, 0x4330a1f4, 0x4330a1f4, 0x601e4c0e, 0x601e4c0e, 0x82696fe9, 0x82696fe9, 0x41073bc1, 0x41073bc1, 0xc26fdc51, 0xc26fdc51, 0xb44ab310, 0xb44ab310, 0x7eea73d0, 0x7eea73d0, 0x51990cc9, 0x51990cc9, 0xba84146a, 0xba84146a, 0x81f97e51, 0x81f97e51, 0x3f03537, 0x3f03537, 0xfc05e3b5, 0xfc05e3b5, 0x3b7cdb50, 0x3b7cdb50, 0x6c348a56, 0x6c348a56, 0xc01c7fa1, 0xc01c7fa1, 0x61d25f00, 0x61d25f00, 0x55e18a76, 0x55e18a76, 0x6420218b, 0x6420218b, 0xf123faa7, 0xf123faa7, 0x696c7eda, 0xcceb9bb0, 0x9263f602, 0x9263f602, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe6e8acc3, 0xe6e8acc3, 0x826fcefc, 0x826fcefc, 0x604df2bf, 0x604df2bf, 0xc4b080b4, 0xc4b080b4, 0x926dc345, 0x926dc345, 0x8c5bdf8b, 0x8c5bdf8b, 0x2e2c4b47, 0x2e2c4b47, 0x5a40ab79, 0x5a40ab79, 0x30273200, 0x30273200, 0xc9baee33, 0xc9baee33, 0xe5bcf997, 0xe5bcf997, 0xe89072ad, 0xe89072ad, 0xa37a82bf, 0xa37a82bf, 0x94820281, 0x94820281, 0xf12d471, 0xf12d471, 0x24066d71, 0x24066d71, 0xc9ccad48, 0xc9ccad48, 0xef4da67a, 0xef4da67a, 0x9b941cce, 0x9b941cce, 0xfc657f55, 0xfc657f55, 0x361b98a5, 0x16a28824, 0x1fb9fe37, 0x1fb9fe37, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f1b6349, 0x9f1b6349, 0x4d602d62, 0x4d602d62, 0xacb261fd, 0xacb261fd, 0x216f238b, 0x216f238b, 0x692ce8e8, 0x692ce8e8, 0xd5728c94, 0xd5728c94, 0xa52a2994, 0xa52a2994, 0x5db1a6cf, 0x5db1a6cf, 0xaba6ebeb, 0xaba6ebeb, 0x52b7b1b2, 0x52b7b1b2, 0x7552f41b, 0x7552f41b, 0xb2c2a7ce, 0xb2c2a7ce, 0x1b7b534e, 0x1b7b534e, 0x76112f0c, 0x76112f0c, 0xaf522ac, 0xaf522ac, 0x27da0578, 0x27da0578, 0x3e09bc10, 0x3e09bc10, 0x5e80fbb9, 0x5e80fbb9, 0x9e6bf207, 0x9e6bf207, 0xcf02355f, 0xcf02355f, 0x1eb1112f, 0xf2a4c25e, 0x63e655c4, 0x63e655c4, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xfb375a6d, 0xfb375a6d, 0xe84b0b99, 0xe84b0b99, 0x47425305, 0x47425305, 0xae2951a0, 0xae2951a0, 0x9c166a1e, 0x9c166a1e, 0xccae4822, 0xccae4822, 0x6ff31033, 0x6ff31033, 0x3ea842c4, 0x3ea842c4, 0x53a0f741, 0x53a0f741, 0x565a8328, 0x565a8328, 0x698498b4, 0x698498b4, 0x956c542b, 0x956c542b, 0x1d90d193, 0x1d90d193, 0x93a302cd, 0x93a302cd, 0x2de75bd, 0x2de75bd, 0x6c6a8682, 0x6c6a8682, 0xcc3eb620, 0xcc3eb620, 0x6a63564b, 0x6a63564b, 0x62934959, 0x62934959, 0xef320100, 0xef320100, 0x94cc54bf, 0x9473a69c, 0x632eb358, 0x632eb358, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f56a4, 0xc24f56a4, 0x3294d372, 0x3294d372, 0x27cc0a5f, 0x27cc0a5f, 0x2ef60b42, 0x2ef60b42, 0xd0985c3d, 0xd0985c3d, 0x8628c70d, 0x8628c70d, 0xfd4baba8, 0xfd4baba8, 0xaad76619, 0xaad76619, 0xcea8ebd6, 0xcea8ebd6, 0x6c20bcf1, 0x6c20bcf1, 0xeeba475, 0xeeba475, 0x149ff274, 0x149ff274, 0xcebe6493, 0xcebe6493, 0x1e505f4b, 0x1e505f4b, 0x7c12f45a, 0x7c12f45a, 0x41703c44, 0x41703c44, 0x346ba166, 0x346ba166, 0x941fe02f, 0x941fe02f, 0xf5be5bb3, 0xf5be5bb3, 0x3d52a9a2, 0x3d52a9a2, 0x33af135a, 0xd4ee3b2, 0x8e3f61b0, 0x8e3f61b0, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb96e28e9, 0xb96e28e9, 0x11da3359, 0x11da3359, 0xc36007c7, 0xc36007c7, 0x77a353a1, 0x77a353a1, 0xeb88539b, 0xeb88539b, 0x1e00cd2e, 0x1e00cd2e, 0xcc58d945, 0xcc58d945, 0x967f9311, 0x967f9311, 0x1b4aee63, 0x1b4aee63, 0x93da5a6a, 0x93da5a6a, 0x66934cb7, 0x66934cb7, 0xbbcefdce, 0xbbcefdce, 0x78f492b1, 0x78f492b1, 0x924f313b, 0x924f313b, 0x83d7a122, 0x83d7a122, 0x330676e1, 0x330676e1, 0x4223f775, 0x4223f775, 0xd023d9f8, 0xd023d9f8, 0x4fdf440, 0x4fdf440, 0x308b0685, 0x308b0685, 0xdc63a02b, 0x9502eb7f, 0x8a3a85e2, 0x8a3a85e2, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x53572ec9, 0x53572ec9, 0xeceb44e4, 0xeceb44e4, 0x5278dfd2, 0x5278dfd2, 0x2ed7d0d4, 0x2ed7d0d4, 0xa3440592, 0xa3440592, 0x92ffa5c6, 0x92ffa5c6, 0xaff2ad3e, 0xaff2ad3e, 0x2a31cab3, 0x2a31cab3, 0x299ef74e, 0x299ef74e, 0x76e54e80, 0x76e54e80, 0xb964e0f3, 0xb964e0f3, 0x2106b636, 0x2106b636, 0x1ee23596, 0x1ee23596, 0xeb3c9e13, 0xeb3c9e13, 0x1aa29e04, 0x1aa29e04, 0x7a262f24, 0x7a262f24, 0x467ad56a, 0x467ad56a, 0xd985c883, 0xd985c883, 0x7e57edbf, 0x7e57edbf, 0xf9d8e719, 0xf9d8e719, 0x1df01339, 0xf04bbace, 0x2a481eef, 0x2a481eef, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa9354fc3, 0xcffaa340, 0xa9354fc3, 0xeac38284, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0xeac38284, 0xeac38284, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe1081bb8, 0x45229c00, 0xe1081bb8, 0xcf0d9ec7, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0xcf0d9ec7, 0xcf0d9ec7, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x75bf9d41, 0xcf33c299, 0x75bf9d41, 0x28a8f0c5, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0x28a8f0c5, 0x28a8f0c5, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc611f412, 0x75b1fd25, 0xc611f412, 0x6847bdca, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0x6847bdca, 0x6847bdca, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf8d2d04, 0x1f7b3665, 0xf8d2d04, 0x792b18b7, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x792b18b7, 0x792b18b7, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcec57923, 0x9abdddfd, 0xcec57923, 0xd5c0a324, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0xd5c0a324, 0xd5c0a324, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf5d1bb8f, 0x5e406c32, 0xf5d1bb8f, 0xa6ea00f, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0xa6ea00f, 0xa6ea00f, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0xa90b01bc, 0xa90b01bc, 0xa90b01bc, 0xf5d3f77c, 0xf5d3f77c, 0xf5d3f77c, 0xdc4b39ee, 0xdc4b39ee, 0xdc4b39ee, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0x11c82fe4, 0x11c82fe4, 0x11c82fe4, 0x449785ee, 0x449785ee, 0x449785ee, 0x2da44da7, 0x2da44da7, 0x2da44da7, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xc52df491, 0xc52df491, 0xc52df491, 0xba935205, 0xba935205, 0xba935205, 0xf8e7327d, 0xf8e7327d, 0xf8e7327d, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x6a50b915, 0x6a50b915, 0x6a50b915, 0x81f55369, 0x81f55369, 0x81f55369, 0x87be5399, 0x87be5399, 0x87be5399, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0xf841f7f, 0xf841f7f, 0xf841f7f, 0x60cdc36e, 0x60cdc36e, 0x60cdc36e, 0x6d3b5d6d, 0x6d3b5d6d, 0x6d3b5d6d, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x5b2ee37, 0x5b2ee37, 0x5b2ee37, 0xc300aa29, 0xc300aa29, 0xc300aa29, 0xd7657a96, 0xd7657a96, 0xd7657a96, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x8001ca17, 0x8001ca17, 0x8001ca17, 0x1f23cc6, 0x1f23cc6, 0x1f23cc6, 0x975685a9, 0x975685a9, 0x975685a9, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x82d8a3c, 0x6cd37a4, 0x82d8a3c, 0x4bdb477b, 0x59c36f00, 0x59c36f00, 0x46da1ede, 0x46da1ede, 0x46da1ede, 0x385a73b8, 0x385a73b8, 0x385a73b8, 0x5aac666a, 0x5aac666a, 0x5aac666a, 0x59c36f00, 0x4bdb477b, 0x4bdb477b, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x78e61710, 0x8cfbe03c, 0x78e61710, 0x56e3926f, 0xaa4593fe, 0xaa4593fe, 0x8e893728, 0x8e893728, 0x8e893728, 0x287c3a4f, 0x287c3a4f, 0x287c3a4f, 0x5449137, 0x5449137, 0x5449137, 0xaa4593fe, 0x56e3926f, 0x56e3926f, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8616c425, 0x949a7fa8, 0x8616c425, 0xdb01a9a1, 0xc9cbf769, 0xc9cbf769, 0xea2a5113, 0xea2a5113, 0xea2a5113, 0x14f290df, 0x14f290df, 0x14f290df, 0xfdb82fd7, 0xfdb82fd7, 0xfdb82fd7, 0xc9cbf769, 0xdb01a9a1, 0xdb01a9a1, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7b96f2e, 0x1a88dd6f, 0x7b96f2e, 0xa9ef26f6, 0x9813a416, 0x9813a416, 0xc6bba65a, 0xc6bba65a, 0xc6bba65a, 0x57602069, 0x57602069, 0x57602069, 0x4eda1db9, 0x4eda1db9, 0x4eda1db9, 0x9813a416, 0xa9ef26f6, 0xa9ef26f6, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x95679383, 0x54029d22, 0x95679383, 0xe3c1a630, 0x5fcf013d, 0x5fcf013d, 0x7cccc38f, 0x7cccc38f, 0x7cccc38f, 0xaedcdbf9, 0xaedcdbf9, 0xaedcdbf9, 0xb8afe466, 0xb8afe466, 0xb8afe466, 0x5fcf013d, 0xe3c1a630, 0xe3c1a630, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdc1ff783, 0x13e0969e, 0xdc1ff783, 0xc71a2d84, 0xdd28f52b, 0xdd28f52b, 0x9227d7c1, 0x9227d7c1, 0x9227d7c1, 0xb31b2e25, 0xb31b2e25, 0xb31b2e25, 0xcea3e5a9, 0xcea3e5a9, 0xcea3e5a9, 0xdd28f52b, 0xc71a2d84, 0xc71a2d84, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x23cfa079, 0x52702665, 0x23cfa079, 0xdc70bbf9, 0x43d1f34, 0x43d1f34, 0x733dddc9, 0x733dddc9, 0x733dddc9, 0xc377461, 0xc377461, 0xc377461, 0x956671e7, 0x956671e7, 0x956671e7, 0x43d1f34, 0xdc70bbf9, 0xdc70bbf9, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4582c049, 0x3db332af, 0x4582c049, 0x6740d0e, 0x59c36f00, 0x59c36f00, 0x1e6dfa2, 0x1e6dfa2, 0x1e6dfa2, 0x7f66b2c4, 0x7f66b2c4, 0x7f66b2c4, 0x1d90a716, 0x1d90a716, 0x1d90a716, 0x59c36f00, 0x6740d0e, 0x6740d0e, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xdc8ccbe5, 0x7f38bbe9, 0xdc8ccbe5, 0xf2894e9a, 0xaa4593fe, 0xaa4593fe, 0xb1e9401e, 0xb1e9401e, 0xb1e9401e, 0x171c4d79, 0x171c4d79, 0x171c4d79, 0x3a24e601, 0x3a24e601, 0x3a24e601, 0xaa4593fe, 0xf2894e9a, 0xf2894e9a, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2ab2ff2f, 0x88773992, 0x2ab2ff2f, 0x77a592ab, 0xc9cbf769, 0xc9cbf769, 0x261a2f75, 0x261a2f75, 0x261a2f75, 0xd8c2eeb9, 0xd8c2eeb9, 0xd8c2eeb9, 0x318851b1, 0x318851b1, 0x318851b1, 0xc9cbf769, 0x77a592ab, 0x77a592ab, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4937982a, 0x671b7841, 0x4937982a, 0xe761d1f2, 0x9813a416, 0x9813a416, 0x87d79e45, 0x87d79e45, 0x87d79e45, 0x160c1876, 0x160c1876, 0x160c1876, 0xfb625a6, 0xfb625a6, 0xfb625a6, 0x9813a416, 0xe761d1f2, 0xe761d1f2, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x617eae5c, 0xfad61931, 0x617eae5c, 0x17d89bef, 0x5fcf013d, 0x5fcf013d, 0xde0c1058, 0xde0c1058, 0xde0c1058, 0xc1c082e, 0xc1c082e, 0xc1c082e, 0x1a6f37b1, 0x1a6f37b1, 0x1a6f37b1, 0x5fcf013d, 0x17d89bef, 0x17d89bef, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfa1ba2c2, 0x640c9857, 0xfa1ba2c2, 0xe11e78c5, 0xdd28f52b, 0xdd28f52b, 0x63b59689, 0x63b59689, 0x63b59689, 0x42896f6d, 0x42896f6d, 0x42896f6d, 0x3f31a4e1, 0x3f31a4e1, 0x3f31a4e1, 0xdd28f52b, 0xe11e78c5, 0xe11e78c5, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8e48efc2, 0xcc38fe16, 0x8e48efc2, 0x71f7f442, 0x43d1f34, 0x43d1f34, 0xebe57216, 0xebe57216, 0xebe57216, 0x94efdbbe, 0x94efdbbe, 0x94efdbbe, 0xdbede38, 0xdbede38, 0xdbede38, 0x43d1f34, 0x71f7f442, 0x71f7f442, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x266da594, 0x24b82ab5, 0x266da594, 0x659b68d3, 0x59c36f00, 0x59c36f00, 0xdb8dd8c4, 0xdb8dd8c4, 0xdb8dd8c4, 0xa50db5a2, 0xa50db5a2, 0xa50db5a2, 0xc7fba070, 0xc7fba070, 0xc7fba070, 0x59c36f00, 0x659b68d3, 0x659b68d3, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xba8fe08d, 0x9d9bc2e, 0xba8fe08d, 0x948a65f2, 0xaa4593fe, 0xaa4593fe, 0xaa152d8e, 0xaa152d8e, 0xaa152d8e, 0xce020e9, 0xce020e9, 0xce020e9, 0x21d88b91, 0x21d88b91, 0x21d88b91, 0xaa4593fe, 0x948a65f2, 0x948a65f2, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9a003828, 0x2ba49253, 0x9a003828, 0xc71755ac, 0xc9cbf769, 0xc9cbf769, 0xaa0a5e12, 0xaa0a5e12, 0xaa0a5e12, 0x54d29fde, 0x54d29fde, 0x54d29fde, 0xbd9820d6, 0xbd9820d6, 0xbd9820d6, 0xc9cbf769, 0xc71755ac, 0xc71755ac, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8187ce81, 0x75269aaa, 0x8187ce81, 0x2fd18759, 0x9813a416, 0x9813a416, 0x12e905c0, 0x12e905c0, 0x12e905c0, 0x833283f3, 0x833283f3, 0x833283f3, 0x9a88be23, 0x9a88be23, 0x9a88be23, 0x9813a416, 0x2fd18759, 0x2fd18759, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x500d0c44, 0x70d2d942, 0x500d0c44, 0x26ab39f7, 0x5fcf013d, 0x5fcf013d, 0x5bde93cf, 0x5bde93cf, 0x5bde93cf, 0x89ce8bb9, 0x89ce8bb9, 0x89ce8bb9, 0x9fbdb426, 0x9fbdb426, 0x9fbdb426, 0x5fcf013d, 0x26ab39f7, 0x26ab39f7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x16591b36, 0x21c0f059, 0x16591b36, 0xd5cc131, 0xdd28f52b, 0xdd28f52b, 0x2010760f, 0x2010760f, 0x2010760f, 0x12c8feb, 0x12c8feb, 0x12c8feb, 0x7c944467, 0x7c944467, 0x7c944467, 0xdd28f52b, 0xd5cc131, 0xd5cc131, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xddbfde17, 0xfb121565, 0xddbfde17, 0x2200c597, 0x43d1f34, 0x43d1f34, 0xb6333f22, 0xb6333f22, 0xb6333f22, 0xc939968a, 0xc939968a, 0xc939968a, 0x5068930c, 0x5068930c, 0x5068930c, 0x43d1f34, 0x2200c597, 0x2200c597, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xde6eb23f, 0x622ba005, 0xde6eb23f, 0x9d987f78, 0x59c36f00, 0x59c36f00, 0xfaf9dd19, 0xfaf9dd19, 0xfaf9dd19, 0x8479b07f, 0x8479b07f, 0x8479b07f, 0xe68fa5ad, 0xe68fa5ad, 0xe68fa5ad, 0x59c36f00, 0x9d987f78, 0x9d987f78, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x920dc865, 0x643d1348, 0x920dc865, 0xbc084d1a, 0xaa4593fe, 0xaa4593fe, 0xb332a002, 0xb332a002, 0xb332a002, 0x15c7ad65, 0x15c7ad65, 0x15c7ad65, 0x38ff061d, 0x38ff061d, 0x38ff061d, 0xaa4593fe, 0xbc084d1a, 0xbc084d1a, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xae96dbc6, 0x1d9c4918, 0xae96dbc6, 0xf381b642, 0xc9cbf769, 0xc9cbf769, 0x9bd7a35, 0x9bd7a35, 0x9bd7a35, 0xf765bbf9, 0xf765bbf9, 0xf765bbf9, 0x1e2f04f1, 0x1e2f04f1, 0x1e2f04f1, 0xc9cbf769, 0xf381b642, 0xf381b642, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x68ab5a83, 0x1dedd3f0, 0x68ab5a83, 0xc6fd135b, 0x9813a416, 0x9813a416, 0xfe9f04ad, 0xfe9f04ad, 0xfe9f04ad, 0x6f44829e, 0x6f44829e, 0x6f44829e, 0x76febf4e, 0x76febf4e, 0x76febf4e, 0x9813a416, 0xc6fd135b, 0xc6fd135b, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa113e90c, 0xc3b993d8, 0xa113e90c, 0xd7b5dcbf, 0x5fcf013d, 0x5fcf013d, 0xd4453517, 0xd4453517, 0xd4453517, 0x6552d61, 0x6552d61, 0x6552d61, 0x102612fe, 0x102612fe, 0x102612fe, 0x5fcf013d, 0xd7b5dcbf, 0xd7b5dcbf, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd74db26e, 0xfee01078, 0xd74db26e, 0xcc486869, 0xdd28f52b, 0xdd28f52b, 0x5b477f04, 0x5b477f04, 0x5b477f04, 0x7a7b86e0, 0x7a7b86e0, 0x7a7b86e0, 0x7c34d6c, 0x7c34d6c, 0x7c34d6c, 0xdd28f52b, 0xcc486869, 0xcc486869, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa80953f6, 0x13208dce, 0xa80953f6, 0x57b64876, 0x43d1f34, 0x43d1f34, 0x15662f13, 0x15662f13, 0x15662f13, 0x6a6c86bb, 0x6a6c86bb, 0x6a6c86bb, 0xf33d833d, 0xf33d833d, 0xf33d833d, 0x43d1f34, 0x57b64876, 0x57b64876, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x28730c5a, 0x10c504c1, 0x28730c5a, 0x6b85c11d, 0x59c36f00, 0x59c36f00, 0xe2713dc2, 0xe2713dc2, 0xe2713dc2, 0x9cf150a4, 0x9cf150a4, 0x9cf150a4, 0xfe074576, 0xfe074576, 0xfe074576, 0x59c36f00, 0x6b85c11d, 0x6b85c11d, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa6720cda, 0x79326293, 0xa6720cda, 0x887789a5, 0xaa4593fe, 0xaa4593fe, 0xf5a98049, 0xf5a98049, 0xf5a98049, 0x535c8d2e, 0x535c8d2e, 0x535c8d2e, 0x7e642656, 0x7e642656, 0x7e642656, 0xaa4593fe, 0x887789a5, 0x887789a5, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefc130b0, 0xc15c12f3, 0xefc130b0, 0xb2d65d34, 0xc9cbf769, 0xc9cbf769, 0xb80d0c51, 0xb80d0c51, 0xb80d0c51, 0x46d5cd9d, 0x46d5cd9d, 0x46d5cd9d, 0xaf9f7295, 0xaf9f7295, 0xaf9f7295, 0xc9cbf769, 0xb2d65d34, 0xb2d65d34, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd363ab7, 0x7fdff86a, 0xd363ab7, 0xa360736f, 0x9813a416, 0x9813a416, 0xf0212278, 0xf0212278, 0xf0212278, 0x61faa44b, 0x61faa44b, 0x61faa44b, 0x7840999b, 0x7840999b, 0x7840999b, 0x9813a416, 0xa360736f, 0xa360736f, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xdd4249ff, 0xf4a0d4a3, 0xdd4249ff, 0xabe47c4c, 0x5fcf013d, 0x5fcf013d, 0x4170c1bb, 0x4170c1bb, 0x4170c1bb, 0x9360d9cd, 0x9360d9cd, 0x9360d9cd, 0x8513e652, 0x8513e652, 0x8513e652, 0x5fcf013d, 0xabe47c4c, 0xabe47c4c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdf2ffd30, 0x53da6bb9, 0xdf2ffd30, 0xc42a2737, 0xdd28f52b, 0xdd28f52b, 0x8077de4, 0x8077de4, 0x8077de4, 0x293b8400, 0x293b8400, 0x293b8400, 0x54834f8c, 0x54834f8c, 0x54834f8c, 0xdd28f52b, 0xc42a2737, 0xc42a2737, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbfb4210a, 0x7a4373, 0xbfb4210a, 0x400b3a8a, 0x43d1f34, 0x43d1f34, 0xd0b7fd4b, 0xd0b7fd4b, 0xd0b7fd4b, 0xafbd54e3, 0xafbd54e3, 0xafbd54e3, 0x36ec5165, 0x36ec5165, 0x36ec5165, 0x43d1f34, 0x400b3a8a, 0x400b3a8a, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd6e69c19, 0xfd01b92b, 0xd6e69c19, 0x9510515e, 0x59c36f00, 0x59c36f00, 0xd41a73d2, 0xd41a73d2, 0xd41a73d2, 0xaa9a1eb4, 0xaa9a1eb4, 0xaa9a1eb4, 0xc86c0b66, 0xc86c0b66, 0xc86c0b66, 0x59c36f00, 0x9510515e, 0x9510515e, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x770e32e, 0xf0e77497, 0x770e32e, 0x29756651, 0xaa4593fe, 0xaa4593fe, 0x9e257fc7, 0x9e257fc7, 0x9e257fc7, 0x38d072a0, 0x38d072a0, 0x38d072a0, 0x15e8d9d8, 0x15e8d9d8, 0x15e8d9d8, 0xaa4593fe, 0x29756651, 0x29756651, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa2fe1c87, 0x3e7869d8, 0xa2fe1c87, 0xffe97103, 0xc9cbf769, 0xc9cbf769, 0xc5920970, 0xc5920970, 0xc5920970, 0x3b4ac8bc, 0x3b4ac8bc, 0x3b4ac8bc, 0xd20077b4, 0xd20077b4, 0xd20077b4, 0xc9cbf769, 0xffe97103, 0xffe97103, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x551e28a2, 0x117eec93, 0x551e28a2, 0xfb48617a, 0x9813a416, 0x9813a416, 0x9bd613bc, 0x9bd613bc, 0x9bd613bc, 0xa0d958f, 0xa0d958f, 0xa0d958f, 0x13b7a85f, 0x13b7a85f, 0x13b7a85f, 0x9813a416, 0xfb48617a, 0xfb48617a, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb371f66c, 0x6f3a4cc9, 0xb371f66c, 0xc5d7c3df, 0x5fcf013d, 0x5fcf013d, 0x1cfef603, 0x1cfef603, 0x1cfef603, 0xceeeee75, 0xceeeee75, 0xceeeee75, 0xd89dd1ea, 0xd89dd1ea, 0xd89dd1ea, 0x5fcf013d, 0xc5d7c3df, 0xc5d7c3df, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc6b72d49, 0xedbe4dae, 0xc6b72d49, 0xddb2f74e, 0xdd28f52b, 0xdd28f52b, 0x86b465e5, 0x86b465e5, 0x86b465e5, 0xa7889c01, 0xa7889c01, 0xa7889c01, 0xda30578d, 0xda30578d, 0xda30578d, 0xdd28f52b, 0xddb2f74e, 0xddb2f74e, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5e2e17e4, 0x9bf82c1b, 0x5e2e17e4, 0xa1910c64, 0x43d1f34, 0x43d1f34, 0x823d979, 0x823d979, 0x823d979, 0x772970d1, 0x772970d1, 0x772970d1, 0xee787557, 0xee787557, 0xee787557, 0x43d1f34, 0xa1910c64, 0xa1910c64, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x15d42b6c, 0x731bc7ef, 0x15d42b6c, 0x5622e62b, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0x5622e62b, 0x5622e62b, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x58683e3c, 0xfc42b984, 0x58683e3c, 0x766dbb43, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0x766dbb43, 0x766dbb43, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf5d76d17, 0x4f5b32cf, 0xf5d76d17, 0xa8c00093, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0xa8c00093, 0xa8c00093, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x73304730, 0xc0904e07, 0x73304730, 0xdd660ee8, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0xdd660ee8, 0xdd660ee8, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4daec3fc, 0x5d58d89d, 0x4daec3fc, 0x3b08f64f, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x3b08f64f, 0x3b08f64f, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5af5f85c, 0xe8d5c82, 0x5af5f85c, 0x41f0225b, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0x41f0225b, 0x41f0225b, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb819f982, 0x13882e3f, 0xb819f982, 0x47a6e202, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0x47a6e202, 0x47a6e202, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4e09ed16, 0x1b959f2, 0x4e09ed16, 0xdff2051, 0x59c36f00, 0x59c36f00, 0x9d5feea7, 0x9d5feea7, 0x9d5feea7, 0xe3df83c1, 0xe3df83c1, 0xe3df83c1, 0x81299613, 0x81299613, 0x81299613, 0x59c36f00, 0xdff2051, 0xdff2051, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb4fe3633, 0xbd9a0250, 0xb4fe3633, 0x9afbb34c, 0xaa4593fe, 0xaa4593fe, 0x8d224121, 0x8d224121, 0x8d224121, 0x2bd74c46, 0x2bd74c46, 0x2bd74c46, 0x6efe73e, 0x6efe73e, 0x6efe73e, 0xaa4593fe, 0x9afbb34c, 0x9afbb34c, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x19cdf337, 0xd89c052a, 0x19cdf337, 0x44da9eb3, 0xc9cbf769, 0xc9cbf769, 0x203fc41b, 0x203fc41b, 0x203fc41b, 0xdee705d7, 0xdee705d7, 0xdee705d7, 0x37adbadf, 0x37adbadf, 0x37adbadf, 0xc9cbf769, 0x44da9eb3, 0x44da9eb3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5bd9226d, 0x73b88c1, 0x5bd9226d, 0xf58f6bb5, 0x9813a416, 0x9813a416, 0x60c7ae6c, 0x60c7ae6c, 0x60c7ae6c, 0xf11c285f, 0xf11c285f, 0xf11c285f, 0xe8a6158f, 0xe8a6158f, 0xe8a6158f, 0x9813a416, 0xf58f6bb5, 0xf58f6bb5, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5bee0c71, 0x22fee848, 0x5bee0c71, 0x2d4839c2, 0x5fcf013d, 0x5fcf013d, 0x56213219, 0x56213219, 0x56213219, 0x84312a6f, 0x84312a6f, 0x84312a6f, 0x924215f0, 0x924215f0, 0x924215f0, 0x5fcf013d, 0x2d4839c2, 0x2d4839c2, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x56e6fad4, 0x3c9e4aea, 0x56e6fad4, 0x4de320d3, 0xdd28f52b, 0xdd28f52b, 0x83d6662d, 0x83d6662d, 0x83d6662d, 0xa2ea9fc9, 0xa2ea9fc9, 0xa2ea9fc9, 0xdf525445, 0xdf525445, 0xdf525445, 0xdd28f52b, 0x4de320d3, 0x4de320d3, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfde17453, 0xe772a7a, 0xfde17453, 0x25e6fd3, 0x43d1f34, 0x43d1f34, 0xad2497d2, 0xad2497d2, 0xad2497d2, 0xd22e3e7a, 0xd22e3e7a, 0xd22e3e7a, 0x4b7f3bfc, 0x4b7f3bfc, 0x4b7f3bfc, 0x43d1f34, 0x25e6fd3, 0x25e6fd3, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5112a279, 0x63608f0d, 0x5112a279, 0x12e46f3e, 0x59c36f00, 0x59c36f00, 0x64cc7367, 0x64cc7367, 0x64cc7367, 0x1a4c1e01, 0x1a4c1e01, 0x1a4c1e01, 0x78ba0bd3, 0x78ba0bd3, 0x78ba0bd3, 0x59c36f00, 0x12e46f3e, 0x12e46f3e, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x428dd311, 0x6168e994, 0x428dd311, 0x6c88566e, 0xaa4593fe, 0xaa4593fe, 0x9a464f37, 0x9a464f37, 0x9a464f37, 0x3cb34250, 0x3cb34250, 0x3cb34250, 0x118be928, 0x118be928, 0x118be928, 0xaa4593fe, 0x6c88566e, 0x6c88566e, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc71c50d3, 0xf111a91c, 0xc71c50d3, 0x9a0b3d57, 0xc9cbf769, 0xc9cbf769, 0x9bc1473d, 0x9bc1473d, 0x9bc1473d, 0x651986f1, 0x651986f1, 0x651986f1, 0x8c5339f9, 0x8c5339f9, 0x8c5339f9, 0xc9cbf769, 0x9a0b3d57, 0x9a0b3d57, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x61d6a73a, 0xf4179296, 0x61d6a73a, 0xcf80eee2, 0x9813a416, 0x9813a416, 0x841b9482, 0x841b9482, 0x841b9482, 0x15c012b1, 0x15c012b1, 0x15c012b1, 0xc7a2f61, 0xc7a2f61, 0xc7a2f61, 0x9813a416, 0xcf80eee2, 0xcf80eee2, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9b88583d, 0x4c7bf28e, 0x9b88583d, 0xed2e6d8e, 0x5fcf013d, 0x5fcf013d, 0x31e3f856, 0x31e3f856, 0x31e3f856, 0xe3f3e020, 0xe3f3e020, 0xe3f3e020, 0xf580dfbf, 0xf580dfbf, 0xf580dfbf, 0x5fcf013d, 0xed2e6d8e, 0xed2e6d8e, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x77b18e2f, 0xe8e63830, 0x77b18e2f, 0x6cb45428, 0xdd28f52b, 0xdd28f52b, 0x8c504561, 0x8c504561, 0x8c504561, 0xad6cbc85, 0xad6cbc85, 0xad6cbc85, 0xd0d47709, 0xd0d47709, 0xd0d47709, 0xdd28f52b, 0x6cb45428, 0x6cb45428, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc7bba485, 0x9b3a97f6, 0xc7bba485, 0x3804bf05, 0x43d1f34, 0x43d1f34, 0xb57a04a9, 0xb57a04a9, 0xb57a04a9, 0xca70ad01, 0xca70ad01, 0xca70ad01, 0x5321a887, 0x5321a887, 0x5321a887, 0x43d1f34, 0x3804bf05, 0x3804bf05, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1d498e, 0x66d2a50d, 0x1d498e, 0x5730f750, 0x59c36f00, 0x59c36f00, 0xfafd31bc, 0xfafd31bc, 0xfafd31bc, 0x847d5cda, 0x847d5cda, 0x847d5cda, 0xe68b4908, 0xe68b4908, 0xe68b4908, 0x59c36f00, 0x5730f750, 0x5730f750, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf23a914f, 0x561016f7, 0xf23a914f, 0x429d4b19, 0xaa4593fe, 0xaa4593fe, 0xc03115b6, 0xc03115b6, 0xc03115b6, 0x66c418d1, 0x66c418d1, 0x66c418d1, 0x4bfcb3a9, 0x4bfcb3a9, 0x4bfcb3a9, 0xaa4593fe, 0x429d4b19, 0x429d4b19, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x731ebcf1, 0xc992e329, 0x731ebcf1, 0x633ba25f, 0xc9cbf769, 0xc9cbf769, 0x600022fb, 0x600022fb, 0x600022fb, 0x9ed8e337, 0x9ed8e337, 0x9ed8e337, 0x77925c3f, 0x77925c3f, 0x77925c3f, 0xc9cbf769, 0x633ba25f, 0x633ba25f, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4a87e91c, 0xf927e02b, 0x4a87e91c, 0x7af61533, 0x9813a416, 0x9813a416, 0x58a063c0, 0x58a063c0, 0x58a063c0, 0xc97be5f3, 0xc97be5f3, 0xc97be5f3, 0xd0c1d823, 0xd0c1d823, 0xd0c1d823, 0x9813a416, 0x7af61533, 0x7af61533, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb4820844, 0xa4741325, 0xb4820844, 0x1a85e7b1, 0x5fcf013d, 0x5fcf013d, 0x19cab3ea, 0x19cab3ea, 0x19cab3ea, 0xcbdaab9c, 0xcbdaab9c, 0xcbdaab9c, 0xdda99403, 0xdda99403, 0xdda99403, 0x5fcf013d, 0x1a85e7b1, 0x1a85e7b1, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x52a9ee36, 0x6d14ae8, 0x52a9ee36, 0xdccd25ec, 0xdd28f52b, 0xdd28f52b, 0xb6275f8e, 0xb6275f8e, 0xb6275f8e, 0x971ba66a, 0x971ba66a, 0x971ba66a, 0xeaa36de6, 0xeaa36de6, 0xeaa36de6, 0xdd28f52b, 0xdccd25ec, 0xdccd25ec, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6d47d8, 0xabfc9065, 0x6d47d8, 0x9735c178, 0x43d1f34, 0x43d1f34, 0xa8a2bd89, 0xa8a2bd89, 0xa8a2bd89, 0xd7a81421, 0xd7a81421, 0xd7a81421, 0x4ef911a7, 0x4ef911a7, 0x4ef911a7, 0x43d1f34, 0x9735c178, 0x9735c178, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3a3fb187, 0x5cf05d04, 0x3a3fb187, 0x82751e4d, 0x59c36f00, 0x59c36f00, 0x935c7fca, 0x935c7fca, 0x935c7fca, 0xeddc12ac, 0xeddc12ac, 0xeddc12ac, 0x8f2a077e, 0x8f2a077e, 0x8f2a077e, 0x59c36f00, 0x82751e4d, 0x82751e4d, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9086a313, 0x34ac24ab, 0x9086a313, 0x53006b9c, 0xaa4593fe, 0xaa4593fe, 0x4b2baf4c, 0x4b2baf4c, 0x4b2baf4c, 0xeddea22b, 0xeddea22b, 0xeddea22b, 0xc0e60953, 0xc0e60953, 0xc0e60953, 0xaa4593fe, 0x53006b9c, 0x53006b9c, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb1b455e8, 0xb380a30, 0xb1b455e8, 0xf3d1a9d5, 0xc9cbf769, 0xc9cbf769, 0xf426354c, 0xf426354c, 0xf426354c, 0xafef480, 0xafef480, 0xafef480, 0xe3b44b88, 0xe3b44b88, 0xe3b44b88, 0xc9cbf769, 0xf3d1a9d5, 0xf3d1a9d5, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x3d86952b, 0x8e269c1c, 0x3d86952b, 0x73953762, 0x9813a416, 0x9813a416, 0xac296590, 0xac296590, 0xac296590, 0x3df2e3a3, 0x3df2e3a3, 0x3df2e3a3, 0x2448de73, 0x2448de73, 0x2448de73, 0x9813a416, 0x73953762, 0x73953762, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xcd662d92, 0xdd9036f3, 0xcd662d92, 0x5e0022a5, 0x5fcf013d, 0x5fcf013d, 0xc05e35aa, 0xc05e35aa, 0xc05e35aa, 0x124e2ddc, 0x124e2ddc, 0x124e2ddc, 0x43d1243, 0x43d1243, 0x43d1243, 0x5fcf013d, 0x5e0022a5, 0x5e0022a5, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4f4e340f, 0x1b3690d1, 0x4f4e340f, 0xa8c8f051, 0xdd28f52b, 0xdd28f52b, 0x73523a9b, 0x73523a9b, 0x73523a9b, 0x526ec37f, 0x526ec37f, 0x526ec37f, 0x2fd608f3, 0x2fd608f3, 0x2fd608f3, 0xdd28f52b, 0xa8c8f051, 0xa8c8f051, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xad11478c, 0x6809031, 0xad11478c, 0xd5991923, 0x43d1f34, 0x43d1f34, 0x4064c649, 0x4064c649, 0x4064c649, 0x3f6e6fe1, 0x3f6e6fe1, 0x3f6e6fe1, 0xa63f6a67, 0xa63f6a67, 0xa63f6a67, 0x43d1f34, 0xd5991923, 0xd5991923, 0x43d1f34, }, 20 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xcd5fc34e, 0xcd5fc34e, 0xeabbecab, 0xeabbecab, 0xc9950151, 0xc9950151, 0x2be222b6, 0x2be222b6, 0xe88c769e, 0xe88c769e, 0x6be4910e, 0x6be4910e, 0x1dc1fe4f, 0x1dc1fe4f, 0xd7613e8f, 0xd7613e8f, 0xf8124196, 0xf8124196, 0x130f5935, 0x130f5935, 0x2872330e, 0x2872330e, 0xaa7b7868, 0xaa7b7868, 0x558eaeea, 0x558eaeea, 0x92f7960f, 0x92f7960f, 0xc5bfc709, 0xc5bfc709, 0x699732fe, 0x699732fe, 0xc859125f, 0xc859125f, 0xfc6ac729, 0xfc6ac729, 0xcdab6cd4, 0xcdab6cd4, 0x58a8b7f8, 0x58a8b7f8, 0xc0e73385, 0x6560d6ef, 0x3be8bb5d, 0x3be8bb5d, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x13029f94, 0x13029f94, 0x7785fdab, 0x7785fdab, 0x95a7c1e8, 0x95a7c1e8, 0x315ab3e3, 0x315ab3e3, 0x6787f012, 0x6787f012, 0x79b1ecdc, 0x79b1ecdc, 0xdbc67810, 0xdbc67810, 0xafaa982e, 0xafaa982e, 0xc5cd0157, 0xc5cd0157, 0x3c50dd64, 0x3c50dd64, 0x1056cac0, 0x1056cac0, 0x1d7a41fa, 0x1d7a41fa, 0x5690b1e8, 0x5690b1e8, 0x616831d6, 0x616831d6, 0xfaf8e726, 0xfaf8e726, 0xd1ec5e26, 0xd1ec5e26, 0x3c269e1f, 0x3c269e1f, 0x1aa7952d, 0x1aa7952d, 0x6e7e2f99, 0x6e7e2f99, 0x98f4c02, 0x98f4c02, 0xc3f1abf2, 0xe348bb73, 0xea53cd60, 0xea53cd60, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8fbb4f4c, 0x8fbb4f4c, 0x5dc00167, 0x5dc00167, 0xbc124df8, 0xbc124df8, 0x31cf0f8e, 0x31cf0f8e, 0x798cc4ed, 0x798cc4ed, 0xc5d2a091, 0xc5d2a091, 0xb58a0591, 0xb58a0591, 0x4d118aca, 0x4d118aca, 0xbb06c7ee, 0xbb06c7ee, 0x42179db7, 0x42179db7, 0x65f2d81e, 0x65f2d81e, 0xa2628bcb, 0xa2628bcb, 0xbdb7f4b, 0xbdb7f4b, 0x66b10309, 0x66b10309, 0x1a550ea9, 0x1a550ea9, 0x377a297d, 0x377a297d, 0x2ea99015, 0x2ea99015, 0x4e20d7bc, 0x4e20d7bc, 0x8ecbde02, 0x8ecbde02, 0xdfa2195a, 0xdfa2195a, 0xe113d2a, 0xe204ee5b, 0x734679c1, 0x734679c1, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe2f6bfe1, 0xe2f6bfe1, 0xf18aee15, 0xf18aee15, 0x5e83b689, 0x5e83b689, 0xb7e8b42c, 0xb7e8b42c, 0x85d78f92, 0x85d78f92, 0xd56fadae, 0xd56fadae, 0x7632f5bf, 0x7632f5bf, 0x2769a748, 0x2769a748, 0x4a6112cd, 0x4a6112cd, 0x4f9b66a4, 0x4f9b66a4, 0x70457d38, 0x70457d38, 0x8cadb1a7, 0x8cadb1a7, 0x451341f, 0x451341f, 0x8a62e741, 0x8a62e741, 0x1b1f9031, 0x1b1f9031, 0x75ab630e, 0x75ab630e, 0xd5ff53ac, 0xd5ff53ac, 0x73a2b3c7, 0x73a2b3c7, 0x7b52acd5, 0x7b52acd5, 0xf6f3e48c, 0xf6f3e48c, 0x8d0db133, 0x8db24310, 0x7aef56d4, 0x7aef56d4, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x838a3f40, 0x838a3f40, 0x7351ba96, 0x7351ba96, 0x660963bb, 0x660963bb, 0x6f3362a6, 0x6f3362a6, 0x915d35d9, 0x915d35d9, 0xc7edaee9, 0xc7edaee9, 0xbc8ec24c, 0xbc8ec24c, 0xeb120ffd, 0xeb120ffd, 0x8f6d8232, 0x8f6d8232, 0x2de5d515, 0x2de5d515, 0x4f2ecd91, 0x4f2ecd91, 0x555a9b90, 0x555a9b90, 0x8f7b0d77, 0x8f7b0d77, 0x5f9536af, 0x5f9536af, 0x3dd79dbe, 0x3dd79dbe, 0xb555a0, 0xb555a0, 0x75aec882, 0x75aec882, 0xd5da89cb, 0xd5da89cb, 0xb47b3257, 0xb47b3257, 0x7c97c046, 0x7c97c046, 0x726a7abe, 0x4c8b8a56, 0xcffa0854, 0xcffa0854, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7bf761e, 0x7bf761e, 0xaf0b6dae, 0xaf0b6dae, 0x7db15930, 0x7db15930, 0xc9720d56, 0xc9720d56, 0x55590d6c, 0x55590d6c, 0xa0d193d9, 0xa0d193d9, 0x728987b2, 0x728987b2, 0x28aecde6, 0x28aecde6, 0xa59bb094, 0xa59bb094, 0x2d0b049d, 0x2d0b049d, 0xd8421240, 0xd8421240, 0x51fa339, 0x51fa339, 0xc625cc46, 0xc625cc46, 0x2c9e6fcc, 0x2c9e6fcc, 0x3d06ffd5, 0x3d06ffd5, 0x8dd72816, 0x8dd72816, 0xfcf2a982, 0xfcf2a982, 0x6ef2870f, 0x6ef2870f, 0xba2caab7, 0xba2caab7, 0x8e5a5872, 0x8e5a5872, 0x62b2fedc, 0x2bd3b588, 0x34ebdb15, 0x34ebdb15, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa133280a, 0xa133280a, 0x1e8f4227, 0x1e8f4227, 0xa01cd911, 0xa01cd911, 0xdcb3d617, 0xdcb3d617, 0x51200351, 0x51200351, 0x609ba305, 0x609ba305, 0x5d96abfd, 0x5d96abfd, 0xd855cc70, 0xd855cc70, 0xdbfaf18d, 0xdbfaf18d, 0x84814843, 0x84814843, 0x4b00e630, 0x4b00e630, 0xd362b0f5, 0xd362b0f5, 0xec863355, 0xec863355, 0x195898d0, 0x195898d0, 0xe8c698c7, 0xe8c698c7, 0x884229e7, 0x884229e7, 0xb41ed3a9, 0xb41ed3a9, 0x2be1ce40, 0x2be1ce40, 0x8c33eb7c, 0x8c33eb7c, 0xbbce1da, 0xbbce1da, 0xef9415fa, 0x22fbc0d, 0xd82c182c, 0xd82c182c, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe029c, 0x6671ee1f, 0xbe029c, 0x4348cfdb, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x4348cfdb, 0x4348cfdb, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x14e228ef, 0xb0c8af57, 0x14e228ef, 0x3ae7ad90, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x3ae7ad90, 0x3ae7ad90, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x651fb144, 0xdf93ee9c, 0x651fb144, 0x3808dcc0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0x3808dcc0, 0x3808dcc0, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xdfd0119e, 0x6c7018a9, 0xdfd0119e, 0x71865846, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x71865846, 0x71865846, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e4844e0, 0x5ebe5f81, 0x4e4844e0, 0x38ee7153, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x38ee7153, 0x38ee7153, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x701427d4, 0x246c830a, 0x701427d4, 0x6b11fdd3, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x6b11fdd3, 0x6b11fdd3, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7b5bd4c, 0xac246af1, 0x7b5bd4c, 0xf80aa6cc, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xf80aa6cc, 0xf80aa6cc, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0x12fd0f21, 0x12fd0f21, 0x12fd0f21, 0x4e25f9e1, 0x4e25f9e1, 0x4e25f9e1, 0x67bd3773, 0x67bd3773, 0x67bd3773, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xf766a14d, 0xf766a14d, 0xf766a14d, 0xa2390b47, 0xa2390b47, 0xa2390b47, 0xcb0ac30e, 0xcb0ac30e, 0xcb0ac30e, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xedc0ad83, 0xedc0ad83, 0xedc0ad83, 0x927e0b17, 0x927e0b17, 0x927e0b17, 0xd00a6b6f, 0xd00a6b6f, 0xd00a6b6f, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0xb35c7e64, 0xb35c7e64, 0xb35c7e64, 0x58f99418, 0x58f99418, 0x58f99418, 0x5eb294e8, 0x5eb294e8, 0x5eb294e8, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x220f7a5e, 0x220f7a5e, 0x220f7a5e, 0x4d46a64f, 0x4d46a64f, 0x4d46a64f, 0x40b0384c, 0x40b0384c, 0x40b0384c, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x377f1aeb, 0x377f1aeb, 0x377f1aeb, 0xf1cd5ef5, 0xf1cd5ef5, 0xf1cd5ef5, 0xe5a88e4a, 0xe5a88e4a, 0xe5a88e4a, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x756a36b9, 0x756a36b9, 0x756a36b9, 0xf499c068, 0xf499c068, 0xf499c068, 0x623d7907, 0x623d7907, 0x623d7907, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa49d26b0, 0xaa7d9b28, 0xa49d26b0, 0xe76bebf7, 0x59c36f00, 0x59c36f00, 0xea6ab252, 0xea6ab252, 0xea6ab252, 0x94eadf34, 0x94eadf34, 0x94eadf34, 0xf61ccae6, 0xf61ccae6, 0xf61ccae6, 0x59c36f00, 0xe76bebf7, 0xe76bebf7, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7a277db, 0xf3bf80f7, 0x7a277db, 0x29a7f2a4, 0xaa4593fe, 0xaa4593fe, 0xf1cd57e3, 0xf1cd57e3, 0xf1cd57e3, 0x57385a84, 0x57385a84, 0x57385a84, 0x7a00f1fc, 0x7a00f1fc, 0x7a00f1fc, 0xaa4593fe, 0x29a7f2a4, 0x29a7f2a4, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x631edf85, 0x71926408, 0x631edf85, 0x3e09b201, 0xc9cbf769, 0xc9cbf769, 0xf224ab3, 0xf224ab3, 0xf224ab3, 0xf1fa8b7f, 0xf1fa8b7f, 0xf1fa8b7f, 0x18b03477, 0x18b03477, 0x18b03477, 0xc9cbf769, 0x3e09b201, 0x3e09b201, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xfbaf4635, 0xe69ef474, 0xfbaf4635, 0x55f90fed, 0x9813a416, 0x9813a416, 0x3aad8f41, 0x3aad8f41, 0x3aad8f41, 0xab760972, 0xab760972, 0xab760972, 0xb2cc34a2, 0xb2cc34a2, 0xb2cc34a2, 0x9813a416, 0x55f90fed, 0x55f90fed, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xdce50745, 0x1d8009e4, 0xdce50745, 0xaa4332f6, 0x5fcf013d, 0x5fcf013d, 0x354e5749, 0x354e5749, 0x354e5749, 0xe75e4f3f, 0xe75e4f3f, 0xe75e4f3f, 0xf12d70a0, 0xf12d70a0, 0xf12d70a0, 0x5fcf013d, 0xaa4332f6, 0xaa4332f6, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x3efebeff, 0xf101dfe2, 0x3efebeff, 0x25fb64f8, 0xdd28f52b, 0xdd28f52b, 0x70c69ebd, 0x70c69ebd, 0x70c69ebd, 0x51fa6759, 0x51fa6759, 0x51fa6759, 0x2c42acd5, 0x2c42acd5, 0x2c42acd5, 0xdd28f52b, 0x25fb64f8, 0x25fb64f8, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x59a34c64, 0x281cca78, 0x59a34c64, 0xa61c57e4, 0x43d1f34, 0x43d1f34, 0x95131d4, 0x95131d4, 0x95131d4, 0x765b987c, 0x765b987c, 0x765b987c, 0xef0a9dfa, 0xef0a9dfa, 0xef0a9dfa, 0x43d1f34, 0xa61c57e4, 0xa61c57e4, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa37c165, 0x72063383, 0xa37c165, 0x49c10c22, 0x59c36f00, 0x59c36f00, 0x4e53de8e, 0x4e53de8e, 0x4e53de8e, 0x30d3b3e8, 0x30d3b3e8, 0x30d3b3e8, 0x5225a63a, 0x5225a63a, 0x5225a63a, 0x59c36f00, 0x49c10c22, 0x49c10c22, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x45bba0ba, 0xe60fd0b6, 0x45bba0ba, 0x6bbe25c5, 0xaa4593fe, 0xaa4593fe, 0x28de2b41, 0x28de2b41, 0x28de2b41, 0x8e2b2626, 0x8e2b2626, 0x8e2b2626, 0xa3138d5e, 0xa3138d5e, 0xa3138d5e, 0xaa4593fe, 0x6bbe25c5, 0x6bbe25c5, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb43d4e9d, 0x16f88820, 0xb43d4e9d, 0xe92a2319, 0xc9cbf769, 0xc9cbf769, 0xb8959ec7, 0xb8959ec7, 0xb8959ec7, 0x464d5f0b, 0x464d5f0b, 0x464d5f0b, 0xaf07e003, 0xaf07e003, 0xaf07e003, 0xc9cbf769, 0xe92a2319, 0xe92a2319, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x46760365, 0x685ae30e, 0x46760365, 0xe8204abd, 0x9813a416, 0x9813a416, 0x8896050a, 0x8896050a, 0x8896050a, 0x194d8339, 0x194d8339, 0x194d8339, 0xf7bee9, 0xf7bee9, 0xf7bee9, 0x9813a416, 0xe8204abd, 0xe8204abd, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6859aa86, 0xf3f11deb, 0x6859aa86, 0x1eff9f35, 0x5fcf013d, 0x5fcf013d, 0xd72b1482, 0xd72b1482, 0xd72b1482, 0x53b0cf4, 0x53b0cf4, 0x53b0cf4, 0x1348336b, 0x1348336b, 0x1348336b, 0x5fcf013d, 0x1eff9f35, 0x1eff9f35, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x688451e7, 0xf6936b72, 0x688451e7, 0x73818be0, 0xdd28f52b, 0xdd28f52b, 0xf12a65ac, 0xf12a65ac, 0xf12a65ac, 0xd0169c48, 0xd0169c48, 0xd0169c48, 0xadae57c4, 0xadae57c4, 0xadae57c4, 0xdd28f52b, 0x73818be0, 0x73818be0, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9616af94, 0xd466be40, 0x9616af94, 0x69a9b414, 0x43d1f34, 0x43d1f34, 0xf3bb3240, 0xf3bb3240, 0xf3bb3240, 0x8cb19be8, 0x8cb19be8, 0x8cb19be8, 0x15e09e6e, 0x15e09e6e, 0x15e09e6e, 0x43d1f34, 0x69a9b414, 0x69a9b414, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x8708d1bd, 0x85dd5e9c, 0x8708d1bd, 0xc4fe1cfa, 0x59c36f00, 0x59c36f00, 0x7ae8aced, 0x7ae8aced, 0x7ae8aced, 0x468c18b, 0x468c18b, 0x468c18b, 0x669ed459, 0x669ed459, 0x669ed459, 0x59c36f00, 0xc4fe1cfa, 0xc4fe1cfa, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa72b1043, 0x147d4ce0, 0xa72b1043, 0x892e953c, 0xaa4593fe, 0xaa4593fe, 0xb7b1dd40, 0xb7b1dd40, 0xb7b1dd40, 0x1144d027, 0x1144d027, 0x1144d027, 0x3c7c7b5f, 0x3c7c7b5f, 0x3c7c7b5f, 0xaa4593fe, 0x892e953c, 0x892e953c, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc5fb1817, 0x745fb26c, 0xc5fb1817, 0x98ec7593, 0xc9cbf769, 0xc9cbf769, 0xf5f17e2d, 0xf5f17e2d, 0xf5f17e2d, 0xb29bfe1, 0xb29bfe1, 0xb29bfe1, 0xe26300e9, 0xe26300e9, 0xe26300e9, 0xc9cbf769, 0x98ec7593, 0x98ec7593, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4be837e1, 0xbf4963ca, 0x4be837e1, 0xe5be7e39, 0x9813a416, 0x9813a416, 0xd886fca0, 0xd886fca0, 0xd886fca0, 0x495d7a93, 0x495d7a93, 0x495d7a93, 0x50e74743, 0x50e74743, 0x50e74743, 0x9813a416, 0xe5be7e39, 0xe5be7e39, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x21a8ccb8, 0x17719be, 0x21a8ccb8, 0x570ef90b, 0x5fcf013d, 0x5fcf013d, 0x2a7b5333, 0x2a7b5333, 0x2a7b5333, 0xf86b4b45, 0xf86b4b45, 0xf86b4b45, 0xee1874da, 0xee1874da, 0xee1874da, 0x5fcf013d, 0x570ef90b, 0x570ef90b, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7001fe50, 0x4798153f, 0x7001fe50, 0x6b042457, 0xdd28f52b, 0xdd28f52b, 0x46489369, 0x46489369, 0x46489369, 0x67746a8d, 0x67746a8d, 0x67746a8d, 0x1acca101, 0x1acca101, 0x1acca101, 0xdd28f52b, 0x6b042457, 0x6b042457, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6e10591c, 0x48bd926e, 0x6e10591c, 0x91af429c, 0x43d1f34, 0x43d1f34, 0x59cb829, 0x59cb829, 0x59cb829, 0x7a961181, 0x7a961181, 0x7a961181, 0xe3c71407, 0xe3c71407, 0xe3c71407, 0x43d1f34, 0x91af429c, 0x91af429c, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67627ed5, 0xdb276cef, 0x67627ed5, 0x2494b392, 0x59c36f00, 0x59c36f00, 0x43f511f3, 0x43f511f3, 0x43f511f3, 0x3d757c95, 0x3d757c95, 0x3d757c95, 0x5f836947, 0x5f836947, 0x5f836947, 0x59c36f00, 0x2494b392, 0x2494b392, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x987cbf71, 0x6e4c645c, 0x987cbf71, 0xb6793a0e, 0xaa4593fe, 0xaa4593fe, 0xb943d716, 0xb943d716, 0xb943d716, 0x1fb6da71, 0x1fb6da71, 0x1fb6da71, 0x328e7109, 0x328e7109, 0x328e7109, 0xaa4593fe, 0xb6793a0e, 0xb6793a0e, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf9987c07, 0x4a92eed9, 0xf9987c07, 0xa48f1183, 0xc9cbf769, 0xc9cbf769, 0x5eb3ddf4, 0x5eb3ddf4, 0x5eb3ddf4, 0xa06b1c38, 0xa06b1c38, 0xa06b1c38, 0x4921a330, 0x4921a330, 0x4921a330, 0xc9cbf769, 0xa48f1183, 0xa48f1183, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xccd804e2, 0xb99e8d91, 0xccd804e2, 0x628e4d3a, 0x9813a416, 0x9813a416, 0x5aec5acc, 0x5aec5acc, 0x5aec5acc, 0xcb37dcff, 0xcb37dcff, 0xcb37dcff, 0xd28de12f, 0xd28de12f, 0xd28de12f, 0x9813a416, 0x628e4d3a, 0x628e4d3a, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4990d896, 0x2b3aa242, 0x4990d896, 0x3f36ed25, 0x5fcf013d, 0x5fcf013d, 0x3cc6048d, 0x3cc6048d, 0x3cc6048d, 0xeed61cfb, 0xeed61cfb, 0xeed61cfb, 0xf8a52364, 0xf8a52364, 0xf8a52364, 0x5fcf013d, 0x3f36ed25, 0x3f36ed25, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4ff5c69f, 0x66586489, 0x4ff5c69f, 0x54f01c98, 0xdd28f52b, 0xdd28f52b, 0xc3ff0bf5, 0xc3ff0bf5, 0xc3ff0bf5, 0xe2c3f211, 0xe2c3f211, 0xe2c3f211, 0x9f7b399d, 0x9f7b399d, 0x9f7b399d, 0xdd28f52b, 0x54f01c98, 0x54f01c98, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x909b7bb4, 0x2bb2a58c, 0x909b7bb4, 0x6f246034, 0x43d1f34, 0x43d1f34, 0x2df40751, 0x2df40751, 0x2df40751, 0x52feaef9, 0x52feaef9, 0x52feaef9, 0xcbafab7f, 0xcbafab7f, 0xcbafab7f, 0x43d1f34, 0x6f246034, 0x6f246034, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc77bfcc6, 0xffcdf45d, 0xc77bfcc6, 0x848d3181, 0x59c36f00, 0x59c36f00, 0xd79cd5e, 0xd79cd5e, 0xd79cd5e, 0x73f9a038, 0x73f9a038, 0x73f9a038, 0x110fb5ea, 0x110fb5ea, 0x110fb5ea, 0x59c36f00, 0x848d3181, 0x848d3181, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5494aa5, 0xa0924ec, 0xd5494aa5, 0xfb4ccfda, 0xaa4593fe, 0xaa4593fe, 0x8692c636, 0x8692c636, 0x8692c636, 0x2067cb51, 0x2067cb51, 0x2067cb51, 0xd5f6029, 0xd5f6029, 0xd5f6029, 0xaa4593fe, 0xfb4ccfda, 0xfb4ccfda, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2436c4f, 0x2cde4e0c, 0x2436c4f, 0x5f5401cb, 0xc9cbf769, 0xc9cbf769, 0x558f50ae, 0x558f50ae, 0x558f50ae, 0xab579162, 0xab579162, 0xab579162, 0x421d2e6a, 0x421d2e6a, 0x421d2e6a, 0xc9cbf769, 0x5f5401cb, 0x5f5401cb, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x86f8a68c, 0xf4116451, 0x86f8a68c, 0x28aeef54, 0x9813a416, 0x9813a416, 0x7befbe43, 0x7befbe43, 0x7befbe43, 0xea343870, 0xea343870, 0xea343870, 0xf38e05a0, 0xf38e05a0, 0xf38e05a0, 0x9813a416, 0x28aeef54, 0x28aeef54, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x156c292f, 0x3c8eb473, 0x156c292f, 0x63ca1c9c, 0x5fcf013d, 0x5fcf013d, 0x895ea16b, 0x895ea16b, 0x895ea16b, 0x5b4eb91d, 0x5b4eb91d, 0x5b4eb91d, 0x4d3d8682, 0x4d3d8682, 0x4d3d8682, 0x5fcf013d, 0x63ca1c9c, 0x63ca1c9c, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf57ebf12, 0x798b299b, 0xf57ebf12, 0xee7b6515, 0xdd28f52b, 0xdd28f52b, 0x22563fc6, 0x22563fc6, 0x22563fc6, 0x36ac622, 0x36ac622, 0x36ac622, 0x7ed20dae, 0x7ed20dae, 0x7ed20dae, 0xdd28f52b, 0xee7b6515, 0xee7b6515, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x2bc82eb1, 0x94064cc8, 0x2bc82eb1, 0xd4773531, 0x43d1f34, 0x43d1f34, 0x44cbf2f0, 0x44cbf2f0, 0x44cbf2f0, 0x3bc15b58, 0x3bc15b58, 0x3bc15b58, 0xa2905ede, 0xa2905ede, 0xa2905ede, 0x43d1f34, 0xd4773531, 0xd4773531, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7f6dd146, 0x548af474, 0x7f6dd146, 0x3c9b1c01, 0x59c36f00, 0x59c36f00, 0x7d913e8d, 0x7d913e8d, 0x7d913e8d, 0x31153eb, 0x31153eb, 0x31153eb, 0x61e74639, 0x61e74639, 0x61e74639, 0x59c36f00, 0x3c9b1c01, 0x3c9b1c01, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf29ad079, 0x50d47c0, 0xf29ad079, 0xdc9f5506, 0xaa4593fe, 0xaa4593fe, 0x6bcf4c90, 0x6bcf4c90, 0x6bcf4c90, 0xcd3a41f7, 0xcd3a41f7, 0xcd3a41f7, 0xe002ea8f, 0xe002ea8f, 0xe002ea8f, 0xaa4593fe, 0xdc9f5506, 0xdc9f5506, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb25e3082, 0x2ed845dd, 0xb25e3082, 0xef495d06, 0xc9cbf769, 0xc9cbf769, 0xd5322575, 0xd5322575, 0xd5322575, 0x2beae4b9, 0x2beae4b9, 0x2beae4b9, 0xc2a05bb1, 0xc2a05bb1, 0xc2a05bb1, 0xc9cbf769, 0xef495d06, 0xef495d06, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4cdfcd2e, 0x8bf091f, 0x4cdfcd2e, 0xe28984f6, 0x9813a416, 0x9813a416, 0x8217f630, 0x8217f630, 0x8217f630, 0x13cc7003, 0x13cc7003, 0x13cc7003, 0xa764dd3, 0xa764dd3, 0xa764dd3, 0x9813a416, 0xe28984f6, 0xe28984f6, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf2b49f88, 0x2eff252d, 0xf2b49f88, 0x8412aa3b, 0x5fcf013d, 0x5fcf013d, 0x5d3b9fe7, 0x5d3b9fe7, 0x5d3b9fe7, 0x8f2b8791, 0x8f2b8791, 0x8f2b8791, 0x9958b80e, 0x9958b80e, 0x9958b80e, 0x5fcf013d, 0x8412aa3b, 0x8412aa3b, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x786673be, 0x536f1359, 0x786673be, 0x6363a9b9, 0xdd28f52b, 0xdd28f52b, 0x38653b12, 0x38653b12, 0x38653b12, 0x1959c2f6, 0x1959c2f6, 0x1959c2f6, 0x64e1097a, 0x64e1097a, 0x64e1097a, 0xdd28f52b, 0x6363a9b9, 0x6363a9b9, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xac4a1127, 0x699c2ad8, 0xac4a1127, 0x53f50aa7, 0x43d1f34, 0x43d1f34, 0xfa47dfba, 0xfa47dfba, 0xfa47dfba, 0x854d7612, 0x854d7612, 0x854d7612, 0x1c1c7394, 0x1c1c7394, 0x1c1c7394, 0x43d1f34, 0x53f50aa7, 0x53f50aa7, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc5f6633, 0xda908ab0, 0xbc5f6633, 0xffa9ab74, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0xffa9ab74, 0xffa9ab74, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xad820d6b, 0x9a88ad3, 0xad820d6b, 0x83878814, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x83878814, 0x83878814, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe5774112, 0x5ffb1eca, 0xe5774112, 0xb8602c96, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xb8602c96, 0xb8602c96, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6af1a2bc, 0xd951ab8b, 0x6af1a2bc, 0xc4a7eb64, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0xc4a7eb64, 0xc4a7eb64, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc6baa18, 0x1c9db179, 0xc6baa18, 0x7acd9fab, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x7acd9fab, 0x7acd9fab, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe424a6ab, 0xb05c0275, 0xe424a6ab, 0xff217cac, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0xff217cac, 0xff217cac, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4a7dff41, 0xe1ec28fc, 0x4a7dff41, 0xb5c2e4c1, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xb5c2e4c1, 0xb5c2e4c1, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3d3e4a2, 0x9c635046, 0xd3d3e4a2, 0x902529e5, 0x59c36f00, 0x59c36f00, 0x85e713, 0x85e713, 0x85e713, 0x7e058a75, 0x7e058a75, 0x7e058a75, 0x1cf39fa7, 0x1cf39fa7, 0x1cf39fa7, 0x59c36f00, 0x902529e5, 0x902529e5, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd61c80f5, 0xdf78b496, 0xd61c80f5, 0xf819058a, 0xaa4593fe, 0xaa4593fe, 0xefc0f7e7, 0xefc0f7e7, 0xefc0f7e7, 0x4935fa80, 0x4935fa80, 0x4935fa80, 0x640d51f8, 0x640d51f8, 0x640d51f8, 0xaa4593fe, 0xf819058a, 0xf819058a, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x936bc89d, 0x523a3e80, 0x936bc89d, 0xce7ca519, 0xc9cbf769, 0xc9cbf769, 0xaa99ffb1, 0xaa99ffb1, 0xaa99ffb1, 0x54413e7d, 0x54413e7d, 0x54413e7d, 0xbd0b8175, 0xbd0b8175, 0xbd0b8175, 0xc9cbf769, 0xce7ca519, 0xce7ca519, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4fdd0291, 0x133fa83d, 0x4fdd0291, 0xe18b4b49, 0x9813a416, 0x9813a416, 0x74c38e90, 0x74c38e90, 0x74c38e90, 0xe51808a3, 0xe51808a3, 0xe51808a3, 0xfca23573, 0xfca23573, 0xfca23573, 0x9813a416, 0xe18b4b49, 0xe18b4b49, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x538203b0, 0x2a92e789, 0x538203b0, 0x25243603, 0x5fcf013d, 0x5fcf013d, 0x5e4d3dd8, 0x5e4d3dd8, 0x5e4d3dd8, 0x8c5d25ae, 0x8c5d25ae, 0x8c5d25ae, 0x9a2e1a31, 0x9a2e1a31, 0x9a2e1a31, 0x5fcf013d, 0x25243603, 0x25243603, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcfc85125, 0xa5b0e11b, 0xcfc85125, 0xd4cd8b22, 0xdd28f52b, 0xdd28f52b, 0x1af8cddc, 0x1af8cddc, 0x1af8cddc, 0x3bc43438, 0x3bc43438, 0x3bc43438, 0x467cffb4, 0x467cffb4, 0x467cffb4, 0xdd28f52b, 0xd4cd8b22, 0xd4cd8b22, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf2469ffb, 0x1d0c1d2, 0xf2469ffb, 0xdf9847b, 0x43d1f34, 0x43d1f34, 0xa2837c7a, 0xa2837c7a, 0xa2837c7a, 0xdd89d5d2, 0xdd89d5d2, 0xdd89d5d2, 0x44d8d054, 0x44d8d054, 0x44d8d054, 0x43d1f34, 0xdf9847b, 0xdf9847b, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x27851cc1, 0x15f731b5, 0x27851cc1, 0x6473d186, 0x59c36f00, 0x59c36f00, 0x125bcddf, 0x125bcddf, 0x125bcddf, 0x6cdba0b9, 0x6cdba0b9, 0x6cdba0b9, 0xe2db56b, 0xe2db56b, 0xe2db56b, 0x59c36f00, 0x6473d186, 0x6473d186, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfcb223c, 0x2c2e18b9, 0xfcb223c, 0x21cea743, 0xaa4593fe, 0xaa4593fe, 0xd700be1a, 0xd700be1a, 0xd700be1a, 0x71f5b37d, 0x71f5b37d, 0x71f5b37d, 0x5ccd1805, 0x5ccd1805, 0x5ccd1805, 0xaa4593fe, 0x21cea743, 0x21cea743, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x807efaa5, 0xb673036a, 0x807efaa5, 0xdd699721, 0xc9cbf769, 0xc9cbf769, 0xdca3ed4b, 0xdca3ed4b, 0xdca3ed4b, 0x227b2c87, 0x227b2c87, 0x227b2c87, 0xcb31938f, 0xcb31938f, 0xcb31938f, 0xc9cbf769, 0xdd699721, 0xdd699721, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x651d0d50, 0xf0dc38fc, 0x651d0d50, 0xcb4b4488, 0x9813a416, 0x9813a416, 0x80d03ee8, 0x80d03ee8, 0x80d03ee8, 0x110bb8db, 0x110bb8db, 0x110bb8db, 0x8b1850b, 0x8b1850b, 0x8b1850b, 0x9813a416, 0xcb4b4488, 0xcb4b4488, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb9b068f, 0xdc68ac3c, 0xb9b068f, 0x7d3d333c, 0x5fcf013d, 0x5fcf013d, 0xa1f0a6e4, 0xa1f0a6e4, 0xa1f0a6e4, 0x73e0be92, 0x73e0be92, 0x73e0be92, 0x6593810d, 0x6593810d, 0x6593810d, 0x5fcf013d, 0x7d3d333c, 0x7d3d333c, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf0789d7e, 0x6f2f2b61, 0xf0789d7e, 0xeb7d4779, 0xdd28f52b, 0xdd28f52b, 0xb995630, 0xb995630, 0xb995630, 0x2aa5afd4, 0x2aa5afd4, 0x2aa5afd4, 0x571d6458, 0x571d6458, 0x571d6458, 0xdd28f52b, 0xeb7d4779, 0xeb7d4779, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x819821ff, 0xdd19128c, 0x819821ff, 0x7e273a7f, 0x43d1f34, 0x43d1f34, 0xf35981d3, 0xf35981d3, 0xf35981d3, 0x8c53287b, 0x8c53287b, 0x8c53287b, 0x15022dfd, 0x15022dfd, 0x15022dfd, 0x43d1f34, 0x7e273a7f, 0x7e273a7f, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa99604d1, 0xcf59e852, 0xa99604d1, 0xfebbba0f, 0x59c36f00, 0x59c36f00, 0x53767ce3, 0x53767ce3, 0x53767ce3, 0x2df61185, 0x2df61185, 0x2df61185, 0x4f000457, 0x4f000457, 0x4f000457, 0x59c36f00, 0xfebbba0f, 0xfebbba0f, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7d0a218, 0xa3fa25a0, 0x7d0a218, 0xb777784e, 0xaa4593fe, 0xaa4593fe, 0x35db26e1, 0x35db26e1, 0x35db26e1, 0x932e2b86, 0x932e2b86, 0x932e2b86, 0xbe1680fe, 0xbe1680fe, 0xbe1680fe, 0xaa4593fe, 0xb777784e, 0xb777784e, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x63be90f4, 0xd932cf2c, 0x63be90f4, 0x739b8e5a, 0xc9cbf769, 0xc9cbf769, 0x70a00efe, 0x70a00efe, 0x70a00efe, 0x8e78cf32, 0x8e78cf32, 0x8e78cf32, 0x6732703a, 0x6732703a, 0x6732703a, 0xc9cbf769, 0x739b8e5a, 0x739b8e5a, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x53460c90, 0xe0e605a7, 0x53460c90, 0x6337f0bf, 0x9813a416, 0x9813a416, 0x4161864c, 0x4161864c, 0x4161864c, 0xd0ba007f, 0xd0ba007f, 0xd0ba007f, 0xc9003daf, 0xc9003daf, 0xc9003daf, 0x9813a416, 0x6337f0bf, 0x6337f0bf, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf54761a0, 0xe5b17ac1, 0xf54761a0, 0x5b408e55, 0x5fcf013d, 0x5fcf013d, 0x580fda0e, 0x580fda0e, 0x580fda0e, 0x8a1fc278, 0x8a1fc278, 0x8a1fc278, 0x9c6cfde7, 0x9c6cfde7, 0x9c6cfde7, 0x5fcf013d, 0x5b408e55, 0x5b408e55, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec78b0c1, 0xb800141f, 0xec78b0c1, 0x621c7b1b, 0xdd28f52b, 0xdd28f52b, 0x8f60179, 0x8f60179, 0x8f60179, 0x29caf89d, 0x29caf89d, 0x29caf89d, 0x54723311, 0x54723311, 0x54723311, 0xdd28f52b, 0x621c7b1b, 0x621c7b1b, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf209411b, 0x599896a6, 0xf209411b, 0x6551c7bb, 0x43d1f34, 0x43d1f34, 0x5ac6bb4a, 0x5ac6bb4a, 0x5ac6bb4a, 0x25cc12e2, 0x25cc12e2, 0x25cc12e2, 0xbc9d1764, 0xbc9d1764, 0xbc9d1764, 0x43d1f34, 0x6551c7bb, 0x6551c7bb, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x93b4fcd8, 0xf57b105b, 0x93b4fcd8, 0x2bfe5312, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x2bfe5312, 0x2bfe5312, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x656c9044, 0xc14617fc, 0x656c9044, 0xa6ea58cb, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0xa6ea58cb, 0xa6ea58cb, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa11479ed, 0x1b982635, 0xa11479ed, 0xe37185d0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xe37185d0, 0xe37185d0, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x244770a7, 0x97e77990, 0x244770a7, 0x6a54d2ee, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x6a54d2ee, 0x6a54d2ee, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8ca34476, 0x9c555f17, 0x8ca34476, 0x1fc54b41, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x1fc54b41, 0x1fc54b41, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf19f6af8, 0xa5e7ce26, 0xf19f6af8, 0x1619aea6, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x1619aea6, 0x1619aea6, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5f75414f, 0xf4e496f2, 0x5f75414f, 0x27fd1fe0, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0x27fd1fe0, 0x27fd1fe0, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From b0bad6fd9449d3333fe1ab58953c0e6c1ce12c0d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 3 May 2017 11:55:52 +0200 Subject: [PATCH 0667/1167] Bump version to 2.03 --- configure.ac | 2 +- grub-core/tests/checksums.h | 196 ++++++++++++++++++------------------ 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/configure.ac b/configure.ac index edd184154..d10d8adac 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.03],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index 68d8ce7c7..921e57ff4 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,101 +1,101 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xcd5fc34e, 0xcd5fc34e, 0xeabbecab, 0xeabbecab, 0xc9950151, 0xc9950151, 0x2be222b6, 0x2be222b6, 0xe88c769e, 0xe88c769e, 0x6be4910e, 0x6be4910e, 0x1dc1fe4f, 0x1dc1fe4f, 0xd7613e8f, 0xd7613e8f, 0xf8124196, 0xf8124196, 0x130f5935, 0x130f5935, 0x2872330e, 0x2872330e, 0xaa7b7868, 0xaa7b7868, 0x558eaeea, 0x558eaeea, 0x92f7960f, 0x92f7960f, 0xc5bfc709, 0xc5bfc709, 0x699732fe, 0x699732fe, 0xc859125f, 0xc859125f, 0xfc6ac729, 0xfc6ac729, 0xcdab6cd4, 0xcdab6cd4, 0x58a8b7f8, 0x58a8b7f8, 0xc0e73385, 0x6560d6ef, 0x3be8bb5d, 0x3be8bb5d, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x13029f94, 0x13029f94, 0x7785fdab, 0x7785fdab, 0x95a7c1e8, 0x95a7c1e8, 0x315ab3e3, 0x315ab3e3, 0x6787f012, 0x6787f012, 0x79b1ecdc, 0x79b1ecdc, 0xdbc67810, 0xdbc67810, 0xafaa982e, 0xafaa982e, 0xc5cd0157, 0xc5cd0157, 0x3c50dd64, 0x3c50dd64, 0x1056cac0, 0x1056cac0, 0x1d7a41fa, 0x1d7a41fa, 0x5690b1e8, 0x5690b1e8, 0x616831d6, 0x616831d6, 0xfaf8e726, 0xfaf8e726, 0xd1ec5e26, 0xd1ec5e26, 0x3c269e1f, 0x3c269e1f, 0x1aa7952d, 0x1aa7952d, 0x6e7e2f99, 0x6e7e2f99, 0x98f4c02, 0x98f4c02, 0xc3f1abf2, 0xe348bb73, 0xea53cd60, 0xea53cd60, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8fbb4f4c, 0x8fbb4f4c, 0x5dc00167, 0x5dc00167, 0xbc124df8, 0xbc124df8, 0x31cf0f8e, 0x31cf0f8e, 0x798cc4ed, 0x798cc4ed, 0xc5d2a091, 0xc5d2a091, 0xb58a0591, 0xb58a0591, 0x4d118aca, 0x4d118aca, 0xbb06c7ee, 0xbb06c7ee, 0x42179db7, 0x42179db7, 0x65f2d81e, 0x65f2d81e, 0xa2628bcb, 0xa2628bcb, 0xbdb7f4b, 0xbdb7f4b, 0x66b10309, 0x66b10309, 0x1a550ea9, 0x1a550ea9, 0x377a297d, 0x377a297d, 0x2ea99015, 0x2ea99015, 0x4e20d7bc, 0x4e20d7bc, 0x8ecbde02, 0x8ecbde02, 0xdfa2195a, 0xdfa2195a, 0xe113d2a, 0xe204ee5b, 0x734679c1, 0x734679c1, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe2f6bfe1, 0xe2f6bfe1, 0xf18aee15, 0xf18aee15, 0x5e83b689, 0x5e83b689, 0xb7e8b42c, 0xb7e8b42c, 0x85d78f92, 0x85d78f92, 0xd56fadae, 0xd56fadae, 0x7632f5bf, 0x7632f5bf, 0x2769a748, 0x2769a748, 0x4a6112cd, 0x4a6112cd, 0x4f9b66a4, 0x4f9b66a4, 0x70457d38, 0x70457d38, 0x8cadb1a7, 0x8cadb1a7, 0x451341f, 0x451341f, 0x8a62e741, 0x8a62e741, 0x1b1f9031, 0x1b1f9031, 0x75ab630e, 0x75ab630e, 0xd5ff53ac, 0xd5ff53ac, 0x73a2b3c7, 0x73a2b3c7, 0x7b52acd5, 0x7b52acd5, 0xf6f3e48c, 0xf6f3e48c, 0x8d0db133, 0x8db24310, 0x7aef56d4, 0x7aef56d4, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x838a3f40, 0x838a3f40, 0x7351ba96, 0x7351ba96, 0x660963bb, 0x660963bb, 0x6f3362a6, 0x6f3362a6, 0x915d35d9, 0x915d35d9, 0xc7edaee9, 0xc7edaee9, 0xbc8ec24c, 0xbc8ec24c, 0xeb120ffd, 0xeb120ffd, 0x8f6d8232, 0x8f6d8232, 0x2de5d515, 0x2de5d515, 0x4f2ecd91, 0x4f2ecd91, 0x555a9b90, 0x555a9b90, 0x8f7b0d77, 0x8f7b0d77, 0x5f9536af, 0x5f9536af, 0x3dd79dbe, 0x3dd79dbe, 0xb555a0, 0xb555a0, 0x75aec882, 0x75aec882, 0xd5da89cb, 0xd5da89cb, 0xb47b3257, 0xb47b3257, 0x7c97c046, 0x7c97c046, 0x726a7abe, 0x4c8b8a56, 0xcffa0854, 0xcffa0854, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7bf761e, 0x7bf761e, 0xaf0b6dae, 0xaf0b6dae, 0x7db15930, 0x7db15930, 0xc9720d56, 0xc9720d56, 0x55590d6c, 0x55590d6c, 0xa0d193d9, 0xa0d193d9, 0x728987b2, 0x728987b2, 0x28aecde6, 0x28aecde6, 0xa59bb094, 0xa59bb094, 0x2d0b049d, 0x2d0b049d, 0xd8421240, 0xd8421240, 0x51fa339, 0x51fa339, 0xc625cc46, 0xc625cc46, 0x2c9e6fcc, 0x2c9e6fcc, 0x3d06ffd5, 0x3d06ffd5, 0x8dd72816, 0x8dd72816, 0xfcf2a982, 0xfcf2a982, 0x6ef2870f, 0x6ef2870f, 0xba2caab7, 0xba2caab7, 0x8e5a5872, 0x8e5a5872, 0x62b2fedc, 0x2bd3b588, 0x34ebdb15, 0x34ebdb15, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa133280a, 0xa133280a, 0x1e8f4227, 0x1e8f4227, 0xa01cd911, 0xa01cd911, 0xdcb3d617, 0xdcb3d617, 0x51200351, 0x51200351, 0x609ba305, 0x609ba305, 0x5d96abfd, 0x5d96abfd, 0xd855cc70, 0xd855cc70, 0xdbfaf18d, 0xdbfaf18d, 0x84814843, 0x84814843, 0x4b00e630, 0x4b00e630, 0xd362b0f5, 0xd362b0f5, 0xec863355, 0xec863355, 0x195898d0, 0x195898d0, 0xe8c698c7, 0xe8c698c7, 0x884229e7, 0x884229e7, 0xb41ed3a9, 0xb41ed3a9, 0x2be1ce40, 0x2be1ce40, 0x8c33eb7c, 0x8c33eb7c, 0xbbce1da, 0xbbce1da, 0xef9415fa, 0x22fbc0d, 0xd82c182c, 0xd82c182c, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe029c, 0x6671ee1f, 0xbe029c, 0x4348cfdb, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x4348cfdb, 0x4348cfdb, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x14e228ef, 0xb0c8af57, 0x14e228ef, 0x3ae7ad90, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x3ae7ad90, 0x3ae7ad90, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x651fb144, 0xdf93ee9c, 0x651fb144, 0x3808dcc0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0x3808dcc0, 0x3808dcc0, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xdfd0119e, 0x6c7018a9, 0xdfd0119e, 0x71865846, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x71865846, 0x71865846, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e4844e0, 0x5ebe5f81, 0x4e4844e0, 0x38ee7153, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x38ee7153, 0x38ee7153, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x701427d4, 0x246c830a, 0x701427d4, 0x6b11fdd3, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x6b11fdd3, 0x6b11fdd3, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7b5bd4c, 0xac246af1, 0x7b5bd4c, 0xf80aa6cc, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xf80aa6cc, 0xf80aa6cc, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0x12fd0f21, 0x12fd0f21, 0x12fd0f21, 0x4e25f9e1, 0x4e25f9e1, 0x4e25f9e1, 0x67bd3773, 0x67bd3773, 0x67bd3773, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xf766a14d, 0xf766a14d, 0xf766a14d, 0xa2390b47, 0xa2390b47, 0xa2390b47, 0xcb0ac30e, 0xcb0ac30e, 0xcb0ac30e, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xedc0ad83, 0xedc0ad83, 0xedc0ad83, 0x927e0b17, 0x927e0b17, 0x927e0b17, 0xd00a6b6f, 0xd00a6b6f, 0xd00a6b6f, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0xb35c7e64, 0xb35c7e64, 0xb35c7e64, 0x58f99418, 0x58f99418, 0x58f99418, 0x5eb294e8, 0x5eb294e8, 0x5eb294e8, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x220f7a5e, 0x220f7a5e, 0x220f7a5e, 0x4d46a64f, 0x4d46a64f, 0x4d46a64f, 0x40b0384c, 0x40b0384c, 0x40b0384c, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x377f1aeb, 0x377f1aeb, 0x377f1aeb, 0xf1cd5ef5, 0xf1cd5ef5, 0xf1cd5ef5, 0xe5a88e4a, 0xe5a88e4a, 0xe5a88e4a, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x756a36b9, 0x756a36b9, 0x756a36b9, 0xf499c068, 0xf499c068, 0xf499c068, 0x623d7907, 0x623d7907, 0x623d7907, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa49d26b0, 0xaa7d9b28, 0xa49d26b0, 0xe76bebf7, 0x59c36f00, 0x59c36f00, 0xea6ab252, 0xea6ab252, 0xea6ab252, 0x94eadf34, 0x94eadf34, 0x94eadf34, 0xf61ccae6, 0xf61ccae6, 0xf61ccae6, 0x59c36f00, 0xe76bebf7, 0xe76bebf7, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7a277db, 0xf3bf80f7, 0x7a277db, 0x29a7f2a4, 0xaa4593fe, 0xaa4593fe, 0xf1cd57e3, 0xf1cd57e3, 0xf1cd57e3, 0x57385a84, 0x57385a84, 0x57385a84, 0x7a00f1fc, 0x7a00f1fc, 0x7a00f1fc, 0xaa4593fe, 0x29a7f2a4, 0x29a7f2a4, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x631edf85, 0x71926408, 0x631edf85, 0x3e09b201, 0xc9cbf769, 0xc9cbf769, 0xf224ab3, 0xf224ab3, 0xf224ab3, 0xf1fa8b7f, 0xf1fa8b7f, 0xf1fa8b7f, 0x18b03477, 0x18b03477, 0x18b03477, 0xc9cbf769, 0x3e09b201, 0x3e09b201, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xfbaf4635, 0xe69ef474, 0xfbaf4635, 0x55f90fed, 0x9813a416, 0x9813a416, 0x3aad8f41, 0x3aad8f41, 0x3aad8f41, 0xab760972, 0xab760972, 0xab760972, 0xb2cc34a2, 0xb2cc34a2, 0xb2cc34a2, 0x9813a416, 0x55f90fed, 0x55f90fed, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xdce50745, 0x1d8009e4, 0xdce50745, 0xaa4332f6, 0x5fcf013d, 0x5fcf013d, 0x354e5749, 0x354e5749, 0x354e5749, 0xe75e4f3f, 0xe75e4f3f, 0xe75e4f3f, 0xf12d70a0, 0xf12d70a0, 0xf12d70a0, 0x5fcf013d, 0xaa4332f6, 0xaa4332f6, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x3efebeff, 0xf101dfe2, 0x3efebeff, 0x25fb64f8, 0xdd28f52b, 0xdd28f52b, 0x70c69ebd, 0x70c69ebd, 0x70c69ebd, 0x51fa6759, 0x51fa6759, 0x51fa6759, 0x2c42acd5, 0x2c42acd5, 0x2c42acd5, 0xdd28f52b, 0x25fb64f8, 0x25fb64f8, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x59a34c64, 0x281cca78, 0x59a34c64, 0xa61c57e4, 0x43d1f34, 0x43d1f34, 0x95131d4, 0x95131d4, 0x95131d4, 0x765b987c, 0x765b987c, 0x765b987c, 0xef0a9dfa, 0xef0a9dfa, 0xef0a9dfa, 0x43d1f34, 0xa61c57e4, 0xa61c57e4, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa37c165, 0x72063383, 0xa37c165, 0x49c10c22, 0x59c36f00, 0x59c36f00, 0x4e53de8e, 0x4e53de8e, 0x4e53de8e, 0x30d3b3e8, 0x30d3b3e8, 0x30d3b3e8, 0x5225a63a, 0x5225a63a, 0x5225a63a, 0x59c36f00, 0x49c10c22, 0x49c10c22, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x45bba0ba, 0xe60fd0b6, 0x45bba0ba, 0x6bbe25c5, 0xaa4593fe, 0xaa4593fe, 0x28de2b41, 0x28de2b41, 0x28de2b41, 0x8e2b2626, 0x8e2b2626, 0x8e2b2626, 0xa3138d5e, 0xa3138d5e, 0xa3138d5e, 0xaa4593fe, 0x6bbe25c5, 0x6bbe25c5, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb43d4e9d, 0x16f88820, 0xb43d4e9d, 0xe92a2319, 0xc9cbf769, 0xc9cbf769, 0xb8959ec7, 0xb8959ec7, 0xb8959ec7, 0x464d5f0b, 0x464d5f0b, 0x464d5f0b, 0xaf07e003, 0xaf07e003, 0xaf07e003, 0xc9cbf769, 0xe92a2319, 0xe92a2319, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x46760365, 0x685ae30e, 0x46760365, 0xe8204abd, 0x9813a416, 0x9813a416, 0x8896050a, 0x8896050a, 0x8896050a, 0x194d8339, 0x194d8339, 0x194d8339, 0xf7bee9, 0xf7bee9, 0xf7bee9, 0x9813a416, 0xe8204abd, 0xe8204abd, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6859aa86, 0xf3f11deb, 0x6859aa86, 0x1eff9f35, 0x5fcf013d, 0x5fcf013d, 0xd72b1482, 0xd72b1482, 0xd72b1482, 0x53b0cf4, 0x53b0cf4, 0x53b0cf4, 0x1348336b, 0x1348336b, 0x1348336b, 0x5fcf013d, 0x1eff9f35, 0x1eff9f35, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x688451e7, 0xf6936b72, 0x688451e7, 0x73818be0, 0xdd28f52b, 0xdd28f52b, 0xf12a65ac, 0xf12a65ac, 0xf12a65ac, 0xd0169c48, 0xd0169c48, 0xd0169c48, 0xadae57c4, 0xadae57c4, 0xadae57c4, 0xdd28f52b, 0x73818be0, 0x73818be0, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9616af94, 0xd466be40, 0x9616af94, 0x69a9b414, 0x43d1f34, 0x43d1f34, 0xf3bb3240, 0xf3bb3240, 0xf3bb3240, 0x8cb19be8, 0x8cb19be8, 0x8cb19be8, 0x15e09e6e, 0x15e09e6e, 0x15e09e6e, 0x43d1f34, 0x69a9b414, 0x69a9b414, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x8708d1bd, 0x85dd5e9c, 0x8708d1bd, 0xc4fe1cfa, 0x59c36f00, 0x59c36f00, 0x7ae8aced, 0x7ae8aced, 0x7ae8aced, 0x468c18b, 0x468c18b, 0x468c18b, 0x669ed459, 0x669ed459, 0x669ed459, 0x59c36f00, 0xc4fe1cfa, 0xc4fe1cfa, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa72b1043, 0x147d4ce0, 0xa72b1043, 0x892e953c, 0xaa4593fe, 0xaa4593fe, 0xb7b1dd40, 0xb7b1dd40, 0xb7b1dd40, 0x1144d027, 0x1144d027, 0x1144d027, 0x3c7c7b5f, 0x3c7c7b5f, 0x3c7c7b5f, 0xaa4593fe, 0x892e953c, 0x892e953c, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc5fb1817, 0x745fb26c, 0xc5fb1817, 0x98ec7593, 0xc9cbf769, 0xc9cbf769, 0xf5f17e2d, 0xf5f17e2d, 0xf5f17e2d, 0xb29bfe1, 0xb29bfe1, 0xb29bfe1, 0xe26300e9, 0xe26300e9, 0xe26300e9, 0xc9cbf769, 0x98ec7593, 0x98ec7593, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4be837e1, 0xbf4963ca, 0x4be837e1, 0xe5be7e39, 0x9813a416, 0x9813a416, 0xd886fca0, 0xd886fca0, 0xd886fca0, 0x495d7a93, 0x495d7a93, 0x495d7a93, 0x50e74743, 0x50e74743, 0x50e74743, 0x9813a416, 0xe5be7e39, 0xe5be7e39, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x21a8ccb8, 0x17719be, 0x21a8ccb8, 0x570ef90b, 0x5fcf013d, 0x5fcf013d, 0x2a7b5333, 0x2a7b5333, 0x2a7b5333, 0xf86b4b45, 0xf86b4b45, 0xf86b4b45, 0xee1874da, 0xee1874da, 0xee1874da, 0x5fcf013d, 0x570ef90b, 0x570ef90b, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7001fe50, 0x4798153f, 0x7001fe50, 0x6b042457, 0xdd28f52b, 0xdd28f52b, 0x46489369, 0x46489369, 0x46489369, 0x67746a8d, 0x67746a8d, 0x67746a8d, 0x1acca101, 0x1acca101, 0x1acca101, 0xdd28f52b, 0x6b042457, 0x6b042457, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6e10591c, 0x48bd926e, 0x6e10591c, 0x91af429c, 0x43d1f34, 0x43d1f34, 0x59cb829, 0x59cb829, 0x59cb829, 0x7a961181, 0x7a961181, 0x7a961181, 0xe3c71407, 0xe3c71407, 0xe3c71407, 0x43d1f34, 0x91af429c, 0x91af429c, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67627ed5, 0xdb276cef, 0x67627ed5, 0x2494b392, 0x59c36f00, 0x59c36f00, 0x43f511f3, 0x43f511f3, 0x43f511f3, 0x3d757c95, 0x3d757c95, 0x3d757c95, 0x5f836947, 0x5f836947, 0x5f836947, 0x59c36f00, 0x2494b392, 0x2494b392, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x987cbf71, 0x6e4c645c, 0x987cbf71, 0xb6793a0e, 0xaa4593fe, 0xaa4593fe, 0xb943d716, 0xb943d716, 0xb943d716, 0x1fb6da71, 0x1fb6da71, 0x1fb6da71, 0x328e7109, 0x328e7109, 0x328e7109, 0xaa4593fe, 0xb6793a0e, 0xb6793a0e, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf9987c07, 0x4a92eed9, 0xf9987c07, 0xa48f1183, 0xc9cbf769, 0xc9cbf769, 0x5eb3ddf4, 0x5eb3ddf4, 0x5eb3ddf4, 0xa06b1c38, 0xa06b1c38, 0xa06b1c38, 0x4921a330, 0x4921a330, 0x4921a330, 0xc9cbf769, 0xa48f1183, 0xa48f1183, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xccd804e2, 0xb99e8d91, 0xccd804e2, 0x628e4d3a, 0x9813a416, 0x9813a416, 0x5aec5acc, 0x5aec5acc, 0x5aec5acc, 0xcb37dcff, 0xcb37dcff, 0xcb37dcff, 0xd28de12f, 0xd28de12f, 0xd28de12f, 0x9813a416, 0x628e4d3a, 0x628e4d3a, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4990d896, 0x2b3aa242, 0x4990d896, 0x3f36ed25, 0x5fcf013d, 0x5fcf013d, 0x3cc6048d, 0x3cc6048d, 0x3cc6048d, 0xeed61cfb, 0xeed61cfb, 0xeed61cfb, 0xf8a52364, 0xf8a52364, 0xf8a52364, 0x5fcf013d, 0x3f36ed25, 0x3f36ed25, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4ff5c69f, 0x66586489, 0x4ff5c69f, 0x54f01c98, 0xdd28f52b, 0xdd28f52b, 0xc3ff0bf5, 0xc3ff0bf5, 0xc3ff0bf5, 0xe2c3f211, 0xe2c3f211, 0xe2c3f211, 0x9f7b399d, 0x9f7b399d, 0x9f7b399d, 0xdd28f52b, 0x54f01c98, 0x54f01c98, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x909b7bb4, 0x2bb2a58c, 0x909b7bb4, 0x6f246034, 0x43d1f34, 0x43d1f34, 0x2df40751, 0x2df40751, 0x2df40751, 0x52feaef9, 0x52feaef9, 0x52feaef9, 0xcbafab7f, 0xcbafab7f, 0xcbafab7f, 0x43d1f34, 0x6f246034, 0x6f246034, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc77bfcc6, 0xffcdf45d, 0xc77bfcc6, 0x848d3181, 0x59c36f00, 0x59c36f00, 0xd79cd5e, 0xd79cd5e, 0xd79cd5e, 0x73f9a038, 0x73f9a038, 0x73f9a038, 0x110fb5ea, 0x110fb5ea, 0x110fb5ea, 0x59c36f00, 0x848d3181, 0x848d3181, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5494aa5, 0xa0924ec, 0xd5494aa5, 0xfb4ccfda, 0xaa4593fe, 0xaa4593fe, 0x8692c636, 0x8692c636, 0x8692c636, 0x2067cb51, 0x2067cb51, 0x2067cb51, 0xd5f6029, 0xd5f6029, 0xd5f6029, 0xaa4593fe, 0xfb4ccfda, 0xfb4ccfda, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2436c4f, 0x2cde4e0c, 0x2436c4f, 0x5f5401cb, 0xc9cbf769, 0xc9cbf769, 0x558f50ae, 0x558f50ae, 0x558f50ae, 0xab579162, 0xab579162, 0xab579162, 0x421d2e6a, 0x421d2e6a, 0x421d2e6a, 0xc9cbf769, 0x5f5401cb, 0x5f5401cb, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x86f8a68c, 0xf4116451, 0x86f8a68c, 0x28aeef54, 0x9813a416, 0x9813a416, 0x7befbe43, 0x7befbe43, 0x7befbe43, 0xea343870, 0xea343870, 0xea343870, 0xf38e05a0, 0xf38e05a0, 0xf38e05a0, 0x9813a416, 0x28aeef54, 0x28aeef54, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x156c292f, 0x3c8eb473, 0x156c292f, 0x63ca1c9c, 0x5fcf013d, 0x5fcf013d, 0x895ea16b, 0x895ea16b, 0x895ea16b, 0x5b4eb91d, 0x5b4eb91d, 0x5b4eb91d, 0x4d3d8682, 0x4d3d8682, 0x4d3d8682, 0x5fcf013d, 0x63ca1c9c, 0x63ca1c9c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf57ebf12, 0x798b299b, 0xf57ebf12, 0xee7b6515, 0xdd28f52b, 0xdd28f52b, 0x22563fc6, 0x22563fc6, 0x22563fc6, 0x36ac622, 0x36ac622, 0x36ac622, 0x7ed20dae, 0x7ed20dae, 0x7ed20dae, 0xdd28f52b, 0xee7b6515, 0xee7b6515, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x2bc82eb1, 0x94064cc8, 0x2bc82eb1, 0xd4773531, 0x43d1f34, 0x43d1f34, 0x44cbf2f0, 0x44cbf2f0, 0x44cbf2f0, 0x3bc15b58, 0x3bc15b58, 0x3bc15b58, 0xa2905ede, 0xa2905ede, 0xa2905ede, 0x43d1f34, 0xd4773531, 0xd4773531, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7f6dd146, 0x548af474, 0x7f6dd146, 0x3c9b1c01, 0x59c36f00, 0x59c36f00, 0x7d913e8d, 0x7d913e8d, 0x7d913e8d, 0x31153eb, 0x31153eb, 0x31153eb, 0x61e74639, 0x61e74639, 0x61e74639, 0x59c36f00, 0x3c9b1c01, 0x3c9b1c01, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf29ad079, 0x50d47c0, 0xf29ad079, 0xdc9f5506, 0xaa4593fe, 0xaa4593fe, 0x6bcf4c90, 0x6bcf4c90, 0x6bcf4c90, 0xcd3a41f7, 0xcd3a41f7, 0xcd3a41f7, 0xe002ea8f, 0xe002ea8f, 0xe002ea8f, 0xaa4593fe, 0xdc9f5506, 0xdc9f5506, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb25e3082, 0x2ed845dd, 0xb25e3082, 0xef495d06, 0xc9cbf769, 0xc9cbf769, 0xd5322575, 0xd5322575, 0xd5322575, 0x2beae4b9, 0x2beae4b9, 0x2beae4b9, 0xc2a05bb1, 0xc2a05bb1, 0xc2a05bb1, 0xc9cbf769, 0xef495d06, 0xef495d06, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4cdfcd2e, 0x8bf091f, 0x4cdfcd2e, 0xe28984f6, 0x9813a416, 0x9813a416, 0x8217f630, 0x8217f630, 0x8217f630, 0x13cc7003, 0x13cc7003, 0x13cc7003, 0xa764dd3, 0xa764dd3, 0xa764dd3, 0x9813a416, 0xe28984f6, 0xe28984f6, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf2b49f88, 0x2eff252d, 0xf2b49f88, 0x8412aa3b, 0x5fcf013d, 0x5fcf013d, 0x5d3b9fe7, 0x5d3b9fe7, 0x5d3b9fe7, 0x8f2b8791, 0x8f2b8791, 0x8f2b8791, 0x9958b80e, 0x9958b80e, 0x9958b80e, 0x5fcf013d, 0x8412aa3b, 0x8412aa3b, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x786673be, 0x536f1359, 0x786673be, 0x6363a9b9, 0xdd28f52b, 0xdd28f52b, 0x38653b12, 0x38653b12, 0x38653b12, 0x1959c2f6, 0x1959c2f6, 0x1959c2f6, 0x64e1097a, 0x64e1097a, 0x64e1097a, 0xdd28f52b, 0x6363a9b9, 0x6363a9b9, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xac4a1127, 0x699c2ad8, 0xac4a1127, 0x53f50aa7, 0x43d1f34, 0x43d1f34, 0xfa47dfba, 0xfa47dfba, 0xfa47dfba, 0x854d7612, 0x854d7612, 0x854d7612, 0x1c1c7394, 0x1c1c7394, 0x1c1c7394, 0x43d1f34, 0x53f50aa7, 0x53f50aa7, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc5f6633, 0xda908ab0, 0xbc5f6633, 0xffa9ab74, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0xffa9ab74, 0xffa9ab74, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xad820d6b, 0x9a88ad3, 0xad820d6b, 0x83878814, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x83878814, 0x83878814, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe5774112, 0x5ffb1eca, 0xe5774112, 0xb8602c96, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xb8602c96, 0xb8602c96, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6af1a2bc, 0xd951ab8b, 0x6af1a2bc, 0xc4a7eb64, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0xc4a7eb64, 0xc4a7eb64, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc6baa18, 0x1c9db179, 0xc6baa18, 0x7acd9fab, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x7acd9fab, 0x7acd9fab, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe424a6ab, 0xb05c0275, 0xe424a6ab, 0xff217cac, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0xff217cac, 0xff217cac, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4a7dff41, 0xe1ec28fc, 0x4a7dff41, 0xb5c2e4c1, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xb5c2e4c1, 0xb5c2e4c1, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3d3e4a2, 0x9c635046, 0xd3d3e4a2, 0x902529e5, 0x59c36f00, 0x59c36f00, 0x85e713, 0x85e713, 0x85e713, 0x7e058a75, 0x7e058a75, 0x7e058a75, 0x1cf39fa7, 0x1cf39fa7, 0x1cf39fa7, 0x59c36f00, 0x902529e5, 0x902529e5, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd61c80f5, 0xdf78b496, 0xd61c80f5, 0xf819058a, 0xaa4593fe, 0xaa4593fe, 0xefc0f7e7, 0xefc0f7e7, 0xefc0f7e7, 0x4935fa80, 0x4935fa80, 0x4935fa80, 0x640d51f8, 0x640d51f8, 0x640d51f8, 0xaa4593fe, 0xf819058a, 0xf819058a, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x936bc89d, 0x523a3e80, 0x936bc89d, 0xce7ca519, 0xc9cbf769, 0xc9cbf769, 0xaa99ffb1, 0xaa99ffb1, 0xaa99ffb1, 0x54413e7d, 0x54413e7d, 0x54413e7d, 0xbd0b8175, 0xbd0b8175, 0xbd0b8175, 0xc9cbf769, 0xce7ca519, 0xce7ca519, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4fdd0291, 0x133fa83d, 0x4fdd0291, 0xe18b4b49, 0x9813a416, 0x9813a416, 0x74c38e90, 0x74c38e90, 0x74c38e90, 0xe51808a3, 0xe51808a3, 0xe51808a3, 0xfca23573, 0xfca23573, 0xfca23573, 0x9813a416, 0xe18b4b49, 0xe18b4b49, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x538203b0, 0x2a92e789, 0x538203b0, 0x25243603, 0x5fcf013d, 0x5fcf013d, 0x5e4d3dd8, 0x5e4d3dd8, 0x5e4d3dd8, 0x8c5d25ae, 0x8c5d25ae, 0x8c5d25ae, 0x9a2e1a31, 0x9a2e1a31, 0x9a2e1a31, 0x5fcf013d, 0x25243603, 0x25243603, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcfc85125, 0xa5b0e11b, 0xcfc85125, 0xd4cd8b22, 0xdd28f52b, 0xdd28f52b, 0x1af8cddc, 0x1af8cddc, 0x1af8cddc, 0x3bc43438, 0x3bc43438, 0x3bc43438, 0x467cffb4, 0x467cffb4, 0x467cffb4, 0xdd28f52b, 0xd4cd8b22, 0xd4cd8b22, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf2469ffb, 0x1d0c1d2, 0xf2469ffb, 0xdf9847b, 0x43d1f34, 0x43d1f34, 0xa2837c7a, 0xa2837c7a, 0xa2837c7a, 0xdd89d5d2, 0xdd89d5d2, 0xdd89d5d2, 0x44d8d054, 0x44d8d054, 0x44d8d054, 0x43d1f34, 0xdf9847b, 0xdf9847b, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x27851cc1, 0x15f731b5, 0x27851cc1, 0x6473d186, 0x59c36f00, 0x59c36f00, 0x125bcddf, 0x125bcddf, 0x125bcddf, 0x6cdba0b9, 0x6cdba0b9, 0x6cdba0b9, 0xe2db56b, 0xe2db56b, 0xe2db56b, 0x59c36f00, 0x6473d186, 0x6473d186, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfcb223c, 0x2c2e18b9, 0xfcb223c, 0x21cea743, 0xaa4593fe, 0xaa4593fe, 0xd700be1a, 0xd700be1a, 0xd700be1a, 0x71f5b37d, 0x71f5b37d, 0x71f5b37d, 0x5ccd1805, 0x5ccd1805, 0x5ccd1805, 0xaa4593fe, 0x21cea743, 0x21cea743, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x807efaa5, 0xb673036a, 0x807efaa5, 0xdd699721, 0xc9cbf769, 0xc9cbf769, 0xdca3ed4b, 0xdca3ed4b, 0xdca3ed4b, 0x227b2c87, 0x227b2c87, 0x227b2c87, 0xcb31938f, 0xcb31938f, 0xcb31938f, 0xc9cbf769, 0xdd699721, 0xdd699721, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x651d0d50, 0xf0dc38fc, 0x651d0d50, 0xcb4b4488, 0x9813a416, 0x9813a416, 0x80d03ee8, 0x80d03ee8, 0x80d03ee8, 0x110bb8db, 0x110bb8db, 0x110bb8db, 0x8b1850b, 0x8b1850b, 0x8b1850b, 0x9813a416, 0xcb4b4488, 0xcb4b4488, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb9b068f, 0xdc68ac3c, 0xb9b068f, 0x7d3d333c, 0x5fcf013d, 0x5fcf013d, 0xa1f0a6e4, 0xa1f0a6e4, 0xa1f0a6e4, 0x73e0be92, 0x73e0be92, 0x73e0be92, 0x6593810d, 0x6593810d, 0x6593810d, 0x5fcf013d, 0x7d3d333c, 0x7d3d333c, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf0789d7e, 0x6f2f2b61, 0xf0789d7e, 0xeb7d4779, 0xdd28f52b, 0xdd28f52b, 0xb995630, 0xb995630, 0xb995630, 0x2aa5afd4, 0x2aa5afd4, 0x2aa5afd4, 0x571d6458, 0x571d6458, 0x571d6458, 0xdd28f52b, 0xeb7d4779, 0xeb7d4779, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x819821ff, 0xdd19128c, 0x819821ff, 0x7e273a7f, 0x43d1f34, 0x43d1f34, 0xf35981d3, 0xf35981d3, 0xf35981d3, 0x8c53287b, 0x8c53287b, 0x8c53287b, 0x15022dfd, 0x15022dfd, 0x15022dfd, 0x43d1f34, 0x7e273a7f, 0x7e273a7f, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa99604d1, 0xcf59e852, 0xa99604d1, 0xfebbba0f, 0x59c36f00, 0x59c36f00, 0x53767ce3, 0x53767ce3, 0x53767ce3, 0x2df61185, 0x2df61185, 0x2df61185, 0x4f000457, 0x4f000457, 0x4f000457, 0x59c36f00, 0xfebbba0f, 0xfebbba0f, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7d0a218, 0xa3fa25a0, 0x7d0a218, 0xb777784e, 0xaa4593fe, 0xaa4593fe, 0x35db26e1, 0x35db26e1, 0x35db26e1, 0x932e2b86, 0x932e2b86, 0x932e2b86, 0xbe1680fe, 0xbe1680fe, 0xbe1680fe, 0xaa4593fe, 0xb777784e, 0xb777784e, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x63be90f4, 0xd932cf2c, 0x63be90f4, 0x739b8e5a, 0xc9cbf769, 0xc9cbf769, 0x70a00efe, 0x70a00efe, 0x70a00efe, 0x8e78cf32, 0x8e78cf32, 0x8e78cf32, 0x6732703a, 0x6732703a, 0x6732703a, 0xc9cbf769, 0x739b8e5a, 0x739b8e5a, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x53460c90, 0xe0e605a7, 0x53460c90, 0x6337f0bf, 0x9813a416, 0x9813a416, 0x4161864c, 0x4161864c, 0x4161864c, 0xd0ba007f, 0xd0ba007f, 0xd0ba007f, 0xc9003daf, 0xc9003daf, 0xc9003daf, 0x9813a416, 0x6337f0bf, 0x6337f0bf, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf54761a0, 0xe5b17ac1, 0xf54761a0, 0x5b408e55, 0x5fcf013d, 0x5fcf013d, 0x580fda0e, 0x580fda0e, 0x580fda0e, 0x8a1fc278, 0x8a1fc278, 0x8a1fc278, 0x9c6cfde7, 0x9c6cfde7, 0x9c6cfde7, 0x5fcf013d, 0x5b408e55, 0x5b408e55, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec78b0c1, 0xb800141f, 0xec78b0c1, 0x621c7b1b, 0xdd28f52b, 0xdd28f52b, 0x8f60179, 0x8f60179, 0x8f60179, 0x29caf89d, 0x29caf89d, 0x29caf89d, 0x54723311, 0x54723311, 0x54723311, 0xdd28f52b, 0x621c7b1b, 0x621c7b1b, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf209411b, 0x599896a6, 0xf209411b, 0x6551c7bb, 0x43d1f34, 0x43d1f34, 0x5ac6bb4a, 0x5ac6bb4a, 0x5ac6bb4a, 0x25cc12e2, 0x25cc12e2, 0x25cc12e2, 0xbc9d1764, 0xbc9d1764, 0xbc9d1764, 0x43d1f34, 0x6551c7bb, 0x6551c7bb, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x93b4fcd8, 0xf57b105b, 0x93b4fcd8, 0x2bfe5312, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x2bfe5312, 0x2bfe5312, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x656c9044, 0xc14617fc, 0x656c9044, 0xa6ea58cb, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0xa6ea58cb, 0xa6ea58cb, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa11479ed, 0x1b982635, 0xa11479ed, 0xe37185d0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xe37185d0, 0xe37185d0, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x244770a7, 0x97e77990, 0x244770a7, 0x6a54d2ee, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x6a54d2ee, 0x6a54d2ee, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8ca34476, 0x9c555f17, 0x8ca34476, 0x1fc54b41, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x1fc54b41, 0x1fc54b41, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf19f6af8, 0xa5e7ce26, 0xf19f6af8, 0x1619aea6, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x1619aea6, 0x1619aea6, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5f75414f, 0xf4e496f2, 0x5f75414f, 0x27fd1fe0, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0x27fd1fe0, 0x27fd1fe0, 0x43d1f34, }, 20 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x8851b0ee, 0x8851b0ee, 0xafb59f0b, 0xafb59f0b, 0x8c9b72f1, 0x8c9b72f1, 0x6eec5116, 0x6eec5116, 0xad82053e, 0xad82053e, 0x2eeae2ae, 0x2eeae2ae, 0x58cf8def, 0x58cf8def, 0x926f4d2f, 0x926f4d2f, 0xbd1c3236, 0xbd1c3236, 0x56012a95, 0x56012a95, 0x6d7c40ae, 0x6d7c40ae, 0xef750bc8, 0xef750bc8, 0x1080dd4a, 0x1080dd4a, 0xd7f9e5af, 0xd7f9e5af, 0x80b1b4a9, 0x80b1b4a9, 0x2c99415e, 0x2c99415e, 0x8d5761ff, 0x8d5761ff, 0xb964b489, 0xb964b489, 0x88a51f74, 0x88a51f74, 0x1da6c458, 0x1da6c458, 0x85e94025, 0x206ea54f, 0x7ee6c8fd, 0x7ee6c8fd, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x834b70a0, 0x834b70a0, 0xe7cc129f, 0xe7cc129f, 0x5ee2edc, 0x5ee2edc, 0xa1135cd7, 0xa1135cd7, 0xf7ce1f26, 0xf7ce1f26, 0xe9f803e8, 0xe9f803e8, 0x4b8f9724, 0x4b8f9724, 0x3fe3771a, 0x3fe3771a, 0x5584ee63, 0x5584ee63, 0xac193250, 0xac193250, 0x801f25f4, 0x801f25f4, 0x8d33aece, 0x8d33aece, 0xc6d95edc, 0xc6d95edc, 0xf121dee2, 0xf121dee2, 0x6ab10812, 0x6ab10812, 0x41a5b112, 0x41a5b112, 0xac6f712b, 0xac6f712b, 0x8aee7a19, 0x8aee7a19, 0xfe37c0ad, 0xfe37c0ad, 0x99c6a336, 0x99c6a336, 0x53b844c6, 0x73015447, 0x7a1a2254, 0x7a1a2254, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb121c912, 0xb121c912, 0x635a8739, 0x635a8739, 0x8288cba6, 0x8288cba6, 0xf5589d0, 0xf5589d0, 0x471642b3, 0x471642b3, 0xfb4826cf, 0xfb4826cf, 0x8b1083cf, 0x8b1083cf, 0x738b0c94, 0x738b0c94, 0x859c41b0, 0x859c41b0, 0x7c8d1be9, 0x7c8d1be9, 0x5b685e40, 0x5b685e40, 0x9cf80d95, 0x9cf80d95, 0x3541f915, 0x3541f915, 0x582b8557, 0x582b8557, 0x24cf88f7, 0x24cf88f7, 0x9e0af23, 0x9e0af23, 0x1033164b, 0x1033164b, 0x70ba51e2, 0x70ba51e2, 0xb051585c, 0xb051585c, 0xe1389f04, 0xe1389f04, 0x308bbb74, 0xdc9e6805, 0x4ddcff9f, 0x4ddcff9f, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xac16e832, 0xac16e832, 0xbf6ab9c6, 0xbf6ab9c6, 0x1063e15a, 0x1063e15a, 0xf908e3ff, 0xf908e3ff, 0xcb37d841, 0xcb37d841, 0x9b8ffa7d, 0x9b8ffa7d, 0x38d2a26c, 0x38d2a26c, 0x6989f09b, 0x6989f09b, 0x481451e, 0x481451e, 0x17b3177, 0x17b3177, 0x3ea52aeb, 0x3ea52aeb, 0xc24de674, 0xc24de674, 0x4ab163cc, 0x4ab163cc, 0xc482b092, 0xc482b092, 0x55ffc7e2, 0x55ffc7e2, 0x3b4b34dd, 0x3b4b34dd, 0x9b1f047f, 0x9b1f047f, 0x3d42e414, 0x3d42e414, 0x35b2fb06, 0x35b2fb06, 0xb813b35f, 0xb813b35f, 0xc3ede6e0, 0xc35214c3, 0x340f0107, 0x340f0107, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9c47caee, 0x9c47caee, 0x6c9c4f38, 0x6c9c4f38, 0x79c49615, 0x79c49615, 0x70fe9708, 0x70fe9708, 0x8e90c077, 0x8e90c077, 0xd8205b47, 0xd8205b47, 0xa34337e2, 0xa34337e2, 0xf4dffa53, 0xf4dffa53, 0x90a0779c, 0x90a0779c, 0x322820bb, 0x322820bb, 0x50e3383f, 0x50e3383f, 0x4a976e3e, 0x4a976e3e, 0x90b6f8d9, 0x90b6f8d9, 0x4058c301, 0x4058c301, 0x221a6810, 0x221a6810, 0x1f78a00e, 0x1f78a00e, 0x6a633d2c, 0x6a633d2c, 0xca177c65, 0xca177c65, 0xabb6c7f9, 0xabb6c7f9, 0x635a35e8, 0x635a35e8, 0x6da78f10, 0x53467ff8, 0xd037fdfa, 0xd037fdfa, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2b6b8225, 0x2b6b8225, 0x83df9995, 0x83df9995, 0x5165ad0b, 0x5165ad0b, 0xe5a6f96d, 0xe5a6f96d, 0x798df957, 0x798df957, 0x8c0567e2, 0x8c0567e2, 0x5e5d7389, 0x5e5d7389, 0x47a39dd, 0x47a39dd, 0x894f44af, 0x894f44af, 0x1dff0a6, 0x1dff0a6, 0xf496e67b, 0xf496e67b, 0x29cb5702, 0x29cb5702, 0xeaf1387d, 0xeaf1387d, 0x4a9bf7, 0x4a9bf7, 0x11d20bee, 0x11d20bee, 0xa103dc2d, 0xa103dc2d, 0xd0265db9, 0xd0265db9, 0x42267334, 0x42267334, 0x96f85e8c, 0x96f85e8c, 0xa28eac49, 0xa28eac49, 0x4e660ae7, 0x70741b3, 0x183f2f2e, 0x183f2f2e, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x77b51f44, 0x77b51f44, 0xc8097569, 0xc8097569, 0x769aee5f, 0x769aee5f, 0xa35e159, 0xa35e159, 0x87a6341f, 0x87a6341f, 0xb61d944b, 0xb61d944b, 0x8b109cb3, 0x8b109cb3, 0xed3fb3e, 0xed3fb3e, 0xd7cc6c3, 0xd7cc6c3, 0x52077f0d, 0x52077f0d, 0x9d86d17e, 0x9d86d17e, 0x5e487bb, 0x5e487bb, 0x3a00041b, 0x3a00041b, 0xcfdeaf9e, 0xcfdeaf9e, 0x3e40af89, 0x3e40af89, 0x5ec41ea9, 0x5ec41ea9, 0x6298e4e7, 0x6298e4e7, 0xfd67f90e, 0xfd67f90e, 0x5ab5dc32, 0x5ab5dc32, 0xdd3ad694, 0xdd3ad694, 0x391222b4, 0xd4a98b43, 0xeaa2f62, 0xeaa2f62, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x45b0713c, 0x237f9dbf, 0x45b0713c, 0x646bc7b, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0x646bc7b, 0x646bc7b, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x84abc7db, 0x20814063, 0x84abc7db, 0xaaae42a4, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0xaaae42a4, 0xaaae42a4, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5b85371a, 0xe10968c2, 0x5b85371a, 0x6925a9e, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0x6925a9e, 0x6925a9e, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9130464d, 0x22904f7a, 0x9130464d, 0x3f660f95, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x3f660f95, 0x3f660f95, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5185b14e, 0x4173aa2f, 0x5185b14e, 0x272384fd, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x272384fd, 0x272384fd, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5cc0d3ef, 0x8b87731, 0x5cc0d3ef, 0x47c509e8, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0x47c509e8, 0x47c509e8, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd1338a02, 0x7aa25dbf, 0xd1338a02, 0x2e8c9182, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0x2e8c9182, 0x2e8c9182, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0x2b88b6ce, 0x2b88b6ce, 0x2b88b6ce, 0x7750400e, 0x7750400e, 0x7750400e, 0x5ec88e9c, 0x5ec88e9c, 0x5ec88e9c, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xa1b1a1b5, 0xa1b1a1b5, 0xa1b1a1b5, 0xf4ee0bbf, 0xf4ee0bbf, 0xf4ee0bbf, 0x9dddc3f6, 0x9dddc3f6, 0x9dddc3f6, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xa07e74d3, 0xa07e74d3, 0xa07e74d3, 0xdfc0d247, 0xdfc0d247, 0xdfc0d247, 0x9db4b23f, 0x9db4b23f, 0x9db4b23f, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x84312594, 0x84312594, 0x84312594, 0x6f94cfe8, 0x6f94cfe8, 0x6f94cfe8, 0x69dfcf18, 0x69dfcf18, 0x69dfcf18, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x131c0760, 0x131c0760, 0x131c0760, 0x7c55db71, 0x7c55db71, 0x7c55db71, 0x71a34572, 0x71a34572, 0x71a34572, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0xb9092e0b, 0xb9092e0b, 0xb9092e0b, 0x7fbb6a15, 0x7fbb6a15, 0x7fbb6a15, 0x6bdebaaa, 0x6bdebaaa, 0x6bdebaaa, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x14f7c6b1, 0x14f7c6b1, 0x14f7c6b1, 0x95043060, 0x95043060, 0x95043060, 0x3a0890f, 0x3a0890f, 0x3a0890f, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x77ff5efc, 0x791fe364, 0x77ff5efc, 0x340993bb, 0x59c36f00, 0x59c36f00, 0x3908ca1e, 0x3908ca1e, 0x3908ca1e, 0x4788a778, 0x4788a778, 0x4788a778, 0x257eb2aa, 0x257eb2aa, 0x257eb2aa, 0x59c36f00, 0x340993bb, 0x340993bb, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb2d04b0f, 0x46cdbc23, 0xb2d04b0f, 0x9cd5ce70, 0xaa4593fe, 0xaa4593fe, 0x44bf6b37, 0x44bf6b37, 0x44bf6b37, 0xe24a6650, 0xe24a6650, 0xe24a6650, 0xcf72cd28, 0xcf72cd28, 0xcf72cd28, 0xaa4593fe, 0x9cd5ce70, 0x9cd5ce70, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4bb823b8, 0x59349835, 0x4bb823b8, 0x16af4e3c, 0xc9cbf769, 0xc9cbf769, 0x2784b68e, 0x2784b68e, 0x2784b68e, 0xd95c7742, 0xd95c7742, 0xd95c7742, 0x3016c84a, 0x3016c84a, 0x3016c84a, 0xc9cbf769, 0x16af4e3c, 0x16af4e3c, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb821e44, 0x16b3ac05, 0xb821e44, 0xa5d4579c, 0x9813a416, 0x9813a416, 0xca80d730, 0xca80d730, 0xca80d730, 0x5b5b5103, 0x5b5b5103, 0x5b5b5103, 0x42e16cd3, 0x42e16cd3, 0x42e16cd3, 0x9813a416, 0xa5d4579c, 0xa5d4579c, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbe0b9671, 0x7f6e98d0, 0xbe0b9671, 0xc8ada3c2, 0x5fcf013d, 0x5fcf013d, 0x57a0c67d, 0x57a0c67d, 0x57a0c67d, 0x85b0de0b, 0x85b0de0b, 0x85b0de0b, 0x93c3e194, 0x93c3e194, 0x93c3e194, 0x5fcf013d, 0xc8ada3c2, 0xc8ada3c2, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9f18b29e, 0x50e7d383, 0x9f18b29e, 0x841d6899, 0xdd28f52b, 0xdd28f52b, 0xd12092dc, 0xd12092dc, 0xd12092dc, 0xf01c6b38, 0xf01c6b38, 0xf01c6b38, 0x8da4a0b4, 0x8da4a0b4, 0x8da4a0b4, 0xdd28f52b, 0x841d6899, 0x841d6899, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4e8d4d8c, 0x3f32cb90, 0x4e8d4d8c, 0xb132560c, 0x43d1f34, 0x43d1f34, 0x1e7f303c, 0x1e7f303c, 0x1e7f303c, 0x61759994, 0x61759994, 0x61759994, 0xf8249c12, 0xf8249c12, 0xf8249c12, 0x43d1f34, 0xb132560c, 0xb132560c, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4f39b2c5, 0x37084023, 0x4f39b2c5, 0xccf7f82, 0x59c36f00, 0x59c36f00, 0xb5dad2e, 0xb5dad2e, 0xb5dad2e, 0x75ddc048, 0x75ddc048, 0x75ddc048, 0x172bd59a, 0x172bd59a, 0x172bd59a, 0x59c36f00, 0xccf7f82, 0xccf7f82, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5f24f8e, 0x76463f82, 0xd5f24f8e, 0xfbf7caf1, 0xaa4593fe, 0xaa4593fe, 0xb897c475, 0xb897c475, 0xb897c475, 0x1e62c912, 0x1e62c912, 0x1e62c912, 0x335a626a, 0x335a626a, 0x335a626a, 0xaa4593fe, 0xfbf7caf1, 0xfbf7caf1, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8aa7c8c3, 0x28620e7e, 0x8aa7c8c3, 0xd7b0a547, 0xc9cbf769, 0xc9cbf769, 0x860f1899, 0x860f1899, 0x860f1899, 0x78d7d955, 0x78d7d955, 0x78d7d955, 0x919d665d, 0x919d665d, 0x919d665d, 0xc9cbf769, 0xd7b0a547, 0xd7b0a547, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x89654b6, 0x26bab4dd, 0x89654b6, 0xa6c01d6e, 0x9813a416, 0x9813a416, 0xc67652d9, 0xc67652d9, 0xc67652d9, 0x57add4ea, 0x57add4ea, 0x57add4ea, 0x4e17e93a, 0x4e17e93a, 0x4e17e93a, 0x9813a416, 0xa6c01d6e, 0xa6c01d6e, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x77945f28, 0xec3ce845, 0x77945f28, 0x1326a9b, 0x5fcf013d, 0x5fcf013d, 0xc8e6e12c, 0xc8e6e12c, 0xc8e6e12c, 0x1af6f95a, 0x1af6f95a, 0x1af6f95a, 0xc85c6c5, 0xc85c6c5, 0xc85c6c5, 0x5fcf013d, 0x1326a9b, 0x1326a9b, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4450a5dc, 0xda479f49, 0x4450a5dc, 0x5f557fdb, 0xdd28f52b, 0xdd28f52b, 0xddfe9197, 0xddfe9197, 0xddfe9197, 0xfcc26873, 0xfcc26873, 0xfcc26873, 0x817aa3ff, 0x817aa3ff, 0x817aa3ff, 0xdd28f52b, 0x5f557fdb, 0x5f557fdb, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x409098da, 0x2e0890e, 0x409098da, 0xbf2f835a, 0x43d1f34, 0x43d1f34, 0x253d050e, 0x253d050e, 0x253d050e, 0x5a37aca6, 0x5a37aca6, 0x5a37aca6, 0xc366a920, 0xc366a920, 0xc366a920, 0x43d1f34, 0xbf2f835a, 0xbf2f835a, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x546aa9f1, 0x56bf26d0, 0x546aa9f1, 0x179c64b6, 0x59c36f00, 0x59c36f00, 0xa98ad4a1, 0xa98ad4a1, 0xa98ad4a1, 0xd70ab9c7, 0xd70ab9c7, 0xd70ab9c7, 0xb5fcac15, 0xb5fcac15, 0xb5fcac15, 0x59c36f00, 0x179c64b6, 0x179c64b6, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x12592c97, 0xa10f7034, 0x12592c97, 0x3c5ca9e8, 0xaa4593fe, 0xaa4593fe, 0x2c3e194, 0x2c3e194, 0x2c3e194, 0xa436ecf3, 0xa436ecf3, 0xa436ecf3, 0x890e478b, 0x890e478b, 0x890e478b, 0xaa4593fe, 0x3c5ca9e8, 0x3c5ca9e8, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xed5de42a, 0x5cf94e51, 0xed5de42a, 0xb04a89ae, 0xc9cbf769, 0xc9cbf769, 0xdd578210, 0xdd578210, 0xdd578210, 0x238f43dc, 0x238f43dc, 0x238f43dc, 0xcac5fcd4, 0xcac5fcd4, 0xcac5fcd4, 0xc9cbf769, 0xb04a89ae, 0xb04a89ae, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbbc56f90, 0x4f643bbb, 0xbbc56f90, 0x15932648, 0x9813a416, 0x9813a416, 0x28aba4d1, 0x28aba4d1, 0x28aba4d1, 0xb97022e2, 0xb97022e2, 0xb97022e2, 0xa0ca1f32, 0xa0ca1f32, 0xa0ca1f32, 0x9813a416, 0x15932648, 0x15932648, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x43465d8c, 0x6399888a, 0x43465d8c, 0x35e0683f, 0x5fcf013d, 0x5fcf013d, 0x4895c207, 0x4895c207, 0x4895c207, 0x9a85da71, 0x9a85da71, 0x9a85da71, 0x8cf6e5ee, 0x8cf6e5ee, 0x8cf6e5ee, 0x5fcf013d, 0x35e0683f, 0x35e0683f, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd1e7f231, 0xe67e195e, 0xd1e7f231, 0xcae22836, 0xdd28f52b, 0xdd28f52b, 0xe7ae9f08, 0xe7ae9f08, 0xe7ae9f08, 0xc69266ec, 0xc69266ec, 0xc69266ec, 0xbb2aad60, 0xbb2aad60, 0xbb2aad60, 0xdd28f52b, 0xcae22836, 0xcae22836, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x793e58f4, 0x5f939386, 0x793e58f4, 0x86814374, 0x43d1f34, 0x43d1f34, 0x12b2b9c1, 0x12b2b9c1, 0x12b2b9c1, 0x6db81069, 0x6db81069, 0x6db81069, 0xf4e915ef, 0xf4e915ef, 0xf4e915ef, 0x43d1f34, 0x86814374, 0x86814374, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x226c0d75, 0x9e291f4f, 0x226c0d75, 0x619ac032, 0x59c36f00, 0x59c36f00, 0x6fb6253, 0x6fb6253, 0x6fb6253, 0x787b0f35, 0x787b0f35, 0x787b0f35, 0x1a8d1ae7, 0x1a8d1ae7, 0x1a8d1ae7, 0x59c36f00, 0x619ac032, 0x619ac032, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8355045, 0xfe058b68, 0x8355045, 0x2630d53a, 0xaa4593fe, 0xaa4593fe, 0x290a3822, 0x290a3822, 0x290a3822, 0x8fff3545, 0x8fff3545, 0x8fff3545, 0xa2c79e3d, 0xa2c79e3d, 0xa2c79e3d, 0xaa4593fe, 0x2630d53a, 0x2630d53a, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc702fa59, 0x74086887, 0xc702fa59, 0x9a1597dd, 0xc9cbf769, 0xc9cbf769, 0x60295baa, 0x60295baa, 0x60295baa, 0x9ef19a66, 0x9ef19a66, 0x9ef19a66, 0x77bb256e, 0x77bb256e, 0x77bb256e, 0xc9cbf769, 0x9a1597dd, 0x9a1597dd, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x82385331, 0xf77eda42, 0x82385331, 0x2c6e1ae9, 0x9813a416, 0x9813a416, 0x140c0d1f, 0x140c0d1f, 0x140c0d1f, 0x85d78b2c, 0x85d78b2c, 0x85d78b2c, 0x9c6db6fc, 0x9c6db6fc, 0x9c6db6fc, 0x9813a416, 0x2c6e1ae9, 0x2c6e1ae9, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x565d2d38, 0x34f757ec, 0x565d2d38, 0x20fb188b, 0x5fcf013d, 0x5fcf013d, 0x230bf123, 0x230bf123, 0x230bf123, 0xf11be955, 0xf11be955, 0xf11be955, 0xe768d6ca, 0xe768d6ca, 0xe768d6ca, 0x5fcf013d, 0x20fb188b, 0x20fb188b, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x632132a4, 0x4a8c90b2, 0x632132a4, 0x7824e8a3, 0xdd28f52b, 0xdd28f52b, 0xef2bffce, 0xef2bffce, 0xef2bffce, 0xce17062a, 0xce17062a, 0xce17062a, 0xb3afcda6, 0xb3afcda6, 0xb3afcda6, 0xdd28f52b, 0x7824e8a3, 0x7824e8a3, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x461d4cfa, 0xfd3492c2, 0x461d4cfa, 0xb9a2577a, 0x43d1f34, 0x43d1f34, 0xfb72301f, 0xfb72301f, 0xfb72301f, 0x847899b7, 0x847899b7, 0x847899b7, 0x1d299c31, 0x1d299c31, 0x1d299c31, 0x43d1f34, 0xb9a2577a, 0xb9a2577a, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x82758f66, 0xbac387fd, 0x82758f66, 0xc1834221, 0x59c36f00, 0x59c36f00, 0x4877befe, 0x4877befe, 0x4877befe, 0x36f7d398, 0x36f7d398, 0x36f7d398, 0x5401c64a, 0x5401c64a, 0x5401c64a, 0x59c36f00, 0xc1834221, 0xc1834221, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4500a591, 0x9a40cbd8, 0x4500a591, 0x6b0520ee, 0xaa4593fe, 0xaa4593fe, 0x16db2902, 0x16db2902, 0x16db2902, 0xb02e2465, 0xb02e2465, 0xb02e2465, 0x9d168f1d, 0x9d168f1d, 0x9d168f1d, 0xaa4593fe, 0x6b0520ee, 0x6b0520ee, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x3cd9ea11, 0x1244c852, 0x3cd9ea11, 0x61ce8795, 0xc9cbf769, 0xc9cbf769, 0x6b15d6f0, 0x6b15d6f0, 0x6b15d6f0, 0x95cd173c, 0x95cd173c, 0x95cd173c, 0x7c87a834, 0x7c87a834, 0x7c87a834, 0xc9cbf769, 0x61ce8795, 0x61ce8795, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc818f15f, 0xbaf13382, 0xc818f15f, 0x664eb887, 0x9813a416, 0x9813a416, 0x350fe990, 0x350fe990, 0x350fe990, 0xa4d46fa3, 0xa4d46fa3, 0xa4d46fa3, 0xbd6e5273, 0xbd6e5273, 0xbd6e5273, 0x9813a416, 0x664eb887, 0x664eb887, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xaa1dc81, 0x234341dd, 0xaa1dc81, 0x7c07e932, 0x5fcf013d, 0x5fcf013d, 0x969354c5, 0x969354c5, 0x969354c5, 0x44834cb3, 0x44834cb3, 0x44834cb3, 0x52f0732c, 0x52f0732c, 0x52f0732c, 0x5fcf013d, 0x7c07e932, 0x7c07e932, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd9aa4b29, 0x555fdda0, 0xd9aa4b29, 0xc2af912e, 0xdd28f52b, 0xdd28f52b, 0xe82cbfd, 0xe82cbfd, 0xe82cbfd, 0x2fbe3219, 0x2fbe3219, 0x2fbe3219, 0x5206f995, 0x5206f995, 0x5206f995, 0xdd28f52b, 0xc2af912e, 0xc2af912e, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfd4e19ff, 0x42807b86, 0xfd4e19ff, 0x2f1027f, 0x43d1f34, 0x43d1f34, 0x924dc5be, 0x924dc5be, 0x924dc5be, 0xed476c16, 0xed476c16, 0xed476c16, 0x74166990, 0x74166990, 0x74166990, 0x43d1f34, 0x2f1027f, 0x2f1027f, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3a63a2e6, 0x118487d4, 0x3a63a2e6, 0x79956fa1, 0x59c36f00, 0x59c36f00, 0x389f4d2d, 0x389f4d2d, 0x389f4d2d, 0x461f204b, 0x461f204b, 0x461f204b, 0x24e93599, 0x24e93599, 0x24e93599, 0x59c36f00, 0x79956fa1, 0x79956fa1, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x62d33f4d, 0x9544a8f4, 0x62d33f4d, 0x4cd6ba32, 0xaa4593fe, 0xaa4593fe, 0xfb86a3a4, 0xfb86a3a4, 0xfb86a3a4, 0x5d73aec3, 0x5d73aec3, 0x5d73aec3, 0x704b05bb, 0x704b05bb, 0x704b05bb, 0xaa4593fe, 0x4cd6ba32, 0x4cd6ba32, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8cc4b6dc, 0x1042c383, 0x8cc4b6dc, 0xd1d3db58, 0xc9cbf769, 0xc9cbf769, 0xeba8a32b, 0xeba8a32b, 0xeba8a32b, 0x157062e7, 0x157062e7, 0x157062e7, 0xfc3addef, 0xfc3addef, 0xfc3addef, 0xc9cbf769, 0xd1d3db58, 0xd1d3db58, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x23f9afd, 0x465f5ecc, 0x23f9afd, 0xac69d325, 0x9813a416, 0x9813a416, 0xccf7a1e3, 0xccf7a1e3, 0xccf7a1e3, 0x5d2c27d0, 0x5d2c27d0, 0x5d2c27d0, 0x44961a00, 0x44961a00, 0x44961a00, 0x9813a416, 0xac69d325, 0xac69d325, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xed796a26, 0x3132d083, 0xed796a26, 0x9bdf5f95, 0x5fcf013d, 0x5fcf013d, 0x42f66a49, 0x42f66a49, 0x42f66a49, 0x90e6723f, 0x90e6723f, 0x90e6723f, 0x86954da0, 0x86954da0, 0x86954da0, 0x5fcf013d, 0x9bdf5f95, 0x9bdf5f95, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x54b28785, 0x7fbbe762, 0x54b28785, 0x4fb75d82, 0xdd28f52b, 0xdd28f52b, 0x14b1cf29, 0x14b1cf29, 0x14b1cf29, 0x358d36cd, 0x358d36cd, 0x358d36cd, 0x4835fd41, 0x4835fd41, 0x4835fd41, 0xdd28f52b, 0x4fb75d82, 0x4fb75d82, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7acc2669, 0xbf1a1d96, 0x7acc2669, 0x85733de9, 0x43d1f34, 0x43d1f34, 0x2cc1e8f4, 0x2cc1e8f4, 0x2cc1e8f4, 0x53cb415c, 0x53cb415c, 0x53cb415c, 0xca9a44da, 0xca9a44da, 0xca9a44da, 0x43d1f34, 0x85733de9, 0x85733de9, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xf9511593, 0x9f9ef910, 0xf9511593, 0xbaa7d8d4, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0xbaa7d8d4, 0xbaa7d8d4, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3dcbe25f, 0x99e165e7, 0x3dcbe25f, 0x13ce6720, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0x13ce6720, 0x13ce6720, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdbedc74c, 0x61619894, 0xdbedc74c, 0x86faaac8, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0x86faaac8, 0x86faaac8, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2411f56f, 0x97b1fc58, 0x2411f56f, 0x8a47bcb7, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x8a47bcb7, 0x8a47bcb7, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x13a65fb6, 0x35044d7, 0x13a65fb6, 0x65006a05, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x65006a05, 0x65006a05, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc8f05290, 0x9c88f64e, 0xc8f05290, 0xd3f58897, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0xd3f58897, 0xd3f58897, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9cfbc80f, 0x376a1fb2, 0x9cfbc80f, 0x6344d38f, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0x6344d38f, 0x6344d38f, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd327ca68, 0x9c977e8c, 0xd327ca68, 0x90d1072f, 0x59c36f00, 0x59c36f00, 0x71c9d9, 0x71c9d9, 0x71c9d9, 0x7ef1a4bf, 0x7ef1a4bf, 0x7ef1a4bf, 0x1c07b16d, 0x1c07b16d, 0x1c07b16d, 0x59c36f00, 0x90d1072f, 0x90d1072f, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2da3855b, 0x24c7b138, 0x2da3855b, 0x3a60024, 0xaa4593fe, 0xaa4593fe, 0x147ff249, 0x147ff249, 0x147ff249, 0xb28aff2e, 0xb28aff2e, 0xb28aff2e, 0x9fb25456, 0x9fb25456, 0x9fb25456, 0xaa4593fe, 0x3a60024, 0x3a60024, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x660ab3d9, 0xa75b45c4, 0x660ab3d9, 0x3b1dde5d, 0xc9cbf769, 0xc9cbf769, 0x5ff884f5, 0x5ff884f5, 0x5ff884f5, 0xa1204539, 0xa1204539, 0xa1204539, 0x486afa31, 0x486afa31, 0x486afa31, 0xc9cbf769, 0x3b1dde5d, 0x3b1dde5d, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x920957ee, 0xceebfd42, 0x920957ee, 0x3c5f1e36, 0x9813a416, 0x9813a416, 0xa917dbef, 0xa917dbef, 0xa917dbef, 0x38cc5ddc, 0x38cc5ddc, 0x38cc5ddc, 0x2176600c, 0x2176600c, 0x2176600c, 0x9813a416, 0x3c5f1e36, 0x3c5f1e36, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8298cd03, 0xfb88293a, 0x8298cd03, 0xf43ef8b0, 0x5fcf013d, 0x5fcf013d, 0x8f57f36b, 0x8f57f36b, 0x8f57f36b, 0x5d47eb1d, 0x5d47eb1d, 0x5d47eb1d, 0x4b34d482, 0x4b34d482, 0x4b34d482, 0x5fcf013d, 0xf43ef8b0, 0xf43ef8b0, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd8bbc577, 0xb2c37549, 0xd8bbc577, 0xc3be1f70, 0xdd28f52b, 0xdd28f52b, 0xd8b598e, 0xd8b598e, 0xd8b598e, 0x2cb7a06a, 0x2cb7a06a, 0x2cb7a06a, 0x510f6be6, 0x510f6be6, 0x510f6be6, 0xdd28f52b, 0xc3be1f70, 0xc3be1f70, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d7993a1, 0xbeefcd88, 0x4d7993a1, 0xb2c68821, 0x43d1f34, 0x43d1f34, 0x1dbc7020, 0x1dbc7020, 0x1dbc7020, 0x62b6d988, 0x62b6d988, 0x62b6d988, 0xfbe7dc0e, 0xfbe7dc0e, 0xfbe7dc0e, 0x43d1f34, 0xb2c68821, 0xb2c68821, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x628b6f61, 0x50f94215, 0x628b6f61, 0x217da226, 0x59c36f00, 0x59c36f00, 0x5755be7f, 0x5755be7f, 0x5755be7f, 0x29d5d319, 0x29d5d319, 0x29d5d319, 0x4b23c6cb, 0x4b23c6cb, 0x4b23c6cb, 0x59c36f00, 0x217da226, 0x217da226, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9f82cd08, 0xbc67f78d, 0x9f82cd08, 0xb1874877, 0xaa4593fe, 0xaa4593fe, 0x4749512e, 0x4749512e, 0x4749512e, 0xe1bc5c49, 0xe1bc5c49, 0xe1bc5c49, 0xcc84f731, 0xcc84f731, 0xcc84f731, 0xaa4593fe, 0xb1874877, 0xb1874877, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xbee47cfb, 0x88e98534, 0xbee47cfb, 0xe3f3117f, 0xc9cbf769, 0xc9cbf769, 0xe2396b15, 0xe2396b15, 0xe2396b15, 0x1ce1aad9, 0x1ce1aad9, 0x1ce1aad9, 0xf5ab15d1, 0xf5ab15d1, 0xf5ab15d1, 0xc9cbf769, 0xe3f3117f, 0xe3f3117f, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2bfd5a83, 0xbe3c6f2f, 0x2bfd5a83, 0x85ab135b, 0x9813a416, 0x9813a416, 0xce30693b, 0xce30693b, 0xce30693b, 0x5febef08, 0x5febef08, 0x5febef08, 0x4651d2d8, 0x4651d2d8, 0x4651d2d8, 0x9813a416, 0x85ab135b, 0x85ab135b, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1456f321, 0xc3a55992, 0x1456f321, 0x62f0c692, 0x5fcf013d, 0x5fcf013d, 0xbe3d534a, 0xbe3d534a, 0xbe3d534a, 0x6c2d4b3c, 0x6c2d4b3c, 0x6c2d4b3c, 0x7a5e74a3, 0x7a5e74a3, 0x7a5e74a3, 0x5fcf013d, 0x62f0c692, 0x62f0c692, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdcac6945, 0x43fbdf5a, 0xdcac6945, 0xc7a9b342, 0xdd28f52b, 0xdd28f52b, 0x274da20b, 0x274da20b, 0x274da20b, 0x6715bef, 0x6715bef, 0x6715bef, 0x7bc99063, 0x7bc99063, 0x7bc99063, 0xdd28f52b, 0xc7a9b342, 0xc7a9b342, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x571e16b1, 0xb9f25c2, 0x571e16b1, 0xa8a10d31, 0x43d1f34, 0x43d1f34, 0x25dfb69d, 0x25dfb69d, 0x25dfb69d, 0x5ad51f35, 0x5ad51f35, 0x5ad51f35, 0xc3841ab3, 0xc3841ab3, 0xc3841ab3, 0x43d1f34, 0xa8a10d31, 0xa8a10d31, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xec987771, 0x8a579bf2, 0xec987771, 0xbbb5c9af, 0x59c36f00, 0x59c36f00, 0x16780f43, 0x16780f43, 0x16780f43, 0x68f86225, 0x68f86225, 0x68f86225, 0xa0e77f7, 0xa0e77f7, 0xa0e77f7, 0x59c36f00, 0xbbb5c9af, 0xbbb5c9af, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x97994d2c, 0x33b3ca94, 0x97994d2c, 0x273e977a, 0xaa4593fe, 0xaa4593fe, 0xa592c9d5, 0xa592c9d5, 0xa592c9d5, 0x367c4b2, 0x367c4b2, 0x367c4b2, 0x2e5f6fca, 0x2e5f6fca, 0x2e5f6fca, 0xaa4593fe, 0x273e977a, 0x273e977a, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5d2416aa, 0xe7a84972, 0x5d2416aa, 0x4d010804, 0xc9cbf769, 0xc9cbf769, 0x4e3a88a0, 0x4e3a88a0, 0x4e3a88a0, 0xb0e2496c, 0xb0e2496c, 0xb0e2496c, 0x59a8f664, 0x59a8f664, 0x59a8f664, 0xc9cbf769, 0x4d010804, 0x4d010804, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1da65b43, 0xae065274, 0x1da65b43, 0x2dd7a76c, 0x9813a416, 0x9813a416, 0xf81d19f, 0xf81d19f, 0xf81d19f, 0x9e5a57ac, 0x9e5a57ac, 0x9e5a57ac, 0x87e06a7c, 0x87e06a7c, 0x87e06a7c, 0x9813a416, 0x2dd7a76c, 0x2dd7a76c, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xea8a940e, 0xfa7c8f6f, 0xea8a940e, 0x448d7bfb, 0x5fcf013d, 0x5fcf013d, 0x47c22fa0, 0x47c22fa0, 0x47c22fa0, 0x95d237d6, 0x95d237d6, 0x95d237d6, 0x83a10849, 0x83a10849, 0x83a10849, 0x5fcf013d, 0x448d7bfb, 0x448d7bfb, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc0ac44fa, 0x94d4e024, 0xc0ac44fa, 0x4ec88f20, 0xdd28f52b, 0xdd28f52b, 0x2422f542, 0x2422f542, 0x2422f542, 0x51e0ca6, 0x51e0ca6, 0x51e0ca6, 0x78a6c72a, 0x78a6c72a, 0x78a6c72a, 0xdd28f52b, 0x4ec88f20, 0x4ec88f20, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x248f7655, 0x8f1ea1e8, 0x248f7655, 0xb3d7f0f5, 0x43d1f34, 0x43d1f34, 0x8c408c04, 0x8c408c04, 0x8c408c04, 0xf34a25ac, 0xf34a25ac, 0xf34a25ac, 0x6a1b202a, 0x6a1b202a, 0x6a1b202a, 0x43d1f34, 0xb3d7f0f5, 0xb3d7f0f5, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd6ba8f78, 0xb07563fb, 0xd6ba8f78, 0x6ef020b2, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0x6ef020b2, 0x6ef020b2, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf5257f70, 0x510ff8c8, 0xf5257f70, 0x36a3b7ff, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0x36a3b7ff, 0x36a3b7ff, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f8effb3, 0x2502a06b, 0x9f8effb3, 0xddeb038e, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0xddeb038e, 0xddeb038e, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6aa72774, 0xd9072e43, 0x6aa72774, 0x24b4853d, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x24b4853d, 0x24b4853d, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x936eb1d8, 0x8398aab9, 0x936eb1d8, 0x8beef, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x8beef, 0x8beef, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd4b9ec3, 0x89333a1d, 0xdd4b9ec3, 0x3acd5a9d, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0x3acd5a9d, 0x3acd5a9d, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x89f37601, 0x2262a1bc, 0x89f37601, 0xf17b28ae, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0xf17b28ae, 0xf17b28ae, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From 5a0c548ba388b343b0bb6d2a38888e7eac5bbb96 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 03:47:13 +0300 Subject: [PATCH 0668/1167] Remove bashisms from tests. Those tests don't actually need bash. Just use common shebang. --- tests/grub_cmd_date.in | 2 +- tests/grub_cmd_regexp.in | 2 +- tests/grub_cmd_set_date.in | 2 +- tests/grub_cmd_sleep.in | 2 +- tests/grub_cmd_test.in | 2 +- tests/grub_cmd_tr.in | 2 +- tests/grub_func_test.in | 2 +- tests/grub_script_blockarg.in | 2 +- tests/grub_script_expansion.in | 2 +- tests/help_test.in | 2 +- tests/test_sha512sum.in | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in index a459353e8..0d8162e98 100644 --- a/tests/grub_cmd_date.in +++ b/tests/grub_cmd_date.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_regexp.in b/tests/grub_cmd_regexp.in index e7e625701..7e9ab86aa 100644 --- a/tests/grub_cmd_regexp.in +++ b/tests/grub_cmd_regexp.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e # Run GRUB script in a Qemu instance diff --git a/tests/grub_cmd_set_date.in b/tests/grub_cmd_set_date.in index c594ae3fc..2f518dd9e 100644 --- a/tests/grub_cmd_set_date.in +++ b/tests/grub_cmd_set_date.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in index eb362aa24..05b8f6b73 100644 --- a/tests/grub_cmd_sleep.in +++ b/tests/grub_cmd_sleep.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in index 6269891c9..49ae8a9c8 100644 --- a/tests/grub_cmd_test.in +++ b/tests/grub_cmd_test.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # create a randome file empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 diff --git a/tests/grub_cmd_tr.in b/tests/grub_cmd_tr.in index 3fb15e35c..0e8d645eb 100644 --- a/tests/grub_cmd_tr.in +++ b/tests/grub_cmd_tr.in @@ -1,4 +1,4 @@ -#! /bin/bash -e +#! /bin/sh -e # Run GRUB script in a Qemu instance # Copyright (C) 2010 Free Software Foundation, Inc. diff --git a/tests/grub_func_test.in b/tests/grub_func_test.in index c8cc26376..b32f24466 100644 --- a/tests/grub_func_test.in +++ b/tests/grub_func_test.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_script_blockarg.in b/tests/grub_script_blockarg.in index 2765b61ac..63b60a2ea 100644 --- a/tests/grub_script_blockarg.in +++ b/tests/grub_script_blockarg.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # Run GRUB script in a Qemu instance # Copyright (C) 2010 Free Software Foundation, Inc. diff --git a/tests/grub_script_expansion.in b/tests/grub_script_expansion.in index e46401c4c..2b7829568 100644 --- a/tests/grub_script_expansion.in +++ b/tests/grub_script_expansion.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e # Run GRUB script in a Qemu instance diff --git a/tests/help_test.in b/tests/help_test.in index e780924ef..aa9645835 100644 --- a/tests/help_test.in +++ b/tests/help_test.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in index d5ef7f9ea..80ebdc59f 100644 --- a/tests/test_sha512sum.in +++ b/tests/test_sha512sum.in @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # create a randome file file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 From 37865c2c4ad26cd5e947b08abf1fde8145699919 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 14:35:59 +0300 Subject: [PATCH 0669/1167] fs-tester: make sh-compatible --- tests/util/grub-fs-tester.in | 306 +++++++++++++++++++---------------- 1 file changed, 169 insertions(+), 137 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 2337771a1..4515d165e 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e @@ -13,8 +13,29 @@ run_it () { LC_ALL=C "$GRUBFSTEST" "$@" } +range() { + range_counter="$1" + while test "$range_counter" -le "$2"; do + echo "$range_counter" + range_counter="$((range_counter + $3))" + done +} + +powrange() { + range_counter="$1" + while test "$range_counter" -le "$2"; do + echo "$range_counter" + range_counter="$((range_counter * 2))" + done +} + run_grubfstest () { - run_it -c $NEED_IMAGES_N "${NEED_IMAGES[@]}" "$@" + need_images= + for i in $(range 0 $((NEED_IMAGES_N-1)) 1); do + need_images="$need_images $FSIMAGEP${i}.img"; + done + + run_it -c $NEED_IMAGES_N $need_images "$@" } # OS LIMITATION: GNU/Linux has no AFS support, so we use a premade image and a reference tar file. I.a. no multiblocksize test @@ -51,7 +72,7 @@ case x"$fs" in # OS limitation: zfs-fuse always uses ashift=9 with loop devices MAXLOGSECSIZE=9;; esac -for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + 1)); do +for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do SECSIZE="$((1 << LOGSECSIZE))" MINBLKSIZE=512 MAXBLKSIZE=512 @@ -169,7 +190,12 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MINBLKSIZE=1024 MAXBLKSIZE=4096;; esac - for ((BLKSIZE=MINBLKSIZE;BLKSIZE<=MAXBLKSIZE;BLKSIZE=BLKSTEP?BLKSIZE+BLKSTEP:2*BLKSIZE)); do + if test "$BLKSTEP" -eq 0; then + blksizes="$(powrange "$MINBLKSIZE" "$MAXBLKSIZE")" + else + blksizes="$(range "$MINBLKSIZE" "$MAXBLKSIZE" "$BLKSTEP")" + fi + for BLKSIZE in $blksizes; do MAXDEVICES=1 MINDEVICES=1 export fs @@ -199,13 +225,11 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MAXDEVICES=7;; esac - for ((NDEVICES=MINDEVICES; NDEVICES <= MAXDEVICES; NDEVICES++)); do + for NDEVICES in $(range "$MINDEVICES" "$MAXDEVICES" 1); do export NDEVICES - unset FSIMAGES - for ((i=0; i < NDEVICES; i++)); do - FSIMAGES[i]="${tempdir}/${fs}_${SECSIZE}_${BLKSIZE}_${NDEVICES}_$i.img" - done - export FSIMAGES + unset FSIMAGEP + FSIMAGEP="${tempdir}/${fs}_${SECSIZE}_${BLKSIZE}_${NDEVICES}_" + export FSIMAGEP unset NEED_IMAGES; case x$fs in @@ -226,11 +250,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + *) NEED_IMAGES_N=$NDEVICES;; esac - for ((i=0;i < NEED_IMAGES_N; i++)); do - NEED_IMAGES[i]="${FSIMAGES[i]}"; - done export NEED_IMAGES_N - export NEED_IMAGES MNTPOINTRO="${tempdir}/${fs}_ro" MNTPOINTRW="${tempdir}/${fs}_rw" @@ -238,20 +258,25 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MOUNTFS="$fs" MASTER="${tempdir}/master" FSLABEL="grub_;/testé莭ð¯¦ð¯¦™ðŸ˜ÐºÐ¸Ñ€Ð¸Ñ‚i urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewrewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfew" - CFILESN=1 - if test -f /usr/share/dict/american-english; then - CFILESSRC[0]="/usr/share/dict/american-english" - else - CFILESSRC[0]="/usr/share/dict/linux.words" + CFILESRC= + for cand in /usr/share/dict/american-english /usr/share/dict/linux.words; do + if test -f "$cand" ; then + CFILESRC="$cand" + break + fi + done + if test "$CFILESRC" = "" ; then + echo "Couldn't find compressible file" >&2 + exit 1 fi case x"$fs" in # FS LIMITATION: 8.3 names xmsdos*) - CFILES[0]="american.eng";; + CFILE="american.eng";; xiso9660) - CFILES[0]="american_english";; + CFILE="american_english";; *) - CFILES[0]="american-english";; + CFILE="american-english";; esac # OS LIMITATION: Limited by NAME_MAX (usually 255) in GNU/Linux LONGNAME="qwertzuiopasdfghjklyxcvbnm1234567890qwertzuiopasdfghjklyxcvbnm1234567890oiewqfiewioqoiqoiurqruewqoiuwoieoiiuewqroreqiufieiuwrnureweriuvceoiroiewqoiricdsalkcndsakfirefoiwqeoircorejwoijfreoijojoiewjfwnfcoirenfoirefnreoifenoiwfnoi" @@ -388,8 +413,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + ;; x"vfat16" | xmsdos16) BIGBLOCKCNT=$((25000 * BLKSIZE)) - if [ $BIGBLOCKCNT -gt $((16#ffffffff)) ]; then - BIGBLOCKCNT=$((16#ffffffff)) + if [ $BIGBLOCKCNT -gt 4294967295 ]; then + BIGBLOCKCNT=4294967295 fi ;; x"minix") @@ -410,7 +435,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + BIGBLOCKCNT=$((4000 * 1048576));; # FS LIMITATION: These FS have uint32 as file size field x"vfat"* | xmsdos* | x"cpio_crc" | x"cpio_newc" | x"cpio_bin" | x"cpio_hpbin" | xsfs*) - BIGBLOCKCNT=$((16#ffffffff));; + BIGBLOCKCNT=4294967295;; # FS LIMITATION: These FS have int32 as file size field # FIXME: not so sure about AFFS # OS LIMITATION: minix2/minix3 could be formatted in a way to permit more. @@ -543,18 +568,18 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + PDIR="" # OS LIMITATION: Limited by PATH_MAX (usually 1024) - for ((i=0;i /dev/null - LODEVICES[i]=`losetup -f` - losetup "${LODEVICES[i]}" "${FSIMAGES[i]}" + for i in $(range 0 $((NDEVICES-1)) 1); do + dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 seek=$((DISKSIZE-1)) &> /dev/null + LODEVICE="$(losetup -f)" + LODEVICES="$LODEVICES $LODEVICE" + losetup "$LODEVICE" "$FSIMAGEP${i}.img" + if test "$i" = 0; then + MOUNTDEVICE="$LODEVICE" + fi done ;; esac - MOUNTDEVICE="${LODEVICES[0]}" case x"$fs" in x"afs") ;; x"btrfs") - "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${LODEVICES[0]}" ;; + "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" ;; x"btrfs_zlib" | x"btrfs_lzo") - "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${LODEVICES[0]}" + "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" MOUNTOPTS="compress=${fs/btrfs_/}," MOUNTFS="btrfs" ;; x"btrfs_raid0") - "mkfs.btrfs" -s $SECSIZE -d raid0 -m raid0 -L "$FSLABEL" "${LODEVICES[@]}" + "mkfs.btrfs" -s $SECSIZE -d raid0 -m raid0 -L "$FSLABEL" $LODEVICES MOUNTFS="btrfs" ;; x"btrfs_raid1") - "mkfs.btrfs" -s $SECSIZE -d raid1 -m raid1 -L "$FSLABEL" "${LODEVICES[@]}" + "mkfs.btrfs" -s $SECSIZE -d raid1 -m raid1 -L "$FSLABEL" $LODEVICES MOUNTFS="btrfs" ;; x"btrfs_raid10") - "mkfs.btrfs" -s $SECSIZE -d raid10 -m raid10 -L "$FSLABEL" "${LODEVICES[@]}" + "mkfs.btrfs" -s $SECSIZE -d raid10 -m raid10 -L "$FSLABEL" $LODEVICES MOUNTFS="btrfs" ;; x"btrfs_single") - "mkfs.btrfs" -s $SECSIZE -d single -L "$FSLABEL" "${LODEVICES[@]}" + "mkfs.btrfs" -s $SECSIZE -d single -L "$FSLABEL" $LODEVICES MOUNTFS="btrfs" ;; x"exfat") - "mkfs.$fs" -s $((BLKSIZE/512)) -n "$FSLABEL" "${LODEVICES[0]}" + "mkfs.$fs" -s $((BLKSIZE/512)) -n "$FSLABEL" "${MOUNTDEVICE}" MOUNTOPTS="iocharset=utf8," MOUNTFS="exfat-fuse";; x"minix") - "mkfs.minix" "${LODEVICES[0]}" + "mkfs.minix" "${MOUNTDEVICE}" ;; # mkfs.hfs and mkfs.hfsplus don't fill UUID. x"hfsplus") - "mkfs.hfsplus" -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" - dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 ;; + "mkfs.hfsplus" -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" + dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 ;; x"hfsplus_wrap") - "mkfs.hfsplus" -w -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" - dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 + "mkfs.hfsplus" -w -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" + dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 MOUNTFS="hfsplus";; x"hfsplus_casesens") - "mkfs.hfsplus" -s -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" - dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 + "mkfs.hfsplus" -s -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" + dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 MOUNTFS="hfsplus";; x"hfs") - "mkfs.hfs" -b $BLKSIZE -v "`echo $FSLABEL |recode utf8..macroman`" -h "${LODEVICES[0]}" - dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#474)) conv=notrunc count=8 + "mkfs.hfs" -b $BLKSIZE -v "`echo $FSLABEL |recode utf8..macroman`" -h "${MOUNTDEVICE}" + dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#474)) conv=notrunc count=8 MOUNTOPTS="iocharset=utf8,codepage=macroman," ;; x"vfat"*|xmsdos*) @@ -643,98 +673,98 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else A= fi - "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${FSIMAGES[0]}" + "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${MOUNTDEVICE}" MOUNTOPTS="iocharset=utf8,codepage=437," MOUNTFS="$(echo "$fs"|sed 's,[0-9]*a\?$,,')";; x"minix2") - "mkfs.minix" -v "${LODEVICES[0]}" + "mkfs.minix" -v "${MOUNTDEVICE}" MOUNTFS="minix";; x"minix3") - "mkfs.minix" -B $BLKSIZE -3 "${LODEVICES[0]}" + "mkfs.minix" -B $BLKSIZE -3 "${MOUNTDEVICE}" MOUNTFS="minix";; x"ntfs"*) - "mkfs.ntfs" -s "$SECSIZE" -c "$BLKSIZE" -L "$FSLABEL" -Q -q "${LODEVICES[0]}" + "mkfs.ntfs" -s "$SECSIZE" -c "$BLKSIZE" -L "$FSLABEL" -Q -q "${MOUNTDEVICE}" MOUNTOPTS="iocharset=utf8,compression," MOUNTFS="ntfs-3g";; x"udf") - "mkudffs" --utf8 -b $BLKSIZE --lvid="$FSLABEL" "${LODEVICES[0]}" + "mkudffs" --utf8 -b $BLKSIZE --lvid="$FSLABEL" "${MOUNTDEVICE}" MOUNTOPTS="iocharset=utf8,bs=$BLKSIZE,";; x"ufs2") - "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 2 "${LODEVICES[0]}" + "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 2 "${MOUNTDEVICE}" MOUNTOPTS="ufstype=ufs2," MOUNTFS="ufs";; x"ufs1") - "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${LODEVICES[0]}" + "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${MOUNTDEVICE}" MOUNTOPTS="ufstype=44bsd," MOUNTFS="ufs";; x"ufs1_sun") - "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${LODEVICES[0]}" + "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${MOUNTDEVICE}" MOUNTOPTS="ufstype=sun," MOUNTFS="ufs";; x"zfs") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"zfs_caseins") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" sleep 1 "zfs" create -o casesensitivity=insensitive "$FSLABEL"/"grub fs" sleep 1;; x"zfs_lzjb" | xzfs_gzip | xzfs_zle) - "zpool" create -O compression=${fs/zfs_/} -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" + "zpool" create -O compression=${fs/zfs_/} -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" sleep 1 "zfs" create -o compression=${fs/zfs_/} "$FSLABEL"/"grub fs" sleep 1;; x"zfs_raidz") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz1 "${LODEVICES[@]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz1 $LODEVICES sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"zfs_raidz2") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz2 "${LODEVICES[@]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz2 $LODEVICES sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"zfs_raidz3") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz3 "${LODEVICES[@]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz3 $LODEVICES sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"zfs_mirror") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" mirror "${LODEVICES[@]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" mirror $LODEVICES sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"zfs_stripe") - "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[@]}" + "zpool" create -R "$MNTPOINTRW" "$FSLABEL" $LODEVICES sleep 1 "zfs" create "$FSLABEL"/"grub fs" sleep 1;; x"tarfs" | x"cpio_"* | x"iso9660" | xjoliet | xrockridge | xrockridge_joliet | x"iso9660_1999" | xjoliet_1999 | xrockridge_1999 | xrockridge_joliet_1999 | x"ziso9660" | x"romfs" | x"squash4_"*) INSTDEVICE=/dev/null;; x"reiserfs") - "mkfs.reiserfs" --format=3.6 -b $BLKSIZE -l "$FSLABEL" -q "${LODEVICES[0]}" ;; + "mkfs.reiserfs" --format=3.6 -b $BLKSIZE -l "$FSLABEL" -q "${MOUNTDEVICE}" ;; x"reiserfs_old") - "mkfs.reiserfs" --format=3.5 -b $BLKSIZE -l "$FSLABEL" -q "${LODEVICES[0]}" + "mkfs.reiserfs" --format=3.5 -b $BLKSIZE -l "$FSLABEL" -q "${MOUNTDEVICE}" MOUNTFS=reiserfs;; x"jfs") - "mkfs.jfs" -L "$FSLABEL" -q "${LODEVICES[0]}" + "mkfs.jfs" -L "$FSLABEL" -q "${MOUNTDEVICE}" MOUNTOPTS="iocharset=utf8,";; x"jfs_caseins") - "mkfs.jfs" -O -L "$FSLABEL" -q "${LODEVICES[0]}" + "mkfs.jfs" -O -L "$FSLABEL" -q "${MOUNTDEVICE}" MOUNTFS=jfs MOUNTOPTS="iocharset=utf8,";; x"mdraid"*) - mdadm -C --chunk=$((BLKSIZE/1024)) --force -e "${fs:6:1}.${fs:7:1}" "/dev/md/${fs}_${NDEVICES}" --level="${fs:13}" --raid-devices="$NDEVICES" "${LODEVICES[@]}" + mdadm -C --chunk=$((BLKSIZE/1024)) --force -e "${fs:6:1}.${fs:7:1}" "/dev/md/${fs}_${NDEVICES}" --level="${fs:13}" --raid-devices="$NDEVICES" $LODEVICES MOUNTDEVICE="/dev/md/${fs}_${NDEVICES}" MOUNTFS=ext2 "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}" ;; x"lvm"*) - for ((i=0;i /dev/null; + cp "${CFILESRC}" "$MNTPOINTRW/$OSDIR/${CFILE}" &> /dev/null; else - for ((i=0;i<$CFILESN;i++)); do - cp "${CFILESSRC[i]}" "$MNTPOINTRW/$OSDIR/${CFILES[i]}"; - done + + cp "${CFILESRC}" "$MNTPOINTRW/$OSDIR/${CFILE}"; + fi if [ x$NOSYMLINK != xy ]; then @@ -968,48 +1000,48 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + sleep 2 ;; x"tarfs") - (cd "$MASTER"; tar cf "${FSIMAGES[0]}" .) ;; + (cd "$MASTER"; tar cf "${FSIMAGEP}0.img" .) ;; x"cpio_"*) - (cd "$MASTER"; find . | cpio -o -H "${fs/cpio_/}" > "${FSIMAGES[0]}" ) ;; + (cd "$MASTER"; find . | cpio -o -H "$(echo ${fs} | sed 's@^cpio_@@')" > "${FSIMAGEP}0.img" ) ;; x"ziso9660") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;; + xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;; x"iso9660") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"joliet") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"rockridge") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"rockridge_joliet") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"iso9660_1999") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"joliet_1999") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"rockridge_1999") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"rockridge_joliet_1999") FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); - xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; + xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; x"romfs") - genromfs -V "$FSLABEL" -f "${FSIMAGES[0]}" -d "$MASTER" ;; + genromfs -V "$FSLABEL" -f "${FSIMAGEP}0.img" -d "$MASTER" ;; xsquash4_*) - echo mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE - mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE ;; + echo mksquashfs "$MASTER" "${FSIMAGEP}0.img" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE + mksquashfs "$MASTER" "${FSIMAGEP}0.img" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE ;; x"bfs") sleep 1 fusermount -u "$MNTPOINTRW" ;; xlvm*) sleep 1 - for ((try=0;try < 20; try++)); do + for try in $(range 0 20 1); do if umount "$MNTPOINTRW" ; then break; fi @@ -1021,7 +1053,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + ;; xmdraid*) sleep 1 - for ((try=0;try < 20; try++)); do + for try in $(range 0 20 1); do if umount "$MNTPOINTRW" ; then break; fi @@ -1033,7 +1065,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + ;; *) sleep 1 - for ((try=0;try < 20; try++)); do + for try in $(range 0 20 1); do if umount "$MNTPOINTRW" ; then break; fi @@ -1066,7 +1098,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + sleep 1 mount -t "$MOUNTFS" "${MOUNTDEVICE}" "$MNTPOINTRO" -o ${MOUNTOPTS}${SELINUXOPTS}ro ;; xmdraid*) - mdadm --assemble /dev/md/"${fs}_$NDEVICES" "${LODEVICES[@]}" + mdadm --assemble /dev/md/"${fs}_$NDEVICES" $LODEVICES sleep 1 mount -t "$MOUNTFS" "${MOUNTDEVICE}" "$MNTPOINTRO" -o ${MOUNTOPTS}${SELINUXOPTS}ro ;; *) @@ -1085,7 +1117,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo LIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi @@ -1094,7 +1126,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo NLIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -lA "$MNTPOINTRO" + TZ=UTC ls -lA "$MNTPOINTRO" exit 1 fi @@ -1103,7 +1135,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo ILIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi @@ -1112,7 +1144,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo LONG LIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi @@ -1123,7 +1155,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo TIME FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi @@ -1133,7 +1165,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo LONG TIME FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi fi @@ -1149,7 +1181,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo DOT IN ROOTDIR FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi @@ -1163,7 +1195,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo DOTDOT IN ROOTDIR FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + TZ=UTC ls -l "$MNTPOINTRO" exit 1 fi ;; @@ -1180,7 +1212,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo SLIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/sdir" + TZ=UTC ls -l "$MNTPOINTRO/sdir" exit 1 fi @@ -1195,7 +1227,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo PLIST FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$PDIR" + TZ=UTC ls -l "$MNTPOINTRO/$PDIR" exit 1 fi @@ -1210,7 +1242,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo DOT IN SUBDIR FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/sdir" + TZ=UTC ls -l "$MNTPOINTRO/$OSDIR/sdir" exit 1 fi @@ -1225,7 +1257,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + else echo DOTDOT IN SUBDIR FAIL echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/ssdir" + TZ=UTC ls -l "$MNTPOINTRO/$OSDIR/ssdir" exit 1 fi @@ -1245,8 +1277,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x"$fs" in x"iso9660" | x"ziso9660" | xrockridge | xjoliet | xrockridge_joliet | x"iso9660_1999" | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) ;; x"zfs"*) - for ((i=0;i Date: Mon, 23 Jan 2017 14:31:36 +0300 Subject: [PATCH 0670/1167] support busybox date. Busybox date doesn't understand weekdays in -d input, so strip them beforehand. --- tests/grub_cmd_date.in | 2 +- tests/grub_cmd_sleep.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in index 0d8162e98..60f039ebc 100644 --- a/tests/grub_cmd_date.in +++ b/tests/grub_cmd_date.in @@ -9,7 +9,7 @@ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; fi pdt="$(date -u +%s)" -dt=`echo date | @builddir@/grub-shell` +dt=`echo date | @builddir@/grub-shell | sed 's, [A-Z][a-z]*$,,'` dtg="$(date -u -d "$dt" +%s)" ndt="$(date -u +%s)" diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in index 05b8f6b73..ac51d4209 100644 --- a/tests/grub_cmd_sleep.in +++ b/tests/grub_cmd_sleep.in @@ -11,8 +11,8 @@ fi # Compare RTC with interval timer. # Not 100% proper but should check that timer is running ok dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell` -dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)" -dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)" +dt1="$(date -u -d "$(echo "$dt" | head -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)" +dt2="$(date -u -d "$(echo "$dt" | tail -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)" # Ignore QEMU bug if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then From 6dec3a26b37e128ded5d912e08abc5cee1592499 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 21:24:05 +0300 Subject: [PATCH 0671/1167] Don't retrieve fstime when it's not useful. --- tests/util/grub-fs-tester.in | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 4515d165e..bf47305f3 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1328,31 +1328,31 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do ;; esac - case x$fs in - xiso9660 | xziso9660 | xrockridge | xjoliet | xrockridge_joliet | xiso9660_1999 | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) - FSTIME="$(date -d "$(echo ${FSUUID} | awk -F - '{ print $1"-"$2"-"$3" "$4":"$5":"$6 ;}')" '+%Y-%m-%d %H:%M:%S')";; - xlvm*|xmdraid*) - # With some abstractions like mdraid flushing to disk - # may be delayed for a long time. - FSTIME="$UMOUNT_TIME";; - *) - FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGEP}0.img"|awk '{print $6; }'|sed 's,_, ,g')";; - esac - # With some abstractions like mdraid computing of UMOUNT_TIME - # is not precise. Account for small difference here. - FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")" - FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")" - FSTIMEM3="$(date -d "$FSTIME UTC -3 second" -u "+%Y-%m-%d %H:%M:%S")" + if [ x$NOFSTIME != xy ]; then + case x$fs in + xiso9660 | xziso9660 | xrockridge | xjoliet | xrockridge_joliet | xiso9660_1999 | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) + FSTIME="$(date -d "$(echo ${FSUUID} | awk -F - '{ print $1"-"$2"-"$3" "$4":"$5":"$6 ;}')" '+%Y-%m-%d %H:%M:%S')";; + xlvm*|xmdraid*) + # With some abstractions like mdraid flushing to disk + # may be delayed for a long time. + FSTIME="$UMOUNT_TIME";; + *) + FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGEP}0.img"|awk '{print $6; }'|sed 's,_, ,g')";; + esac + # With some abstractions like mdraid computing of UMOUNT_TIME + # is not precise. Account for small difference here. + FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")" + FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")" + FSTIMEM3="$(date -d "$FSTIME UTC -3 second" -u "+%Y-%m-%d %H:%M:%S")" - if [ x$NOFSTIME = xy ]; then - : - elif echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then - : - else - echo FSTIME FAIL - echo "$FSTIME" - echo "$LSOUT" - exit 1 + if echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then + : + else + echo FSTIME FAIL + echo "$FSTIME" + echo "$LSOUT" + exit 1 + fi fi if [ x$NOHARDLINK != xy ]; then From 608bec51128008afb81c9e3f297283e9f830a146 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 20:21:05 +0300 Subject: [PATCH 0672/1167] Support lseek64. Android doesn't have 64-bit off_t, so use off64_t instead. --- configure.ac | 5 ++++- grub-core/osdep/unix/hostdisk.c | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d10d8adac..e0262e159 100644 --- a/configure.ac +++ b/configure.ac @@ -373,7 +373,10 @@ case "$host_os" in ;; *) AC_CHECK_SIZEOF(off_t) - test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);; + if test x"$ac_cv_sizeof_off_t" != x8 ; then + AC_CHECK_SIZEOF(off64_t) + test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required]) + fi;; esac if test x$USE_NLS = xno; then diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index 2a8c5882e..5450cf416 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -77,11 +77,19 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz int grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) { +#if SIZEOF_OFF_T == 8 off_t offset = (off_t) off; if (lseek (fd, offset, SEEK_SET) != offset) return -1; +#elif SIZEOF_OFF64_T == 8 + off64_t offset = (off64_t) off; + if (lseek64 (fd, offset, SEEK_SET) != offset) + return -1; +#else +#error "No large file support" +#endif return 0; } From c2ea443446b7feea868e54f94a87781f69820375 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 00:55:30 +0300 Subject: [PATCH 0673/1167] Use $(SHELL) rather than /bin/sh. /bin/sh doesn't exist under termux. --- grub-core/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 04e9395fd..809a8aa26 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -278,7 +278,7 @@ BUILT_SOURCES += symlist.h symlist.c: symlist.h gensymlist.sh $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1) - cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1) + cat symlist.p | $(SHELL) $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1) rm -f symlist.p CLEANFILES += symlist.c BUILT_SOURCES += symlist.c From 4341f82af0b61d3dfbe675670d4105dc759c0df3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 14:54:03 +0300 Subject: [PATCH 0674/1167] po: Use @SHELL@ rather than /bin/sh. /bin/sh might not exist. --- po/Makefile.in.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/Makefile.in.in b/po/Makefile.in.in index 3619458e8..e68e9da84 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -15,7 +15,7 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -SHELL = /bin/sh +SHELL = @SHELL@ @SET_MAKE@ srcdir = @srcdir@ From 1073ddb12078f3c8edbdb74bb8f5afc674983f40 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Jan 2017 14:52:48 +0300 Subject: [PATCH 0675/1167] Add termux path to dict. --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index bf47305f3..468d9e785 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -259,7 +259,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do MASTER="${tempdir}/master" FSLABEL="grub_;/testé莭ð¯¦ð¯¦™ðŸ˜ÐºÐ¸Ñ€Ð¸Ñ‚i urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewrewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfew" CFILESRC= - for cand in /usr/share/dict/american-english /usr/share/dict/linux.words; do + for cand in /usr/share/dict/american-english /usr/share/dict/linux.words /data/data/com.termux/files/usr/share/hunspell/en_US.dic; do if test -f "$cand" ; then CFILESRC="$cand" break From a827807a1330d5ad619faa103bc7f12d89fc8bee Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Jan 2017 20:22:34 +0300 Subject: [PATCH 0676/1167] Fix shebang for termux. Termux doesn't have a /bin/sh. So we needto use $SHELL. Keep /bin/sh as much as possible. --- configure.ac | 10 ++++++++++ grub-core/genmod.sh.in | 2 +- grub-core/gensyminfo.sh.in | 2 +- grub-core/modinfo.sh.in | 2 +- tests/ahci_test.in | 2 +- tests/btrfs_test.in | 2 +- tests/cdboot_test.in | 2 +- tests/core_compress_test.in | 2 +- tests/cpio_test.in | 2 +- tests/ehci_test.in | 2 +- tests/example_scripted_test.in | 2 +- tests/exfat_test.in | 2 +- tests/ext234_test.in | 2 +- tests/fat_test.in | 2 +- tests/fddboot_test.in | 2 +- tests/file_filter_test.in | 2 +- tests/gettext_strings_test.in | 2 +- tests/grub_cmd_date.in | 2 +- tests/grub_cmd_regexp.in | 2 +- tests/grub_cmd_set_date.in | 2 +- tests/grub_cmd_sleep.in | 2 +- tests/grub_cmd_test.in | 2 +- tests/grub_cmd_tr.in | 2 +- tests/grub_func_test.in | 2 +- tests/grub_script_blanklines.in | 2 +- tests/grub_script_blockarg.in | 2 +- tests/grub_script_dollar.in | 2 +- tests/grub_script_expansion.in | 2 +- tests/grub_script_final_semicolon.in | 2 +- tests/grub_script_no_commands.in | 2 +- tests/gzcompress_test.in | 2 +- tests/hddboot_test.in | 2 +- tests/help_test.in | 2 +- tests/hfs_test.in | 2 +- tests/hfsplus_test.in | 2 +- tests/iso9660_test.in | 2 +- tests/jfs_test.in | 2 +- tests/lzocompress_test.in | 2 +- tests/minixfs_test.in | 2 +- tests/netboot_test.in | 2 +- tests/nilfs2_test.in | 2 +- tests/ntfs_test.in | 2 +- tests/ohci_test.in | 2 +- tests/partmap_test.in | 2 +- tests/pata_test.in | 2 +- tests/pseries_test.in | 2 +- tests/reiserfs_test.in | 2 +- tests/romfs_test.in | 2 +- tests/squashfs_test.in | 2 +- tests/syslinux_test.in | 2 +- tests/tar_test.in | 2 +- tests/test_sha512sum.in | 2 +- tests/udf_test.in | 2 +- tests/uhci_test.in | 2 +- tests/util/grub-fs-tester.in | 2 +- tests/util/grub-shell-tester.in | 2 +- tests/util/grub-shell.in | 2 +- tests/xfs_test.in | 2 +- tests/xzcompress_test.in | 2 +- tests/zfs_test.in | 2 +- 60 files changed, 69 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index e0262e159..ee2c86537 100644 --- a/configure.ac +++ b/configure.ac @@ -459,6 +459,16 @@ case "$build_os" in esac AC_SUBST(BUILD_EXEEXT) +# In some build environments like termux /bin/sh is not a valid +# shebang. Use $SHELL instead if it's executable and /bin/sh isn't +BUILD_SHEBANG=/bin/sh +for she in /bin/sh "$SHELL"; do + if test -x "$she" ; then + BUILD_SHEBANG="$she" + fi +done +AC_SUBST(BUILD_SHEBANG) + # For gnulib. gl_INIT diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 03cc3b7f6..3de06ee01 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e # Copyright (C) 2010 Free Software Foundation, Inc. diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in index 2e8716b42..9bc767532 100644 --- a/grub-core/gensyminfo.sh.in +++ b/grub-core/gensyminfo.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e # Copyright (C) 2010 Free Software Foundation, Inc. diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in index faf0ad30e..f6cd657ce 100644 --- a/grub-core/modinfo.sh.in +++ b/grub-core/modinfo.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ # User-controllable options grub_modinfo_target_cpu=@target_cpu@ diff --git a/tests/ahci_test.in b/tests/ahci_test.in index 1d01d1f59..7df560462 100644 --- a/tests/ahci_test.in +++ b/tests/ahci_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2013 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/btrfs_test.in b/tests/btrfs_test.in index c55d9477f..2b37ddd33 100644 --- a/tests/btrfs_test.in +++ b/tests/btrfs_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e diff --git a/tests/cdboot_test.in b/tests/cdboot_test.in index 1cc901977..75acdfedb 100644 --- a/tests/cdboot_test.in +++ b/tests/cdboot_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2013 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/core_compress_test.in b/tests/core_compress_test.in index 1003587cc..9d216ebcf 100644 --- a/tests/core_compress_test.in +++ b/tests/core_compress_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2013 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/cpio_test.in b/tests/cpio_test.in index 0b09db549..5742cf17b 100644 --- a/tests/cpio_test.in +++ b/tests/cpio_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e diff --git a/tests/ehci_test.in b/tests/ehci_test.in index 7dd8d3e8f..b197f8cdc 100644 --- a/tests/ehci_test.in +++ b/tests/ehci_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2013 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/example_scripted_test.in b/tests/example_scripted_test.in index 09633e893..783b7f138 100644 --- a/tests/example_scripted_test.in +++ b/tests/example_scripted_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e true diff --git a/tests/exfat_test.in b/tests/exfat_test.in index fc1a0fe5e..cd3cd4cb2 100644 --- a/tests/exfat_test.in +++ b/tests/exfat_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e diff --git a/tests/ext234_test.in b/tests/ext234_test.in index c986960a8..892b99cbd 100644 --- a/tests/ext234_test.in +++ b/tests/ext234_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e diff --git a/tests/fat_test.in b/tests/fat_test.in index 1d132b517..b6b4748ca 100644 --- a/tests/fat_test.in +++ b/tests/fat_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ set -e diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in index a59645b7f..2d7dfc889 100644 --- a/tests/fddboot_test.in +++ b/tests/fddboot_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2013 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/file_filter_test.in b/tests/file_filter_test.in index 8909e4021..bfb638227 100644 --- a/tests/file_filter_test.in +++ b/tests/file_filter_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # Copyright (C) 2014 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/tests/gettext_strings_test.in b/tests/gettext_strings_test.in index 5c305e75b..813999ebe 100644 --- a/tests/gettext_strings_test.in +++ b/tests/gettext_strings_test.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@BUILD_SHEBANG@ cd '@srcdir@' diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in index 60f039ebc..f7c9ca004 100644 --- a/tests/grub_cmd_date.in +++ b/tests/grub_cmd_date.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_regexp.in b/tests/grub_cmd_regexp.in index 7e9ab86aa..6520bd6d7 100644 --- a/tests/grub_cmd_regexp.in +++ b/tests/grub_cmd_regexp.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e # Run GRUB script in a Qemu instance diff --git a/tests/grub_cmd_set_date.in b/tests/grub_cmd_set_date.in index 2f518dd9e..aac120a6c 100644 --- a/tests/grub_cmd_set_date.in +++ b/tests/grub_cmd_set_date.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in index ac51d4209..8797f6632 100644 --- a/tests/grub_cmd_sleep.in +++ b/tests/grub_cmd_sleep.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in index 49ae8a9c8..3399eb292 100644 --- a/tests/grub_cmd_test.in +++ b/tests/grub_cmd_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ # create a randome file empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 diff --git a/tests/grub_cmd_tr.in b/tests/grub_cmd_tr.in index 0e8d645eb..bed469c03 100644 --- a/tests/grub_cmd_tr.in +++ b/tests/grub_cmd_tr.in @@ -1,4 +1,4 @@ -#! /bin/sh -e +#! @BUILD_SHEBANG@ -e # Run GRUB script in a Qemu instance # Copyright (C) 2010 Free Software Foundation, Inc. diff --git a/tests/grub_func_test.in b/tests/grub_func_test.in index b32f24466..c67f9e422 100644 --- a/tests/grub_func_test.in +++ b/tests/grub_func_test.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e . "@builddir@/grub-core/modinfo.sh" diff --git a/tests/grub_script_blanklines.in b/tests/grub_script_blanklines.in index 89ed763d3..bd8735491 100644 --- a/tests/grub_script_blanklines.in +++ b/tests/grub_script_blanklines.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @BUILD_SHEBANG@ set -e @builddir@/grub-script-check < Date: Wed, 3 May 2017 12:58:15 +0200 Subject: [PATCH 0677/1167] Add strtoull test. --- grub-core/Makefile.core.def | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2dfa22a92..8dcd0e5a9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1961,6 +1961,11 @@ module = { common = tests/example_functional_test.c; }; +module = { + name = strtoull_test; + common = tests/strtoull_test.c; +}; + module = { name = setjmp_test; common = tests/setjmp_test.c; From dc6e1b5af83eb1c4290baf97c2d221c0865127be Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 10 Aug 2016 17:49:42 +0200 Subject: [PATCH 0678/1167] strtoull: Fix behaviour on chars between '9' and 'a'. Reported by: Aaron Miller --- grub-core/kern/misc.c | 13 +++++++------ grub-core/tests/lib/functional_test.c | 13 +++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index d1a54df6c..3b633d51f 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -391,12 +391,13 @@ grub_strtoull (const char *str, char **end, int base) unsigned long digit; digit = grub_tolower (*str) - '0'; - if (digit > 9) - { - digit += '0' - 'a' + 10; - if (digit >= (unsigned long) base) - break; - } + if (digit >= 'a' - '0') + digit += '0' - 'a' + 10; + else if (digit > 9) + break; + + if (digit >= (unsigned long) base) + break; found = 1; diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index d4822a124..96781fb39 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -26,14 +26,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_err_t grub_functional_test (grub_extcmd_context_t ctxt __attribute__ ((unused)), - int argc __attribute__ ((unused)), - char **args __attribute__ ((unused))) + int argc, + char **args) { grub_test_t test; int ok = 1; + int i; FOR_LIST_ELEMENTS (test, grub_test_list) { + if (argc != 0) + { + for (i = 0; i < argc; i++) + if (grub_strcmp(args[i], test->name) == 0) + break; + if (i == argc) + continue; + } grub_errno = 0; ok = ok && !grub_test_run (test); grub_errno = 0; From d9f7de0ae3c0c09cff7257c55418450261f3e082 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Mon, 23 Dec 2013 12:32:02 -0200 Subject: [PATCH 0679/1167] Add Virtual LAN support. This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows multiple VLANs in a bridged network to share the same physical network link but maintain isolation: http://en.wikipedia.org/wiki/IEEE_802.1Q * grub-core/net/ethernet.c: Add check, get, and set vlan tag id. * grub-core/net/drivers/ieee1275/ofnet.c: Get vlan tag id from bootargs. * grub-core/net/arp.c: Add check. * grub-core/net/ip.c: Likewise. * include/grub/net/arp.h: Add vlantag attribute. * include/grub/net/ip.h: Likewise. --- grub-core/net/arp.c | 12 +++++-- grub-core/net/drivers/ieee1275/ofnet.c | 9 ++++- grub-core/net/ethernet.c | 47 +++++++++++++++++++++++--- grub-core/net/ip.c | 33 +++++++++++++----- include/grub/net.h | 3 ++ include/grub/net/arp.h | 5 +-- include/grub/net/ip.h | 3 +- 7 files changed, 92 insertions(+), 20 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 4b68c4151..54306e3b1 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -111,8 +111,8 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, } grub_err_t -grub_net_arp_receive (struct grub_net_buff *nb, - struct grub_net_card *card) +grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, + grub_uint16_t *vlantag) { struct arppkt *arp_packet = (struct arppkt *) nb->data; grub_net_network_level_address_t sender_addr, target_addr; @@ -138,6 +138,14 @@ grub_net_arp_receive (struct grub_net_buff *nb, FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { + /* Verify vlantag id */ + if (inf->card == card && inf->vlantag != *vlantag) + { + grub_dprintf ("net", "invalid vlantag! %x != %x\n", + inf->vlantag, *vlantag); + break; + } + /* Am I the protocol address target? */ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index a78d164db..002446be1 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -153,11 +153,11 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, char *comma_char = 0; char *equal_char = 0; grub_size_t field_counter = 0; - grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; grub_net_link_level_address_t hw_addr; grub_net_interface_flags_t flags = 0; struct grub_net_network_level_interface *inter = NULL; + grub_uint16_t vlantag = 0; hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -175,6 +175,11 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, *equal_char = 0; grub_env_set_net_property ((*card)->name, args, equal_char + 1, grub_strlen(equal_char + 1)); + + if ((grub_strcmp (args, "vtag") == 0) && + (grub_strlen (equal_char + 1) == 8)) + vlantag = grub_strtoul (equal_char + 1 + 4, 0, 16); + *equal_char = '='; } else @@ -213,8 +218,10 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, hw_addr.mac, sizeof(hw_addr.mac), 0); inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, flags); + inter->vlantag = vlantag; grub_net_add_ipv4_local (inter, __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); + } if (gateway_addr.ipv4 != 0) diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c index c397b1b34..4d7ceed6f 100644 --- a/grub-core/net/ethernet.c +++ b/grub-core/net/ethernet.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -56,10 +57,17 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, { struct etherhdr *eth; grub_err_t err; + grub_uint8_t etherhdr_size; + grub_uint16_t vlantag_id = VLANTAG_IDENTIFIER; - COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE); + etherhdr_size = sizeof (*eth); + COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE); - err = grub_netbuff_push (nb, sizeof (*eth)); + /* Increase ethernet header in case of vlantag */ + if (inf->vlantag != 0) + etherhdr_size += 4; + + err = grub_netbuff_push (nb, etherhdr_size); if (err) return err; eth = (struct etherhdr *) nb->data; @@ -76,6 +84,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, return err; inf->card->opened = 1; } + + /* Check and add a vlan-tag if needed. */ + if (inf->vlantag != 0) + { + /* Move eth type to the right */ + grub_memcpy ((char *) nb->data + etherhdr_size - 2, + (char *) nb->data + etherhdr_size - 6, 2); + + /* Add the tag in the middle */ + grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag_id, 2); + grub_memcpy ((char *) nb->data + etherhdr_size - 4, (char *) &(inf->vlantag), 2); + } + return inf->card->driver->send (inf->card, nb); } @@ -90,10 +111,25 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, grub_net_link_level_address_t hwaddress; grub_net_link_level_address_t src_hwaddress; grub_err_t err; + grub_uint8_t etherhdr_size = sizeof (*eth); + grub_uint16_t vlantag = 0; + + + /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */ + /* longer than the original one. The vlantag id is extracted and the header */ + /* is reseted to the original size. */ + if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == VLANTAG_IDENTIFIER) + { + vlantag = grub_get_unaligned16 (nb->data + etherhdr_size); + etherhdr_size += 4; + /* Move eth type to the original position */ + grub_memcpy((char *) nb->data + etherhdr_size - 6, + (char *) nb->data + etherhdr_size - 2, 2); + } eth = (struct etherhdr *) nb->data; type = grub_be_to_cpu16 (eth->type); - err = grub_netbuff_pull (nb, sizeof (*eth)); + err = grub_netbuff_pull (nb, etherhdr_size); if (err) return err; @@ -121,13 +157,14 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, { /* ARP packet. */ case GRUB_NET_ETHERTYPE_ARP: - grub_net_arp_receive (nb, card); + grub_net_arp_receive (nb, card, &vlantag); grub_netbuff_free (nb); return GRUB_ERR_NONE; /* IP packet. */ case GRUB_NET_ETHERTYPE_IP: case GRUB_NET_ETHERTYPE_IP6: - return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress); + return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress, + &vlantag); } grub_netbuff_free (nb); return GRUB_ERR_NONE; diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index aba4f8908..7c95cc746 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -228,12 +228,13 @@ handle_dgram (struct grub_net_buff *nb, grub_net_ip_protocol_t proto, const grub_net_network_level_address_t *source, const grub_net_network_level_address_t *dest, + grub_uint16_t *vlantag, grub_uint8_t ttl) { struct grub_net_network_level_interface *inf = NULL; grub_err_t err; int multicast = 0; - + /* DHCP needs special treatment since we don't know IP yet. */ { struct udphdr *udph; @@ -293,6 +294,15 @@ handle_dgram (struct grub_net_buff *nb, && grub_net_addr_cmp (&inf->address, dest) == 0 && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0) break; + + /* Verify vlantag id */ + if (inf->card == card && inf->vlantag != *vlantag) + { + grub_dprintf ("net", "invalid vlantag! %x != %x\n", + inf->vlantag, *vlantag); + break; + } + /* Solicited node multicast. */ if (inf->card == card && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 @@ -383,7 +393,8 @@ static grub_err_t grub_net_recv_ip4_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t *vlantag) { struct iphdr *iph = (struct iphdr *) nb->data; grub_err_t err; @@ -458,7 +469,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, dest.ipv4 = iph->dest; return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, - &source, &dest, iph->ttl); + &source, &dest, vlantag, iph->ttl); } for (prev = &reassembles, rsm = *prev; rsm; prev = &rsm->next, rsm = *prev) @@ -594,7 +605,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, dest.ipv4 = dst; return handle_dgram (ret, card, src_hwaddress, - hwaddress, proto, &source, &dest, + hwaddress, proto, &source, &dest, vlantag, ttl); } } @@ -652,7 +663,8 @@ static grub_err_t grub_net_recv_ip6_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t *vlantag) { struct ip6hdr *iph = (struct ip6hdr *) nb->data; grub_err_t err; @@ -703,21 +715,24 @@ grub_net_recv_ip6_packets (struct grub_net_buff *nb, grub_memcpy (dest.ipv6, &iph->dest, sizeof (dest.ipv6)); return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, - &source, &dest, iph->ttl); + &source, &dest, vlantag, iph->ttl); } grub_err_t grub_net_recv_ip_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress) + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t *vlantag) { struct iphdr *iph = (struct iphdr *) nb->data; if ((iph->verhdrlen >> 4) == 4) - return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress); + return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress, + vlantag); if ((iph->verhdrlen >> 4) == 6) - return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress); + return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress, + vlantag); grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4)); grub_netbuff_free (nb); return GRUB_ERR_NONE; diff --git a/include/grub/net.h b/include/grub/net.h index 2192fa186..1096b2432 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -291,6 +291,7 @@ struct grub_net_network_level_interface grub_net_interface_flags_t flags; struct grub_net_bootp_packet *dhcp_ack; grub_size_t dhcp_acklen; + grub_uint16_t vlantag; void *data; }; @@ -561,4 +562,6 @@ extern char *grub_net_default_server; #define GRUB_NET_INTERVAL 400 #define GRUB_NET_INTERVAL_ADDITION 20 +#define VLANTAG_IDENTIFIER 0x8100 + #endif /* ! GRUB_NET_HEADER */ diff --git a/include/grub/net/arp.h b/include/grub/net/arp.h index bb1703622..8d9d08113 100644 --- a/include/grub/net/arp.h +++ b/include/grub/net/arp.h @@ -22,10 +22,11 @@ #include extern grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, - struct grub_net_card *card); + struct grub_net_card *card, + grub_uint16_t *vlantag); grub_err_t grub_net_arp_send_request (struct grub_net_network_level_interface *inf, - const grub_net_network_level_address_t *proto_addr); + const grub_net_network_level_address_t *proto_addr); #endif diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h index dcceaa568..ab9d68f98 100644 --- a/include/grub/net/ip.h +++ b/include/grub/net/ip.h @@ -48,7 +48,8 @@ grub_err_t grub_net_recv_ip_packets (struct grub_net_buff *nb, struct grub_net_card *card, const grub_net_link_level_address_t *hwaddress, - const grub_net_link_level_address_t *src_hwaddress); + const grub_net_link_level_address_t *src_hwaddress, + grub_uint16_t *vlantag); grub_err_t grub_net_send_ip_packet (struct grub_net_network_level_interface *inf, From a35ac854308b0af7c86c2c7b199f6abdfa2110b0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 17:32:15 +0200 Subject: [PATCH 0680/1167] mkimage: Pass layout to mkimage_generate_elfXX rather than some fields. This allows easier extension of this function without having too long of arguments list. --- include/grub/util/mkimage.h | 8 ++++---- util/grub-mkimagexx.c | 35 ++++++++++++++++++----------------- util/mkimage.c | 4 ++-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 1a18708a8..b3a5ca132 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -51,13 +51,13 @@ grub_mkimage_load_image64 (const char *kernel_path, void grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, int note, char **core_img, size_t *core_size, - Elf32_Addr target_addr, grub_size_t align, - size_t kernel_size, size_t bss_size); + Elf32_Addr target_addr, + struct grub_mkimage_layout *layout); void grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target, int note, char **core_img, size_t *core_size, - Elf64_Addr target_addr, grub_size_t align, - size_t kernel_size, size_t bss_size); + Elf64_Addr target_addr, + struct grub_mkimage_layout *layout); struct grub_install_image_target_desc { diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index e63f148e4..3fab93e20 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -185,8 +185,8 @@ grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) void SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target, int note, char **core_img, size_t *core_size, - Elf_Addr target_addr, grub_size_t align, - size_t kernel_size, size_t bss_size) + Elf_Addr target_addr, + struct grub_mkimage_layout *layout) { char *elf_img; size_t program_size; @@ -214,7 +214,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc footer_size += XEN_NOTE_SIZE; } header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr) - + shnum * sizeof (*shdr) + string_size, align); + + shnum * sizeof (*shdr) + string_size, layout->align); program_size = ALIGN_ADDR (*core_size); @@ -258,7 +258,8 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc 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 (align > image_target->link_align ? align : image_target->link_align); + phdr->p_align = grub_host_to_target32 (layout->align > image_target->link_align ? + layout->align : image_target->link_align); if (image_target->id == IMAGE_LOONGSON_ELF) ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER | EF_MIPS_PIC | EF_MIPS_CPIC); @@ -272,27 +273,27 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc else { grub_uint32_t target_addr_mods; - phdr->p_filesz = grub_host_to_target32 (kernel_size); - phdr->p_memsz = grub_host_to_target32 (kernel_size + bss_size); + phdr->p_filesz = grub_host_to_target32 (layout->kernel_size); + phdr->p_memsz = grub_host_to_target32 (layout->kernel_size + layout->bss_size); phdr++; phdr->p_type = grub_host_to_target32 (PT_GNU_STACK); - phdr->p_offset = grub_host_to_target32 (header_size + kernel_size); + phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size); phdr->p_paddr = phdr->p_vaddr = phdr->p_filesz = phdr->p_memsz = 0; phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X); phdr->p_align = grub_host_to_target32 (image_target->link_align); phdr++; phdr->p_type = grub_host_to_target32 (PT_LOAD); - phdr->p_offset = grub_host_to_target32 (header_size + kernel_size); + phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size); phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X); phdr->p_filesz = phdr->p_memsz - = grub_host_to_target32 (*core_size - kernel_size); + = grub_host_to_target32 (*core_size - layout->kernel_size); if (image_target->id == IMAGE_COREBOOT) target_addr_mods = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR; else - target_addr_mods = ALIGN_UP (target_addr + kernel_size + bss_size + target_addr_mods = ALIGN_UP (target_addr + layout->kernel_size + layout->bss_size + image_target->mod_gap, image_target->mod_align); phdr->p_vaddr = grub_host_to_target_addr (target_addr_mods); @@ -434,7 +435,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_size = grub_host_to_target32 (string_size); shdr->sh_link = grub_host_to_target32 (0); shdr->sh_info = grub_host_to_target32 (0); - shdr->sh_addralign = grub_host_to_target32 (align); + shdr->sh_addralign = grub_host_to_target32 (layout->align); shdr->sh_entsize = grub_host_to_target32 (0); shdr++; @@ -445,10 +446,10 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); shdr->sh_addr = grub_host_to_target_addr (target_addr); shdr->sh_offset = grub_host_to_target_addr (header_size); - shdr->sh_size = grub_host_to_target32 (kernel_size); + shdr->sh_size = grub_host_to_target32 (layout->kernel_size); shdr->sh_link = grub_host_to_target32 (0); shdr->sh_info = grub_host_to_target32 (0); - shdr->sh_addralign = grub_host_to_target32 (align); + shdr->sh_addralign = grub_host_to_target32 (layout->align); shdr->sh_entsize = grub_host_to_target32 (0); shdr++; @@ -456,9 +457,9 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_name = grub_host_to_target32 (ptr - str_start); ptr += sizeof ("mods"); shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); - shdr->sh_addr = grub_host_to_target_addr (target_addr + kernel_size); - shdr->sh_offset = grub_host_to_target_addr (header_size + kernel_size); - shdr->sh_size = grub_host_to_target32 (*core_size - kernel_size); + shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size); + shdr->sh_offset = grub_host_to_target_addr (header_size + layout->kernel_size); + shdr->sh_size = grub_host_to_target32 (*core_size - layout->kernel_size); shdr->sh_link = grub_host_to_target32 (0); shdr->sh_info = grub_host_to_target32 (0); shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof); @@ -471,7 +472,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_name = grub_host_to_target32 (ptr - str_start); ptr += sizeof (".xen"); shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); - shdr->sh_addr = grub_host_to_target_addr (target_addr + kernel_size); + shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size); shdr->sh_offset = grub_host_to_target_addr (program_size + header_size); shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE); shdr->sh_link = grub_host_to_target32 (0); diff --git a/util/mkimage.c b/util/mkimage.c index 9ad4cfe42..528166c87 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1638,10 +1638,10 @@ grub_install_generate_image (const char *dir, const char *prefix, target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, - target_addr, layout.align, layout.kernel_size, layout.bss_size); + target_addr, &layout); else grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, - target_addr, layout.align, layout.kernel_size, layout.bss_size); + target_addr, &layout); } break; } From d08c9685149e7788001ac9a209baa1d84c3628e0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 17:47:57 +0200 Subject: [PATCH 0681/1167] Refactor arm-uboot code to make it genereic. arm-coreboot startup code can be very similar to arm-uboot but current code has U-Boot specific references. So split U-Boot part from generic part. --- grub-core/Makefile.core.def | 4 +- grub-core/kern/arm/{uboot => }/startup.S | 64 +++------------------ grub-core/kern/arm/uboot/init.c | 70 +++++++++++++++++++++++ grub-core/kern/arm/uboot/uboot.S | 73 ++++++++++++++++++++++++ grub-core/kern/uboot/init.c | 16 ------ grub-core/kern/uboot/uboot.c | 35 ------------ include/grub/arm/startup.h | 16 ++++++ 7 files changed, 170 insertions(+), 108 deletions(-) rename grub-core/kern/arm/{uboot => }/startup.S (77%) create mode 100644 grub-core/kern/arm/uboot/init.c create mode 100644 grub-core/kern/arm/uboot/uboot.S create mode 100644 include/grub/arm/startup.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 8dcd0e5a9..fb59a7b1d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -105,7 +105,7 @@ kernel = { mips_startup = kern/mips/startup.S; sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S; powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S; - arm_uboot_startup = kern/arm/uboot/startup.S; + arm_uboot_startup = kern/arm/startup.S; arm_efi_startup = kern/arm/efi/startup.S; arm64_efi_startup = kern/arm64/efi/startup.S; @@ -149,6 +149,8 @@ kernel = { uboot = kern/uboot/init.c; uboot = kern/uboot/hw.c; uboot = term/uboot/console.c; + arm_uboot = kern/arm/uboot/init.c; + arm_uboot = kern/arm/uboot/uboot.S; terminfoinkernel = term/terminfo.c; terminfoinkernel = term/tparm.c; diff --git a/grub-core/kern/arm/uboot/startup.S b/grub-core/kern/arm/startup.S similarity index 77% rename from grub-core/kern/arm/uboot/startup.S rename to grub-core/kern/arm/startup.S index 5efaae16e..640837cba 100644 --- a/grub-core/kern/arm/uboot/startup.S +++ b/grub-core/kern/arm/startup.S @@ -86,7 +86,7 @@ FUNCTION(codestart) @ Stack pointer used as start address for signature probing mov r12, sp adr sp, entry_state - push {r1-r12,lr} @ store U-Boot context (sp in r12) + push {r0-r12,lr} @ store U-Boot context (sp in r12) adr r1, _start ldr r0, bss_start_ptr @ src @@ -153,69 +153,21 @@ reloc_done: b EXT_C(grub_main) - /* - * uboot_syscall(): - * This function is effectively a veneer, so it cannot - * modify the stack or corrupt any registers other than - * r12 (ip). Furthermore it needs to restore r8 for - * U-Boot (Global Data Pointer) and preserve it for Grub. - */ -FUNCTION(grub_uboot_syscall) - str r8, transition_space - str lr, transition_space + 4 - str r9, transition_space + 8 - - ldr r8, gd_backup - ldr r9, gd_backup + 4 - - bl do_syscall - - ldr r8, transition_space - ldr lr, transition_space + 4 - ldr r9, transition_space + 8 - - bx lr -do_syscall: - - ldr ip, grub_uboot_syscall_ptr - bx ip - -FUNCTION(grub_uboot_return) - adr sp, entry_state_end - pop {r4-r12, lr} - mov sp, r12 - bx lr - - .align 3 -@ U-boot context stack space -entry_state_end: -VARIABLE(grub_uboot_machine_type) +@ U-boot/coreboot context stack space +VARIABLE(grub_arm_saved_registers) + .long 0 @ r0 .long 0 @ r1 -VARIABLE(grub_uboot_boot_data) .long 0 @ r2 .long 0 @ r3 .long 0 @ r4 .long 0 @ r5 .long 0 @ r6 .long 0 @ r7 -gd_backup: - .long 0 @ r8 - U-Boot global data pointer up to 2013-09-21 - .long 0 @ r9 - U-Boot global data pointer 2013-09-21 onwards + .long 0 @ r8 + .long 0 @ r9 .long 0 @ r10 .long 0 @ r11 -VARIABLE(grub_uboot_search_hint)@ U-Boot stack pointer - - .long 0 @ also API signature address hint. + .long 0 @ sp .long 0 @ lr -entry_state: @ backup for U-Boot context - -@ GRUB context stack space -transition_space: - .long 0 @ r8 - .long 0 @ lr - .long 0 @ r9 - -VARIABLE(grub_uboot_syscall_ptr) - .long 0 @ - - END +entry_state: diff --git a/grub-core/kern/arm/uboot/init.c b/grub-core/kern/arm/uboot/init.c new file mode 100644 index 000000000..2a6aa3fdd --- /dev/null +++ b/grub-core/kern/arm/uboot/init.c @@ -0,0 +1,70 @@ +/* init.c - generic U-Boot initialization and finalization */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include +#include + +extern int (*grub_uboot_syscall_ptr) (int, int *, ...); + +grub_uint32_t +grub_uboot_get_machine_type (void) +{ + return grub_arm_saved_registers.r[1]; +} + +grub_addr_t +grub_uboot_get_boot_data (void) +{ + return grub_arm_saved_registers.r[2]; +} + +int +grub_uboot_api_init (void) +{ + struct api_signature *start, *end; + struct api_signature *p; + grub_addr_t grub_uboot_search_hint = grub_arm_saved_registers.sp; + if (grub_uboot_search_hint) + { + /* Extended search range to work around Trim Slice U-Boot issue */ + start = (struct api_signature *) ((grub_uboot_search_hint & ~0x000fffff) + - 0x00500000); + end = + (struct api_signature *) ((grub_addr_t) start + UBOOT_API_SEARCH_LEN - + API_SIG_MAGLEN + 0x00500000); + } + else + { + start = 0; + end = (struct api_signature *) (256 * 1024 * 1024); + } + + /* Structure alignment is (at least) 8 bytes */ + for (p = start; p < end; p = (void *) ((grub_addr_t) p + 8)) + { + if (grub_memcmp (&(p->magic), API_SIG_MAGIC, API_SIG_MAGLEN) == 0) + { + grub_uboot_syscall_ptr = p->syscall; + return p->version; + } + } + + return 0; +} diff --git a/grub-core/kern/arm/uboot/uboot.S b/grub-core/kern/arm/uboot/uboot.S new file mode 100644 index 000000000..d128775f1 --- /dev/null +++ b/grub-core/kern/arm/uboot/uboot.S @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#include +#include +#include + + /* + * uboot_syscall(): + * This function is effectively a veneer, so it cannot + * modify the stack or corrupt any registers other than + * r12 (ip). Furthermore it needs to restore r8 for + * U-Boot (Global Data Pointer) and preserve it for Grub. + */ +FUNCTION(grub_uboot_syscall) + str r8, transition_space + str lr, transition_space + 4 + str r9, transition_space + 8 + + ldr ip, saved_registers_ptr + ldr r8, [ip, #4 * 8] + ldr r9, [ip, #4 * 9] + + bl do_syscall + + ldr r8, transition_space + ldr lr, transition_space + 4 + ldr r9, transition_space + 8 + + bx lr +do_syscall: + + ldr ip, grub_uboot_syscall_ptr + bx ip + +FUNCTION(grub_uboot_return) + ldr ip, saved_registers_ptr + ldr sp, [ip, #4 * 4] + pop {r4-r12, lr} + mov sp, r12 + bx lr + + + .align 3 + +@ GRUB context stack space +transition_space: + .long 0 @ r8 + .long 0 @ lr + .long 0 @ r9 + +saved_registers_ptr: + .long EXT_C(grub_arm_saved_registers) + +VARIABLE(grub_uboot_syscall_ptr) + .long 0 @ + + END diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c index 5dcc106ed..3e338645c 100644 --- a/grub-core/kern/uboot/init.c +++ b/grub-core/kern/uboot/init.c @@ -36,30 +36,14 @@ extern char __bss_start[]; extern char _end[]; extern grub_size_t grub_total_module_size; -extern int (*grub_uboot_syscall_ptr) (int, int *, ...); static unsigned long timer_start; -extern grub_uint32_t grub_uboot_machine_type; -extern grub_addr_t grub_uboot_boot_data; - void grub_exit (void) { grub_uboot_return (0); } -grub_uint32_t -grub_uboot_get_machine_type (void) -{ - return grub_uboot_machine_type; -} - -grub_addr_t -grub_uboot_get_boot_data (void) -{ - return grub_uboot_boot_data; -} - static grub_uint64_t uboot_timer_ms (void) { diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c index 6800a4beb..cf0168e62 100644 --- a/grub-core/kern/uboot/uboot.c +++ b/grub-core/kern/uboot/uboot.c @@ -39,48 +39,13 @@ * returns: 0 if the call not found, 1 if serviced */ -extern int (*grub_uboot_syscall_ptr) (int, int *, ...); extern int grub_uboot_syscall (int, int *, ...); -extern grub_addr_t grub_uboot_search_hint; static struct sys_info uboot_sys_info; static struct mem_region uboot_mem_info[5]; static struct device_info * devices; static int num_devices; -int -grub_uboot_api_init (void) -{ - struct api_signature *start, *end; - struct api_signature *p; - - if (grub_uboot_search_hint) - { - /* Extended search range to work around Trim Slice U-Boot issue */ - start = (struct api_signature *) ((grub_uboot_search_hint & ~0x000fffff) - - 0x00500000); - end = - (struct api_signature *) ((grub_addr_t) start + UBOOT_API_SEARCH_LEN - - API_SIG_MAGLEN + 0x00500000); - } - else - { - start = 0; - end = (struct api_signature *) (256 * 1024 * 1024); - } - - /* Structure alignment is (at least) 8 bytes */ - for (p = start; p < end; p = (void *) ((grub_addr_t) p + 8)) - { - if (grub_memcmp (&(p->magic), API_SIG_MAGIC, API_SIG_MAGLEN) == 0) - { - grub_uboot_syscall_ptr = p->syscall; - return p->version; - } - } - - return 0; -} /* * All functions below are wrappers around the grub_uboot_syscall() function diff --git a/include/grub/arm/startup.h b/include/grub/arm/startup.h new file mode 100644 index 000000000..9afb6c57c --- /dev/null +++ b/include/grub/arm/startup.h @@ -0,0 +1,16 @@ +#ifndef GRUB_STARTUP_CPU_HEADER +#define GRUB_STARTUP_CPU_HEADER + +struct grub_arm_startup_registers +{ + /* registers 0-11 */ + /* for U-boot r[1] is machine type */ + /* for U-boot r[2] is boot data */ + grub_uint32_t r[12]; + grub_uint32_t sp; + grub_uint32_t lr; +}; + +extern struct grub_arm_startup_registers grub_arm_saved_registers; + +#endif From 461bfab7b7e47fd0a76bf6076a438af1b7e2184a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 19:06:22 +0200 Subject: [PATCH 0682/1167] coreboot: Split parts that are platform-independent. We currently assume that coreboot is always i386, it's no longer the case, so split i386-coreboot parts from generic coreboot code. --- grub-core/Makefile.am | 2 +- grub-core/Makefile.core.def | 6 +- .../commands/i386/coreboot/cb_timestamps.c | 2 +- grub-core/commands/i386/coreboot/cbls.c | 2 +- grub-core/kern/coreboot/cbtable.c | 70 +++++++++++++++++++ grub-core/kern/{i386 => }/coreboot/mmap.c | 6 +- grub-core/kern/i386/coreboot/cbtable.c | 53 ++------------ grub-core/term/i386/coreboot/cbmemc.c | 2 +- grub-core/video/{i386 => }/coreboot/cbfb.c | 2 +- include/grub/{i386 => }/coreboot/lbio.h | 9 +++ 10 files changed, 99 insertions(+), 55 deletions(-) create mode 100644 grub-core/kern/coreboot/cbtable.c rename grub-core/kern/{i386 => }/coreboot/mmap.c (97%) rename grub-core/video/{i386 => }/coreboot/cbfb.c (99%) rename include/grub/{i386 => }/coreboot/lbio.h (93%) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 809a8aa26..781d0ffbf 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -112,7 +112,7 @@ endif if COND_i386_coreboot KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/coreboot/lbio.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index fb59a7b1d..45ed0fa6b 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -166,7 +166,7 @@ kernel = { i386_multiboot = kern/i386/coreboot/init.c; i386_qemu = kern/i386/qemu/init.c; i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c; - i386_coreboot = video/i386/coreboot/cbfb.c; + i386_coreboot = video/coreboot/cbfb.c; efi = disk/efi/efidisk.c; efi = kern/efi/efi.c; @@ -227,8 +227,9 @@ kernel = { i386_qemu = kern/vga_init.c; i386_qemu = kern/i386/qemu/mmap.c; - i386_coreboot = kern/i386/coreboot/mmap.c; + i386_coreboot = kern/coreboot/mmap.c; i386_coreboot = kern/i386/coreboot/cbtable.c; + i386_coreboot = kern/coreboot/cbtable.c; i386_multiboot = kern/i386/multiboot_mmap.c; @@ -643,6 +644,7 @@ module = { module = { name = cbtable; common = kern/i386/coreboot/cbtable.c; + common = kern/coreboot/cbtable.c; enable = i386_pc; enable = i386_efi; enable = i386_qemu; diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c index e72f38d6e..e97ea6bed 100644 --- a/grub-core/commands/i386/coreboot/cb_timestamps.c +++ b/grub-core/commands/i386/coreboot/cb_timestamps.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/grub-core/commands/i386/coreboot/cbls.c b/grub-core/commands/i386/coreboot/cbls.c index e0a10596f..102291f42 100644 --- a/grub-core/commands/i386/coreboot/cbls.c +++ b/grub-core/commands/i386/coreboot/cbls.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/grub-core/kern/coreboot/cbtable.c b/grub-core/kern/coreboot/cbtable.c new file mode 100644 index 000000000..996d3f407 --- /dev/null +++ b/grub-core/kern/coreboot/cbtable.c @@ -0,0 +1,70 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2007,2008,2013 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 . + */ + +#include +#include +#include +#include +#include +#include + +/* Helper for grub_linuxbios_table_iterate. */ +int +grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header) +{ + if (! grub_memcmp (tbl_header->signature, "LBIO", 4)) + return 1; + + return 0; +} + +grub_err_t +grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t, + void *), + void *hook_data) +{ + grub_linuxbios_table_header_t table_header = grub_linuxbios_get_tables (); + grub_linuxbios_table_item_t table_item; + + if (!table_header) + return 0; + +signature_found: + + table_item = + (grub_linuxbios_table_item_t) ((char *) table_header + + table_header->header_size); + for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header + + table_header->header_size + + table_header->table_size); + table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size)) + { + if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK + && grub_linuxbios_check_signature ((grub_linuxbios_table_header_t) (grub_addr_t) + *(grub_uint64_t *) (table_item + 1))) + { + table_header = (grub_linuxbios_table_header_t) (grub_addr_t) + *(grub_uint64_t *) (table_item + 1); + goto signature_found; + } + if (hook (table_item, hook_data)) + return 1; + } + + return 0; +} diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/coreboot/mmap.c similarity index 97% rename from grub-core/kern/i386/coreboot/mmap.c rename to grub-core/kern/coreboot/mmap.c index 4d29f6b7d..caf8f7cef 100644 --- a/grub-core/kern/i386/coreboot/mmap.c +++ b/grub-core/kern/coreboot/mmap.c @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#include -#include +#include +#include #include #include #include @@ -49,6 +49,7 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data) { grub_uint64_t start = mem_region->addr; grub_uint64_t end = mem_region->addr + mem_region->size; +#ifdef __i386__ /* Mark region 0xa0000 - 0x100000 as reserved. */ if (start < 0x100000 && end >= 0xa0000 && mem_region->type == GRUB_MACHINE_MEMORY_AVAILABLE) @@ -75,6 +76,7 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data) if (end <= start) continue; } +#endif if (ctx->hook (start, end - start, /* Multiboot mmaps match with the coreboot mmap definition. Therefore, we can just pass type diff --git a/grub-core/kern/i386/coreboot/cbtable.c b/grub-core/kern/i386/coreboot/cbtable.c index 1669bc0ca..34a2b59be 100644 --- a/grub-core/kern/i386/coreboot/cbtable.c +++ b/grub-core/kern/i386/coreboot/cbtable.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include @@ -25,59 +25,20 @@ GRUB_MOD_LICENSE ("GPLv3+"); -/* Helper for grub_linuxbios_table_iterate. */ -static int -check_signature (grub_linuxbios_table_header_t tbl_header) -{ - if (! grub_memcmp (tbl_header->signature, "LBIO", 4)) - return 1; - - return 0; -} - -grub_err_t -grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t, - void *), - void *hook_data) +grub_linuxbios_table_header_t +grub_linuxbios_get_tables (void) { grub_linuxbios_table_header_t table_header; - grub_linuxbios_table_item_t table_item; - /* Assuming table_header is aligned to its size (8 bytes). */ - for (table_header = (grub_linuxbios_table_header_t) 0x500; table_header < (grub_linuxbios_table_header_t) 0x1000; table_header++) - if (check_signature (table_header)) - goto signature_found; + if (grub_linuxbios_check_signature (table_header)) + return table_header; for (table_header = (grub_linuxbios_table_header_t) 0xf0000; table_header < (grub_linuxbios_table_header_t) 0x100000; table_header++) - if (check_signature (table_header)) - goto signature_found; - - return 0; - -signature_found: - - table_item = - (grub_linuxbios_table_item_t) ((char *) table_header + - table_header->header_size); - for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header - + table_header->header_size - + table_header->table_size); - table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size)) - { - if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK - && check_signature ((grub_linuxbios_table_header_t) (grub_addr_t) - *(grub_uint64_t *) (table_item + 1))) - { - table_header = (grub_linuxbios_table_header_t) (grub_addr_t) - *(grub_uint64_t *) (table_item + 1); - goto signature_found; - } - if (hook (table_item, hook_data)) - return 1; - } + if (grub_linuxbios_check_signature (table_header)) + return table_header; return 0; } diff --git a/grub-core/term/i386/coreboot/cbmemc.c b/grub-core/term/i386/coreboot/cbmemc.c index 25e64a05c..129248c7f 100644 --- a/grub-core/term/i386/coreboot/cbmemc.c +++ b/grub-core/term/i386/coreboot/cbmemc.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/grub-core/video/i386/coreboot/cbfb.c b/grub-core/video/coreboot/cbfb.c similarity index 99% rename from grub-core/video/i386/coreboot/cbfb.c rename to grub-core/video/coreboot/cbfb.c index dede0c37e..9af81fa5b 100644 --- a/grub-core/video/i386/coreboot/cbfb.c +++ b/grub-core/video/coreboot/cbfb.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable; diff --git a/include/grub/i386/coreboot/lbio.h b/include/grub/coreboot/lbio.h similarity index 93% rename from include/grub/i386/coreboot/lbio.h rename to include/grub/coreboot/lbio.h index 1c3fa6f19..5076d36c7 100644 --- a/include/grub/i386/coreboot/lbio.h +++ b/include/grub/coreboot/lbio.h @@ -20,6 +20,9 @@ #ifndef _GRUB_MACHINE_LBIO_HEADER #define _GRUB_MACHINE_LBIO_HEADER 1 +#include +#include + struct grub_linuxbios_table_header { grub_uint8_t signature[4]; @@ -102,4 +105,10 @@ EXPORT_FUNC(grub_linuxbios_table_iterate) (int (*hook) (grub_linuxbios_table_ite void *), void *hook_data); +grub_linuxbios_table_header_t +grub_linuxbios_get_tables (void); + +int +grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header); + #endif From 1daa716c7017f1858de117a20a31da66815435c5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 19:31:55 +0200 Subject: [PATCH 0683/1167] Rename uboot/halt.c to dummy/halt.c. It's not U-Boot specific and it's a stub. --- grub-core/Makefile.core.def | 2 +- grub-core/lib/{uboot => dummy}/halt.c | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename grub-core/lib/{uboot => dummy}/halt.c (100%) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 45ed0fa6b..2a38bd4bc 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -841,7 +841,7 @@ module = { efi = lib/efi/halt.c; ieee1275 = lib/ieee1275/halt.c; emu = lib/emu/halt.c; - uboot = lib/uboot/halt.c; + uboot = lib/dummy/halt.c; }; module = { diff --git a/grub-core/lib/uboot/halt.c b/grub-core/lib/dummy/halt.c similarity index 100% rename from grub-core/lib/uboot/halt.c rename to grub-core/lib/dummy/halt.c From 9808c3ef956c6472a96790b60cf74f4eaa742010 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 19:37:29 +0200 Subject: [PATCH 0684/1167] Rename uboot/datetime to dummy/datetime. It's just a stub and is not UBoot-specific. --- grub-core/Makefile.core.def | 2 +- grub-core/lib/{uboot => dummy}/datetime.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) rename grub-core/lib/{uboot => dummy}/datetime.c (91%) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2a38bd4bc..6540dc951 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1552,7 +1552,7 @@ module = { name = datetime; cmos = lib/cmos_datetime.c; efi = lib/efi/datetime.c; - uboot = lib/uboot/datetime.c; + uboot = lib/dummy/datetime.c; sparc64_ieee1275 = lib/ieee1275/datetime.c; powerpc_ieee1275 = lib/ieee1275/datetime.c; sparc64_ieee1275 = lib/ieee1275/cmos.c; diff --git a/grub-core/lib/uboot/datetime.c b/grub-core/lib/dummy/datetime.c similarity index 91% rename from grub-core/lib/uboot/datetime.c rename to grub-core/lib/dummy/datetime.c index 4be716928..cf693fc6b 100644 --- a/grub-core/lib/uboot/datetime.c +++ b/grub-core/lib/dummy/datetime.c @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -30,12 +29,12 @@ grub_err_t grub_get_datetime (struct grub_datetime *datetime __attribute__ ((unused))) { return grub_error (GRUB_ERR_INVALID_COMMAND, - "can\'t get datetime using U-Boot"); + "can\'t get datetime on this machine"); } grub_err_t grub_set_datetime (struct grub_datetime * datetime __attribute__ ((unused))) { return grub_error (GRUB_ERR_INVALID_COMMAND, - "can\'t set datetime using U-Boot"); + "can\'t set datetime on this machine"); } From 24e37a885269bdec9b27babf1da0bba3692d55c0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 20:53:28 +0200 Subject: [PATCH 0685/1167] arm-coreboot: Start new port. --- configure.ac | 2 + gentpl.py | 8 +- grub-core/Makefile.am | 10 ++ grub-core/Makefile.core.def | 18 +++- grub-core/kern/arm/coreboot/cbtable.c | 40 ++++++++ grub-core/kern/arm/coreboot/coreboot.S | 44 +++++++++ grub-core/kern/arm/coreboot/init.c | 127 +++++++++++++++++++++++++ grub-core/kern/arm/coreboot/timer.c | 65 +++++++++++++ grub-core/kern/arm/startup.S | 4 + grub-core/kern/coreboot/cbtable.c | 2 + grub-core/lib/dummy/reboot.c | 32 +++++++ grub-core/loader/arm/linux.c | 3 + include/grub/arm/coreboot/console.h | 29 ++++++ include/grub/arm/coreboot/kernel.h | 44 +++++++++ include/grub/offsets.h | 6 ++ util/grub-mkimagexx.c | 19 +++- util/mkimage.c | 41 +++++++- 17 files changed, 482 insertions(+), 12 deletions(-) create mode 100644 grub-core/kern/arm/coreboot/cbtable.c create mode 100644 grub-core/kern/arm/coreboot/coreboot.S create mode 100644 grub-core/kern/arm/coreboot/init.c create mode 100644 grub-core/kern/arm/coreboot/timer.c create mode 100644 grub-core/lib/dummy/reboot.c create mode 100644 include/grub/arm/coreboot/console.h create mode 100644 include/grub/arm/coreboot/kernel.h diff --git a/configure.ac b/configure.ac index ee2c86537..571f7a0b5 100644 --- a/configure.ac +++ b/configure.ac @@ -167,6 +167,7 @@ case "$target_cpu"-"$platform" in mipsel-fuloong) platform=loongson ;; mipsel-loongson) ;; arm-uboot) ;; + arm-coreboot) ;; arm-efi) ;; arm64-efi) ;; *-emu) ;; @@ -1918,6 +1919,7 @@ AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips]) AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) +AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot]) AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) diff --git a/gentpl.py b/gentpl.py index f08bcc404..ed268178b 100644 --- a/gentpl.py +++ b/gentpl.py @@ -31,7 +31,8 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_xen", "x86_64_xen", "mips_loongson", "sparc64_ieee1275", "powerpc_ieee1275", "mips_arc", "ia64_efi", - "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi" ] + "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi", + "arm_coreboot"] GROUPS = {} @@ -44,7 +45,7 @@ GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ] GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ] -GROUPS["arm"] = [ "arm_uboot", "arm_efi" ] +GROUPS["arm"] = [ "arm_uboot", "arm_efi", "arm_coreboot" ] GROUPS["arm64"] = [ "arm64_efi" ] # Groups based on firmware @@ -52,6 +53,7 @@ GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] GROUPS["uboot"] = [ "arm_uboot" ] GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ] +GROUPS["coreboot"] = [ "i386_coreboot", "arm_coreboot" ] # emu is a special case so many core functionality isn't needed on this platform GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") @@ -64,7 +66,7 @@ GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"] GROUPS["usb"] = GROUPS["pci"] # If gfxterm is main output console integrate it into kernel -GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot" ] +GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot", "arm_coreboot" ] GROUPS["videomodules"] = GRUB_PLATFORMS[:]; for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 781d0ffbf..bec058554 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -239,6 +239,16 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h endif +if COND_arm_coreboot +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h +endif + if COND_arm_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6540dc951..411dca46b 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -92,6 +92,8 @@ kernel = { emu_cppflags = '$(CPPFLAGS_GNULIB)'; arm_uboot_ldflags = '-Wl,-r,-d'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; + arm_coreboot_ldflags = '-Wl,-r,-d'; + arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; i386_pc_startup = kern/i386/pc/startup.S; i386_efi_startup = kern/i386/efi/startup.S; @@ -106,6 +108,7 @@ kernel = { sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S; powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S; arm_uboot_startup = kern/arm/startup.S; + arm_coreboot_startup = kern/arm/startup.S; arm_efi_startup = kern/arm/efi/startup.S; arm64_efi_startup = kern/arm64/efi/startup.S; @@ -152,6 +155,10 @@ kernel = { arm_uboot = kern/arm/uboot/init.c; arm_uboot = kern/arm/uboot/uboot.S; + arm_coreboot = kern/arm/coreboot/init.c; + arm_coreboot = kern/arm/coreboot/timer.c; + arm_coreboot = kern/arm/coreboot/coreboot.S; + terminfoinkernel = term/terminfo.c; terminfoinkernel = term/tparm.c; terminfoinkernel = commands/extcmd.c; @@ -166,7 +173,7 @@ kernel = { i386_multiboot = kern/i386/coreboot/init.c; i386_qemu = kern/i386/qemu/init.c; i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c; - i386_coreboot = video/coreboot/cbfb.c; + coreboot = video/coreboot/cbfb.c; efi = disk/efi/efidisk.c; efi = kern/efi/efi.c; @@ -227,9 +234,10 @@ kernel = { i386_qemu = kern/vga_init.c; i386_qemu = kern/i386/qemu/mmap.c; - i386_coreboot = kern/coreboot/mmap.c; + coreboot = kern/coreboot/mmap.c; i386_coreboot = kern/i386/coreboot/cbtable.c; - i386_coreboot = kern/coreboot/cbtable.c; + coreboot = kern/coreboot/cbtable.c; + arm_coreboot = kern/arm/coreboot/cbtable.c; i386_multiboot = kern/i386/multiboot_mmap.c; @@ -758,6 +766,7 @@ module = { enable = arm_efi; enable = arm64_efi; enable = arm_uboot; + enable = arm_coreboot; }; module = { @@ -842,6 +851,7 @@ module = { ieee1275 = lib/ieee1275/halt.c; emu = lib/emu/halt.c; uboot = lib/dummy/halt.c; + arm_coreboot = lib/dummy/halt.c; }; module = { @@ -859,6 +869,7 @@ module = { mips_qemu_mips = lib/mips/qemu_mips/reboot.c; xen = lib/xen/reboot.c; uboot = lib/uboot/reboot.c; + arm_coreboot = lib/dummy/reboot.c; common = commands/reboot.c; }; @@ -1553,6 +1564,7 @@ module = { cmos = lib/cmos_datetime.c; efi = lib/efi/datetime.c; uboot = lib/dummy/datetime.c; + arm_coreboot = lib/dummy/datetime.c; sparc64_ieee1275 = lib/ieee1275/datetime.c; powerpc_ieee1275 = lib/ieee1275/datetime.c; sparc64_ieee1275 = lib/ieee1275/cmos.c; diff --git a/grub-core/kern/arm/coreboot/cbtable.c b/grub-core/kern/arm/coreboot/cbtable.c new file mode 100644 index 000000000..8a655bb5c --- /dev/null +++ b/grub-core/kern/arm/coreboot/cbtable.c @@ -0,0 +1,40 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2007,2008,2013 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 . + */ + +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +#pragma GCC diagnostic ignored "-Wcast-align" + +grub_linuxbios_table_header_t +grub_linuxbios_get_tables (void) +{ + grub_linuxbios_table_header_t table_header + = (grub_linuxbios_table_header_t) grub_arm_saved_registers.r[0]; + + if (!grub_linuxbios_check_signature (table_header)) + return 0; + + return table_header; +} diff --git a/grub-core/kern/arm/coreboot/coreboot.S b/grub-core/kern/arm/coreboot/coreboot.S new file mode 100644 index 000000000..a1104526c --- /dev/null +++ b/grub-core/kern/arm/coreboot/coreboot.S @@ -0,0 +1,44 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include + + .file "coreboot.S" + .text + .syntax unified +#if !defined (__thumb2__) + .arch armv7a + .arm +#else + .arch armv7 + .thumb +#endif + +FUNCTION(grub_arm_pfr1) + mrc p15, 0, r0, c0, c1, 1 + bx lr + +FUNCTION(grub_armv7_get_timer_value) + isb + mrrc p15, 1, r0, r1, c14 + bx lr + +FUNCTION(grub_armv7_get_timer_frequency) + mrc p15, 0, r0, c14, c0, 0 + bx lr + diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c new file mode 100644 index 000000000..51ecaceb0 --- /dev/null +++ b/grub-core/kern/arm/coreboot/init.c @@ -0,0 +1,127 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2013 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern grub_uint8_t _start[]; +extern grub_uint8_t _end[]; +extern grub_uint8_t _edata[]; +grub_addr_t start_of_ram = ~(grub_addr_t)0; + +void __attribute__ ((noreturn)) +grub_exit (void) +{ + /* We can't use grub_fatal() in this function. This would create an infinite + loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ + while (1) + grub_cpu_idle (); +} + +static grub_uint64_t modend; +static int have_memory = 0; + +/* Helper for grub_machine_init. */ +static int +heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, + void *data __attribute__ ((unused))) +{ + grub_uint64_t begin = addr, end = addr + size; + +#if GRUB_CPU_SIZEOF_VOID_P == 4 + /* Restrict ourselves to 32-bit memory space. */ + if (begin > GRUB_ULONG_MAX) + return 0; + if (end > GRUB_ULONG_MAX) + end = GRUB_ULONG_MAX; +#endif + + if (start_of_ram > begin) + start_of_ram = begin; + + if (type != GRUB_MEMORY_AVAILABLE) + return 0; + + if (modend && begin < modend) + { + if (begin < (grub_addr_t)_start) + { + grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) ((grub_addr_t)_start - begin)); + have_memory = 1; + } + begin = modend; + } + + /* Avoid DMA problems. */ + if (end >= 0xfe000000) + end = 0xfe000000; + + if (end <= begin) + return 0; + + grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin)); + + have_memory = 1; + + return 0; +} + +void +grub_machine_init (void) +{ + modend = grub_modules_get_end (); + + grub_video_coreboot_fb_early_init (); + + grub_machine_mmap_iterate (heap_init, NULL); + if (!have_memory) + grub_fatal ("No memory found"); + + grub_video_coreboot_fb_late_init (); + + grub_font_init (); + grub_gfxterm_init (); + + grub_machine_timer_init (); +} + +void +grub_machine_get_bootlocation (char **device __attribute__ ((unused)), + char **path __attribute__ ((unused))) +{ +} + +void +grub_machine_fini (int flags __attribute__ ((unused))) +{ +} diff --git a/grub-core/kern/arm/coreboot/timer.c b/grub-core/kern/arm/coreboot/timer.c new file mode 100644 index 000000000..ebefb99d5 --- /dev/null +++ b/grub-core/kern/arm/coreboot/timer.c @@ -0,0 +1,65 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include +#include +#include +#include +#include + +grub_uint64_t +grub_armv7_get_timer_value(void); + +grub_uint32_t +grub_armv7_get_timer_frequency(void); + +grub_uint32_t +grub_arm_pfr1(void); + +static int have_timer = 0; +static grub_uint32_t timer_frequency_in_khz; + +static grub_uint64_t +generic_get_time_ms (void) +{ + return grub_divmod64 (grub_armv7_get_timer_value(), timer_frequency_in_khz, 0); +} + +static int +try_generic_timer (void) +{ + if (((grub_arm_pfr1 () >> 16) & 0xf) != 1) + return 0; + grub_printf ("freq = %x\n", grub_armv7_get_timer_frequency()); + timer_frequency_in_khz = 0x016e3600 / 1000; //grub_armv7_get_timer_frequency() / 1000; + if (timer_frequency_in_khz == 0) + return 0; + grub_install_get_time_ms (generic_get_time_ms); + have_timer = 1; + return 1; +} + +void +grub_machine_timer_init (void) +{ + if (!have_timer) + try_generic_timer (); + if (!have_timer) + grub_fatal ("No timer found"); +} diff --git a/grub-core/kern/arm/startup.S b/grub-core/kern/arm/startup.S index 640837cba..3946fe8e1 100644 --- a/grub-core/kern/arm/startup.S +++ b/grub-core/kern/arm/startup.S @@ -24,6 +24,7 @@ * GRUB is called from U-Boot as a Linux Kernel type image, which * means among other things that it always enters in ARM state. * + * coreboot starts in ARM mode as well. * * Overview of GRUB image layout: * @@ -127,6 +128,8 @@ reloc_done: str r1, EXT_C(grub_modbase) + /* Coreboot already places modules at right place. */ +#ifndef GRUB_MACHINE_COREBOOT add r1, r1, r2 add r0, r0, r2 sub r1, r1, #4 @@ -136,6 +139,7 @@ reloc_done: str r3, [r1], #-4 @ *dst-- = r3 subs r2, #4 @ remaining -= 4 bne 1b @ while remaining != 0 +#endif @ Since we _are_ the C run-time, we need to manually zero the BSS @ region before continuing diff --git a/grub-core/kern/coreboot/cbtable.c b/grub-core/kern/coreboot/cbtable.c index 996d3f407..aec63dbd1 100644 --- a/grub-core/kern/coreboot/cbtable.c +++ b/grub-core/kern/coreboot/cbtable.c @@ -23,6 +23,8 @@ #include #include +#pragma GCC diagnostic ignored "-Wcast-align" + /* Helper for grub_linuxbios_table_iterate. */ int grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header) diff --git a/grub-core/lib/dummy/reboot.c b/grub-core/lib/dummy/reboot.c new file mode 100644 index 000000000..b8cbed8f8 --- /dev/null +++ b/grub-core/lib/dummy/reboot.c @@ -0,0 +1,32 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#include +#include +#include +#include + +void +grub_reboot (void) +{ + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); + + /* Just stop here */ + + while (1); +} diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 5b39f02bb..01374ee78 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -31,6 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#ifndef GRUB_MACHINE_COREBOOT + static grub_dl_t my_mod; static grub_addr_t initrd_start; @@ -527,3 +529,4 @@ GRUB_MOD_FINI (linux) grub_unregister_command (cmd_initrd); grub_unregister_command (cmd_devicetree); } +#endif diff --git a/include/grub/arm/coreboot/console.h b/include/grub/arm/coreboot/console.h new file mode 100644 index 000000000..13a14b783 --- /dev/null +++ b/include/grub/arm/coreboot/console.h @@ -0,0 +1,29 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 . + */ + +#ifndef GRUB_MACHINE_CONSOLE_HEADER +#define GRUB_MACHINE_CONSOLE_HEADER 1 + +void grub_video_coreboot_fb_init (void); +void grub_video_coreboot_fb_early_init (void); +void grub_video_coreboot_fb_late_init (void); +void grub_video_coreboot_fb_fini (void); + +extern struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable; + +#endif /* ! GRUB_MACHINE_CONSOLE_HEADER */ diff --git a/include/grub/arm/coreboot/kernel.h b/include/grub/arm/coreboot/kernel.h new file mode 100644 index 000000000..09cd7fe32 --- /dev/null +++ b/include/grub/arm/coreboot/kernel.h @@ -0,0 +1,44 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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 . + */ + +#ifndef GRUB_KERNEL_MACHINE_HEADER +#define GRUB_KERNEL_MACHINE_HEADER 1 + +#ifndef ASM_FILE + +#include +#include + +struct grub_fdt_board +{ + const char *vendor, *part; + const grub_uint8_t *dtb; + grub_size_t dtb_size; +}; + +extern struct grub_fdt_board grub_fdt_boards[]; +void grub_machine_timer_init (void); +void grub_pl050_init (void); +void +grub_cros_init (void); +extern grub_addr_t EXPORT_VAR (start_of_ram); +#endif /* ! ASM_FILE */ + +#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE + +#endif /* ! GRUB_KERNEL_MACHINE_HEADER */ diff --git a/include/grub/offsets.h b/include/grub/offsets.h index c88c86d4d..bf0689fc9 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -122,6 +122,12 @@ #define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 0x8 #define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE 0x4 +#define GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN 0x8 +#define GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE 0x4 + +#define GRUB_KERNEL_ARM_STACK_SIZE 0x40000 +#define GRUB_KERNEL_ARM_COREBOOT_MOD_GAP (GRUB_KERNEL_ARM_STACK_SIZE + 1024) + /* Minimal gap between _end and the start of the modules. It's a hack for PowerMac to prevent "CLAIM failed" error. The real fix is to rewrite grub-mkimage to generate valid ELF files. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 3fab93e20..a2bb05439 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -87,7 +87,8 @@ struct fixup_block_list static int is_relocatable (const struct grub_install_image_target_desc *image_target) { - return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT; + return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT + || (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM); } #ifdef MKIMAGE_ELF32 @@ -274,7 +275,10 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc { grub_uint32_t target_addr_mods; phdr->p_filesz = grub_host_to_target32 (layout->kernel_size); - phdr->p_memsz = grub_host_to_target32 (layout->kernel_size + layout->bss_size); + if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM) + phdr->p_memsz = grub_host_to_target32 (layout->kernel_size); + else + phdr->p_memsz = grub_host_to_target32 (layout->kernel_size + layout->bss_size); phdr++; phdr->p_type = grub_host_to_target32 (PT_GNU_STACK); @@ -290,8 +294,12 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc phdr->p_filesz = phdr->p_memsz = grub_host_to_target32 (*core_size - layout->kernel_size); - if (image_target->id == IMAGE_COREBOOT) + if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_386) target_addr_mods = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR; + else if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM) + target_addr_mods = ALIGN_UP (target_addr + layout->end + + image_target->mod_gap, + image_target->mod_align); else target_addr_mods = ALIGN_UP (target_addr + layout->kernel_size + layout->bss_size + image_target->mod_gap, @@ -1876,7 +1884,7 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, Platforms other than EFI and U-boot shouldn't have .bss in their binaries as we build with -Wl,-Ttext. */ - if (image_target->id != IMAGE_UBOOT) + if (image_target->id == IMAGE_EFI || !is_relocatable (image_target)) layout->kernel_size = layout->end; return section_addresses; @@ -1979,6 +1987,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (image_target->id == IMAGE_SPARC64_AOUT || image_target->id == IMAGE_SPARC64_RAW || image_target->id == IMAGE_UBOOT + || image_target->id == IMAGE_COREBOOT || image_target->id == IMAGE_SPARC64_CDCORE) layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); @@ -2084,7 +2093,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, Platforms other than EFI and U-boot shouldn't have .bss in their binaries as we build with -Wl,-Ttext. */ - || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id != IMAGE_UBOOT)) + || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id == IMAGE_EFI || !is_relocatable (image_target))) || SUFFIX (is_text_section) (s, image_target)) { if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) diff --git a/util/mkimage.c b/util/mkimage.c index 528166c87..6aa77ed73 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -533,6 +533,45 @@ static const struct grub_install_image_target_desc image_targets[] = .mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, .link_align = 4 }, + /* For coreboot versions that don't support self-relocating images. */ + { + .dirname = "arm-coreboot-vexpress", + .names = { "arm-coreboot-vexpress", NULL }, + .voidp_sizeof = 4, + .bigendian = 0, + .id = IMAGE_COREBOOT, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, + .vaddr_offset = 0, + .elf_target = EM_ARM, + .mod_gap = GRUB_KERNEL_ARM_COREBOOT_MOD_GAP, + .mod_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, + .link_align = 4, + .link_addr = 0x62000000, + }, + { + .dirname = "arm-coreboot-veyron", + .names = { "arm-coreboot-veyron", NULL }, + .voidp_sizeof = 4, + .bigendian = 0, + .id = IMAGE_COREBOOT, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, + .vaddr_offset = 0, + .elf_target = EM_ARM, + .mod_gap = GRUB_KERNEL_ARM_COREBOOT_MOD_GAP, + .mod_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, + .link_align = 4, + .link_addr = 0x43000000, + }, { .dirname = "arm-efi", .names = { "arm-efi", NULL }, @@ -1033,7 +1072,7 @@ grub_install_generate_image (const char *dir, const char *prefix, /* fallthrough */ case IMAGE_COREBOOT: case IMAGE_QEMU: - if (layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) + if (image_target->elf_target != EM_ARM && layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) grub_util_error (_("kernel image is too big (0x%x > 0x%x)"), (unsigned) layout.kernel_size + (unsigned) layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR, From fcbb723d4b1f7ad4687191562621dd0eb25f4d9e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:19:59 +0200 Subject: [PATCH 0686/1167] Add support for device-tree-based drivers. --- conf/Makefile.common | 4 +- grub-core/Makefile.am | 10 ++ grub-core/Makefile.core.def | 2 + grub-core/bus/fdt.c | 255 +++++++++++++++++++++++++++++ grub-core/kern/arm/coreboot/init.c | 20 +++ grub-core/lib/fdt.c | 142 ++++++++++++---- include/grub/fdt.h | 23 ++- include/grub/fdtbus.h | 73 +++++++++ include/grub/kernel.h | 3 +- include/grub/util/install.h | 2 +- util/grub-install-common.c | 2 +- util/grub-mkimage.c | 11 +- util/mkimage.c | 24 ++- 13 files changed, 519 insertions(+), 52 deletions(-) create mode 100644 grub-core/bus/fdt.c create mode 100644 include/grub/fdtbus.h diff --git a/conf/Makefile.common b/conf/Makefile.common index 11296b550..311da61c6 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -86,9 +86,11 @@ CPPFLAGS_TERMINAL_LIST += '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)' CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)' CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)' +CPPFLAGS_FDT_LIST := '-Dgrub_fdtbus_register(...)=FDT_DRIVER_LIST_MARKER(__VA_ARGS__)' CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \ $(CPPFLAGS_PARTTOOL_LIST) $(CPPFLAGS_PARTMAP_LIST) \ - $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) + $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) \ + $(CPPFLAGS_FDT_LIST) # Define these variables to calm down automake diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index bec058554..fc6ca3051 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -368,6 +368,16 @@ terminal.lst: $(MARKER_FILES) platform_DATA += terminal.lst CLEANFILES += terminal.lst +fdt.lst: $(MARKER_FILES) + (for pp in $^; do \ + b=`basename $$pp .marker`; \ + sed -n \ + -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \ + -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \ + done) | sort -u > $@ +platform_DATA += fdt.lst +CLEANFILES += fdt.lst + parttool.lst: $(MARKER_FILES) (for pp in $^; do \ b=`basename $$pp .marker`; \ diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 411dca46b..77d0b019e 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -158,6 +158,8 @@ kernel = { arm_coreboot = kern/arm/coreboot/init.c; arm_coreboot = kern/arm/coreboot/timer.c; arm_coreboot = kern/arm/coreboot/coreboot.S; + arm_coreboot = lib/fdt.c; + arm_coreboot = bus/fdt.c; terminfoinkernel = term/terminfo.c; terminfoinkernel = term/tparm.c; diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c new file mode 100644 index 000000000..6fb077000 --- /dev/null +++ b/grub-core/bus/fdt.c @@ -0,0 +1,255 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#include +#include +#include + +static const void *dtb; +static grub_size_t root_address_cells, root_size_cells; +/* Pointer to this symbol signals invalid mapping. */ +char grub_fdtbus_invalid_mapping[1]; + +struct grub_fdtbus_dev +{ + struct grub_fdtbus_dev *next; + struct grub_fdtbus_dev *parent; + int node; + struct grub_fdtbus_driver *driver; +}; + +struct grub_fdtbus_dev *devs; +struct grub_fdtbus_driver *drivers; + +static int +is_compatible (struct grub_fdtbus_driver *driver, + int node) +{ + grub_size_t compatible_size; + const char *compatible = grub_fdt_get_prop (dtb, node, "compatible", + &compatible_size); + const char *compatible_end = compatible + compatible_size; + while (compatible < compatible_end) + { + if (grub_strcmp (driver->compatible, compatible) == 0) + return 1; + compatible += grub_strlen (compatible) + 1; + } + return 0; +} + +static void +fdtbus_scan (struct grub_fdtbus_dev *parent) +{ + int node; + for (node = grub_fdt_first_node (dtb, parent ? parent->node : 0); node >= 0; + node = grub_fdt_next_node (dtb, node)) + { + struct grub_fdtbus_dev *dev; + struct grub_fdtbus_driver *driver; + dev = grub_zalloc (sizeof (*dev)); + if (!dev) + { + grub_print_error (); + return; + } + dev->node = node; + dev->next = devs; + dev->parent = parent; + devs = dev; + FOR_LIST_ELEMENTS(driver, drivers) + if (!dev->driver && is_compatible (driver, node)) + { + if (driver->attach(dev) == GRUB_ERR_NONE) + { + dev->driver = driver; + break; + } + grub_print_error (); + } + fdtbus_scan (dev); + } +} + +void +grub_fdtbus_register (struct grub_fdtbus_driver *driver) +{ + struct grub_fdtbus_dev *dev; + grub_list_push (GRUB_AS_LIST_P (&drivers), + GRUB_AS_LIST (driver)); + for (dev = devs; dev; dev = dev->next) + if (!dev->driver && is_compatible (driver, dev->node)) + { + if (driver->attach(dev) == GRUB_ERR_NONE) + dev->driver = driver; + grub_print_error (); + } +} + +void +grub_fdtbus_unregister (struct grub_fdtbus_driver *driver) +{ + grub_list_remove (GRUB_AS_LIST (driver)); + struct grub_fdtbus_dev *dev; + for (dev = devs; dev; dev = dev->next) + if (dev->driver == driver) + { + if (driver->detach) + driver->detach(dev); + dev->driver = 0; + } +} + +void +grub_fdtbus_init (const void *dtb_in, grub_size_t size) +{ + if (!dtb_in || grub_fdt_check_header (dtb_in, size) < 0) + grub_fatal ("invalid FDT"); + dtb = dtb_in; + const grub_uint32_t *prop = grub_fdt_get_prop (dtb, 0, "#address-cells", 0); + if (prop) + root_address_cells = grub_be_to_cpu32 (*prop); + else + root_address_cells = 1; + + prop = grub_fdt_get_prop (dtb, 0, "#size-cells", 0); + if (prop) + root_size_cells = grub_be_to_cpu32 (*prop); + else + root_size_cells = 1; + + fdtbus_scan (0); +} + +static int +get_address_cells (const struct grub_fdtbus_dev *dev) +{ + const grub_uint32_t *prop; + if (!dev) + return root_address_cells; + prop = grub_fdt_get_prop (dtb, dev->node, "#address-cells", 0); + if (prop) + return grub_be_to_cpu32 (*prop); + return 1; +} + +static int +get_size_cells (const struct grub_fdtbus_dev *dev) +{ + const grub_uint32_t *prop; + if (!dev) + return root_size_cells; + prop = grub_fdt_get_prop (dtb, dev->node, "#size-cells", 0); + if (prop) + return grub_be_to_cpu32 (*prop); + return 1; +} + +static grub_uint64_t +get64 (const grub_uint32_t *reg, grub_size_t cells) +{ + grub_uint64_t val = 0; + if (cells >= 1) + val = grub_be_to_cpu32 (reg[cells - 1]); + if (cells >= 2) + val |= ((grub_uint64_t) grub_be_to_cpu32 (reg[cells - 2])) << 32; + return val; +} + +static volatile void * +translate (const struct grub_fdtbus_dev *dev, const grub_uint32_t *reg) +{ + volatile void *ret; + const grub_uint32_t *ranges; + grub_size_t ranges_size, cells_per_mapping; + grub_size_t parent_address_cells, child_address_cells, child_size_cells; + grub_size_t nmappings, i; + if (dev == 0) + { + grub_uint64_t val; + val = get64 (reg, root_address_cells); + if (sizeof (void *) == 4 && (val >> 32)) + return grub_fdtbus_invalid_mapping; + return (void *) (grub_addr_t) val; + } + ranges = grub_fdt_get_prop (dtb, dev->node, "ranges", &ranges_size); + if (!ranges) + return grub_fdtbus_invalid_mapping; + if (ranges_size == 0) + return translate (dev->parent, reg); + parent_address_cells = get_address_cells (dev->parent); + child_address_cells = get_address_cells (dev); + child_size_cells = get_size_cells (dev); + cells_per_mapping = parent_address_cells + child_address_cells + child_size_cells; + nmappings = ranges_size / 4 / cells_per_mapping; + for (i = 0; i < nmappings; i++) + { + const grub_uint32_t *child_addr = &ranges[i * cells_per_mapping]; + const grub_uint32_t *parent_addr = child_addr + child_address_cells; + grub_uint64_t child_size = get64 (parent_addr + parent_address_cells, child_size_cells); + + if (child_address_cells > 2 && grub_memcmp (reg, child_addr, (child_address_cells - 2) * 4) != 0) + continue; + if (get64 (reg, child_address_cells) < get64 (child_addr, child_address_cells)) + continue; + + grub_uint64_t offset = get64 (reg, child_address_cells) - get64 (child_addr, child_address_cells); + if (offset >= child_size) + continue; + + ret = translate (dev->parent, parent_addr); + if (grub_fdtbus_is_mapping_valid (ret)) + ret = (volatile char *) ret + offset; + return ret; + } + return grub_fdtbus_invalid_mapping; +} + +volatile void * +grub_fdtbus_map_reg (const struct grub_fdtbus_dev *dev, int regno, grub_size_t *size) +{ + grub_size_t address_cells, size_cells; + address_cells = get_address_cells (dev->parent); + size_cells = get_size_cells (dev->parent); + const grub_uint32_t *reg = grub_fdt_get_prop (dtb, dev->node, "reg", 0); + if (size && size_cells) + *size = reg[(address_cells + size_cells) * regno + address_cells]; + if (size && !size_cells) + *size = 0; + return translate (dev->parent, reg + (address_cells + size_cells) * regno); +} + +const char * +grub_fdtbus_get_name (const struct grub_fdtbus_dev *dev) +{ + return grub_fdt_get_nodename (dtb, dev->node); +} + +const void * +grub_fdtbus_get_prop (const struct grub_fdtbus_dev *dev, + const char *name, + grub_uint32_t *len) +{ + return grub_fdt_get_prop (dtb, dev->node, name, len); +} + +const void * +grub_fdtbus_get_fdt (void) +{ + return dtb; +} diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c index 51ecaceb0..aec75c672 100644 --- a/grub-core/kern/arm/coreboot/init.c +++ b/grub-core/kern/arm/coreboot/init.c @@ -33,6 +33,7 @@ #include #include #include +#include extern grub_uint8_t _start[]; extern grub_uint8_t _end[]; @@ -99,6 +100,10 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void grub_machine_init (void) { + struct grub_module_header *header; + void *dtb = 0; + grub_size_t dtb_size = 0; + modend = grub_modules_get_end (); grub_video_coreboot_fb_early_init (); @@ -112,6 +117,21 @@ grub_machine_init (void) grub_font_init (); grub_gfxterm_init (); + FOR_MODULES (header) + if (header->type == OBJ_TYPE_DTB) + { + char *dtb_orig_addr, *dtb_copy; + dtb_orig_addr = (char *) header + sizeof (struct grub_module_header); + + dtb_size = header->size - sizeof (struct grub_module_header); + dtb = dtb_copy = grub_malloc (dtb_size); + grub_memmove (dtb_copy, dtb_orig_addr, dtb_size); + break; + } + if (!dtb) + grub_fatal ("No DTB found"); + grub_fdtbus_init (dtb, dtb_size); + grub_machine_timer_init (); } diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index b5d520f20..bdc630244 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -102,13 +102,13 @@ static grub_uint32_t *get_next_node (const void *fdt, char *node_name) static int get_mem_rsvmap_size (const void *fdt) { int size = 0; - grub_uint64_t *ptr = (void *) ((grub_addr_t) fdt - + grub_fdt_get_off_mem_rsvmap (fdt)); + grub_unaligned_uint64_t *ptr = (void *) ((grub_addr_t) fdt + + grub_fdt_get_off_mem_rsvmap (fdt)); do { size += 2 * sizeof(*ptr); - if (!*ptr && !*(ptr + 1)) + if (!ptr[0].val && !ptr[1].val) return size; ptr += 2; } while ((grub_addr_t) ptr <= (grub_addr_t) fdt + grub_fdt_get_totalsize (fdt) @@ -229,7 +229,7 @@ static int rearrange_blocks (void *fdt, unsigned int clearance) return 0; } -static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset, +static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset, const char *name) { grub_uint32_t *prop = (void *) ((grub_addr_t) fdt @@ -268,9 +268,9 @@ static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset, the size allocated for the FDT; if this function is called before the other functions in this file and returns success, the other functions are guaranteed not to access memory locations outside the allocated memory. */ -int grub_fdt_check_header_nosize (void *fdt) +int grub_fdt_check_header_nosize (const void *fdt) { - if (((grub_addr_t) fdt & 0x7) || (grub_fdt_get_magic (fdt) != FDT_MAGIC) + if (((grub_addr_t) fdt & 0x3) || (grub_fdt_get_magic (fdt) != FDT_MAGIC) || (grub_fdt_get_version (fdt) < FDT_SUPPORTED_VERSION) || (grub_fdt_get_last_comp_version (fdt) > FDT_SUPPORTED_VERSION) || (grub_fdt_get_off_dt_struct (fdt) & 0x00000003) @@ -286,7 +286,7 @@ int grub_fdt_check_header_nosize (void *fdt) return 0; } -int grub_fdt_check_header (void *fdt, unsigned int size) +int grub_fdt_check_header (const void *fdt, unsigned int size) { if (size < sizeof (grub_fdt_header_t) || (grub_fdt_get_totalsize (fdt) > size) @@ -295,41 +295,29 @@ int grub_fdt_check_header (void *fdt, unsigned int size) return 0; } -/* Find a direct sub-node of a given parent node. */ -int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, - const char *name) +static const grub_uint32_t * +advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t *end, int skip_current) { - grub_uint32_t *token, *end; - char *node_name; - - if (parentoffset & 0x3) - return -1; - token = (void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) - + parentoffset); - end = (void *) struct_end (fdt); - if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE)) - return -1; - SKIP_NODE_NAME(node_name, token, end); - while (token < end) + for (; token < end; skip_current = 0) { - switch (grub_be_to_cpu32(*token)) + switch (grub_be_to_cpu32 (*token)) { case FDT_BEGIN_NODE: - node_name = (char *) (token + 1); - if (node_name + grub_strlen (name) >= (char *) end) - return -1; - if (!grub_strcmp (node_name, name)) - return (int) ((grub_addr_t) token - (grub_addr_t) fdt - - grub_fdt_get_off_dt_struct (fdt)); - token = get_next_node (fdt, node_name); - if (!token) - return -1; - break; + if (skip_current) + { + token = get_next_node (fdt, (char *) (token + 1)); + continue; + } + char *ptr; + for (ptr = (char *) (token + 1); *ptr && ptr < (char *) end; ptr++); + if (ptr >= (char *) end) + return 0; + return token; case FDT_PROP: /* Skip property token and following data (len, nameoff and property value). */ if (token >= end - 1) - return -1; + return 0; token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; @@ -337,10 +325,74 @@ int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, token++; break; default: - return -1; + return 0; } } - return -1; + return 0; +} + +int grub_fdt_next_node (const void *fdt, unsigned int currentoffset) +{ + const grub_uint32_t *token = (const grub_uint32_t *) fdt + (currentoffset + grub_fdt_get_off_dt_struct (fdt)) / 4; + token = advance_token (fdt, token, (const void *) struct_end (fdt), 1); + if (!token) + return -1; + return (int) ((grub_addr_t) token - (grub_addr_t) fdt + - grub_fdt_get_off_dt_struct (fdt)); +} + +int grub_fdt_first_node (const void *fdt, unsigned int parentoffset) +{ + const grub_uint32_t *token, *end; + char *node_name; + + if (parentoffset & 0x3) + return -1; + token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) + + parentoffset); + end = (const void *) struct_end (fdt); + if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE)) + return -1; + SKIP_NODE_NAME(node_name, token, end); + token = advance_token (fdt, token, end, 0); + if (!token) + return -1; + return (int) ((grub_addr_t) token - (grub_addr_t) fdt + - grub_fdt_get_off_dt_struct (fdt)); +} + +/* Find a direct sub-node of a given parent node. */ +int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, + const char *name) +{ + const grub_uint32_t *token, *end; + const char *node_name; + int skip_current = 0; + + if (parentoffset & 0x3) + return -1; + token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) + + parentoffset); + end = (const void *) struct_end (fdt); + if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE)) + return -1; + SKIP_NODE_NAME(node_name, token, end); + while (1) { + token = advance_token (fdt, token, end, skip_current); + if (!token) + return -1; + skip_current = 1; + node_name = (const char *) token + 4; + if (grub_strcmp (node_name, name) == 0) + return (int) ((grub_addr_t) token - (grub_addr_t) fdt + - grub_fdt_get_off_dt_struct (fdt)); + } +} + +const char * +grub_fdt_get_nodename (const void *fdt, unsigned int nodeoffset) +{ + return (const char *) fdt + grub_fdt_get_off_dt_struct(fdt) + nodeoffset + 4; } int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, @@ -359,6 +411,24 @@ int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, return add_subnode (fdt, parentoffset, name); } +const void * +grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name, + grub_uint32_t *len) +{ + grub_uint32_t *prop; + if ((nodeoffset >= grub_fdt_get_size_dt_struct (fdt)) || (nodeoffset & 0x3) + || (grub_be_to_cpu32(*(grub_uint32_t *) ((grub_addr_t) fdt + + grub_fdt_get_off_dt_struct (fdt) + nodeoffset)) + != FDT_BEGIN_NODE)) + return 0; + prop = find_prop (fdt, nodeoffset, name); + if (!prop) + return 0; + if (len) + *len = grub_be_to_cpu32 (*(prop + 1)); + return prop + 3; +} + int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, const void *val, grub_uint32_t len) { diff --git a/include/grub/fdt.h b/include/grub/fdt.h index fdfca75bf..75525fa31 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -20,6 +20,7 @@ #define GRUB_FDT_HEADER 1 #include +#include #define FDT_MAGIC 0xD00DFEED @@ -95,16 +96,22 @@ struct grub_fdt_empty_tree { #define grub_fdt_set_size_dt_struct(fdt, value) \ grub_fdt_set_header(fdt, size_dt_struct, value) -int grub_fdt_create_empty_tree (void *fdt, unsigned int size); -int grub_fdt_check_header (void *fdt, unsigned int size); -int grub_fdt_check_header_nosize (void *fdt); -int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, - const char *name); -int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, +int EXPORT_FUNC(grub_fdt_create_empty_tree) (void *fdt, unsigned int size); +int EXPORT_FUNC(grub_fdt_check_header) (const void *fdt, unsigned int size); +int EXPORT_FUNC(grub_fdt_check_header_nosize) (const void *fdt); +int EXPORT_FUNC(grub_fdt_find_subnode) (const void *fdt, unsigned int parentoffset, + const char *name); +int EXPORT_FUNC(grub_fdt_first_node) (const void *fdt, unsigned int parentoffset); +int EXPORT_FUNC(grub_fdt_next_node) (const void *fdt, unsigned int currentoffset); +int EXPORT_FUNC(grub_fdt_add_subnode) (void *fdt, unsigned int parentoffset, const char *name); +const char * +EXPORT_FUNC(grub_fdt_get_nodename) (const void *fdt, unsigned int nodeoffset); +const void *EXPORT_FUNC(grub_fdt_get_prop) (const void *fdt, unsigned int nodeoffset, const char *name, + grub_uint32_t *len); -int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, - const void *val, grub_uint32_t len); +int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const char *name, + const void *val, grub_uint32_t len); #define grub_fdt_set_prop32(fdt, nodeoffset, name, val) \ ({ \ grub_uint32_t _val = grub_cpu_to_be32(val); \ diff --git a/include/grub/fdtbus.h b/include/grub/fdtbus.h new file mode 100644 index 000000000..985837e55 --- /dev/null +++ b/include/grub/fdtbus.h @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 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 . + */ + +#ifndef GRUB_FDTBUS_HEADER +#define GRUB_FDTBUS_HEADER 1 + +#include +#include + +struct grub_fdtbus_dev; + +struct grub_fdtbus_driver +{ + struct grub_fdtbus_driver *next; + struct grub_fdtbus_driver **prev; + + const char *compatible; + + grub_err_t (*attach) (const struct grub_fdtbus_dev *dev); + void (*detach) (const struct grub_fdtbus_dev *dev); +}; + +extern char EXPORT_VAR(grub_fdtbus_invalid_mapping)[1]; + +static inline int +grub_fdtbus_is_mapping_valid (volatile void *m) +{ + return m != grub_fdtbus_invalid_mapping; +} + +volatile void * +EXPORT_FUNC(grub_fdtbus_map_reg) (const struct grub_fdtbus_dev *dev, int reg, grub_size_t *size); + +const void * +EXPORT_FUNC(grub_fdtbus_get_fdt) (void); + +const char * +EXPORT_FUNC(grub_fdtbus_get_name) (const struct grub_fdtbus_dev *dev); + +const void * +EXPORT_FUNC(grub_fdtbus_get_prop) (const struct grub_fdtbus_dev *dev, + const char *name, + grub_uint32_t *len); + +void +EXPORT_FUNC(grub_fdtbus_register) (struct grub_fdtbus_driver *driver); + +void +EXPORT_FUNC(grub_fdtbus_unregister) (struct grub_fdtbus_driver *driver); + +/* Must be called before any register(). */ +/* dtb is assumed to be unfreeable and must remain + valid for lifetime of GRUB. + */ +void +grub_fdtbus_init (const void *dtb, grub_size_t size); + +#endif diff --git a/include/grub/kernel.h b/include/grub/kernel.h index 20ddf2da2..ecd88ca72 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -28,7 +28,8 @@ enum OBJ_TYPE_MEMDISK, OBJ_TYPE_CONFIG, OBJ_TYPE_PREFIX, - OBJ_TYPE_PUBKEY + OBJ_TYPE_PUBKEY, + OBJ_TYPE_DTB }; /* The module header. */ diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 5ca4811cd..6abd288c3 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -176,7 +176,7 @@ grub_install_generate_image (const char *dir, const char *prefix, char *config_path, const struct grub_install_image_target_desc *image_target, int note, - grub_compression_t comp); + grub_compression_t comp, const char *dtb_file); const struct grub_install_image_target_desc * grub_install_get_image_target (const char *arg); diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 452b230da..8539ff348 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -499,7 +499,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, pubkeys, npubkeys, config_path, tgt, - note, compression); + note, compression, 0); while (dc--) grub_install_pop_module (); } diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index aba19d21b..98d24cc06 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -71,6 +71,7 @@ static struct argp_option options[] = { N_("embed FILE as a memdisk image\n" "Implies `-p (memdisk)/boot/grub' and overrides any prefix supplied previously," " but the prefix itself can be overridden by later options"), 0}, + {"dtb", 'D', N_("FILE"), 0, N_("embed FILE as a device tree (DTB)\n"), 0}, /* TRANSLATORS: "embed" is a verb (command description). "*/ {"config", 'c', N_("FILE"), 0, N_("embed FILE as an early config"), 0}, /* TRANSLATORS: "embed" is a verb (command description). "*/ @@ -117,6 +118,7 @@ struct arguments char *dir; char *prefix; char *memdisk; + char *dtb; char **pubkeys; size_t npubkeys; char *font; @@ -176,6 +178,13 @@ argp_parser (int key, char *arg, struct argp_state *state) arguments->prefix = xstrdup ("(memdisk)/boot/grub"); break; + case 'D': + if (arguments->dtb) + free (arguments->dtb); + + arguments->dtb = xstrdup (arg); + break; + case 'k': arguments->pubkeys = xrealloc (arguments->pubkeys, sizeof (arguments->pubkeys[0]) @@ -300,7 +309,7 @@ main (int argc, char *argv[]) arguments.memdisk, arguments.pubkeys, arguments.npubkeys, arguments.config, arguments.image_target, arguments.note, - arguments.comp); + arguments.comp, arguments.dtb); grub_util_file_sync (fp); fclose (fp); diff --git a/util/mkimage.c b/util/mkimage.c index 6aa77ed73..e22d82afa 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -777,13 +777,12 @@ grub_install_generate_image (const char *dir, const char *prefix, char *memdisk_path, char **pubkey_paths, size_t npubkeys, char *config_path, const struct grub_install_image_target_desc *image_target, - int note, - grub_compression_t comp) + int note, grub_compression_t comp, const char *dtb_path) { char *kernel_img, *core_img; size_t total_module_size, core_size; size_t memdisk_size = 0, config_size = 0; - size_t prefix_size = 0; + size_t prefix_size = 0, dtb_size = 0; char *kernel_path; size_t offset; struct grub_util_path_list *path_list, *p; @@ -828,6 +827,12 @@ grub_install_generate_image (const char *dir, const char *prefix, total_module_size += memdisk_size + sizeof (struct grub_module_header); } + if (dtb_path) + { + dtb_size = ALIGN_UP(grub_util_get_image_size (dtb_path), 4); + total_module_size += dtb_size + sizeof (struct grub_module_header); + } + if (config_path) { config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1); @@ -950,6 +955,19 @@ grub_install_generate_image (const char *dir, const char *prefix, offset += memdisk_size; } + if (dtb_path) + { + struct grub_module_header *header; + + header = (struct grub_module_header *) (kernel_img + offset); + header->type = grub_host_to_target32 (OBJ_TYPE_DTB); + header->size = grub_host_to_target32 (dtb_size + sizeof (*header)); + offset += sizeof (*header); + + grub_util_load_image (dtb_path, kernel_img + offset); + offset += dtb_size; + } + if (config_path) { struct grub_module_header *header; From 5a865b37866ee8cd64c080bc6fb1e537f8e2b3c6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:26:36 +0200 Subject: [PATCH 0687/1167] arm-coreboot: Support for vexpress timer. --- grub-core/kern/arm/coreboot/timer.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/grub-core/kern/arm/coreboot/timer.c b/grub-core/kern/arm/coreboot/timer.c index ebefb99d5..d97b844f8 100644 --- a/grub-core/kern/arm/coreboot/timer.c +++ b/grub-core/kern/arm/coreboot/timer.c @@ -21,6 +21,7 @@ #include #include #include +#include #include grub_uint64_t @@ -33,6 +34,39 @@ grub_uint32_t grub_arm_pfr1(void); static int have_timer = 0; +static volatile grub_uint32_t *sp804_regs; + +static grub_uint64_t +sp804_get_time_ms (void) +{ + static grub_uint32_t high, last_low; + grub_uint32_t low = ~sp804_regs[1]; + if (last_low > low) + high++; + last_low = low; + return grub_divmod64 ((((grub_uint64_t) high) << 32) | low, + 1000, 0); +} + +static grub_err_t +sp804_attach(const struct grub_fdtbus_dev *dev) +{ + if (have_timer) + return GRUB_ERR_NONE; + sp804_regs = grub_fdtbus_map_reg (dev, 0, 0); + if (!grub_fdtbus_is_mapping_valid (sp804_regs)) + return grub_error (GRUB_ERR_IO, "could not map sp804: %p", sp804_regs); + grub_install_get_time_ms (sp804_get_time_ms); + have_timer = 1; + return GRUB_ERR_NONE; +} + +struct grub_fdtbus_driver sp804 = +{ + .compatible = "arm,sp804", + .attach = sp804_attach +}; + static grub_uint32_t timer_frequency_in_khz; static grub_uint64_t @@ -58,6 +92,8 @@ try_generic_timer (void) void grub_machine_timer_init (void) { + grub_fdtbus_register (&sp804); + if (!have_timer) try_generic_timer (); if (!have_timer) From ac6b41b89fbb82a3ba843a7ed19115d81432b604 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:29:48 +0200 Subject: [PATCH 0688/1167] arm-coreboot: Export FDT routines. We need to use them from modules as well. --- grub-core/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index fc6ca3051..147e6959c 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -246,7 +246,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h endif if COND_arm_efi From 216950a4eea1a1ead1c28eaca94e34ea2ef2ad19 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:41:22 +0200 Subject: [PATCH 0689/1167] at_keyboard: Split protocol from controller code. On vexpress controller is different but protocol is the same, so reuse the code. --- grub-core/Makefile.core.def | 3 + grub-core/term/at_keyboard.c | 426 +++-------------------------------- grub-core/term/ps2.c | 387 +++++++++++++++++++++++++++++++ include/grub/at_keyboard.h | 4 - include/grub/ps2.h | 43 ++++ 5 files changed, 462 insertions(+), 401 deletions(-) create mode 100644 grub-core/term/ps2.c create mode 100644 include/grub/ps2.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 77d0b019e..6ade6e950 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -251,6 +251,7 @@ kernel = { mips_qemu_mips = term/ns8250.c; mips_qemu_mips = term/serial.c; mips_qemu_mips = term/at_keyboard.c; + mips_qemu_mips = term/ps2.c; mips_qemu_mips = commands/boot.c; mips_qemu_mips = commands/keylayouts.c; mips_qemu_mips = term/i386/pc/vga_text.c; @@ -266,6 +267,7 @@ kernel = { mips_loongson = bus/pci.c; mips_loongson = kern/mips/loongson/init.c; mips_loongson = term/at_keyboard.c; + mips_loongson = term/ps2.c; mips_loongson = commands/boot.c; mips_loongson = term/serial.c; mips_loongson = video/sm712.c; @@ -1887,6 +1889,7 @@ module = { module = { name = at_keyboard; common = term/at_keyboard.c; + common = term/ps2.c; enable = x86; }; diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index b4ea9ff7e..3ab4e205f 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -22,212 +22,21 @@ #include #include #include -#include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -static short at_keyboard_status = 0; -static int e0_received = 0; -static int f0_received = 0; - -static grub_uint8_t led_status; - -#define KEYBOARD_LED_SCROLL (1 << 0) -#define KEYBOARD_LED_NUM (1 << 1) -#define KEYBOARD_LED_CAPS (1 << 2) - static grub_uint8_t grub_keyboard_controller_orig; static grub_uint8_t grub_keyboard_orig_set; -static grub_uint8_t current_set; +struct grub_ps2_state ps2_state; + +static int ping_sent; static void grub_keyboard_controller_init (void); -static const grub_uint8_t set1_mapping[128] = - { - /* 0x00 */ 0 /* Unused */, GRUB_KEYBOARD_KEY_ESCAPE, - /* 0x02 */ GRUB_KEYBOARD_KEY_1, GRUB_KEYBOARD_KEY_2, - /* 0x04 */ GRUB_KEYBOARD_KEY_3, GRUB_KEYBOARD_KEY_4, - /* 0x06 */ GRUB_KEYBOARD_KEY_5, GRUB_KEYBOARD_KEY_6, - /* 0x08 */ GRUB_KEYBOARD_KEY_7, GRUB_KEYBOARD_KEY_8, - /* 0x0a */ GRUB_KEYBOARD_KEY_9, GRUB_KEYBOARD_KEY_0, - /* 0x0c */ GRUB_KEYBOARD_KEY_DASH, GRUB_KEYBOARD_KEY_EQUAL, - /* 0x0e */ GRUB_KEYBOARD_KEY_BACKSPACE, GRUB_KEYBOARD_KEY_TAB, - /* 0x10 */ GRUB_KEYBOARD_KEY_Q, GRUB_KEYBOARD_KEY_W, - /* 0x12 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_R, - /* 0x14 */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_Y, - /* 0x16 */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_I, - /* 0x18 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_P, - /* 0x1a */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_RBRACKET, - /* 0x1c */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_LEFT_CTRL, - /* 0x1e */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_S, - /* 0x20 */ GRUB_KEYBOARD_KEY_D, GRUB_KEYBOARD_KEY_F, - /* 0x22 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_H, - /* 0x24 */ GRUB_KEYBOARD_KEY_J, GRUB_KEYBOARD_KEY_K, - /* 0x26 */ GRUB_KEYBOARD_KEY_L, GRUB_KEYBOARD_KEY_SEMICOLON, - /* 0x28 */ GRUB_KEYBOARD_KEY_DQUOTE, GRUB_KEYBOARD_KEY_RQUOTE, - /* 0x2a */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, GRUB_KEYBOARD_KEY_BACKSLASH, - /* 0x2c */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_X, - /* 0x2e */ GRUB_KEYBOARD_KEY_C, GRUB_KEYBOARD_KEY_V, - /* 0x30 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_N, - /* 0x32 */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_COMMA, - /* 0x34 */ GRUB_KEYBOARD_KEY_DOT, GRUB_KEYBOARD_KEY_SLASH, - /* 0x36 */ GRUB_KEYBOARD_KEY_RIGHT_SHIFT, GRUB_KEYBOARD_KEY_NUMMUL, - /* 0x38 */ GRUB_KEYBOARD_KEY_LEFT_ALT, GRUB_KEYBOARD_KEY_SPACE, - /* 0x3a */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_F1, - /* 0x3c */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F3, - /* 0x3e */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_F5, - /* 0x40 */ GRUB_KEYBOARD_KEY_F6, GRUB_KEYBOARD_KEY_F7, - /* 0x42 */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F9, - /* 0x44 */ GRUB_KEYBOARD_KEY_F10, GRUB_KEYBOARD_KEY_NUM_LOCK, - /* 0x46 */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, GRUB_KEYBOARD_KEY_NUM7, - /* 0x48 */ GRUB_KEYBOARD_KEY_NUM8, GRUB_KEYBOARD_KEY_NUM9, - /* 0x4a */ GRUB_KEYBOARD_KEY_NUMMINUS, GRUB_KEYBOARD_KEY_NUM4, - /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6, - /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1, - /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3, - /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, - /* 0x54 */ 0, 0, - /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11, - /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0, - /* 0x5a */ 0, 0, - /* 0x5c */ 0, 0, - /* 0x5e */ 0, 0, - /* 0x60 */ 0, 0, - /* 0x62 */ 0, 0, - /* OLPC keys. Just mapped to normal keys. */ - /* 0x64 */ 0, GRUB_KEYBOARD_KEY_UP, - /* 0x66 */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_LEFT, - /* 0x68 */ GRUB_KEYBOARD_KEY_RIGHT, 0, - /* 0x6a */ 0, 0, - /* 0x6c */ 0, 0, - /* 0x6e */ 0, 0, - /* 0x70 */ 0, 0, - /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO, - /* 0x74 */ 0, 0, - /* 0x76 */ 0, 0, - /* 0x78 */ 0, 0, - /* 0x7a */ 0, 0, - /* 0x7c */ 0, GRUB_KEYBOARD_KEY_JP_YEN, - /* 0x7e */ GRUB_KEYBOARD_KEY_KPCOMMA - }; - -static const struct -{ - grub_uint8_t from, to; -} set1_e0_mapping[] = - { - {0x1c, GRUB_KEYBOARD_KEY_NUMENTER}, - {0x1d, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, - {0x35, GRUB_KEYBOARD_KEY_NUMSLASH }, - {0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT}, - {0x47, GRUB_KEYBOARD_KEY_HOME}, - {0x48, GRUB_KEYBOARD_KEY_UP}, - {0x49, GRUB_KEYBOARD_KEY_PPAGE}, - {0x4b, GRUB_KEYBOARD_KEY_LEFT}, - {0x4d, GRUB_KEYBOARD_KEY_RIGHT}, - {0x4f, GRUB_KEYBOARD_KEY_END}, - {0x50, GRUB_KEYBOARD_KEY_DOWN}, - {0x51, GRUB_KEYBOARD_KEY_NPAGE}, - {0x52, GRUB_KEYBOARD_KEY_INSERT}, - {0x53, GRUB_KEYBOARD_KEY_DELETE}, - }; - -static const grub_uint8_t set2_mapping[256] = - { - /* 0x00 */ 0, GRUB_KEYBOARD_KEY_F9, - /* 0x02 */ 0, GRUB_KEYBOARD_KEY_F5, - /* 0x04 */ GRUB_KEYBOARD_KEY_F3, GRUB_KEYBOARD_KEY_F1, - /* 0x06 */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F12, - /* 0x08 */ 0, GRUB_KEYBOARD_KEY_F10, - /* 0x0a */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F6, - /* 0x0c */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_TAB, - /* 0x0e */ GRUB_KEYBOARD_KEY_RQUOTE, 0, - /* 0x10 */ 0, GRUB_KEYBOARD_KEY_LEFT_ALT, - /* 0x12 */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, 0, - /* 0x14 */ GRUB_KEYBOARD_KEY_LEFT_CTRL, GRUB_KEYBOARD_KEY_Q, - /* 0x16 */ GRUB_KEYBOARD_KEY_1, 0, - /* 0x18 */ 0, 0, - /* 0x1a */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_S, - /* 0x1c */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_W, - /* 0x1e */ GRUB_KEYBOARD_KEY_2, 0, - /* 0x20 */ 0, GRUB_KEYBOARD_KEY_C, - /* 0x22 */ GRUB_KEYBOARD_KEY_X, GRUB_KEYBOARD_KEY_D, - /* 0x24 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_4, - /* 0x26 */ GRUB_KEYBOARD_KEY_3, 0, - /* 0x28 */ 0, GRUB_KEYBOARD_KEY_SPACE, - /* 0x2a */ GRUB_KEYBOARD_KEY_V, GRUB_KEYBOARD_KEY_F, - /* 0x2c */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_R, - /* 0x2e */ GRUB_KEYBOARD_KEY_5, 0, - /* 0x30 */ 0, GRUB_KEYBOARD_KEY_N, - /* 0x32 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_H, - /* 0x34 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_Y, - /* 0x36 */ GRUB_KEYBOARD_KEY_6, 0, - /* 0x38 */ 0, 0, - /* 0x3a */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_J, - /* 0x3c */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_7, - /* 0x3e */ GRUB_KEYBOARD_KEY_8, 0, - /* 0x40 */ 0, GRUB_KEYBOARD_KEY_COMMA, - /* 0x42 */ GRUB_KEYBOARD_KEY_K, GRUB_KEYBOARD_KEY_I, - /* 0x44 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_0, - /* 0x46 */ GRUB_KEYBOARD_KEY_9, 0, - /* 0x48 */ 0, GRUB_KEYBOARD_KEY_DOT, - /* 0x4a */ GRUB_KEYBOARD_KEY_SLASH, GRUB_KEYBOARD_KEY_L, - /* 0x4c */ GRUB_KEYBOARD_KEY_SEMICOLON, GRUB_KEYBOARD_KEY_P, - /* 0x4e */ GRUB_KEYBOARD_KEY_DASH, 0, - /* 0x50 */ 0, GRUB_KEYBOARD_KEY_JP_RO, - /* 0x52 */ GRUB_KEYBOARD_KEY_DQUOTE, 0, - /* 0x54 */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_EQUAL, - /* 0x56 */ 0, 0, - /* 0x58 */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_RIGHT_SHIFT, - /* 0x5a */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_RBRACKET, - /* 0x5c */ 0, GRUB_KEYBOARD_KEY_BACKSLASH, - /* 0x5e */ 0, 0, - /* 0x60 */ 0, GRUB_KEYBOARD_KEY_102ND, - /* 0x62 */ 0, 0, - /* 0x64 */ 0, 0, - /* 0x66 */ GRUB_KEYBOARD_KEY_BACKSPACE, 0, - /* 0x68 */ 0, GRUB_KEYBOARD_KEY_NUM1, - /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4, - /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA, - /* 0x6e */ 0, 0, - /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, - /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5, - /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8, - /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK, - /* 0x78 */ GRUB_KEYBOARD_KEY_F11, GRUB_KEYBOARD_KEY_NUMPLUS, - /* 0x7a */ GRUB_KEYBOARD_KEY_NUM3, GRUB_KEYBOARD_KEY_NUMMINUS, - /* 0x7c */ GRUB_KEYBOARD_KEY_NUMMUL, GRUB_KEYBOARD_KEY_NUM9, - /* 0x7e */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, 0, - /* 0x80 */ 0, 0, - /* 0x82 */ 0, GRUB_KEYBOARD_KEY_F7, - }; - -static const struct -{ - grub_uint8_t from, to; -} set2_e0_mapping[] = - { - {0x11, GRUB_KEYBOARD_KEY_RIGHT_ALT}, - {0x14, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, - {0x4a, GRUB_KEYBOARD_KEY_NUMSLASH}, - {0x5a, GRUB_KEYBOARD_KEY_NUMENTER}, - {0x69, GRUB_KEYBOARD_KEY_END}, - {0x6b, GRUB_KEYBOARD_KEY_LEFT}, - {0x6c, GRUB_KEYBOARD_KEY_HOME}, - {0x70, GRUB_KEYBOARD_KEY_INSERT}, - {0x71, GRUB_KEYBOARD_KEY_DELETE}, - {0x72, GRUB_KEYBOARD_KEY_DOWN}, - {0x74, GRUB_KEYBOARD_KEY_RIGHT}, - {0x75, GRUB_KEYBOARD_KEY_UP}, - {0x7a, GRUB_KEYBOARD_KEY_NPAGE}, - {0x7d, GRUB_KEYBOARD_KEY_PPAGE}, - }; - -static int ping_sent; - static void keyboard_controller_wait_until_ready (void) { @@ -350,12 +159,12 @@ set_scancodes (void) if (!grub_keyboard_orig_set) { grub_dprintf ("atkeyb", "No sets support assumed\n"); - current_set = 1; + ps2_state.current_set = 1; return; } #if !USE_SCANCODE_SET - current_set = 1; + ps2_state.current_set = 1; return; #else @@ -363,15 +172,15 @@ set_scancodes (void) & ~KEYBOARD_AT_TRANSLATE); write_mode (2); - current_set = query_mode (); - grub_dprintf ("atkeyb", "returned set %d\n", current_set); - if (current_set == 2) + ps2_state.current_set = query_mode (); + grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); + if (ps2_state.current_set == 2) return; write_mode (1); - current_set = query_mode (); - grub_dprintf ("atkeyb", "returned set %d\n", current_set); - if (current_set == 1) + ps2_state.current_set = query_mode (); + grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); + if (ps2_state.current_set == 1) return; grub_dprintf ("atkeyb", "no supported scancode set found\n"); #endif @@ -386,164 +195,10 @@ keyboard_controller_led (grub_uint8_t leds) grub_outb (leds & 0x7, KEYBOARD_REG_DATA); } -static int -fetch_key (int *is_break) -{ - int was_ext = 0; - grub_uint8_t at_key; - int ret = 0; - - if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) - return -1; - at_key = grub_inb (KEYBOARD_REG_DATA); - /* May happen if no keyboard is connected. Just ignore this. */ - if (at_key == 0xff) - return -1; - if (at_key == 0xe0) - { - e0_received = 1; - return -1; - } - - if ((current_set == 2 || current_set == 3) && at_key == 0xf0) - { - f0_received = 1; - return -1; - } - - /* Setting LEDs may generate ACKs. */ - if (at_key == GRUB_AT_ACK) - return -1; - - was_ext = e0_received; - e0_received = 0; - - switch (current_set) - { - case 1: - *is_break = !!(at_key & 0x80); - if (!was_ext) - ret = set1_mapping[at_key & 0x7f]; - else - { - unsigned i; - for (i = 0; i < ARRAY_SIZE (set1_e0_mapping); i++) - if (set1_e0_mapping[i].from == (at_key & 0x7f)) - { - ret = set1_e0_mapping[i].to; - break; - } - } - break; - case 2: - *is_break = f0_received; - f0_received = 0; - if (!was_ext) - ret = set2_mapping[at_key]; - else - { - unsigned i; - for (i = 0; i < ARRAY_SIZE (set2_e0_mapping); i++) - if (set2_e0_mapping[i].from == at_key) - { - ret = set2_e0_mapping[i].to; - break; - } - } - break; - default: - return -1; - } - if (!ret) - { - if (was_ext) - grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n", - at_key, current_set); - else - grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n", - at_key, current_set); - return -1; - } - return ret; -} - -/* FIXME: This should become an interrupt service routine. For now - it's just used to catch events from control keys. */ -static int -grub_keyboard_isr (grub_keyboard_key_t key, int is_break) -{ - if (!is_break) - switch (key) - { - case GRUB_KEYBOARD_KEY_LEFT_SHIFT: - at_keyboard_status |= GRUB_TERM_STATUS_LSHIFT; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: - at_keyboard_status |= GRUB_TERM_STATUS_RSHIFT; - return 1; - case GRUB_KEYBOARD_KEY_LEFT_CTRL: - at_keyboard_status |= GRUB_TERM_STATUS_LCTRL; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_CTRL: - at_keyboard_status |= GRUB_TERM_STATUS_RCTRL; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_ALT: - at_keyboard_status |= GRUB_TERM_STATUS_RALT; - return 1; - case GRUB_KEYBOARD_KEY_LEFT_ALT: - at_keyboard_status |= GRUB_TERM_STATUS_LALT; - return 1; - default: - return 0; - } - else - switch (key) - { - case GRUB_KEYBOARD_KEY_LEFT_SHIFT: - at_keyboard_status &= ~GRUB_TERM_STATUS_LSHIFT; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: - at_keyboard_status &= ~GRUB_TERM_STATUS_RSHIFT; - return 1; - case GRUB_KEYBOARD_KEY_LEFT_CTRL: - at_keyboard_status &= ~GRUB_TERM_STATUS_LCTRL; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_CTRL: - at_keyboard_status &= ~GRUB_TERM_STATUS_RCTRL; - return 1; - case GRUB_KEYBOARD_KEY_RIGHT_ALT: - at_keyboard_status &= ~GRUB_TERM_STATUS_RALT; - return 1; - case GRUB_KEYBOARD_KEY_LEFT_ALT: - at_keyboard_status &= ~GRUB_TERM_STATUS_LALT; - return 1; - default: - return 0; - } -} - -/* If there is a raw key pending, return it; otherwise return -1. */ -static int -grub_keyboard_getkey (void) -{ - int key; - int is_break = 0; - - key = fetch_key (&is_break); - if (key == -1) - return -1; - - if (grub_keyboard_isr (key, is_break)) - return -1; - if (is_break) - return -1; - return key; -} - int grub_at_keyboard_is_alive (void) { - if (current_set != 0) + if (ps2_state.current_set != 0) return 1; if (ping_sent && KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)) @@ -566,51 +221,28 @@ grub_at_keyboard_is_alive (void) static int grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) { - int code; + grub_uint8_t at_key; + int ret; + grub_uint8_t old_led; if (!grub_at_keyboard_is_alive ()) return GRUB_TERM_NO_KEY; - code = grub_keyboard_getkey (); - if (code == -1) - return GRUB_TERM_NO_KEY; -#ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "Detected key 0x%x\n", code); -#endif - switch (code) - { - case GRUB_KEYBOARD_KEY_CAPS_LOCK: - at_keyboard_status ^= GRUB_TERM_STATUS_CAPS; - led_status ^= KEYBOARD_LED_CAPS; - keyboard_controller_led (led_status); + if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) + return -1; + at_key = grub_inb (KEYBOARD_REG_DATA); + old_led = ps2_state.led_status; -#ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & GRUB_KEYBOARD_STATUS_CAPS_LOCK)); -#endif - return GRUB_TERM_NO_KEY; - case GRUB_KEYBOARD_KEY_NUM_LOCK: - at_keyboard_status ^= GRUB_TERM_STATUS_NUM; - led_status ^= KEYBOARD_LED_NUM; - keyboard_controller_led (led_status); - -#ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "num_lock = %d\n", !!(at_keyboard_status & GRUB_KEYBOARD_STATUS_NUM_LOCK)); -#endif - return GRUB_TERM_NO_KEY; - case GRUB_KEYBOARD_KEY_SCROLL_LOCK: - at_keyboard_status ^= GRUB_TERM_STATUS_SCROLL; - led_status ^= KEYBOARD_LED_SCROLL; - keyboard_controller_led (led_status); - return GRUB_TERM_NO_KEY; - default: - return grub_term_map_key (code, at_keyboard_status); - } + ret = grub_ps2_process_incoming_byte (&ps2_state, at_key); + if (old_led != ps2_state.led_status) + keyboard_controller_led (ps2_state.led_status); + return ret; } static void grub_keyboard_controller_init (void) { - at_keyboard_status = 0; + ps2_state.at_keyboard_status = 0; /* Drain input buffer. */ while (1) { @@ -632,13 +264,13 @@ grub_keyboard_controller_init (void) grub_keyboard_orig_set = query_mode (); #endif set_scancodes (); - keyboard_controller_led (led_status); + keyboard_controller_led (ps2_state.led_status); } static grub_err_t grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused))) { - if (current_set == 0) + if (ps2_state.current_set == 0) return GRUB_ERR_NONE; if (grub_keyboard_orig_set) write_mode (grub_keyboard_orig_set); @@ -655,7 +287,7 @@ grub_at_fini_hw (int noreturn __attribute__ ((unused))) static grub_err_t grub_at_restore_hw (void) { - if (current_set == 0) + if (ps2_state.current_set == 0) return GRUB_ERR_NONE; /* Drain input buffer. */ @@ -668,7 +300,7 @@ grub_at_restore_hw (void) grub_inb (KEYBOARD_REG_DATA); } set_scancodes (); - keyboard_controller_led (led_status); + keyboard_controller_led (ps2_state.led_status); return GRUB_ERR_NONE; } diff --git a/grub-core/term/ps2.c b/grub-core/term/ps2.c new file mode 100644 index 000000000..7ae4e9f2f --- /dev/null +++ b/grub-core/term/ps2.c @@ -0,0 +1,387 @@ +/* + * 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 . + */ + +#include +#include +#include +#include +#include + +#define KEYBOARD_LED_SCROLL (1 << 0) +#define KEYBOARD_LED_NUM (1 << 1) +#define KEYBOARD_LED_CAPS (1 << 2) + +static const grub_uint8_t set1_mapping[128] = + { + /* 0x00 */ 0 /* Unused */, GRUB_KEYBOARD_KEY_ESCAPE, + /* 0x02 */ GRUB_KEYBOARD_KEY_1, GRUB_KEYBOARD_KEY_2, + /* 0x04 */ GRUB_KEYBOARD_KEY_3, GRUB_KEYBOARD_KEY_4, + /* 0x06 */ GRUB_KEYBOARD_KEY_5, GRUB_KEYBOARD_KEY_6, + /* 0x08 */ GRUB_KEYBOARD_KEY_7, GRUB_KEYBOARD_KEY_8, + /* 0x0a */ GRUB_KEYBOARD_KEY_9, GRUB_KEYBOARD_KEY_0, + /* 0x0c */ GRUB_KEYBOARD_KEY_DASH, GRUB_KEYBOARD_KEY_EQUAL, + /* 0x0e */ GRUB_KEYBOARD_KEY_BACKSPACE, GRUB_KEYBOARD_KEY_TAB, + /* 0x10 */ GRUB_KEYBOARD_KEY_Q, GRUB_KEYBOARD_KEY_W, + /* 0x12 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_R, + /* 0x14 */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_Y, + /* 0x16 */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_I, + /* 0x18 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_P, + /* 0x1a */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_RBRACKET, + /* 0x1c */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_LEFT_CTRL, + /* 0x1e */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_S, + /* 0x20 */ GRUB_KEYBOARD_KEY_D, GRUB_KEYBOARD_KEY_F, + /* 0x22 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_H, + /* 0x24 */ GRUB_KEYBOARD_KEY_J, GRUB_KEYBOARD_KEY_K, + /* 0x26 */ GRUB_KEYBOARD_KEY_L, GRUB_KEYBOARD_KEY_SEMICOLON, + /* 0x28 */ GRUB_KEYBOARD_KEY_DQUOTE, GRUB_KEYBOARD_KEY_RQUOTE, + /* 0x2a */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, GRUB_KEYBOARD_KEY_BACKSLASH, + /* 0x2c */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_X, + /* 0x2e */ GRUB_KEYBOARD_KEY_C, GRUB_KEYBOARD_KEY_V, + /* 0x30 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_N, + /* 0x32 */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_COMMA, + /* 0x34 */ GRUB_KEYBOARD_KEY_DOT, GRUB_KEYBOARD_KEY_SLASH, + /* 0x36 */ GRUB_KEYBOARD_KEY_RIGHT_SHIFT, GRUB_KEYBOARD_KEY_NUMMUL, + /* 0x38 */ GRUB_KEYBOARD_KEY_LEFT_ALT, GRUB_KEYBOARD_KEY_SPACE, + /* 0x3a */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_F1, + /* 0x3c */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F3, + /* 0x3e */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_F5, + /* 0x40 */ GRUB_KEYBOARD_KEY_F6, GRUB_KEYBOARD_KEY_F7, + /* 0x42 */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F9, + /* 0x44 */ GRUB_KEYBOARD_KEY_F10, GRUB_KEYBOARD_KEY_NUM_LOCK, + /* 0x46 */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, GRUB_KEYBOARD_KEY_NUM7, + /* 0x48 */ GRUB_KEYBOARD_KEY_NUM8, GRUB_KEYBOARD_KEY_NUM9, + /* 0x4a */ GRUB_KEYBOARD_KEY_NUMMINUS, GRUB_KEYBOARD_KEY_NUM4, + /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6, + /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1, + /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3, + /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, + /* 0x54 */ 0, 0, + /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11, + /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0, + /* 0x5a */ 0, 0, + /* 0x5c */ 0, 0, + /* 0x5e */ 0, 0, + /* 0x60 */ 0, 0, + /* 0x62 */ 0, 0, + /* OLPC keys. Just mapped to normal keys. */ + /* 0x64 */ 0, GRUB_KEYBOARD_KEY_UP, + /* 0x66 */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_LEFT, + /* 0x68 */ GRUB_KEYBOARD_KEY_RIGHT, 0, + /* 0x6a */ 0, 0, + /* 0x6c */ 0, 0, + /* 0x6e */ 0, 0, + /* 0x70 */ 0, 0, + /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO, + /* 0x74 */ 0, 0, + /* 0x76 */ 0, 0, + /* 0x78 */ 0, 0, + /* 0x7a */ 0, 0, + /* 0x7c */ 0, GRUB_KEYBOARD_KEY_JP_YEN, + /* 0x7e */ GRUB_KEYBOARD_KEY_KPCOMMA + }; + +static const struct +{ + grub_uint8_t from, to; +} set1_e0_mapping[] = + { + {0x1c, GRUB_KEYBOARD_KEY_NUMENTER}, + {0x1d, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, + {0x35, GRUB_KEYBOARD_KEY_NUMSLASH }, + {0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT}, + {0x47, GRUB_KEYBOARD_KEY_HOME}, + {0x48, GRUB_KEYBOARD_KEY_UP}, + {0x49, GRUB_KEYBOARD_KEY_PPAGE}, + {0x4b, GRUB_KEYBOARD_KEY_LEFT}, + {0x4d, GRUB_KEYBOARD_KEY_RIGHT}, + {0x4f, GRUB_KEYBOARD_KEY_END}, + {0x50, GRUB_KEYBOARD_KEY_DOWN}, + {0x51, GRUB_KEYBOARD_KEY_NPAGE}, + {0x52, GRUB_KEYBOARD_KEY_INSERT}, + {0x53, GRUB_KEYBOARD_KEY_DELETE}, + }; + +static const grub_uint8_t set2_mapping[256] = + { + /* 0x00 */ 0, GRUB_KEYBOARD_KEY_F9, + /* 0x02 */ 0, GRUB_KEYBOARD_KEY_F5, + /* 0x04 */ GRUB_KEYBOARD_KEY_F3, GRUB_KEYBOARD_KEY_F1, + /* 0x06 */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F12, + /* 0x08 */ 0, GRUB_KEYBOARD_KEY_F10, + /* 0x0a */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F6, + /* 0x0c */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_TAB, + /* 0x0e */ GRUB_KEYBOARD_KEY_RQUOTE, 0, + /* 0x10 */ 0, GRUB_KEYBOARD_KEY_LEFT_ALT, + /* 0x12 */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, 0, + /* 0x14 */ GRUB_KEYBOARD_KEY_LEFT_CTRL, GRUB_KEYBOARD_KEY_Q, + /* 0x16 */ GRUB_KEYBOARD_KEY_1, 0, + /* 0x18 */ 0, 0, + /* 0x1a */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_S, + /* 0x1c */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_W, + /* 0x1e */ GRUB_KEYBOARD_KEY_2, 0, + /* 0x20 */ 0, GRUB_KEYBOARD_KEY_C, + /* 0x22 */ GRUB_KEYBOARD_KEY_X, GRUB_KEYBOARD_KEY_D, + /* 0x24 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_4, + /* 0x26 */ GRUB_KEYBOARD_KEY_3, 0, + /* 0x28 */ 0, GRUB_KEYBOARD_KEY_SPACE, + /* 0x2a */ GRUB_KEYBOARD_KEY_V, GRUB_KEYBOARD_KEY_F, + /* 0x2c */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_R, + /* 0x2e */ GRUB_KEYBOARD_KEY_5, 0, + /* 0x30 */ 0, GRUB_KEYBOARD_KEY_N, + /* 0x32 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_H, + /* 0x34 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_Y, + /* 0x36 */ GRUB_KEYBOARD_KEY_6, 0, + /* 0x38 */ 0, 0, + /* 0x3a */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_J, + /* 0x3c */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_7, + /* 0x3e */ GRUB_KEYBOARD_KEY_8, 0, + /* 0x40 */ 0, GRUB_KEYBOARD_KEY_COMMA, + /* 0x42 */ GRUB_KEYBOARD_KEY_K, GRUB_KEYBOARD_KEY_I, + /* 0x44 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_0, + /* 0x46 */ GRUB_KEYBOARD_KEY_9, 0, + /* 0x48 */ 0, GRUB_KEYBOARD_KEY_DOT, + /* 0x4a */ GRUB_KEYBOARD_KEY_SLASH, GRUB_KEYBOARD_KEY_L, + /* 0x4c */ GRUB_KEYBOARD_KEY_SEMICOLON, GRUB_KEYBOARD_KEY_P, + /* 0x4e */ GRUB_KEYBOARD_KEY_DASH, 0, + /* 0x50 */ 0, GRUB_KEYBOARD_KEY_JP_RO, + /* 0x52 */ GRUB_KEYBOARD_KEY_DQUOTE, 0, + /* 0x54 */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_EQUAL, + /* 0x56 */ 0, 0, + /* 0x58 */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_RIGHT_SHIFT, + /* 0x5a */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_RBRACKET, + /* 0x5c */ 0, GRUB_KEYBOARD_KEY_BACKSLASH, + /* 0x5e */ 0, 0, + /* 0x60 */ 0, GRUB_KEYBOARD_KEY_102ND, + /* 0x62 */ 0, 0, + /* 0x64 */ 0, 0, + /* 0x66 */ GRUB_KEYBOARD_KEY_BACKSPACE, 0, + /* 0x68 */ 0, GRUB_KEYBOARD_KEY_NUM1, + /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4, + /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA, + /* 0x6e */ 0, 0, + /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, + /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5, + /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8, + /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK, + /* 0x78 */ GRUB_KEYBOARD_KEY_F11, GRUB_KEYBOARD_KEY_NUMPLUS, + /* 0x7a */ GRUB_KEYBOARD_KEY_NUM3, GRUB_KEYBOARD_KEY_NUMMINUS, + /* 0x7c */ GRUB_KEYBOARD_KEY_NUMMUL, GRUB_KEYBOARD_KEY_NUM9, + /* 0x7e */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, 0, + /* 0x80 */ 0, 0, + /* 0x82 */ 0, GRUB_KEYBOARD_KEY_F7, + }; + +static const struct +{ + grub_uint8_t from, to; +} set2_e0_mapping[] = + { + {0x11, GRUB_KEYBOARD_KEY_RIGHT_ALT}, + {0x14, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, + {0x4a, GRUB_KEYBOARD_KEY_NUMSLASH}, + {0x5a, GRUB_KEYBOARD_KEY_NUMENTER}, + {0x69, GRUB_KEYBOARD_KEY_END}, + {0x6b, GRUB_KEYBOARD_KEY_LEFT}, + {0x6c, GRUB_KEYBOARD_KEY_HOME}, + {0x70, GRUB_KEYBOARD_KEY_INSERT}, + {0x71, GRUB_KEYBOARD_KEY_DELETE}, + {0x72, GRUB_KEYBOARD_KEY_DOWN}, + {0x74, GRUB_KEYBOARD_KEY_RIGHT}, + {0x75, GRUB_KEYBOARD_KEY_UP}, + {0x7a, GRUB_KEYBOARD_KEY_NPAGE}, + {0x7d, GRUB_KEYBOARD_KEY_PPAGE}, + }; + +static int +fetch_key (struct grub_ps2_state *ps2_state, grub_uint8_t at_key, int *is_break) +{ + int was_ext = 0; + int ret = 0; + + /* May happen if no keyboard is connected. Just ignore this. */ + if (at_key == 0xff) + return -1; + if (at_key == 0xe0) + { + ps2_state->e0_received = 1; + return -1; + } + + if ((ps2_state->current_set == 2 || ps2_state->current_set == 3) && at_key == 0xf0) + { + ps2_state->f0_received = 1; + return -1; + } + + /* Setting LEDs may generate ACKs. */ + if (at_key == GRUB_AT_ACK) + return -1; + + was_ext = ps2_state->e0_received; + ps2_state->e0_received = 0; + + switch (ps2_state->current_set) + { + case 1: + *is_break = !!(at_key & 0x80); + if (!was_ext) + ret = set1_mapping[at_key & 0x7f]; + else + { + unsigned i; + for (i = 0; i < ARRAY_SIZE (set1_e0_mapping); i++) + if (set1_e0_mapping[i].from == (at_key & 0x7f)) + { + ret = set1_e0_mapping[i].to; + break; + } + } + break; + case 2: + *is_break = ps2_state->f0_received; + ps2_state->f0_received = 0; + if (!was_ext) + ret = set2_mapping[at_key]; + else + { + unsigned i; + for (i = 0; i < ARRAY_SIZE (set2_e0_mapping); i++) + if (set2_e0_mapping[i].from == at_key) + { + ret = set2_e0_mapping[i].to; + break; + } + } + break; + default: + return -1; + } + if (!ret) + { + if (was_ext) + grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n", + at_key, ps2_state->current_set); + else + grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n", + at_key, ps2_state->current_set); + return -1; + } + return ret; +} + +/* FIXME: This should become an interrupt service routine. For now + it's just used to catch events from control keys. */ +static int +grub_keyboard_isr (struct grub_ps2_state *ps2_state, + grub_keyboard_key_t key, int is_break) +{ + if (!is_break) + switch (key) + { + case GRUB_KEYBOARD_KEY_LEFT_SHIFT: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LSHIFT; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RSHIFT; + return 1; + case GRUB_KEYBOARD_KEY_LEFT_CTRL: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LCTRL; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_CTRL: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RCTRL; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_ALT: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RALT; + return 1; + case GRUB_KEYBOARD_KEY_LEFT_ALT: + ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LALT; + return 1; + default: + return 0; + } + else + switch (key) + { + case GRUB_KEYBOARD_KEY_LEFT_SHIFT: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LSHIFT; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RSHIFT; + return 1; + case GRUB_KEYBOARD_KEY_LEFT_CTRL: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LCTRL; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_CTRL: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RCTRL; + return 1; + case GRUB_KEYBOARD_KEY_RIGHT_ALT: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RALT; + return 1; + case GRUB_KEYBOARD_KEY_LEFT_ALT: + ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LALT; + return 1; + default: + return 0; + } +} + +/* If there is a key pending, return it; otherwise return GRUB_TERM_NO_KEY. */ +int +grub_ps2_process_incoming_byte (struct grub_ps2_state *ps2_state, + grub_uint8_t at_key) +{ + int code; + int is_break = 0; + + code = fetch_key (ps2_state, at_key, &is_break); + if (code == -1) + return GRUB_TERM_NO_KEY; + + if (grub_keyboard_isr (ps2_state, code, is_break)) + return GRUB_TERM_NO_KEY; + if (is_break) + return GRUB_TERM_NO_KEY; +#ifdef DEBUG_AT_KEYBOARD + grub_dprintf ("atkeyb", "Detected key 0x%x\n", code); +#endif + switch (code) + { + case GRUB_KEYBOARD_KEY_CAPS_LOCK: + ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_CAPS; + ps2_state->led_status ^= KEYBOARD_LED_CAPS; + +#ifdef DEBUG_AT_KEYBOARD + grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_CAPS_LOCK)); +#endif + return GRUB_TERM_NO_KEY; + case GRUB_KEYBOARD_KEY_NUM_LOCK: + ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_NUM; + ps2_state->led_status ^= KEYBOARD_LED_NUM; + +#ifdef DEBUG_AT_KEYBOARD + grub_dprintf ("atkeyb", "num_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_NUM_LOCK)); +#endif + return GRUB_TERM_NO_KEY; + case GRUB_KEYBOARD_KEY_SCROLL_LOCK: + ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_SCROLL; + ps2_state->led_status ^= KEYBOARD_LED_SCROLL; + return GRUB_TERM_NO_KEY; + default: + return grub_term_map_key (code, ps2_state->at_keyboard_status); + } +} diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h index b4f8ff0a0..b031523eb 100644 --- a/include/grub/at_keyboard.h +++ b/include/grub/at_keyboard.h @@ -27,10 +27,6 @@ #define KEYBOARD_AT_TRANSLATE 0x40 -#define GRUB_AT_ACK 0xfa -#define GRUB_AT_NACK 0xfe -#define GRUB_AT_TRIES 5 - #define KEYBOARD_ISMAKE(x) !((x) & 0x80) #define KEYBOARD_ISREADY(x) ((x) & 0x01) #define KEYBOARD_SCANCODE(x) ((x) & 0x7f) diff --git a/include/grub/ps2.h b/include/grub/ps2.h new file mode 100644 index 000000000..4f2e527e4 --- /dev/null +++ b/include/grub/ps2.h @@ -0,0 +1,43 @@ +/* + * 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 . + */ + +#ifndef GRUB_PS2_HEADER +#define GRUB_PS2_HEADER 1 + +#include + +#define GRUB_AT_ACK 0xfa +#define GRUB_AT_NACK 0xfe +#define GRUB_AT_TRIES 5 + +/* Make sure it's zeroed-out and set current_set at init. */ +struct grub_ps2_state +{ + int e0_received; + int f0_received; + grub_uint8_t led_status; + short at_keyboard_status; + grub_uint8_t current_set; +}; + +/* If there is a key pending, return it; otherwise return GRUB_TERM_NO_KEY. */ +int +grub_ps2_process_incoming_byte (struct grub_ps2_state *ps2_state, + grub_uint8_t data); + +#endif From 848bed9d92cf20e9f25db4c69a20efad23996ca0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:42:37 +0200 Subject: [PATCH 0690/1167] arm_coreboot: Support keyboard for vexpress. --- grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 3 + grub-core/kern/arm/coreboot/init.c | 1 + grub-core/term/arm/pl050.c | 189 +++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 grub-core/term/arm/pl050.c diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 147e6959c..a2aaf9f54 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -240,6 +240,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h endif if COND_arm_coreboot +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6ade6e950..6be6e7f61 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -160,6 +160,9 @@ kernel = { arm_coreboot = kern/arm/coreboot/coreboot.S; arm_coreboot = lib/fdt.c; arm_coreboot = bus/fdt.c; + arm_coreboot = term/ps2.c; + arm_coreboot = term/arm/pl050.c; + arm_coreboot = commands/keylayouts.c; terminfoinkernel = term/terminfo.c; terminfoinkernel = term/tparm.c; diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c index aec75c672..a06ccb72f 100644 --- a/grub-core/kern/arm/coreboot/init.c +++ b/grub-core/kern/arm/coreboot/init.c @@ -133,6 +133,7 @@ grub_machine_init (void) grub_fdtbus_init (dtb, dtb_size); grub_machine_timer_init (); + grub_pl050_init (); } void diff --git a/grub-core/term/arm/pl050.c b/grub-core/term/arm/pl050.c new file mode 100644 index 000000000..e4cda3056 --- /dev/null +++ b/grub-core/term/arm/pl050.c @@ -0,0 +1,189 @@ +/* + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static volatile grub_uint32_t *pl050_regs; + +struct grub_ps2_state ps2_state; + +static void +keyboard_controller_wait_until_ready (void) +{ + while (! (pl050_regs[1] & 0x40)); +} + +static grub_uint8_t +wait_ack (void) +{ + grub_uint64_t endtime; + grub_uint8_t ack; + + endtime = grub_get_time_ms () + 20; + do + ack = pl050_regs[2]; + while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK + && grub_get_time_ms () < endtime); + return ack; +} + + +static int +write_mode (int mode) +{ + unsigned i; + for (i = 0; i < GRUB_AT_TRIES; i++) + { + grub_uint8_t ack; + keyboard_controller_wait_until_ready (); + pl050_regs[2] = 0xf0; + keyboard_controller_wait_until_ready (); + pl050_regs[2] = mode; + keyboard_controller_wait_until_ready (); + ack = wait_ack (); + if (ack == GRUB_AT_NACK) + continue; + if (ack == GRUB_AT_ACK) + break; + return 0; + } + + return (i != GRUB_AT_TRIES); +} + +static int +query_mode (void) +{ + grub_uint8_t ret; + int e; + + e = write_mode (0); + if (!e) + return 0; + + keyboard_controller_wait_until_ready (); + + do + ret = pl050_regs[2]; + while (ret == GRUB_AT_ACK); + + /* QEMU translates the set even in no-translate mode. */ + if (ret == 0x43 || ret == 1) + return 1; + if (ret == 0x41 || ret == 2) + return 2; + if (ret == 0x3f || ret == 3) + return 3; + return 0; +} + +static void +set_scancodes (void) +{ + write_mode (2); + ps2_state.current_set = query_mode (); + grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); + if (ps2_state.current_set == 2) + return; + + write_mode (1); + ps2_state.current_set = query_mode (); + grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); + if (ps2_state.current_set == 1) + return; + grub_dprintf ("atkeyb", "no supported scancode set found\n"); +} + +static void +keyboard_controller_led (grub_uint8_t leds) +{ + keyboard_controller_wait_until_ready (); + pl050_regs[2] = 0xed; + keyboard_controller_wait_until_ready (); + pl050_regs[2] = leds & 0x7; +} + +/* If there is a character pending, return it; + otherwise return GRUB_TERM_NO_KEY. */ +static int +grub_pl050_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) +{ + grub_uint8_t at_key; + int ret; + grub_uint8_t old_led; + + if (!(pl050_regs[1] & 0x10)) + return -1; + at_key = pl050_regs[2]; + old_led = ps2_state.led_status; + + ret = grub_ps2_process_incoming_byte (&ps2_state, at_key); + if (old_led != ps2_state.led_status) + keyboard_controller_led (ps2_state.led_status); + return ret; +} + +static struct grub_term_input grub_pl050_keyboard_term = + { + .name = "pl050_keyboard", + .getkey = grub_pl050_keyboard_getkey + }; + +static grub_err_t +pl050_attach(const struct grub_fdtbus_dev *dev) +{ + const grub_uint32_t *reg; + reg = grub_fdtbus_get_prop (dev, "reg", 0); + + /* Mouse. Nothing to do. */ + if (grub_be_to_cpu32 (*reg) == 0x7000) + return 0; + + pl050_regs = grub_fdtbus_map_reg (dev, 0, 0); + + if (!grub_fdtbus_is_mapping_valid (pl050_regs)) + return grub_error (GRUB_ERR_IO, "could not map pl050"); + + ps2_state.at_keyboard_status = 0; + set_scancodes (); + keyboard_controller_led (ps2_state.led_status); + + grub_term_register_input ("pl050_keyboard", &grub_pl050_keyboard_term); + return GRUB_ERR_NONE; +} + +struct grub_fdtbus_driver pl050 = +{ + .compatible = "arm,pl050", + .attach = pl050_attach +}; + +void +grub_pl050_init (void) +{ + grub_fdtbus_register (&pl050); +} From 3edabad8fefb112cc4b2d43be6e97d43c909ceee Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 21:59:48 +0200 Subject: [PATCH 0691/1167] arm_coreboot: Support grub-mkstandalone. --- include/grub/util/install.h | 6 +++++- util/grub-install-common.c | 12 ++++++++++-- util/grub-install.c | 7 +++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 6abd288c3..5910b0c09 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -29,6 +29,8 @@ #define GRUB_INSTALL_OPTIONS \ { "modules", GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"), \ 0, N_("pre-load specified modules MODULES"), 1 }, \ + { "dtb", GRUB_INSTALL_OPTIONS_DTB, N_("FILE"), \ + 0, N_("embed a specific DTB"), 1 }, \ { "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES, \ N_("MODULES"), 0, \ N_("install only MODULES and their dependencies [default=all]"), 1 }, \ @@ -99,6 +101,7 @@ enum grub_install_plat GRUB_INSTALL_PLATFORM_I386_XEN, GRUB_INSTALL_PLATFORM_X86_64_XEN, GRUB_INSTALL_PLATFORM_ARM64_EFI, + GRUB_INSTALL_PLATFORM_ARM_COREBOOT, GRUB_INSTALL_PLATFORM_MAX }; @@ -115,7 +118,8 @@ enum grub_install_options { GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, - GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS + GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, + GRUB_INSTALL_OPTIONS_DTB }; extern char *grub_install_source_directory; diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 8539ff348..9e3e358c9 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -73,6 +73,7 @@ grub_install_help_filter (int key, const char *text, static int (*compress_func) (const char *src, const char *dest) = NULL; char *grub_install_copy_buffer; +static char *dtb; int grub_install_copy_file (const char *src, @@ -364,6 +365,11 @@ grub_install_parse (int key, char *arg) case GRUB_INSTALL_OPTIONS_INSTALL_FONTS: handle_install_list (&install_fonts, arg, 0); return 1; + case GRUB_INSTALL_OPTIONS_DTB: + if (dtb) + free (dtb); + dtb = xstrdup (arg); + return 1; case GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS: if (strcmp (arg, "no") == 0 || strcmp (arg, "none") == 0) @@ -486,9 +492,10 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_util_info ("grub-mkimage --directory '%s' --prefix '%s'" " --output '%s' " + " --dtb '%s' " "--format '%s' --compression '%s' %s %s\n", dir, prefix, - outname, mkimage_target, + outname, dtb ? : "", mkimage_target, compnames[compression], note ? "--note" : "", s); free (s); @@ -499,7 +506,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, pubkeys, npubkeys, config_path, tgt, - note, compression, 0); + note, compression, dtb); while (dc--) grub_install_pop_module (); } @@ -666,6 +673,7 @@ static struct [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm", "efi" }, [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64", "efi" }, [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, + [GRUB_INSTALL_PLATFORM_ARM_COREBOOT] = { "arm", "coreboot" }, }; char * diff --git a/util/grub-install.c b/util/grub-install.c index 9074d3e9e..75e3e5ba6 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -486,6 +486,7 @@ have_bootdev (enum grub_install_plat pl) case GRUB_INSTALL_PLATFORM_I386_QEMU: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: @@ -911,6 +912,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_I386_QEMU: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: @@ -946,6 +948,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_ARM_UBOOT: case GRUB_INSTALL_PLATFORM_I386_QEMU: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: @@ -1448,6 +1451,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: case GRUB_INSTALL_PLATFORM_I386_QEMU: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: @@ -1542,6 +1546,7 @@ main (int argc, char *argv[]) break; case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_I386_IEEE1275: case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275: @@ -1629,6 +1634,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_I386_PC: case GRUB_INSTALL_PLATFORM_MIPSEL_ARC: @@ -1889,6 +1895,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_I386_COREBOOT: + case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: case GRUB_INSTALL_PLATFORM_MIPSEL_ARC: case GRUB_INSTALL_PLATFORM_ARM_UBOOT: From 656c3b0d7fbe23f0e1ab561c8faa4ac4a37364d1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 22:00:06 +0200 Subject: [PATCH 0692/1167] arm_coreboot: Support loading linux images. --- grub-core/loader/arm/linux.c | 132 ++++++++++++++++++----------------- include/grub/arm/linux.h | 16 +++++ 2 files changed, 83 insertions(+), 65 deletions(-) diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 01374ee78..260cbf068 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -31,8 +31,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); -#ifndef GRUB_MACHINE_COREBOOT - static grub_dl_t my_mod; static grub_addr_t initrd_start; @@ -44,7 +42,7 @@ static grub_size_t linux_size; static char *linux_args; static grub_uint32_t machine_type; -static void *fdt_addr; +static const void *current_fdt; typedef void (*kernel_entry_t) (int, unsigned long, void *); @@ -56,9 +54,9 @@ typedef void (*kernel_entry_t) (int, unsigned long, void *); #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) static grub_size_t -get_atag_size (grub_uint32_t *atag) +get_atag_size (const grub_uint32_t *atag) { - grub_uint32_t *atag0 = atag; + const grub_uint32_t *atag0 = atag; while (atag[0] && atag[1]) atag += atag[0]; return atag - atag0; @@ -70,10 +68,11 @@ get_atag_size (grub_uint32_t *atag) * Merges in command line parameters and sets up initrd addresses. */ static grub_err_t -linux_prepare_atag (void) +linux_prepare_atag (void *target_atag) { - grub_uint32_t *atag_orig = (grub_uint32_t *) fdt_addr; - grub_uint32_t *tmp_atag, *from, *to; + const grub_uint32_t *atag_orig = (const grub_uint32_t *) current_fdt; + grub_uint32_t *tmp_atag, *to; + const grub_uint32_t *from; grub_size_t tmp_size; grub_size_t arg_size = grub_strlen (linux_args); char *cmdline_orig = NULL; @@ -144,7 +143,7 @@ linux_prepare_atag (void) to += 2; /* Copy updated FDT to its launch location */ - grub_memcpy (atag_orig, tmp_atag, sizeof (grub_uint32_t) * (to - tmp_atag)); + grub_memcpy (target_atag, tmp_atag, sizeof (grub_uint32_t) * (to - tmp_atag)); grub_free (tmp_atag); grub_dprintf ("loader", "ATAG updated for Linux boot\n"); @@ -158,19 +157,19 @@ linux_prepare_atag (void) * Merges in command line parameters and sets up initrd addresses. */ static grub_err_t -linux_prepare_fdt (void) +linux_prepare_fdt (void *target_fdt) { int node; int retval; int tmp_size; void *tmp_fdt; - tmp_size = grub_fdt_get_totalsize (fdt_addr) + 0x100 + grub_strlen (linux_args); + tmp_size = grub_fdt_get_totalsize (current_fdt) + 0x100 + grub_strlen (linux_args); tmp_fdt = grub_malloc (tmp_size); if (!tmp_fdt) return grub_errno; - grub_memcpy (tmp_fdt, fdt_addr, grub_fdt_get_totalsize (fdt_addr)); + grub_memcpy (tmp_fdt, current_fdt, grub_fdt_get_totalsize (current_fdt)); grub_fdt_set_totalsize (tmp_fdt, tmp_size); /* Find or create '/chosen' node */ @@ -211,7 +210,7 @@ linux_prepare_fdt (void) } /* Copy updated FDT to its launch location */ - grub_memcpy (fdt_addr, tmp_fdt, tmp_size); + grub_memcpy (target_fdt, tmp_fdt, tmp_size); grub_free (tmp_fdt); grub_dprintf ("loader", "FDT updated for Linux boot\n"); @@ -228,16 +227,17 @@ linux_boot (void) { kernel_entry_t linuxmain; int fdt_valid, atag_valid; + void *target_fdt = 0; - fdt_valid = (fdt_addr && grub_fdt_check_header_nosize (fdt_addr) == 0); - atag_valid = ((((grub_uint16_t *) fdt_addr)[3] & ~3) == 0x5440 - && *((grub_uint32_t *) fdt_addr)); + fdt_valid = (current_fdt && grub_fdt_check_header_nosize (current_fdt) == 0); + atag_valid = ((((const grub_uint16_t *) current_fdt)[3] & ~3) == 0x5440 + && *((const grub_uint32_t *) current_fdt)); grub_dprintf ("loader", "atag: %p, %x, %x, %s, %s\n", - fdt_addr, - ((grub_uint16_t *) fdt_addr)[3], - *((grub_uint32_t *) fdt_addr), - (char *) fdt_addr, - (char *) fdt_addr + 1); + current_fdt, + ((const grub_uint16_t *) current_fdt)[3], + *((const grub_uint32_t *) current_fdt), + (const char *) current_fdt, + (const char *) current_fdt + 1); if (!fdt_valid && machine_type == GRUB_ARM_MACHINE_TYPE_FDT) return grub_error (GRUB_ERR_FILE_NOT_FOUND, @@ -247,23 +247,40 @@ linux_boot (void) grub_dprintf ("loader", "Kernel at: 0x%x\n", linux_addr); + if (fdt_valid || atag_valid) + { +#ifdef GRUB_MACHINE_EFI + grub_size_t size; + if (fdt_valid) + size = grub_fdt_get_totalsize (fdt_addr); + else + size = 4 * get_atag_size (atag_orig); + size += grub_strlen (linux_args) + 256; + target_fdt = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size); + if (!fdt_addr) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); +#else + target_fdt = (void *) LINUX_FDT_ADDRESS; +#endif + } + if (fdt_valid) { grub_err_t err; - err = linux_prepare_fdt (); + err = linux_prepare_fdt (target_fdt); if (err) return err; - grub_dprintf ("loader", "FDT @ 0x%p\n", fdt_addr); + grub_dprintf ("loader", "FDT @ %p\n", target_fdt); } else if (atag_valid) { grub_err_t err; - err = linux_prepare_atag (); + err = linux_prepare_atag (target_fdt); if (err) return err; - grub_dprintf ("loader", "ATAG @ 0x%p\n", fdt_addr); + grub_dprintf ("loader", "ATAG @ %p\n", target_fdt); } grub_dprintf ("loader", "Jumping to Linux...\n"); @@ -287,7 +304,7 @@ linux_boot (void) grub_arm_disable_caches_mmu (); - linuxmain (0, machine_type, fdt_addr); + linuxmain (0, machine_type, target_fdt); return grub_error (GRUB_ERR_BAD_OS, "Linux call returned"); } @@ -446,11 +463,26 @@ fail: static grub_err_t load_dtb (grub_file_t dtb, int size) { - if ((grub_file_read (dtb, fdt_addr, size) != size) - || (grub_fdt_check_header (fdt_addr, size) != 0)) - return grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); + void *new_fdt = grub_zalloc (size); + if (!new_fdt) + return grub_errno; + grub_dprintf ("loader", "Loading device tree to %p\n", + new_fdt); + if ((grub_file_read (dtb, new_fdt, size) != size) + || (grub_fdt_check_header (new_fdt, size) != 0)) + { + grub_free (new_fdt); + return grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); + } + + grub_fdt_set_totalsize (new_fdt, size); + current_fdt = new_fdt; + /* + * We've successfully loaded an FDT, so any machine type passed + * from firmware is now obsolete. + */ + machine_type = GRUB_ARM_MACHINE_TYPE_FDT; - grub_fdt_set_totalsize (fdt_addr, size); return GRUB_ERR_NONE; } @@ -466,42 +498,13 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), dtb = grub_file_open (argv[0]); if (!dtb) - goto out; + return grub_errno; size = grub_file_size (dtb); if (size == 0) - { - grub_error (GRUB_ERR_BAD_OS, "empty file"); - goto out; - } - -#ifdef GRUB_MACHINE_EFI - fdt_addr = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size); - if (!fdt_addr) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - goto out; - } -#else - fdt_addr = (void *) LINUX_FDT_ADDRESS; -#endif - - grub_dprintf ("loader", "Loading device tree to 0x%08x\n", - (grub_addr_t) fdt_addr); - load_dtb (dtb, size); - if (grub_errno != GRUB_ERR_NONE) - { - fdt_addr = NULL; - goto out; - } - - /* - * We've successfully loaded an FDT, so any machine type passed - * from firmware is now obsolete. - */ - machine_type = GRUB_ARM_MACHINE_TYPE_FDT; - - out: + grub_error (GRUB_ERR_BAD_OS, "empty file"); + else + load_dtb (dtb, size); grub_file_close (dtb); return grub_errno; @@ -519,7 +522,7 @@ GRUB_MOD_INIT (linux) /* TRANSLATORS: DTB stands for device tree blob. */ 0, N_("Load DTB file.")); my_mod = mod; - fdt_addr = (void *) grub_arm_firmware_get_boot_data (); + current_fdt = grub_arm_firmware_get_boot_data (); machine_type = grub_arm_firmware_get_machine_type (); } @@ -529,4 +532,3 @@ GRUB_MOD_FINI (linux) grub_unregister_command (cmd_initrd); grub_unregister_command (cmd_devicetree); } -#endif diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index a66caad13..f217f8281 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -46,6 +46,22 @@ grub_arm_firmware_get_machine_type (void) { return GRUB_ARM_MACHINE_TYPE_FDT; } +#elif defined (GRUB_MACHINE_COREBOOT) +#include +#include +# define LINUX_ADDRESS (start_of_ram + 0x8000) +# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) +# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) +static inline const void * +grub_arm_firmware_get_boot_data (void) +{ + return grub_fdtbus_get_fdt (); +} +static inline grub_uint32_t +grub_arm_firmware_get_machine_type (void) +{ + return GRUB_ARM_MACHINE_TYPE_FDT; +} #endif #define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 From 265292f2b0da0eb414c409871ba0f94a99ec33c1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 22:06:04 +0200 Subject: [PATCH 0693/1167] arm_coreboot: Support DMA. This is needed to support USB and some other busses. --- grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 1 + grub-core/kern/arm/cache.c | 34 ++++++++++++++++++ grub-core/kern/arm/cache_armv7.S | 12 +++++++ grub-core/kern/arm/coreboot/dma.c | 59 +++++++++++++++++++++++++++++++ include/grub/cache.h | 7 ++-- include/grub/dma.h | 44 +++++++++++++++++++++++ include/grub/pci.h | 22 +----------- 8 files changed, 155 insertions(+), 25 deletions(-) create mode 100644 grub-core/kern/arm/coreboot/dma.c create mode 100644 include/grub/dma.h diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index a2aaf9f54..104513847 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -248,6 +248,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dma.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h endif diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6be6e7f61..e4f253a20 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -163,6 +163,7 @@ kernel = { arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; arm_coreboot = commands/keylayouts.c; + arm_coreboot = kern/arm/coreboot/dma.c; terminfoinkernel = term/terminfo.c; terminfoinkernel = term/tparm.c; diff --git a/grub-core/kern/arm/cache.c b/grub-core/kern/arm/cache.c index 34154ccdb..af1c4bbf5 100644 --- a/grub-core/kern/arm/cache.c +++ b/grub-core/kern/arm/cache.c @@ -29,6 +29,8 @@ void grub_arm_clean_dcache_range_armv6 (grub_addr_t start, grub_addr_t end, grub_addr_t dlinesz); void grub_arm_clean_dcache_range_armv7 (grub_addr_t start, grub_addr_t end, grub_addr_t dlinesz); +void grub_arm_clean_dcache_range_poc_armv7 (grub_addr_t start, grub_addr_t end, + grub_addr_t dlinesz); void grub_arm_invalidate_icache_range_armv6 (grub_addr_t start, grub_addr_t end, grub_addr_t dlinesz); void grub_arm_invalidate_icache_range_armv7 (grub_addr_t start, grub_addr_t end, @@ -252,6 +254,38 @@ grub_arch_sync_caches (void *address, grub_size_t len) } } +void +grub_arch_sync_dma_caches (volatile void *address, grub_size_t len) +{ + grub_addr_t start = (grub_addr_t) address; + grub_addr_t end = start + len; + + if (type == ARCH_UNKNOWN) + probe_caches (); + start = ALIGN_DOWN (start, grub_arch_cache_max_linesz); + end = ALIGN_UP (end, grub_arch_cache_max_linesz); + switch (type) + { + case ARCH_ARMV6: + grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz); + grub_arm_invalidate_icache_range_armv6 (start, end, + grub_arch_cache_ilinesz); + break; + case ARCH_ARMV5_WRITE_THROUGH: + case ARCH_ARMV6_UNIFIED: + grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz); + break; + case ARCH_ARMV7: + grub_arm_clean_dcache_range_poc_armv7 (start, end, grub_arch_cache_dlinesz); + grub_arm_invalidate_icache_range_armv7 (start, end, + grub_arch_cache_ilinesz); + break; + /* Pacify GCC. */ + case ARCH_UNKNOWN: + break; + } +} + void grub_arm_disable_caches_mmu (void) { diff --git a/grub-core/kern/arm/cache_armv7.S b/grub-core/kern/arm/cache_armv7.S index 1ef2754af..5ae76a3d8 100644 --- a/grub-core/kern/arm/cache_armv7.S +++ b/grub-core/kern/arm/cache_armv7.S @@ -33,6 +33,18 @@ # define ISB isb #define ARMV7 1 +FUNCTION(grub_arm_clean_dcache_range_poc_armv7) + DSB + @ Clean data cache for range to point-of-coherence +1: cmp r0, r1 + bge 2f + mcr p15, 0, r0, c7, c14, 1 @ DCCMVAC + add r0, r0, r2 @ Next line + b 1b +2: DSB + bx lr + + @ r0 - CLIDR @ r1 - LoC @ r2 - current level diff --git a/grub-core/kern/arm/coreboot/dma.c b/grub-core/kern/arm/coreboot/dma.c new file mode 100644 index 000000000..2c2a62789 --- /dev/null +++ b/grub-core/kern/arm/coreboot/dma.c @@ -0,0 +1,59 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2007,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 . + */ + +#include +#include +#include +#include +#include +#include + +struct grub_pci_dma_chunk * +grub_memalign_dma32 (grub_size_t align, grub_size_t size) +{ + void *ret; + if (align < 64) + align = 64; + size = ALIGN_UP (size, align); + ret = grub_memalign (align, size); + if (!ret) + return 0; + grub_arch_sync_dma_caches (ret, size); + return ret; +} + +void +grub_dma_free (struct grub_pci_dma_chunk *ch) +{ + grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN; + grub_arch_sync_dma_caches (ch, size); + grub_free (ch); +} + +volatile void * +grub_dma_get_virt (struct grub_pci_dma_chunk *ch) +{ + return (void *) ch; +} + +grub_uint32_t +grub_dma_get_phys (struct grub_pci_dma_chunk *ch) +{ + return (grub_uint32_t) (grub_addr_t) ch; +} + diff --git a/include/grub/cache.h b/include/grub/cache.h index fc669dfd1..1c98ce270 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -34,15 +34,14 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); #endif #ifndef GRUB_MACHINE_EMU -#ifdef _mips -void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, - grub_size_t len); -#else +#if defined (__i386__) || defined (__x86_64__) static inline void grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) { } +#else +void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, grub_size_t len); #endif #endif diff --git a/include/grub/dma.h b/include/grub/dma.h new file mode 100644 index 000000000..19992ebc1 --- /dev/null +++ b/include/grub/dma.h @@ -0,0 +1,44 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 . + */ + +#ifndef GRUB_DMA_H +#define GRUB_DMA_H 1 + +struct grub_pci_dma_chunk; + +struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align, + grub_size_t size); +void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch); +volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch); +grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch); + +static inline void * +grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk) +{ + return ((grub_uint8_t *) grub_dma_get_virt (chunk) + + (phys - grub_dma_get_phys (chunk))); +} + +static inline grub_uint32_t +grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk) +{ + return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk)) + + grub_dma_get_phys (chunk)); +} + +#endif diff --git a/include/grub/pci.h b/include/grub/pci.h index 70d9a0513..262c89b74 100644 --- a/include/grub/pci.h +++ b/include/grub/pci.h @@ -142,27 +142,7 @@ grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev, void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook, void *hook_data); -struct grub_pci_dma_chunk; - -struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align, - grub_size_t size); -void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch); -volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch); -grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch); - -static inline void * -grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk) -{ - return ((grub_uint8_t *) grub_dma_get_virt (chunk) - + (phys - grub_dma_get_phys (chunk))); -} - -static inline grub_uint32_t -grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk) -{ - return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk)) - + grub_dma_get_phys (chunk)); -} +#include grub_uint8_t EXPORT_FUNC (grub_pci_find_capability) (grub_pci_device_t dev, grub_uint8_t cap); From 058df7b5a9cc7aaa9872eaa916b715544a8f9840 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 22:10:26 +0200 Subject: [PATCH 0694/1167] ehci: Split core code from PCI part. On ARM often EHCI is present without PCI and just declared in device tree. So splitcore from PCI part. --- grub-core/Makefile.core.def | 1 + grub-core/bus/usb/ehci-pci.c | 208 +++++++++++++++++++++++++++++++++++ grub-core/bus/usb/ehci.c | 201 +++------------------------------ 3 files changed, 223 insertions(+), 187 deletions(-) create mode 100644 grub-core/bus/usb/ehci-pci.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index e4f253a20..4745eb4d9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -593,6 +593,7 @@ module = { module = { name = ehci; common = bus/usb/ehci.c; + pci = bus/usb/ehci-pci.c; enable = pci; }; diff --git a/grub-core/bus/usb/ehci-pci.c b/grub-core/bus/usb/ehci-pci.c new file mode 100644 index 000000000..65e6cb574 --- /dev/null +++ b/grub-core/bus/usb/ehci-pci.c @@ -0,0 +1,208 @@ +/* ehci.c - EHCI Support. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2011 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +#define GRUB_EHCI_PCI_SBRN_REG 0x60 +#define GRUB_EHCI_ADDR_MEM_MASK (~0xff) + +/* USBLEGSUP bits and related OS OWNED byte offset */ +enum +{ + GRUB_EHCI_BIOS_OWNED = (1 << 16), + GRUB_EHCI_OS_OWNED = (1 << 24) +}; + +/* PCI iteration function... */ +static int +grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, + void *data __attribute__ ((unused))) +{ + volatile grub_uint32_t *regs; + grub_uint32_t base, base_h; + grub_uint32_t eecp_offset; + grub_uint32_t usblegsup = 0; + grub_uint64_t maxtime; + grub_uint32_t interf; + grub_uint32_t subclass; + grub_uint32_t class; + grub_uint8_t release; + grub_uint32_t class_code; + + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: begin\n"); + + if (pciid == GRUB_CS5536_PCIID) + { + grub_uint64_t basereg; + + basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE); + if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE)) + { + /* Shouldn't happen. */ + grub_dprintf ("ehci", "No EHCI address is assigned\n"); + return 0; + } + base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK); + basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER; + basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED; + basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS; + basereg &= ~GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE; + grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE, basereg); + } + else + { + grub_pci_address_t addr; + addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); + class_code = grub_pci_read (addr) >> 8; + interf = class_code & 0xFF; + subclass = (class_code >> 8) & 0xFF; + class = class_code >> 16; + + /* If this is not an EHCI controller, just return. */ + if (class != 0x0c || subclass != 0x03 || interf != 0x20) + return 0; + + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: class OK\n"); + + /* Check Serial Bus Release Number */ + addr = grub_pci_make_address (dev, GRUB_EHCI_PCI_SBRN_REG); + release = grub_pci_read_byte (addr); + if (release != 0x20) + { + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: Wrong SBRN: %0x\n", + release); + return 0; + } + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: bus rev. num. OK\n"); + + /* Determine EHCI EHCC registers base address. */ + addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); + base = grub_pci_read (addr); + addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1); + base_h = grub_pci_read (addr); + /* Stop if registers are mapped above 4G - GRUB does not currently + * work with registers mapped above 4G */ + if (((base & GRUB_PCI_ADDR_MEM_TYPE_MASK) != GRUB_PCI_ADDR_MEM_TYPE_32) + && (base_h != 0)) + { + grub_dprintf ("ehci", + "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n"); + return 0; + } + base &= GRUB_PCI_ADDR_MEM_MASK; + if (!base) + { + grub_dprintf ("ehci", + "EHCI: EHCI is not mapped\n"); + return 0; + } + + /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ + addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); + grub_pci_write_word(addr, + GRUB_PCI_COMMAND_MEM_ENABLED + | GRUB_PCI_COMMAND_BUS_MASTER + | grub_pci_read_word(addr)); + + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n"); + } + + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of EHCC: %08x\n", + (base & GRUB_EHCI_ADDR_MEM_MASK)); + + regs = grub_pci_device_map_range (dev, + (base & GRUB_EHCI_ADDR_MEM_MASK), + 0x100); + + /* Is there EECP ? */ + eecp_offset = (grub_le_to_cpu32 (regs[2]) >> 8) & 0xff; + + /* Determine and change ownership. */ + /* EECP offset valid in HCCPARAMS */ + /* Ownership can be changed via EECP only */ + if (pciid != GRUB_CS5536_PCIID && eecp_offset >= 0x40) + { + grub_pci_address_t pciaddr_eecp; + pciaddr_eecp = grub_pci_make_address (dev, eecp_offset); + + usblegsup = grub_pci_read (pciaddr_eecp); + if (usblegsup & GRUB_EHCI_BIOS_OWNED) + { + grub_boot_time ("Taking ownership of EHCI controller"); + grub_dprintf ("ehci", + "EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n"); + /* Ownership change - set OS_OWNED bit */ + grub_pci_write (pciaddr_eecp, usblegsup | GRUB_EHCI_OS_OWNED); + /* Ensure PCI register is written */ + grub_pci_read (pciaddr_eecp); + + /* Wait for finish of ownership change, EHCI specification + * doesn't say how long it can take... */ + maxtime = grub_get_time_ms () + 1000; + while ((grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) + && (grub_get_time_ms () < maxtime)); + if (grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) + { + grub_dprintf ("ehci", + "EHCI grub_ehci_pci_iter: EHCI change ownership timeout"); + /* Change ownership in "hard way" - reset BIOS ownership */ + grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); + /* Ensure PCI register is written */ + grub_pci_read (pciaddr_eecp); + } + } + else if (usblegsup & GRUB_EHCI_OS_OWNED) + /* XXX: What to do in this case - nothing ? Can it happen ? */ + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: EHCI owned by: OS\n"); + else + { + grub_dprintf ("ehci", + "EHCI grub_ehci_pci_iter: EHCI owned by: NONE\n"); + /* XXX: What to do in this case ? Can it happen ? + * Is code below correct ? */ + /* Ownership change - set OS_OWNED bit */ + grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); + /* Ensure PCI register is written */ + grub_pci_read (pciaddr_eecp); + } + + /* Disable SMI, just to be sure. */ + pciaddr_eecp = grub_pci_make_address (dev, eecp_offset + 4); + grub_pci_write (pciaddr_eecp, 0); + /* Ensure PCI register is written */ + grub_pci_read (pciaddr_eecp); + } + + grub_dprintf ("ehci", "inithw: EHCI grub_ehci_pci_iter: ownership OK\n"); + + grub_ehci_init_device (regs); + return 0; +} + +void +grub_ehci_pci_scan (void) +{ + grub_pci_iterate (grub_ehci_pci_iter, NULL); +} diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index 5f4297bb2..c772e7654 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -22,13 +22,10 @@ #include #include #include -#include -#include -#include #include #include -#include #include +#include #include GRUB_MOD_LICENSE ("GPLv3+"); @@ -39,8 +36,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); * - is not supporting interrupt transfers */ -#define GRUB_EHCI_PCI_SBRN_REG 0x60 - /* Capability registers offsets */ enum { @@ -54,7 +49,6 @@ enum #define GRUB_EHCI_EECP_MASK (0xff << 8) #define GRUB_EHCI_EECP_SHIFT 8 -#define GRUB_EHCI_ADDR_MEM_MASK (~0xff) #define GRUB_EHCI_POINTER_MASK (~0x1f) /* Capability register SPARAMS bits */ @@ -85,13 +79,6 @@ enum #define GRUB_EHCI_QH_EMPTY 1 -/* USBLEGSUP bits and related OS OWNED byte offset */ -enum -{ - GRUB_EHCI_BIOS_OWNED = (1 << 16), - GRUB_EHCI_OS_OWNED = (1 << 24) -}; - /* Operational registers offsets */ enum { @@ -455,9 +442,10 @@ grub_ehci_reset (struct grub_ehci *e) sync_all_caches (e); + grub_dprintf ("ehci", "reset\n"); + grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, - GRUB_EHCI_CMD_HC_RESET - | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); + GRUB_EHCI_CMD_HC_RESET); /* Ensure command is written */ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND); /* XXX: How long time could take reset of HC ? */ @@ -473,116 +461,24 @@ grub_ehci_reset (struct grub_ehci *e) } /* PCI iteration function... */ -static int -grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - void *data __attribute__ ((unused))) +void +grub_ehci_init_device (volatile void *regs) { - grub_uint8_t release; - grub_uint32_t class_code; - grub_uint32_t interf; - grub_uint32_t subclass; - grub_uint32_t class; - grub_uint32_t base, base_h; struct grub_ehci *e; - grub_uint32_t eecp_offset; grub_uint32_t fp; int i; - grub_uint32_t usblegsup = 0; - grub_uint64_t maxtime; grub_uint32_t n_ports; grub_uint8_t caplen; - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: begin\n"); - - if (pciid == GRUB_CS5536_PCIID) - { - grub_uint64_t basereg; - - basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE); - if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE)) - { - /* Shouldn't happen. */ - grub_dprintf ("ehci", "No EHCI address is assigned\n"); - return 0; - } - base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK); - basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER; - basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED; - basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS; - basereg &= ~GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE; - grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE, basereg); - } - else - { - grub_pci_address_t addr; - addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); - class_code = grub_pci_read (addr) >> 8; - interf = class_code & 0xFF; - subclass = (class_code >> 8) & 0xFF; - class = class_code >> 16; - - /* If this is not an EHCI controller, just return. */ - if (class != 0x0c || subclass != 0x03 || interf != 0x20) - return 0; - - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: class OK\n"); - - /* Check Serial Bus Release Number */ - addr = grub_pci_make_address (dev, GRUB_EHCI_PCI_SBRN_REG); - release = grub_pci_read_byte (addr); - if (release != 0x20) - { - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: Wrong SBRN: %0x\n", - release); - return 0; - } - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: bus rev. num. OK\n"); - - /* Determine EHCI EHCC registers base address. */ - addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); - base = grub_pci_read (addr); - addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1); - base_h = grub_pci_read (addr); - /* Stop if registers are mapped above 4G - GRUB does not currently - * work with registers mapped above 4G */ - if (((base & GRUB_PCI_ADDR_MEM_TYPE_MASK) != GRUB_PCI_ADDR_MEM_TYPE_32) - && (base_h != 0)) - { - grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n"); - return 0; - } - base &= GRUB_PCI_ADDR_MEM_MASK; - if (!base) - { - grub_dprintf ("ehci", - "EHCI: EHCI is not mapped\n"); - return 0; - } - - /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ - addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); - grub_pci_write_word(addr, - GRUB_PCI_COMMAND_MEM_ENABLED - | GRUB_PCI_COMMAND_BUS_MASTER - | grub_pci_read_word(addr)); - - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n"); - } - /* Allocate memory for the controller and fill basic values. */ e = grub_zalloc (sizeof (*e)); if (!e) - return 1; + return; e->framelist_chunk = NULL; e->td_chunk = NULL; e->qh_chunk = NULL; - e->iobase_ehcc = grub_pci_device_map_range (dev, - (base & GRUB_EHCI_ADDR_MEM_MASK), - 0x100); + e->iobase_ehcc = regs; - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of EHCC: %08x\n", - (base & GRUB_EHCI_ADDR_MEM_MASK)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CAPLEN: %02x\n", grub_ehci_ehcc_read8 (e, GRUB_EHCI_EHCC_CAPLEN)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: VERSION: %04x\n", @@ -598,7 +494,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, if (caplen & (sizeof (grub_uint32_t) - 1)) { grub_dprintf ("ehci", "Unaligned caplen\n"); - return 0; + return; } e->iobase = ((volatile grub_uint32_t *) e->iobase_ehcc + (caplen / sizeof (grub_uint32_t))); @@ -609,7 +505,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", - (base & GRUB_EHCI_ADDR_MEM_MASK) + caplen); + (grub_addr_t) e->iobase_ehcc + caplen); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", @@ -625,10 +521,6 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG)); - /* Is there EECP ? */ - eecp_offset = (grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_CPARAMS) - & GRUB_EHCI_EECP_MASK) >> GRUB_EHCI_EECP_SHIFT; - /* Check format of data structures requested by EHCI */ /* XXX: In fact it is not used at any place, it is prepared for future * This implementation uses 32-bits pointers only */ @@ -732,65 +624,6 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: QH/TD init. OK\n"); - /* Determine and change ownership. */ - /* EECP offset valid in HCCPARAMS */ - /* Ownership can be changed via EECP only */ - if (pciid != GRUB_CS5536_PCIID && eecp_offset >= 0x40) - { - grub_pci_address_t pciaddr_eecp; - pciaddr_eecp = grub_pci_make_address (dev, eecp_offset); - - usblegsup = grub_pci_read (pciaddr_eecp); - if (usblegsup & GRUB_EHCI_BIOS_OWNED) - { - grub_boot_time ("Taking ownership of EHCI controller"); - grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n"); - /* Ownership change - set OS_OWNED bit */ - grub_pci_write (pciaddr_eecp, usblegsup | GRUB_EHCI_OS_OWNED); - /* Ensure PCI register is written */ - grub_pci_read (pciaddr_eecp); - - /* Wait for finish of ownership change, EHCI specification - * doesn't say how long it can take... */ - maxtime = grub_get_time_ms () + 1000; - while ((grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) - && (grub_get_time_ms () < maxtime)); - if (grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) - { - grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: EHCI change ownership timeout"); - /* Change ownership in "hard way" - reset BIOS ownership */ - grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); - /* Ensure PCI register is written */ - grub_pci_read (pciaddr_eecp); - } - } - else if (usblegsup & GRUB_EHCI_OS_OWNED) - /* XXX: What to do in this case - nothing ? Can it happen ? */ - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: EHCI owned by: OS\n"); - else - { - grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: EHCI owned by: NONE\n"); - /* XXX: What to do in this case ? Can it happen ? - * Is code below correct ? */ - /* Ownership change - set OS_OWNED bit */ - grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); - /* Ensure PCI register is written */ - grub_pci_read (pciaddr_eecp); - } - - /* Disable SMI, just to be sure. */ - pciaddr_eecp = grub_pci_make_address (dev, eecp_offset + 4); - grub_pci_write (pciaddr_eecp, 0); - /* Ensure PCI register is written */ - grub_pci_read (pciaddr_eecp); - - } - - grub_dprintf ("ehci", "inithw: EHCI grub_ehci_pci_iter: ownership OK\n"); - /* Now we can setup EHCI (maybe...) */ /* Check if EHCI is halted and halt it if not */ @@ -864,7 +697,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", - (base & GRUB_EHCI_ADDR_MEM_MASK)); + (grub_addr_t) regs); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", @@ -880,7 +713,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG)); - return 0; + return; fail: if (e) @@ -894,7 +727,7 @@ fail: } grub_free (e); - return 0; + return; } static int @@ -1891,12 +1724,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed) } } -static void -grub_ehci_inithw (void) -{ - grub_pci_iterate (grub_ehci_pci_iter, NULL); -} - static grub_err_t grub_ehci_restore_hw (void) { @@ -1997,7 +1824,7 @@ GRUB_MOD_INIT (ehci) grub_stop_disk_firmware (); grub_boot_time ("Initing EHCI hardware"); - grub_ehci_inithw (); + grub_ehci_pci_scan (); grub_boot_time ("Registering EHCI driver"); grub_usb_controller_dev_register (&usb_controller); grub_boot_time ("EHCI driver registered"); From d11ced1e1fb93676942e51618eb53c140f541890 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 May 2017 22:14:28 +0200 Subject: [PATCH 0695/1167] arm_coreboot: Support EHCI. --- gentpl.py | 2 +- grub-core/Makefile.core.def | 2 ++ grub-core/bus/usb/ehci-fdt.c | 45 ++++++++++++++++++++++++++++++++++++ grub-core/bus/usb/usbtrans.c | 2 +- include/grub/usb.h | 4 ++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 grub-core/bus/usb/ehci-fdt.c diff --git a/gentpl.py b/gentpl.py index ed268178b..da67965a4 100644 --- a/gentpl.py +++ b/gentpl.py @@ -63,7 +63,7 @@ GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips", "sparc64_ieee1275", "powerpc_ieee1275"] GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi"); GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"] -GROUPS["usb"] = GROUPS["pci"] +GROUPS["usb"] = GROUPS["pci"] + ["arm_coreboot"] # If gfxterm is main output console integrate it into kernel GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot", "arm_coreboot" ] diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 4745eb4d9..5ce506597 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -593,8 +593,10 @@ module = { module = { name = ehci; common = bus/usb/ehci.c; + arm_coreboot = bus/usb/ehci-fdt.c; pci = bus/usb/ehci-pci.c; enable = pci; + enable = arm_coreboot; }; module = { diff --git a/grub-core/bus/usb/ehci-fdt.c b/grub-core/bus/usb/ehci-fdt.c new file mode 100644 index 000000000..29b50bdd5 --- /dev/null +++ b/grub-core/bus/usb/ehci-fdt.c @@ -0,0 +1,45 @@ +/* ehci.c - EHCI Support. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2011 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 . + */ + +#include +#include +#include +#include +#include + +static grub_err_t +ehci_attach(const struct grub_fdtbus_dev *dev) +{ + grub_dprintf ("ehci", "Found generic-ehci\n"); + + grub_ehci_init_device (grub_fdtbus_map_reg (dev, 0, 0)); + return 0; +} + +struct grub_fdtbus_driver ehci = +{ + .compatible = "generic-ehci", + .attach = ehci_attach +}; + +void +grub_ehci_pci_scan (void) +{ + grub_fdtbus_register (&ehci); +} diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index 9266e4931..85f081fff 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/include/grub/usb.h b/include/grub/usb.h index 11d96481f..512ae1dd0 100644 --- a/include/grub/usb.h +++ b/include/grub/usb.h @@ -321,5 +321,9 @@ grub_usb_err_t grub_usb_check_transfer (grub_usb_transfer_t trans, grub_size_t *actual); void grub_usb_cancel_transfer (grub_usb_transfer_t trans); +void +grub_ehci_init_device (volatile void *regs); +void +grub_ehci_pci_scan (void); #endif /* GRUB_USB_H */ From 4f8471532d454b2db96434c28bf7105ed69e0f4d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 08:39:40 +0200 Subject: [PATCH 0696/1167] Fix bug on FDT nodes with compatible property --- grub-core/bus/fdt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c index 6fb077000..34d535457 100644 --- a/grub-core/bus/fdt.c +++ b/grub-core/bus/fdt.c @@ -43,6 +43,8 @@ is_compatible (struct grub_fdtbus_driver *driver, grub_size_t compatible_size; const char *compatible = grub_fdt_get_prop (dtb, node, "compatible", &compatible_size); + if (!compatible) + return 0; const char *compatible_end = compatible + compatible_size; while (compatible < compatible_end) { From c4313c812dc14e82a774b580b5e34d40e7f3fae6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 08:40:29 +0200 Subject: [PATCH 0697/1167] fdtbus: Add ability to send/receive messages on parent busses. --- grub-core/bus/fdt.c | 35 +++++++++++++++++------------------ include/grub/fdtbus.h | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c index 34d535457..135da497b 100644 --- a/grub-core/bus/fdt.c +++ b/grub-core/bus/fdt.c @@ -25,30 +25,22 @@ static grub_size_t root_address_cells, root_size_cells; /* Pointer to this symbol signals invalid mapping. */ char grub_fdtbus_invalid_mapping[1]; -struct grub_fdtbus_dev -{ - struct grub_fdtbus_dev *next; - struct grub_fdtbus_dev *parent; - int node; - struct grub_fdtbus_driver *driver; -}; - struct grub_fdtbus_dev *devs; struct grub_fdtbus_driver *drivers; -static int -is_compatible (struct grub_fdtbus_driver *driver, - int node) +int +grub_fdtbus_is_compatible (const char *compat_string, + const struct grub_fdtbus_dev *dev) { grub_size_t compatible_size; - const char *compatible = grub_fdt_get_prop (dtb, node, "compatible", + const char *compatible = grub_fdt_get_prop (dtb, dev->node, "compatible", &compatible_size); if (!compatible) return 0; const char *compatible_end = compatible + compatible_size; while (compatible < compatible_end) { - if (grub_strcmp (driver->compatible, compatible) == 0) + if (grub_strcmp (compat_string, compatible) == 0) return 1; compatible += grub_strlen (compatible) + 1; } @@ -75,10 +67,12 @@ fdtbus_scan (struct grub_fdtbus_dev *parent) dev->parent = parent; devs = dev; FOR_LIST_ELEMENTS(driver, drivers) - if (!dev->driver && is_compatible (driver, node)) + if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev)) { - if (driver->attach(dev) == GRUB_ERR_NONE) + grub_dprintf ("fdtbus", "Attaching %s\n", driver->compatible); + if (driver->attach (dev) == GRUB_ERR_NONE) { + grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible); dev->driver = driver; break; } @@ -92,13 +86,18 @@ void grub_fdtbus_register (struct grub_fdtbus_driver *driver) { struct grub_fdtbus_dev *dev; + grub_dprintf ("fdtbus", "Registering %s\n", driver->compatible); grub_list_push (GRUB_AS_LIST_P (&drivers), GRUB_AS_LIST (driver)); for (dev = devs; dev; dev = dev->next) - if (!dev->driver && is_compatible (driver, dev->node)) + if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev)) { - if (driver->attach(dev) == GRUB_ERR_NONE) - dev->driver = driver; + grub_dprintf ("fdtbus", "Attaching %s (%p)\n", driver->compatible, dev); + if (driver->attach (dev) == GRUB_ERR_NONE) + { + grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible); + dev->driver = driver; + } grub_print_error (); } } diff --git a/include/grub/fdtbus.h b/include/grub/fdtbus.h index 985837e55..f519c40ec 100644 --- a/include/grub/fdtbus.h +++ b/include/grub/fdtbus.h @@ -22,7 +22,13 @@ #include #include -struct grub_fdtbus_dev; +struct grub_fdtbus_dev +{ + struct grub_fdtbus_dev *next; + struct grub_fdtbus_dev *parent; + int node; + struct grub_fdtbus_driver *driver; +}; struct grub_fdtbus_driver { @@ -33,6 +39,12 @@ struct grub_fdtbus_driver grub_err_t (*attach) (const struct grub_fdtbus_dev *dev); void (*detach) (const struct grub_fdtbus_dev *dev); + + /* Message bus operations. */ + grub_err_t (*send) (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz); + grub_err_t (*receive) (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz); + grub_err_t (*start) (const struct grub_fdtbus_dev *dev); + void (*stop) (const struct grub_fdtbus_dev *dev); }; extern char EXPORT_VAR(grub_fdtbus_invalid_mapping)[1]; @@ -63,6 +75,10 @@ EXPORT_FUNC(grub_fdtbus_register) (struct grub_fdtbus_driver *driver); void EXPORT_FUNC(grub_fdtbus_unregister) (struct grub_fdtbus_driver *driver); +int +EXPORT_FUNC(grub_fdtbus_is_compatible) (const char *compat_string, + const struct grub_fdtbus_dev *dev); + /* Must be called before any register(). */ /* dtb is assumed to be unfreeable and must remain valid for lifetime of GRUB. From b0b1b81a11f8bae8ab9e8edd87ac3f4f7949d03b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 08:42:14 +0200 Subject: [PATCH 0698/1167] rk3288_spi: Add SPI driver --- grub-core/Makefile.core.def | 1 + grub-core/bus/spi/rk3288_spi.c | 103 +++++++++++++++++++++++++++++ grub-core/kern/arm/coreboot/init.c | 2 + include/grub/arm/coreboot/kernel.h | 4 +- 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 grub-core/bus/spi/rk3288_spi.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 5ce506597..d2239f171 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -162,6 +162,7 @@ kernel = { arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; + arm_coreboot = bus/spi/rk3288_spi.c; arm_coreboot = commands/keylayouts.c; arm_coreboot = kern/arm/coreboot/dma.c; diff --git a/grub-core/bus/spi/rk3288_spi.c b/grub-core/bus/spi/rk3288_spi.c new file mode 100644 index 000000000..aacb79ffe --- /dev/null +++ b/grub-core/bus/spi/rk3288_spi.c @@ -0,0 +1,103 @@ +/* + * GRUB -- GRand Unified Bootloader + * + * Copyright (C) 2012 Google Inc. + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * This is based on depthcharge code. + * + * 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 . + */ + +#include +#include +#include +#include +#include + +static grub_err_t +spi_send (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz) +{ + const grub_uint8_t *ptr = data, *end = ptr + sz; + volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); + spi[2] = 0; + spi[1] = sz - 1; + spi[0] = ((1 << 18) | spi[0]) & ~(1 << 19); + spi[2] = 1; + while (ptr < end) + { + while (spi[9] & 2); + spi[256] = *ptr++; + } + while (spi[9] & 1); + return GRUB_ERR_NONE; +} + +static grub_err_t +spi_receive (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz) +{ + grub_uint8_t *ptr = data, *end = ptr + sz; + volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); + spi[2] = 0; + spi[1] = sz - 1; + spi[0] = ((1 << 19) | spi[0]) & ~(1 << 18); + spi[2] = 1; + while (ptr < end) + { + while (spi[9] & 8); + *ptr++ = spi[512]; + } + while (spi[9] & 1); + return GRUB_ERR_NONE; +} + +static grub_err_t +spi_start (const struct grub_fdtbus_dev *dev) +{ + volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); + spi[3] = 1; + return GRUB_ERR_NONE; +} + +static void +spi_stop (const struct grub_fdtbus_dev *dev) +{ + volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); + spi[3] = 0; +} + +static grub_err_t +spi_attach(const struct grub_fdtbus_dev *dev) +{ + if (!grub_fdtbus_is_mapping_valid (grub_fdtbus_map_reg (dev, 0, 0))) + return GRUB_ERR_IO; + + return GRUB_ERR_NONE; +} + +static struct grub_fdtbus_driver spi = +{ + .compatible = "rockchip,rk3288-spi", + .attach = spi_attach, + .send = spi_send, + .receive = spi_receive, + .start = spi_start, + .stop = spi_stop, +}; + +void +grub_rk3288_spi_init (void) +{ + grub_fdtbus_register (&spi); +} diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c index a06ccb72f..0126ff638 100644 --- a/grub-core/kern/arm/coreboot/init.c +++ b/grub-core/kern/arm/coreboot/init.c @@ -132,6 +132,8 @@ grub_machine_init (void) grub_fatal ("No DTB found"); grub_fdtbus_init (dtb, dtb_size); + grub_rk3288_spi_init (); + grub_machine_timer_init (); grub_pl050_init (); } diff --git a/include/grub/arm/coreboot/kernel.h b/include/grub/arm/coreboot/kernel.h index 09cd7fe32..269505342 100644 --- a/include/grub/arm/coreboot/kernel.h +++ b/include/grub/arm/coreboot/kernel.h @@ -34,8 +34,8 @@ struct grub_fdt_board extern struct grub_fdt_board grub_fdt_boards[]; void grub_machine_timer_init (void); void grub_pl050_init (void); -void -grub_cros_init (void); +void grub_cros_init (void); +void grub_rk3288_spi_init (void); extern grub_addr_t EXPORT_VAR (start_of_ram); #endif /* ! ASM_FILE */ From 5c3fd1b135bd73c8e3467b9b635b25ca4d360a19 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 08:47:34 +0200 Subject: [PATCH 0699/1167] arm_coreboot: Add Chromebook keyboard driver. --- grub-core/term/arm/cros.c | 125 ++++++++++++++++++ grub-core/term/arm/cros_ec.c | 238 +++++++++++++++++++++++++++++++++++ include/grub/arm/cros_ec.h | 21 ++++ 3 files changed, 384 insertions(+) create mode 100644 grub-core/term/arm/cros.c create mode 100644 grub-core/term/arm/cros_ec.c create mode 100644 include/grub/arm/cros_ec.h diff --git a/grub-core/term/arm/cros.c b/grub-core/term/arm/cros.c new file mode 100644 index 000000000..1ff9f8ccf --- /dev/null +++ b/grub-core/term/arm/cros.c @@ -0,0 +1,125 @@ +/* + * GRUB -- GRand Unified Bootloader + * + * Copyright (C) 2012 Google Inc. + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * This is based on depthcharge code. + * + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grub_ps2_state ps2_state; + +struct grub_cros_ec_keyscan old_scan; + +static const struct grub_fdtbus_dev *cros_ec; + +static grub_uint8_t map_code[GRUB_CROS_EC_KEYSCAN_COLS][GRUB_CROS_EC_KEYSCAN_ROWS]; + +static grub_uint8_t e0_translate[16] = + { + 0x1c, 0x1d, 0x35, 0x00, + 0x38, 0x00, 0x47, 0x48, + 0x49, 0x4b, 0x4d, 0x4f, + 0x50, 0x51, 0x52, 0x53, + }; + +/* If there is a character pending, return it; + otherwise return GRUB_TERM_NO_KEY. */ +static int +grub_cros_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) +{ + struct grub_cros_ec_keyscan scan; + int i, j; + if (grub_cros_ec_scan_keyboard (cros_ec, &scan) < 0) + return GRUB_TERM_NO_KEY; + for (i = 0; i < GRUB_CROS_EC_KEYSCAN_COLS; i++) + if (scan.data[i] ^ old_scan.data[i]) + for (j = 0; j < GRUB_CROS_EC_KEYSCAN_ROWS; j++) + if ((scan.data[i] ^ old_scan.data[i]) & (1 << j)) + { + grub_uint8_t code = map_code[i][j]; + int ret; + grub_uint8_t brk = 0; + if (!(scan.data[i] & (1 << j))) + brk = 0x80; + grub_dprintf ("cros_keyboard", "key <%d, %d> code %x\n", i, j, code); + if (code < 0x60) + ret = grub_ps2_process_incoming_byte (&ps2_state, code | brk); + else if (code >= 0x60 && code < 0x70 && e0_translate[code - 0x60]) + { + grub_ps2_process_incoming_byte (&ps2_state, 0xe0); + ret = grub_ps2_process_incoming_byte (&ps2_state, e0_translate[code - 0x60] | brk); + } + else + ret = GRUB_TERM_NO_KEY; + old_scan.data[i] ^= (1 << j); + if (ret != GRUB_TERM_NO_KEY) + return ret; + } + return GRUB_TERM_NO_KEY; +} + +static struct grub_term_input grub_cros_keyboard_term = + { + .name = "cros_keyboard", + .getkey = grub_cros_keyboard_getkey + }; + +static grub_err_t +cros_attach (const struct grub_fdtbus_dev *dev) +{ + grub_size_t keymap_size, i; + const grub_uint8_t *keymap = grub_fdtbus_get_prop (dev, "linux,keymap", &keymap_size); + + if (!dev->parent || !grub_cros_ec_validate (dev->parent)) + return GRUB_ERR_IO; + + if (keymap) + { + for (i = 0; i + 3 < keymap_size; i += 4) + if (keymap[i+1] < GRUB_CROS_EC_KEYSCAN_COLS && keymap[i] < GRUB_CROS_EC_KEYSCAN_ROWS + && keymap[i+2] == 0 && keymap[i+3] < 0x80) + map_code[keymap[i+1]][keymap[i]] = keymap[i+3]; + } + + cros_ec = dev->parent; + ps2_state.current_set = 1; + ps2_state.at_keyboard_status = 0; + grub_term_register_input ("cros_keyboard", &grub_cros_keyboard_term); + return GRUB_ERR_NONE; +} + +static struct grub_fdtbus_driver cros = +{ + .compatible = "google,cros-ec-keyb", + .attach = cros_attach +}; + +void +grub_cros_init (void) +{ + grub_fdtbus_register (&cros); +} diff --git a/grub-core/term/arm/cros_ec.c b/grub-core/term/arm/cros_ec.c new file mode 100644 index 000000000..f4144818b --- /dev/null +++ b/grub-core/term/arm/cros_ec.c @@ -0,0 +1,238 @@ +/* + * GRUB -- GRand Unified Bootloader + * + * Copyright (C) 2012 Google Inc. + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * This is based on depthcharge code. + * + * 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 . + */ + +#include +#include +#include +#include +#include + +static const grub_uint64_t FRAMING_TIMEOUT_MS = 300; + +static const grub_uint8_t EC_FRAMING_BYTE = 0xec; + +#define EC_CMD_MKBP_STATE 0x60 +#define EC_CMD_VERSION0 0xdc + +static grub_uint64_t last_transfer; + +static void +stop_bus (const struct grub_fdtbus_dev *spi) +{ + spi->driver->stop (spi); + last_transfer = grub_get_time_ms (); +} + +static int +wait_for_frame (const struct grub_fdtbus_dev *spi) +{ + grub_uint64_t start = grub_get_time_ms (); + grub_uint8_t byte; + do + { + if (spi->driver->receive (spi, &byte, 1)) + return -1; + if (byte != EC_FRAMING_BYTE && + grub_get_time_ms () - start > FRAMING_TIMEOUT_MS) + { + grub_dprintf ("cros", "Timeout waiting for framing byte.\n"); + return -1; + } + } + while (byte != EC_FRAMING_BYTE); + return 0; +} + +/* + * Calculate a simple 8-bit checksum of a data block + * + * @param data Data block to checksum + * @param size Size of data block in bytes + * @return checksum value (0 to 255) + */ +static grub_uint8_t +cros_ec_calc_checksum (const void *data, int size) +{ + grub_uint8_t csum; + const grub_uint8_t *bytes = data; + int i; + + for (i = csum = 0; i < size; i++) + csum += bytes[i]; + return csum & 0xff; +} + +enum +{ + /* response, arglen */ + CROS_EC_SPI_IN_HDR_SIZE = 2, + /* version, cmd, arglen */ + CROS_EC_SPI_OUT_HDR_SIZE = 3 +}; + +static grub_uint8_t busbuf[256]; +#define MSG_BYTES ((int)sizeof (busbuf)) + +static int +ec_command (const struct grub_fdtbus_dev *dev, int cmd, int cmd_version, + const void *dout, int dout_len, void *din, int din_len) +{ + const struct grub_fdtbus_dev *spi = dev->parent; + grub_uint8_t *bytes; + + /* Header + data + checksum. */ + grub_uint32_t out_bytes = CROS_EC_SPI_OUT_HDR_SIZE + dout_len + 1; + grub_uint32_t in_bytes = CROS_EC_SPI_IN_HDR_SIZE + din_len + 1; + + /* + * Sanity-check I/O sizes given transaction overhead in internal + * buffers. + */ + if (out_bytes > MSG_BYTES) + { + grub_dprintf ("cros", "Cannot send %d bytes\n", dout_len); + return -1; + } + if (in_bytes > MSG_BYTES) + { + grub_dprintf ("cros", "Cannot receive %d bytes\n", din_len); + return -1; + } + + /* Prepare the output. */ + bytes = busbuf; + *bytes++ = EC_CMD_VERSION0 + cmd_version; + *bytes++ = cmd; + *bytes++ = dout_len; + grub_memcpy (bytes, dout, dout_len); + bytes += dout_len; + + *bytes++ = cros_ec_calc_checksum (busbuf, + CROS_EC_SPI_OUT_HDR_SIZE + dout_len); + + /* Depthcharge uses 200 us here but GRUB timer resolution is only 1ms, + decrease this when we increase timer resolution. */ + while (grub_get_time_ms () - last_transfer < 1) + ; + + if (spi->driver->start (spi)) + return -1; + + /* Allow EC to ramp up clock after being awoken. */ + /* Depthcharge only waits 100 us here but GRUB timer resolution is only 1ms, + decrease this when we increase timer resolution. */ + grub_millisleep (1); + + if (spi->driver->send (spi, busbuf, out_bytes)) + { + stop_bus (spi); + return -1; + } + + /* Wait until the EC is ready. */ + if (wait_for_frame (spi)) + { + stop_bus (spi); + return -1; + } + + /* Read the response code and the data length. */ + bytes = busbuf; + if (spi->driver->receive (spi, bytes, 2)) + { + stop_bus (spi); + return -1; + } + grub_uint8_t result = *bytes++; + grub_uint8_t length = *bytes++; + + /* Make sure there's enough room for the data. */ + if (CROS_EC_SPI_IN_HDR_SIZE + length + 1 > MSG_BYTES) + { + grub_dprintf ("cros", "Received length %#02x too large\n", length); + stop_bus (spi); + return -1; + } + + /* Read the data and the checksum, and finish up. */ + if (spi->driver->receive (spi, bytes, length + 1)) + { + stop_bus (spi); + return -1; + } + bytes += length; + int expected = *bytes++; + stop_bus (spi); + + /* Check the integrity of the response. */ + if (result != 0) + { + grub_dprintf ("cros", "Received bad result code %d\n", result); + return -result; + } + + int csum = cros_ec_calc_checksum (busbuf, + CROS_EC_SPI_IN_HDR_SIZE + length); + + if (csum != expected) + { + grub_dprintf ("cros", "Invalid checksum rx %#02x, calced %#02x\n", + expected, csum); + return -1; + } + + /* If the caller wants the response, copy it out for them. */ + if (length < din_len) + din_len = length; + if (din) + { + grub_memcpy (din, (grub_uint8_t *) busbuf + CROS_EC_SPI_IN_HDR_SIZE, din_len); + } + + return din_len; +} + +int +grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev, struct grub_cros_ec_keyscan *scan) +{ + if (ec_command (dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan, + sizeof (*scan)) < (int) sizeof (*scan)) + return -1; + + return 0; +} + +int +grub_cros_ec_validate (const struct grub_fdtbus_dev *dev) +{ + if (!grub_fdtbus_is_compatible("google,cros-ec-spi", dev)) + return 0; + if (!dev->parent) + return 0; + if (!dev->parent->driver) + return 0; + if (!dev->parent->driver->send + || !dev->parent->driver->receive) + return 0; + return 1; +} + diff --git a/include/grub/arm/cros_ec.h b/include/grub/arm/cros_ec.h new file mode 100644 index 000000000..45a372572 --- /dev/null +++ b/include/grub/arm/cros_ec.h @@ -0,0 +1,21 @@ +#ifndef GRUB_ARM_CROS_EC_H +#define GRUB_ARM_CROS_EC_H 1 + +#include +#include + +#define GRUB_CROS_EC_KEYSCAN_COLS 13 +#define GRUB_CROS_EC_KEYSCAN_ROWS 8 + +struct grub_cros_ec_keyscan { + grub_uint8_t data[GRUB_CROS_EC_KEYSCAN_COLS]; +}; + +int +grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev, + struct grub_cros_ec_keyscan *scan); + +int +grub_cros_ec_validate (const struct grub_fdtbus_dev *dev); + +#endif From c6eaa982d12e3cfc5465dda5ea372774188b6b81 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 09:02:15 +0200 Subject: [PATCH 0700/1167] Missing parts of previous commit --- grub-core/Makefile.core.def | 2 ++ grub-core/kern/arm/coreboot/init.c | 1 + 2 files changed, 3 insertions(+) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d2239f171..1d86bd22e 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -162,6 +162,8 @@ kernel = { arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; + arm_coreboot = term/arm/cros.c; + arm_coreboot = term/arm/cros_ec.c; arm_coreboot = bus/spi/rk3288_spi.c; arm_coreboot = commands/keylayouts.c; arm_coreboot = kern/arm/coreboot/dma.c; diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c index 0126ff638..8d8c5b829 100644 --- a/grub-core/kern/arm/coreboot/init.c +++ b/grub-core/kern/arm/coreboot/init.c @@ -135,6 +135,7 @@ grub_machine_init (void) grub_rk3288_spi_init (); grub_machine_timer_init (); + grub_cros_init (); grub_pl050_init (); } From 70b555a52a065b2beb91e6fc97a6b358c931b303 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Tue, 9 May 2017 09:03:02 +0200 Subject: [PATCH 0701/1167] coreboot: Changed cbmemc to support updated console format from coreboot. --- grub-core/term/i386/coreboot/cbmemc.c | 50 +++++++++++++++++++-------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/grub-core/term/i386/coreboot/cbmemc.c b/grub-core/term/i386/coreboot/cbmemc.c index 129248c7f..cea9b8431 100644 --- a/grub-core/term/i386/coreboot/cbmemc.c +++ b/grub-core/term/i386/coreboot/cbmemc.c @@ -29,11 +29,14 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#define CURSOR_MASK ((1 << 28) - 1) +#define OVERFLOW (1 << 31) + struct grub_linuxbios_cbmemc { grub_uint32_t size; - grub_uint32_t pointer; - char data[0]; + grub_uint32_t cursor; + char body[0]; }; static struct grub_linuxbios_cbmemc *cbmemc; @@ -41,11 +44,20 @@ static struct grub_linuxbios_cbmemc *cbmemc; static void put (struct grub_term_output *term __attribute__ ((unused)), const int c) { + grub_uint32_t flags, cursor; if (!cbmemc) return; - if (cbmemc->pointer < cbmemc->size) - cbmemc->data[cbmemc->pointer] = c; - cbmemc->pointer++; + flags = cbmemc->cursor & ~CURSOR_MASK; + cursor = cbmemc->cursor & CURSOR_MASK; + if (cursor >= cbmemc->size) + return; + cbmemc->body[cursor++] = c; + if (cursor >= cbmemc->size) + { + cursor = 0; + flags |= OVERFLOW; + } + cbmemc->cursor = flags | cursor; } struct grub_terminfo_output_state grub_cbmemc_terminfo_output = @@ -87,21 +99,29 @@ grub_cmd_cbmemc (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused))) { - grub_size_t len; - char *str; - struct grub_linuxbios_cbmemc *cbmemc_saved; + grub_size_t size, cursor; + struct grub_linuxbios_cbmemc *real_cbmemc; if (!cbmemc) return grub_error (GRUB_ERR_IO, "no CBMEM console found"); - len = cbmemc->pointer; - if (len > cbmemc->size) - len = cbmemc->size; - str = cbmemc->data; - cbmemc_saved = cbmemc; + real_cbmemc = cbmemc; cbmemc = 0; - grub_xnputs (str, len); - cbmemc = cbmemc_saved; + cursor = real_cbmemc->cursor & CURSOR_MASK; + if (!(real_cbmemc->cursor & OVERFLOW) && cursor < real_cbmemc->size) + size = cursor; + else + size = real_cbmemc->size; + if (real_cbmemc->cursor & OVERFLOW) + { + if (cursor > size) + cursor = 0; + grub_xnputs(real_cbmemc->body + cursor, size - cursor); + grub_xnputs(real_cbmemc->body, cursor); + } + else + grub_xnputs(real_cbmemc->body, size); + cbmemc = real_cbmemc; return 0; } From c4b8bec5fee4e30a165fd14a188cf3ab8eccd095 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 14:27:52 +0200 Subject: [PATCH 0702/1167] at_keyboard: Fix falco chromebook case. EC is slow, so we need few delays for it to toggle the bits correctly. Command to enable clock and keyboard were not sent. --- grub-core/term/at_keyboard.c | 23 ++++++++++++++--------- include/grub/at_keyboard.h | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 3ab4e205f..f0a986eb1 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -40,6 +40,8 @@ grub_keyboard_controller_init (void); static void keyboard_controller_wait_until_ready (void) { + /* 50 us would be enough but our current time resolution is 1ms. */ + grub_millisleep (1); while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); } @@ -50,10 +52,11 @@ wait_ack (void) grub_uint8_t ack; endtime = grub_get_time_ms () + 20; - do + do { + keyboard_controller_wait_until_ready (); ack = grub_inb (KEYBOARD_REG_DATA); - while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK - && grub_get_time_ms () < endtime); + } while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK + && grub_get_time_ms () < endtime); return ack; } @@ -135,12 +138,10 @@ query_mode (void) if (!e) return 0; - keyboard_controller_wait_until_ready (); - - do + do { + keyboard_controller_wait_until_ready (); ret = grub_inb (KEYBOARD_REG_DATA); - while (ret == GRUB_AT_ACK); - + } while (ret == GRUB_AT_ACK); /* QEMU translates the set even in no-translate mode. */ if (ret == 0x43 || ret == 1) return 1; @@ -169,7 +170,11 @@ set_scancodes (void) #else grub_keyboard_controller_write (grub_keyboard_controller_orig - & ~KEYBOARD_AT_TRANSLATE); + & ~KEYBOARD_AT_TRANSLATE + & ~KEYBOARD_AT_DISABLE); + + keyboard_controller_wait_until_ready (); + grub_outb (KEYBOARD_COMMAND_ENABLE, KEYBOARD_REG_DATA); write_mode (2); ps2_state.current_set = query_mode (); diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h index b031523eb..bcb4d9ba7 100644 --- a/include/grub/at_keyboard.h +++ b/include/grub/at_keyboard.h @@ -23,9 +23,11 @@ #define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02) #define KEYBOARD_COMMAND_READ 0x20 #define KEYBOARD_COMMAND_WRITE 0x60 +#define KEYBOARD_COMMAND_ENABLE 0xf4 #define KEYBOARD_COMMAND_REBOOT 0xfe #define KEYBOARD_AT_TRANSLATE 0x40 +#define KEYBOARD_AT_DISABLE 0x10 #define KEYBOARD_ISMAKE(x) !((x) & 0x80) #define KEYBOARD_ISREADY(x) ((x) & 0x01) From bd4e40aadded7093908d786d03b4acf60b7b1707 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 11 May 2017 18:42:23 -0700 Subject: [PATCH 0703/1167] sparc64: Close cdboot ihandle The ihandle is left open with a cd-core image. This will cause a delay booting grub from a virtual cdrom in a LDOM. It will also cause problems as Linux boots, since it expects the ihandle to be closed during init. Orabug: 25911275 Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/boot/sparc64/ieee1275/boot.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 586efb401..9ea9b4e06 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -69,6 +69,10 @@ prom_seek_name: .asciz "seek" prom_read_name: .asciz "read" prom_exit_name: .asciz "exit" grub_name: .asciz "GRUB " +#ifdef CDBOOT +prom_close_name: .asciz "close" +#endif + #define GRUB_NAME_LEN 5 .align 4 @@ -213,6 +217,12 @@ bootpath_known: call prom_call_3_1_o1 #ifdef CDBOOT LDUW_ABS(kernel_size, 0x00, %o3) + + GET_ABS(prom_close_name, %o0) + mov 1, %g1 + mov 0, %o5 + call prom_call + mov BOOTDEV_REG, %o1 #else mov 512, %o3 #endif From ae5817f1dcbf0b99f7a849f56afe442165317840 Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Fri, 19 Feb 2016 16:28:52 +0000 Subject: [PATCH 0704/1167] arm64/xen_boot: Fix Xen boot using GRUB2 on AARCH64 Xen is currently crashing because of malformed compatible property for the boot module. This is because the property string is not null-terminated as requested by the ePAR spec. Signed-off-by: Julien Grall Tested-by: Fu Wei Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/xen_boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index a914eb8e2..8ae43d7e8 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -156,7 +156,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", - MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1); + MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE)); if (retval) return grub_error (GRUB_ERR_IO, "failed to update FDT"); From 8eed7be8a61c295df700e918744a984162378ca9 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Sun, 14 May 2017 15:43:45 +0800 Subject: [PATCH 0705/1167] arm64: Add "--nounzip" option support in xen_module command This patch adds "--nounzip" option support in order to be compatible with the module command of multiboot on other architecture, by this way we can simplify grub-mkconfig support code. This patch also allow us to use zip compressed module(like Linux kernel for Dom0). Signed-off-by: Fu Wei Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/xen_boot.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 8ae43d7e8..27ede46ca 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -379,6 +379,20 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), struct xen_boot_binary *module = NULL; grub_file_t file = 0; + int nounzip = 0; + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + if (grub_strcmp (argv[0], "--nounzip") == 0) + { + argv++; + argc--; + nounzip = 1; + } if (!argc) { @@ -403,6 +417,8 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), grub_dprintf ("xen_loader", "Init module and node info\n"); + if (nounzip) + grub_file_filter_disable_compression (); file = grub_file_open (argv[0]); if (!file) goto fail; From d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Sun, 14 May 2017 15:43:46 +0800 Subject: [PATCH 0706/1167] util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64 This patch adds the support of xen_boot command for aarch64: xen_hypervisor xen_module These two commands are only for aarch64, since it has its own protocol and commands to boot xen hypervisor and Dom0, but not multiboot. For other architectures, they are still using multiboot and module commands. Signed-off-by: Fu Wei Reviewed-by: Daniel Kiper --- util/grub.d/20_linux_xen.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index c48af948d..c002fc9f9 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -122,16 +122,16 @@ linux_entry () else xen_rm_opts="no-real-mode edd=off" fi - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} + ${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} + ${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - module --nounzip ${rel_dirname}/${initrd} + ${module_loader} --nounzip ${rel_dirname}/${initrd} EOF fi sed "s/^/$submenu_indentation/" << EOF @@ -206,6 +206,14 @@ while [ "x${xen_list}" != "x" ] ; do if [ "x$is_top_level" != xtrue ]; then echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {" fi + $grub_file --is-arm64-efi $current_xen + if [ $? -ne 0 ]; then + xen_loader="multiboot" + module_loader="module" + else + xen_loader="xen_hypervisor" + module_loader="xen_module" + fi while [ "x$list" != "x" ] ; do linux=`version_find_latest $list` gettext_printf "Found linux image: %s\n" "$linux" >&2 From 26c2f306fd425d2c0348023b8dcb7eb40a01851a Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Sun, 14 May 2017 15:43:47 +0800 Subject: [PATCH 0707/1167] arm64: Update the introduction of Xen boot commands in docs/grub.texi delete: xen_linux, xen_initrd, xen_xsm add: xen_module This update bases on commit 0edd750e50698854068358ea53528100a9192902 Author: Vladimir Serbinenko Date: Fri Jan 22 10:18:47 2016 +0100 xen_boot: Remove obsolete module type distinctions. Also bases on the module loading mechanism of Xen code: 488c2a8 docs/arm64: clarify the documention for loading XSM support 67831c4 docs/arm64: update the documentation for loading XSM support ca32012 xen/arm64: check XSM Magic from the second unknown module. Signed-off-by: Fu Wei Reviewed-by: Julien Grall Reviewed-by: Daniel Kiper --- docs/grub.texi | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index e935af33e..a0c4b9e4e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3873,11 +3873,9 @@ you forget a command, you can run the command @command{help} @comment * vbeinfo:: List available video modes * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes -@comment * xen_*:: Xen boot commands -* xen_hypervisor:: Load xen hypervisor binary -* xen_linux:: Load dom0 kernel for xen hypervisor -* xen_initrd:: Load dom0 initrd for dom0 kernel -* xen_xsm:: Load xen security module for xen hypervisor +@comment * xen_*:: Xen boot commands for AArch64 +* xen_hypervisor:: Load xen hypervisor binary (only on AArch64) +* xen_module:: Load xen modules for xen hypervisor (only on AArch64) @end menu @@ -5153,32 +5151,22 @@ List available video modes. If resolution is given, show only matching modes. Load a Xen hypervisor binary from @var{file}. The rest of the line is passed verbatim as the @dfn{kernel command-line}. Any other binaries must be reloaded after using this command. +This command is only available on AArch64 systems. @end deffn -@node xen_linux -@subsection xen_linux +@node xen_module +@subsection xen_module -@deffn Command xen_linux file [arguments] -Load a dom0 kernel image for xen hypervisor at the booting process of xen. +@deffn Command xen_module [--nounzip] file [arguments] +Load a module for xen hypervisor at the booting process of xen. The rest of the line is passed verbatim as the module command line. +Modules should be loaded in the following order: + - dom0 kernel image + - dom0 ramdisk if present + - XSM policy if present +This command is only available on AArch64 systems. @end deffn -@node xen_initrd -@subsection xen_initrd - -@deffn Command xen_initrd file -Load a initrd image for dom0 kernel at the booting process of xen. -@end deffn - -@node xen_xsm -@subsection xen_xsm - -@deffn Command xen_xsm file -Load a xen security module for xen hypervisor at the booting process of xen. -See @uref{http://wiki.xen.org/wiki/XSM} for more detail. -@end deffn - - @node Networking commands @section The list of networking commands From f8679cedff703b437171f4708d46adbfcff80a65 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 18 May 2017 17:10:22 -0600 Subject: [PATCH 0708/1167] sparc64: Don't use devspec to determine the OBP path Don't use devspec to determine the OBP path on SPARC hardware. Within all versions of Linux on SPARC, the devspec returns one of three values: "none", "vnet-port", or "vdisk". Unlike on PPC, none of these values are useful in determining the OBP path. Before this patch grub-ofpathname always returned the wrong value for a virtual disk. For example: % grub-ofpathname /dev/vdiskc2 vdisk/disk@2:b After this patch it now returns the correct value: % grub-ofpathname /dev/vdiskc2 /virtual-devices@100/channel-devices@200/disk@2:b Orabug: 24459765 Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index a79682a5e..dce4e59d0 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -120,6 +120,8 @@ find_obppath (const char *sysfs_path_orig) #endif fd = open(path, O_RDONLY); + +#ifndef __sparc__ if (fd < 0 || fstat (fd, &st) < 0) { if (fd >= 0) @@ -127,6 +129,7 @@ find_obppath (const char *sysfs_path_orig) snprintf(path, path_size, "%s/devspec", sysfs_path); fd = open(path, O_RDONLY); } +#endif if (fd < 0 || fstat (fd, &st) < 0) { From 734668238fcc0ef691a080839e04f33854fa133a Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 29 Jun 2017 13:27:49 +0000 Subject: [PATCH 0709/1167] Allow GRUB to mount ext2/3/4 filesystems that have the encryption feature. On such a filesystem, inodes may have EXT4_ENCRYPT_FLAG set. For a regular file, this means its contents are encrypted; for a directory, this means the filenames in its directory entries are encrypted; and for a symlink, this means its target is encrypted. Since GRUB cannot decrypt encrypted contents or filenames, just issue an error if it would need to do so. This is sufficient to allow unencrypted boot files to co-exist with encrypted files elsewhere on the filesystem. (Note that encrypted regular files and symlinks will not normally be encountered outside an encrypted directory; however, it's possible via hard links, so they still need to be handled.) Tested by booting from an ext4 /boot partition on which I had run 'tune2fs -O encrypt'. I also verified that the expected error messages are printed when trying to access encrypted directories, files, and symlinks from the GRUB command line. Also ran 'sudo ./grub-fs-tester ext4_encrypt'; note that this requires e2fsprogs v1.43+ and Linux v4.1+. Signed-off-by: Eric Biggers --- grub-core/fs/ext2.c | 23 ++++++++++++++++++++++- tests/ext234_test.in | 1 + tests/util/grub-fs-tester.in | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index cdce63bcc..b8ad75a0f 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -102,6 +102,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 +#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 /* The set of back-incompatible features this driver DOES support. Add (OR) * flags here as the related features are implemented into the driver. */ @@ -109,7 +110,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); | EXT4_FEATURE_INCOMPAT_EXTENTS \ | EXT4_FEATURE_INCOMPAT_FLEX_BG \ | EXT2_FEATURE_INCOMPAT_META_BG \ - | EXT4_FEATURE_INCOMPAT_64BIT) + | EXT4_FEATURE_INCOMPAT_64BIT \ + | EXT4_FEATURE_INCOMPAT_ENCRYPT) /* List of rationales for the ignored "incompatible" features: * needs_recovery: Not really back-incompatible - was added as such to forbid * ext2 drivers from mounting an ext3 volume with a dirty @@ -138,6 +140,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT3_JOURNAL_FLAG_DELETED 4 #define EXT3_JOURNAL_FLAG_LAST_TAG 8 +#define EXT4_ENCRYPT_FLAG 0x800 #define EXT4_EXTENTS_FLAG 0x80000 /* The ext2 superblock. */ @@ -706,6 +709,12 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) grub_ext2_read_inode (diro->data, diro->ino, &diro->inode); if (grub_errno) return 0; + + if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "symlink is encrypted"); + return 0; + } } symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1); @@ -749,6 +758,12 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir, return 0; } + if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "directory is encrypted"); + return 0; + } + /* Search the file. */ while (fpos < grub_le_to_cpu32 (diro->inode.size)) { @@ -859,6 +874,12 @@ grub_ext2_open (struct grub_file *file, const char *name) goto fail; } + if (fdiro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) + { + err = grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "file is encrypted"); + goto fail; + } + grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode)); grub_free (fdiro); diff --git a/tests/ext234_test.in b/tests/ext234_test.in index 892b99cbd..4f1eb527e 100644 --- a/tests/ext234_test.in +++ b/tests/ext234_test.in @@ -30,3 +30,4 @@ fi "@builddir@/grub-fs-tester" ext3 "@builddir@/grub-fs-tester" ext4 "@builddir@/grub-fs-tester" ext4_metabg +"@builddir@/grub-fs-tester" ext4_encrypt diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 88cbe7365..fd7e0f14b 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -156,6 +156,12 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do # Could go further but what's the point? MAXBLKSIZE=$((65536*1024)) ;; + xext4_encrypt) + # OS LIMITATION: Linux currently only allows the 'encrypt' feature + # in combination with block_size = PAGE_SIZE (4096 bytes on x86). + MINBLKSIZE=$(getconf PAGE_SIZE) + MAXBLKSIZE=$MINBLKSIZE + ;; xext*) MINBLKSIZE=1024 if [ $MINBLKSIZE -lt $SECSIZE ]; then @@ -796,6 +802,10 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext4" -O meta_bg,^resize_inode -b $BLKSIZE -L "$FSLABEL" -q "${MOUNTDEVICE}" MOUNTFS=ext4 ;; + xext4_encrypt) + MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext4" -O encrypt -b $BLKSIZE -L "$FSLABEL" -q "${MOUNTDEVICE}" + MOUNTFS=ext4 + ;; xext*) MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${MOUNTDEVICE}" ;; xxfs) From edb37fb30bbc8a3b6bec67911c7200e4eb071127 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 9 Jul 2017 20:58:31 +0200 Subject: [PATCH 0710/1167] ehci: Fix compilation for amd64 --- grub-core/bus/usb/ehci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index c772e7654..7b7061f53 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -504,8 +504,8 @@ grub_ehci_init_device (volatile void *regs) #endif grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", - (grub_addr_t) e->iobase_ehcc + caplen); + "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llxx\n", + (unsigned long long) e->iobase_ehcc + caplen); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", @@ -696,8 +696,8 @@ grub_ehci_init_device (volatile void *regs) grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n"); grub_dprintf ("ehci", - "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", - (grub_addr_t) regs); + "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llx\n", + (unsigned long long) regs); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", From d8901e3ba115d705c9c08ecedd201aca8b4867b8 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 9 Jul 2017 20:59:15 +0200 Subject: [PATCH 0711/1167] cache: Fix compilation for ppc, sparc and arm64 --- include/grub/cache.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/grub/cache.h b/include/grub/cache.h index 1c98ce270..ccfa717e6 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -34,7 +34,9 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); #endif #ifndef GRUB_MACHINE_EMU -#if defined (__i386__) || defined (__x86_64__) +#if defined (__aarch64__) || defined (__powerpc__) || defined (__sparc__) + +#elif defined (__i386__) || defined (__x86_64__) static inline void grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) From 284afab081ef7ed7db2c59151853aa3c92d988f2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 9 Jul 2017 21:31:19 +0200 Subject: [PATCH 0712/1167] ehci: Fix compilation on i386 --- grub-core/bus/usb/ehci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index 7b7061f53..d966fc210 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -505,7 +505,7 @@ grub_ehci_init_device (volatile void *regs) grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llxx\n", - (unsigned long long) e->iobase_ehcc + caplen); + (unsigned long long) (grub_addr_t) e->iobase_ehcc + caplen); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", @@ -697,7 +697,7 @@ grub_ehci_init_device (volatile void *regs) grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llx\n", - (unsigned long long) regs); + (unsigned long long) (grub_addr_t) regs); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", From a0fe0c26aa8a1c0ad66d9527611bd726b849c623 Mon Sep 17 00:00:00 2001 From: AppChecker Date: Sun, 9 Jul 2017 21:57:35 +0200 Subject: [PATCH 0713/1167] crypto: Fix use after free. Reported by: AppChecker Transformed to patch by: Satish Govindarajan --- grub-core/normal/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c index 2bfd67c8e..e6d345f33 100644 --- a/grub-core/normal/crypto.c +++ b/grub-core/normal/crypto.c @@ -147,8 +147,8 @@ read_crypto_list (const char *prefix) if (! cur->modname) { grub_errno = GRUB_ERR_NONE; - grub_free (cur); grub_free (cur->name); + grub_free (cur); continue; } cur->next = crypto_specs; From cb8b7e4e36bf32dccbbba8252aa44ad3ada4fbc1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 9 Jul 2017 21:48:37 +0000 Subject: [PATCH 0714/1167] arm-efi: Fix compilation --- grub-core/loader/arm/linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 260cbf068..e64c79a95 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -252,12 +252,12 @@ linux_boot (void) #ifdef GRUB_MACHINE_EFI grub_size_t size; if (fdt_valid) - size = grub_fdt_get_totalsize (fdt_addr); + size = grub_fdt_get_totalsize (current_fdt); else - size = 4 * get_atag_size (atag_orig); + size = 4 * get_atag_size (current_fdt); size += grub_strlen (linux_args) + 256; target_fdt = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size); - if (!fdt_addr) + if (!target_fdt) return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); #else target_fdt = (void *) LINUX_FDT_ADDRESS; @@ -522,7 +522,7 @@ GRUB_MOD_INIT (linux) /* TRANSLATORS: DTB stands for device tree blob. */ 0, N_("Load DTB file.")); my_mod = mod; - current_fdt = grub_arm_firmware_get_boot_data (); + current_fdt = (const void *) grub_arm_firmware_get_boot_data (); machine_type = grub_arm_firmware_get_machine_type (); } From 68d54b55f49249c5e0517bf189f0f3df7ee6a36f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 10 Jul 2017 01:34:22 +0000 Subject: [PATCH 0715/1167] fdt: silence clang warning. --- grub-core/lib/fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index bdc630244..2705f2629 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -309,7 +309,8 @@ advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t continue; } char *ptr; - for (ptr = (char *) (token + 1); *ptr && ptr < (char *) end; ptr++); + for (ptr = (char *) (token + 1); *ptr && ptr < (char *) end; ptr++) + ; if (ptr >= (char *) end) return 0; return token; From e8ab5a1a9e2889eb59d1fa494ba441a53698dcd2 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 19 Jul 2017 15:47:41 -0400 Subject: [PATCH 0716/1167] Fix a segfault in lsefi when protocols_per_handle returns error, we can't use the pointers we passed to it, and that includes trusting num_protocols. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- grub-core/commands/efi/lsefi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c index d901c3892..d1ce99af4 100644 --- a/grub-core/commands/efi/lsefi.c +++ b/grub-core/commands/efi/lsefi.c @@ -109,8 +109,10 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle, handle, &protocols, &num_protocols); - if (status != GRUB_EFI_SUCCESS) + if (status != GRUB_EFI_SUCCESS) { grub_printf ("Unable to retrieve protocols\n"); + continue; + } for (j = 0; j < num_protocols; j++) { for (k = 0; k < ARRAY_SIZE (known_protocols); k++) From fa42786264cef98c56e972b3bb6b8448000e1c70 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 3 Aug 2017 15:46:15 +0100 Subject: [PATCH 0717/1167] zfs: remove size_t typedef and use grub_size_t instead * Prevents some toolchains from issuing a warning on size_t redef. --- grub-core/fs/zfs/zfs_lz4.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c index 2f73449f0..5453822d0 100644 --- a/grub-core/fs/zfs/zfs_lz4.c +++ b/grub-core/fs/zfs/zfs_lz4.c @@ -73,7 +73,6 @@ static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, #define U32 grub_uint32_t #define S32 grub_int32_t #define U64 grub_uint64_t -typedef grub_size_t size_t; typedef struct _U16_S { U16 v; @@ -133,10 +132,10 @@ typedef struct _U64_S { /* Decompression functions */ grub_err_t -lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len); +lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len); grub_err_t -lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len) +lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len) { const BYTE *src = s_start; U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | @@ -167,7 +166,7 @@ LZ4_uncompress_unknownOutputSize(const char *source, BYTE *const oend = op + maxOutputSize; BYTE *cpy; - size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 }; + grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 }; /* Main Loop */ while (ip < iend) { @@ -237,8 +236,8 @@ LZ4_uncompress_unknownOutputSize(const char *source, /* copy repeated sequence */ if unlikely(op - ref < STEPSIZE) { #if LZ4_ARCH64 - size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; - size_t dec2 = dec2table[op - ref]; + grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; + grub_size_t dec2 = dec2table[op - ref]; #else const int dec2 = 0; #endif From 76188809d5ca40c5285b0ab202b5edea7be3f04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 22 Jun 2017 14:33:17 +0200 Subject: [PATCH 0718/1167] udf: Fix reading label, lvd.ident is dstring UDF dstring has stored length in the last byte of buffer. Therefore last byte is not part of recorded characters. And empty string in dstring is encoded as empty buffer, including first byte (compression id). --- grub-core/fs/udf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 839bff889..258745633 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -860,6 +860,25 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) return outbuf; } +static char * +read_dstring (const grub_uint8_t *raw, grub_size_t sz) +{ + grub_size_t len; + + if (raw[0] == 0) { + char *outbuf = grub_malloc (1); + if (!outbuf) + return NULL; + outbuf[0] = 0; + return outbuf; + } + + len = raw[sz - 1]; + if (len > sz - 1) + len = sz - 1; + return read_string (raw, len, NULL); +} + static int grub_udf_iterate_dir (grub_fshelp_node_t dir, grub_fshelp_iterate_dir_hook_t hook, void *hook_data) @@ -1197,7 +1216,7 @@ grub_udf_label (grub_device_t device, char **label) if (data) { - *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0); + *label = read_dstring (data->lvd.ident, sizeof (data->lvd.ident)); grub_free (data); } else From 435fa75e01ef40917239c7f775e505e86f70d202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 22 Jun 2017 14:42:16 +0200 Subject: [PATCH 0719/1167] * grub-core/fs/udf.c: Add support for UUID Use same algorithm as in libblkid from util-linux v2.30. 1. Take first 16 bytes from UTF-8 encoded string of VolumeSetIdentifier 2. If all bytes are hexadecimal digits, convert to lowercase and use as UUID 3. If first 8 bytes are not all hexadecimal digits, convert those 8 bytes to their hexadecimal representation, resulting in 16 bytes for UUID 4. Otherwise, compose UUID from two parts: 1. part: converted first 8 bytes (which are hexadecimal digits) to lowercase 2. part: encoded following 4 bytes to their hexadecimal representation (16 bytes) So UUID would always have 16 hexadecimal digits in lowercase variant. According to UDF specification, first 16 Unicode characters of VolumeSetIdentifier should be unique value and first 8 should be hexadecimal characters. In most cases all 16 characters are hexadecimal, but e.g. MS Windows format.exe set only first 8 as hexadecimal and remaining as fixed (non-unique) which violates specification. --- grub-core/fs/udf.c | 121 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 258745633..00a16098b 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -321,6 +321,32 @@ struct grub_udf_partmap }; } GRUB_PACKED; +struct grub_udf_pvd +{ + struct grub_udf_tag tag; + grub_uint32_t seq_num; + grub_uint32_t pvd_num; + grub_uint8_t ident[32]; + grub_uint16_t vol_seq_num; + grub_uint16_t max_vol_seq_num; + grub_uint16_t interchange_level; + grub_uint16_t max_interchange_level; + grub_uint32_t charset_list; + grub_uint32_t max_charset_list; + grub_uint8_t volset_ident[128]; + struct grub_udf_charspec desc_charset; + struct grub_udf_charspec expl_charset; + struct grub_udf_extent_ad vol_abstract; + struct grub_udf_extent_ad vol_copyright; + struct grub_udf_regid app_ident; + struct grub_udf_timestamp recording_time; + struct grub_udf_regid imp_ident; + grub_uint8_t imp_use[64]; + grub_uint32_t pred_vds_loc; + grub_uint16_t flags; + grub_uint8_t reserved[22]; +} GRUB_PACKED; + struct grub_udf_lvd { struct grub_udf_tag tag; @@ -348,6 +374,7 @@ struct grub_udf_aed struct grub_udf_data { grub_disk_t disk; + struct grub_udf_pvd pvd; struct grub_udf_lvd lvd; struct grub_udf_pd pds[GRUB_UDF_MAX_PDS]; struct grub_udf_partmap *pms[GRUB_UDF_MAX_PMS]; @@ -692,7 +719,17 @@ grub_udf_mount (grub_disk_t disk) } tag.tag_ident = U16 (tag.tag_ident); - if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) + if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PVD) + { + if (grub_disk_read (disk, block << lbshift, 0, + sizeof (struct grub_udf_pvd), + &data->pvd)) + { + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); + goto fail; + } + } + else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) { if (data->npd >= GRUB_UDF_MAX_PDS) { @@ -1225,6 +1262,87 @@ grub_udf_label (grub_device_t device, char **label) return grub_errno; } +static char * +gen_uuid_from_volset (char *volset_ident) +{ + grub_size_t i; + grub_size_t len; + grub_size_t nonhexpos; + grub_uint8_t buf[17]; + char *uuid; + + len = grub_strlen (volset_ident); + if (len < 8) + return NULL; + + uuid = grub_malloc (17); + if (!uuid) + return NULL; + + if (len > 16) + len = 16; + + grub_memset (buf, 0, sizeof (buf)); + grub_memcpy (buf, volset_ident, len); + + nonhexpos = 16; + for (i = 0; i < 16; ++i) + { + if (!grub_isxdigit (buf[i])) + { + nonhexpos = i; + break; + } + } + + if (nonhexpos < 8) + { + grub_snprintf (uuid, 17, "%02x%02x%02x%02x%02x%02x%02x%02x", + buf[0], buf[1], buf[2], buf[3], + buf[4], buf[5], buf[6], buf[7]); + } + else if (nonhexpos < 16) + { + for (i = 0; i < 8; ++i) + uuid[i] = grub_tolower (buf[i]); + grub_snprintf (uuid+8, 9, "%02x%02x%02x%02x", + buf[8], buf[9], buf[10], buf[11]); + } + else + { + for (i = 0; i < 16; ++i) + uuid[i] = grub_tolower (buf[i]); + uuid[16] = 0; + } + + return uuid; +} + +static grub_err_t +grub_udf_uuid (grub_device_t device, char **uuid) +{ + char *volset_ident; + struct grub_udf_data *data; + data = grub_udf_mount (device->disk); + + if (data) + { + volset_ident = read_dstring (data->pvd.volset_ident, sizeof (data->pvd.volset_ident)); + if (volset_ident) + { + *uuid = gen_uuid_from_volset (volset_ident); + grub_free (volset_ident); + } + else + *uuid = 0; + grub_free (data); + } + else + *uuid = 0; + + return grub_errno; +} + static struct grub_fs grub_udf_fs = { .name = "udf", .dir = grub_udf_dir, @@ -1232,6 +1350,7 @@ static struct grub_fs grub_udf_fs = { .read = grub_udf_read, .close = grub_udf_close, .label = grub_udf_label, + .uuid = grub_udf_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, From 9e962fd3c42081e2eef1f99a0eaab38fd04d2620 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 7 Aug 2017 18:05:17 +0200 Subject: [PATCH 0720/1167] mkrescue: Check xorriso presence before doing anything else. mkrescue can't do anything useful without xorriso, so abort early if it's not available. --- util/grub-mkrescue.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 238d4840e..38f154397 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -323,6 +323,7 @@ check_xorriso (const char *val) char *buf = NULL; size_t len = 0; int ret = 0; + int wstatus = 0; argv[0] = xorriso; argv[1] = "-as"; @@ -347,8 +348,10 @@ check_xorriso (const char *val) } close (fd); - waitpid (pid, NULL, 0); + waitpid (pid, &wstatus, 0); free (buf); + if (!WIFEXITED (wstatus) || WEXITSTATUS(wstatus) != 0) + return 0; return ret; } @@ -478,6 +481,10 @@ main (int argc, char *argv[]) if (!output_image) grub_util_error ("%s", _("output file must be specified")); + if (!check_xorriso ("graft-points")) { + grub_util_error ("%s", _("xorriso not found")); + } + grub_init_all (); grub_hostfs_init (); grub_host_init (); From e66dc5d71ebfc9763420a76c274e6980d54641c3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 7 Aug 2017 18:08:39 +0200 Subject: [PATCH 0721/1167] Fail if xorriso failed. If xorriso failed most likely we didn't generate a meaningful image. --- util/grub-mkrescue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 38f154397..9545945d8 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -429,6 +429,7 @@ main (int argc, char *argv[]) char **argp_argv; int xorriso_tail_argc; char **xorriso_tail_argv; + int rv; grub_util_host_init (&argc, &argv); grub_util_disable_fd_syncs (); @@ -794,7 +795,6 @@ main (int argc, char *argv[]) free (efidir_efi_boot); efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img"); - int rv; rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", efiimgfat, "::", NULL }); if (rv != 0) @@ -967,7 +967,9 @@ main (int argc, char *argv[]) xorriso_argv[xorriso_argc] = NULL; - grub_util_exec ((const char *const *)xorriso_argv); + rv = grub_util_exec ((const char *const *)xorriso_argv); + if (rv != 0) + grub_util_error ("`%s` invocation failed\n", "xorriso"); grub_util_unlink_recursive (iso9660_dir); From dd5fde2df83c5c03b7ba04d2cc5b7be96de8da7b Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 3 Aug 2017 11:04:23 +0100 Subject: [PATCH 0722/1167] efi: refactor grub_efi_allocate_pages Expose a new function, grub_efi_allocate_pages_real(), making it possible to specify allocation type and memory type as supported by the UEFI AllocatePages boot service. Make grub_efi_allocate_pages() a consumer of the new function, maintaining its old functionality. Also delete some left-around #if 1/#else blocks in the affected functions. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 46 +++++++++++++++++++++-------------------- include/grub/efi/efi.h | 5 +++++ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 20a47aaf5..d88bc5e43 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -51,36 +51,20 @@ int grub_efi_is_finished = 0; /* Allocate pages. Return the pointer to the first of allocated pages. */ void * -grub_efi_allocate_pages (grub_efi_physical_address_t address, - grub_efi_uintn_t pages) +grub_efi_allocate_pages_real (grub_efi_physical_address_t address, + grub_efi_uintn_t pages, + grub_efi_allocate_type_t alloctype, + grub_efi_memory_type_t memtype) { - grub_efi_allocate_type_t type; grub_efi_status_t status; grub_efi_boot_services_t *b; -#if 1 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) return 0; -#endif - -#if 1 - if (address == 0) - { - type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; - address = GRUB_EFI_MAX_USABLE_ADDRESS; - } - else - type = GRUB_EFI_ALLOCATE_ADDRESS; -#else - if (address == 0) - type = GRUB_EFI_ALLOCATE_ANY_PAGES; - else - type = GRUB_EFI_ALLOCATE_ADDRESS; -#endif b = grub_efi_system_table->boot_services; - status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); + status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); if (status != GRUB_EFI_SUCCESS) return 0; @@ -89,7 +73,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, /* Uggh, the address 0 was allocated... This is too annoying, so reallocate another one. */ address = GRUB_EFI_MAX_USABLE_ADDRESS; - status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); + status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) return 0; @@ -98,6 +82,24 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, return (void *) ((grub_addr_t) address); } +void * +grub_efi_allocate_pages (grub_efi_physical_address_t address, + grub_efi_uintn_t pages) +{ + grub_efi_allocate_type_t alloctype; + + if (address == 0) + { + alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS; + address = GRUB_EFI_MAX_USABLE_ADDRESS; + } + else + alloctype = GRUB_EFI_ALLOCATE_ADDRESS; + + return grub_efi_allocate_pages_real (address, pages, alloctype, + GRUB_EFI_LOADER_DATA); +} + /* Free pages starting from ADDRESS. */ void grub_efi_free_pages (grub_efi_physical_address_t address, diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index e9c601f34..b4cbebf38 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -38,6 +38,11 @@ void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, int EXPORT_FUNC(grub_efi_set_text_mode) (int on); void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); void * +EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, + grub_efi_uintn_t pages, + grub_efi_allocate_type_t alloctype, + grub_efi_memory_type_t memtype); +void * EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, From 4bc909bf89f5b4ff86c9e4e609d4fe0c11a66b0c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 7 Aug 2017 18:33:29 +0200 Subject: [PATCH 0723/1167] Remove grub_efi_allocate_pages. grub_efi_allocate_pages Essentially does 2 unrelated things: * Allocate at fixed address. * Allocate at any address. To switch between 2 different functions it uses address == 0 as magic value which is wrong as 0 is a perfectly valid fixed adress to allocate at. --- grub-core/kern/arm/efi/misc.c | 4 ++-- grub-core/kern/efi/mm.c | 30 ++++++++++++++---------------- grub-core/loader/arm64/fdt.c | 2 +- grub-core/loader/arm64/linux.c | 7 +++---- grub-core/loader/arm64/xen_boot.c | 7 +++---- grub-core/loader/ia64/efi/linux.c | 10 +++++----- include/grub/autoefi.h | 2 +- include/grub/efi/efi.h | 4 +++- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c index 7cd41842a..c95e8299d 100644 --- a/grub-core/kern/arm/efi/misc.c +++ b/grub-core/kern/arm/efi/misc.c @@ -146,7 +146,7 @@ grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size) continue; grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n", __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start); - mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1); + mem = grub_efi_allocate_fixed (start, (size >> PAGE_SHIFT) + 1); grub_dprintf("mm", "%s: retval=0x%08x\n", __FUNCTION__, (grub_addr_t) mem); if (! mem) @@ -189,7 +189,7 @@ grub_efi_prepare_platform (void) mmap_size = find_mmap_size (); if (! mmap_size) return GRUB_ERR_OUT_OF_MEMORY; - mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); + mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); if (! mmap_buf) return GRUB_ERR_OUT_OF_MEMORY; diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index d88bc5e43..b97b05fe8 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -83,20 +83,19 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } void * -grub_efi_allocate_pages (grub_efi_physical_address_t address, +grub_efi_allocate_any_pages (grub_efi_uintn_t pages) +{ + return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, + pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, + GRUB_EFI_LOADER_DATA); +} + +void * +grub_efi_allocate_fixed (grub_efi_physical_address_t address, grub_efi_uintn_t pages) { - grub_efi_allocate_type_t alloctype; - - if (address == 0) - { - alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS; - address = GRUB_EFI_MAX_USABLE_ADDRESS; - } - else - alloctype = GRUB_EFI_ALLOCATE_ADDRESS; - - return grub_efi_allocate_pages_real (address, pages, alloctype, + return grub_efi_allocate_pages_real (address, pages, + GRUB_EFI_ALLOCATE_ADDRESS, GRUB_EFI_LOADER_DATA); } @@ -404,7 +403,7 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, pages = required_pages; } - addr = grub_efi_allocate_pages (start, pages); + addr = grub_efi_allocate_fixed (start, pages); if (! addr) grub_fatal ("cannot allocate conventional memory %p with %u pages", (void *) ((grub_addr_t) start), @@ -456,8 +455,7 @@ grub_efi_mm_init (void) int mm_status; /* Prepare a memory region to store two memory maps. */ - memory_map = grub_efi_allocate_pages (0, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); if (! memory_map) grub_fatal ("cannot allocate memory"); @@ -475,7 +473,7 @@ grub_efi_mm_init (void) /* Freeing/allocating operations may increase memory map size. */ map_size += desc_size * 32; - memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size)); + memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size)); if (! memory_map) grub_fatal ("cannot allocate memory"); diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index db49cf649..368001696 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -50,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size) size += additional_size; grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); - fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); + fdt = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (size)); if (!fdt) return NULL; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9519d2e4d..ee3fcaa86 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -148,8 +148,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) loaded_image->load_options_size = len = (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = - grub_efi_allocate_pages (0, - GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); + grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); if (!loaded_image->load_options) return grub_errno; @@ -223,7 +222,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); - initrd_mem = grub_efi_allocate_pages (0, initrd_pages); + initrd_mem = grub_efi_allocate_any_pages (initrd_pages); if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); @@ -277,7 +276,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset(); grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size); - kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); + kernel_addr = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_dprintf ("linux", "kernel numpages: %lld\n", (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size)); if (!kernel_addr) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 27ede46ca..6c145a771 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -324,10 +324,9 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size); binary->start - = (grub_addr_t) grub_efi_allocate_pages (0, - GRUB_EFI_BYTES_TO_PAGES - (binary->size + - binary->align)); + = (grub_addr_t) grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES + (binary->size + + binary->align)); if (!binary->start) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index efaa42ccd..750330d45 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -252,7 +252,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages, aligned_start += align; if (aligned_start + size > end) continue; - mem = grub_efi_allocate_pages (aligned_start, size_pages); + mem = grub_efi_allocate_fixed (aligned_start, size_pages); if (! mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); @@ -326,7 +326,7 @@ grub_linux_boot (void) mmap_size = find_mmap_size (); if (! mmap_size) return grub_errno; - mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); + mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); if (! mmap_buf) return grub_error (GRUB_ERR_IO, "cannot allocate memory map"); err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, @@ -422,7 +422,7 @@ grub_load_elf64 (grub_file_t file, void *buffer, const char *filename) relocate = grub_env_get ("linux_relocate"); if (!relocate || grub_strcmp (relocate, "force") != 0) { - kernel_mem = grub_efi_allocate_pages (low_addr, kernel_pages); + kernel_mem = grub_efi_allocate_fixed (low_addr, kernel_pages); reloc_offset = 0; } /* Try to relocate. */ @@ -524,7 +524,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len += grub_strlen (argv[i]) + 1; len += sizeof (struct ia64_boot_param) + 512; /* Room for extensions. */ boot_param_pages = page_align (len) >> 12; - boot_param = grub_efi_allocate_pages (0, boot_param_pages); + boot_param = grub_efi_allocate_any_pages (boot_param_pages); if (boot_param == 0) { grub_error (GRUB_ERR_OUT_OF_MEMORY, @@ -589,7 +589,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (page_align (initrd_size) >> 12); - initrd_mem = grub_efi_allocate_pages (0, initrd_pages); + initrd_mem = grub_efi_allocate_any_pages (initrd_pages); if (! initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate pages"); diff --git a/include/grub/autoefi.h b/include/grub/autoefi.h index b75591176..b7a252e07 100644 --- a/include/grub/autoefi.h +++ b/include/grub/autoefi.h @@ -55,7 +55,7 @@ static inline grub_err_t grub_autoefi_prepare (void) # define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR # define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN # define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE -# define grub_efi_allocate_pages(x,y) (x) +# define grub_efi_allocate_fixed(x,y) (x) # define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS # define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services # define EFI_PRESENT 1 diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index b4cbebf38..3fa082816 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -43,8 +43,10 @@ EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, grub_efi_allocate_type_t alloctype, grub_efi_memory_type_t memtype); void * -EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, +EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); +void * +EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); int From 8c9465fac901caac6802d6872a1374518b001517 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 3 Aug 2017 11:04:24 +0100 Subject: [PATCH 0724/1167] efi: move fdt helper library There is nothing ARM64 (or even ARM) specific about the efi fdt helper library, which is used for locating or overriding a firmware-provided devicetree in a UEFI system - so move it to loader/efi for reuse. Move the fdtload.h include file to grub/efi and update path to efi/fdtload.h in source code referring to it. Signed-off-by: Leif Lindholm --- grub-core/Makefile.core.def | 2 +- grub-core/loader/arm64/linux.c | 2 +- grub-core/loader/arm64/xen_boot.c | 2 +- grub-core/loader/{arm64 => efi}/fdt.c | 2 +- include/grub/{arm64 => efi}/fdtload.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename grub-core/loader/{arm64 => efi}/fdt.c (99%) rename include/grub/{arm64 => efi}/fdtload.h (100%) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 1d86bd22e..a65c27f7f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1707,7 +1707,7 @@ module = { module = { name = fdt; - arm64 = loader/arm64/fdt.c; + arm64 = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index ee3fcaa86..3e2f9b742 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 6c145a771..c95d6c5a8 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -27,9 +27,9 @@ #include #include #include -#include #include #include +#include #include /* required by struct xen_hypervisor_header */ #include #include diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c similarity index 99% rename from grub-core/loader/arm64/fdt.c rename to grub-core/loader/efi/fdt.c index 368001696..091e9ddf4 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -18,12 +18,12 @@ #include #include -#include #include #include #include #include #include +#include static void *loaded_fdt; static void *fdt; diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h similarity index 100% rename from include/grub/arm64/fdtload.h rename to include/grub/efi/fdtload.h From c5841ba7f0d14c193f20854e7e55b4f7ce9207d5 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 3 Aug 2017 11:04:25 +0100 Subject: [PATCH 0725/1167] efi: Add GRUB_PE32_MAGIC definition Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete the existing one in arm64/linux.h. Update arm64 Linux loader to use this new definition. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 2 +- include/grub/arm64/linux.h | 2 -- include/grub/efi/pe32.h | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 3e2f9b742..a652ee908 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -52,7 +52,7 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) if (lh->magic != GRUB_ARM64_LINUX_MAGIC) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); - if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC) + if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 1ea23696e..a981df5d1 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,8 +23,6 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ -#define GRUB_EFI_PE_MAGIC 0x5A4D - /* From linux/Documentation/arm64/booting.txt */ struct grub_arm64_linux_kernel_header { diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index f79c36c02..7d44732d2 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -45,6 +45,8 @@ #define GRUB_PE32_MSDOS_STUB_SIZE 0x80 +#define GRUB_PE32_MAGIC 0x5a4d + /* According to the spec, the minimal alignment is 512 bytes... But some examples (such as EFI drivers in the Intel Sample Implementation) use 32 bytes (0x20) instead, and it seems From 91212e0aa07e704a61e4540c18a27f149f5e51c3 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 3 Aug 2017 11:04:26 +0100 Subject: [PATCH 0726/1167] arm64 linux loader: improve type portability In preparation for turning this into a common loader for 32-bit and 64-bit platforms, ensure the code will compile cleanly for either. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 15 ++++++--------- grub-core/loader/efi/fdt.c | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index a652ee908..746edd104 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -57,8 +57,6 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); grub_dprintf ("linux", "UEFI stub kernel:\n"); - grub_dprintf ("linux", "text_offset = 0x%012llx\n", - (long long unsigned) lh->text_offset); grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset); return GRUB_ERR_NONE; @@ -86,8 +84,8 @@ finalize_params_linux (void) /* Set initrd info */ if (initrd_start && initrd_end > initrd_start) { - grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n", - initrd_start, initrd_end); + grub_dprintf ("linux", "Initrd @ %p-%p\n", + (void *) initrd_start, (void *) initrd_end); retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", initrd_start); @@ -161,7 +159,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) /* When successful, not reached */ b->unload_image (image_handle); - grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, + grub_efi_free_pages ((grub_addr_t) loaded_image->load_options, GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); return grub_errno; @@ -188,7 +186,7 @@ grub_linux_unload (void) initrd_start = initrd_end = 0; grub_free (linux_args); if (kernel_addr) - grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, + grub_efi_free_pages ((grub_addr_t) kernel_addr, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_fdt_unload (); return GRUB_ERR_NONE; @@ -240,8 +238,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), fail: grub_initrd_close (&initrd_ctx); if (initrd_mem && !initrd_start) - grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem, - initrd_pages); + grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages); return grub_errno; } @@ -328,7 +325,7 @@ fail: grub_free (linux_args); if (kernel_addr && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, + grub_efi_free_pages ((grub_addr_t) kernel_addr, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); return grub_errno; diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index 091e9ddf4..17212c38d 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -32,12 +32,12 @@ void * grub_fdt_load (grub_size_t additional_size) { void *raw_fdt; - grub_size_t size; + unsigned int size; if (fdt) { size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); + grub_efi_free_pages ((grub_addr_t) fdt, size); } if (loaded_fdt) @@ -49,7 +49,7 @@ grub_fdt_load (grub_size_t additional_size) raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; size += additional_size; - grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); + grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); fdt = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (size)); if (!fdt) return NULL; @@ -88,7 +88,7 @@ grub_fdt_unload (void) { if (!fdt) { return; } - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, + grub_efi_free_pages ((grub_addr_t) fdt, GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); fdt = NULL; } From f826330683675f0deb55b58fd229afd7d65fb053 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 3 Aug 2017 11:04:32 +0100 Subject: [PATCH 0727/1167] efi: change heap allocation type to GRUB_EFI_LOADER_CODE With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may not return regions with execute ability. Since modules are loaded onto the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in order to permit execution on systems with this feature enabled. Closes: 50420 Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index b97b05fe8..ac2a4c556 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -403,7 +403,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, pages = required_pages; } - addr = grub_efi_allocate_fixed (start, pages); + addr = grub_efi_allocate_pages_real (start, pages, + GRUB_EFI_ALLOCATE_ADDRESS, + GRUB_EFI_LOADER_CODE); if (! addr) grub_fatal ("cannot allocate conventional memory %p with %u pages", (void *) ((grub_addr_t) start), From bdd89d239cd9b4089630bfb5ec862aab8086dca2 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 7 Aug 2017 16:20:30 +0100 Subject: [PATCH 0728/1167] core: use GRUB_TERM_ definitions when handling term characters * Also use hex value for GRUB_TERM_ESC as '\e' is not in the C standard and is not understood by some compilers --- grub-core/commands/keylayouts.c | 6 +++--- grub-core/commands/menuentry.c | 4 ++-- grub-core/lib/crypto.c | 4 ++-- grub-core/normal/auth.c | 6 +++--- grub-core/normal/cmdline.c | 4 ++-- grub-core/normal/menu.c | 2 +- grub-core/normal/menu_entry.c | 2 +- grub-core/term/efi/console.c | 2 +- grub-core/term/i386/pc/console.c | 2 +- grub-core/term/terminfo.c | 10 +++++----- grub-core/tests/cmdline_cat_test.c | 2 +- grub-core/tests/gfxterm_menu.c | 2 +- include/grub/term.h | 3 ++- 13 files changed, 25 insertions(+), 24 deletions(-) diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index f4b773020..f35d3a369 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -40,7 +40,7 @@ static struct grub_keyboard_layout layout_us = { /* 0x10 */ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', /* 0x18 */ 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', /* 0x20 */ '3', '4', '5', '6', '7', '8', '9', '0', - /* 0x28 */ '\n', '\e', '\b', '\t', ' ', '-', '=', '[', + /* 0x28 */ '\n', GRUB_TERM_ESC, GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, ' ', '-', '=', '[', /* According to usage table 0x31 should be mapped to '/' but testing with real keyboard shows that 0x32 is remapped to '/'. Map 0x31 to 0. @@ -82,8 +82,8 @@ static struct grub_keyboard_layout layout_us = { /* 0x10 */ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', /* 0x18 */ 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', /* 0x20 */ '#', '$', '%', '^', '&', '*', '(', ')', - /* 0x28 */ '\n' | GRUB_TERM_SHIFT, '\e' | GRUB_TERM_SHIFT, - /* 0x2a */ '\b' | GRUB_TERM_SHIFT, '\t' | GRUB_TERM_SHIFT, + /* 0x28 */ '\n' | GRUB_TERM_SHIFT, GRUB_TERM_ESC | GRUB_TERM_SHIFT, + /* 0x2a */ GRUB_TERM_BACKSPACE | GRUB_TERM_SHIFT, GRUB_TERM_TAB | GRUB_TERM_SHIFT, /* 0x2c */ ' ' | GRUB_TERM_SHIFT, '_', '+', '{', /* According to usage table 0x31 should be mapped to '/' but testing with real keyboard shows that 0x32 is remapped to '/'. diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 58d4dadf6..2c5363da7 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -52,8 +52,8 @@ static struct int key; } hotkey_aliases[] = { - {"backspace", '\b'}, - {"tab", '\t'}, + {"backspace", GRUB_TERM_BACKSPACE}, + {"tab", GRUB_TERM_TAB}, {"delete", GRUB_TERM_KEY_DC}, {"insert", GRUB_TERM_KEY_INSERT}, {"f1", GRUB_TERM_KEY_F1}, diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 683a8aaa7..ca334d5a4 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -462,7 +462,7 @@ grub_password_get (char buf[], unsigned buf_size) if (key == '\n' || key == '\r') break; - if (key == '\e') + if (key == GRUB_TERM_ESC) { cur_len = 0; break; @@ -487,7 +487,7 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); - return (key != '\e'); + return (key != GRUB_TERM_ESC); } #endif diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index 7338f8245..6be678c0d 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -166,13 +166,13 @@ grub_username_get (char buf[], unsigned buf_size) if (key == '\n' || key == '\r') break; - if (key == '\e') + if (key == GRUB_TERM_ESC) { cur_len = 0; break; } - if (key == '\b') + if (key == GRUB_TERM_BACKSPACE) { if (cur_len) { @@ -197,7 +197,7 @@ grub_username_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); - return (key != '\e'); + return (key != GRUB_TERM_ESC); } grub_err_t diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c index a36180d75..c037d5050 100644 --- a/grub-core/normal/cmdline.c +++ b/grub-core/normal/cmdline.c @@ -626,12 +626,12 @@ grub_cmdline_get (const char *prompt_translated) cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, kill_buf); break; - case '\e': + case GRUB_TERM_ESC: grub_free (cl_terms); grub_free (buf); return 0; - case '\b': + case GRUB_TERM_BACKSPACE: if (lpos > 0) { lpos--; diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 719e2fb1c..e7a83c2d6 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -763,7 +763,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) *auto_boot = 0; return current_entry; - case '\e': + case GRUB_TERM_ESC: if (nested) { menu_fini (); diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index eeeee5580..cdf3590a3 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1403,7 +1403,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) goto fail; break; - case '\e': + case GRUB_TERM_ESC: destroy_screen (screen); return; diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 7d31095b1..02f64ea74 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -104,7 +104,7 @@ const unsigned efi_codes[] = GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, - GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, '\e' + GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, GRUB_TERM_ESC }; static int diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c index 28de46b57..f6142a2de 100644 --- a/grub-core/term/i386/pc/console.c +++ b/grub-core/term/i386/pc/console.c @@ -204,7 +204,7 @@ static int grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) { const grub_uint16_t bypass_table[] = { - 0x0100 | '\e', 0x0f00 | '\t', 0x0e00 | '\b', 0x1c00 | '\r', 0x1c00 | '\n' + 0x0100 | GRUB_TERM_ESC, 0x0f00 | GRUB_TERM_TAB, 0x0e00 | GRUB_TERM_BACKSPACE, 0x1c00 | '\r', 0x1c00 | '\n' }; struct grub_bios_int_registers regs; unsigned i; diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index f0d3e3deb..d317efa36 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -426,12 +426,12 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, } *len = 1; keys[0] = c; - if (c != ANSI_CSI && c != '\e') + if (c != ANSI_CSI && c != GRUB_TERM_ESC) { /* Backspace: Ctrl-h. */ if (c == 0x7f) - c = '\b'; - if (c < 0x20 && c != '\t' && c!= '\b' && c != '\n' && c != '\r') + c = GRUB_TERM_BACKSPACE; + if (c < 0x20 && c != GRUB_TERM_TAB && c!= GRUB_TERM_BACKSPACE && c != '\n' && c != '\r') c = GRUB_TERM_CTRL | (c - 1 + 'a'); *len = 1; keys[0] = c; @@ -487,7 +487,7 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END }; unsigned i; - if (c == '\e') + if (c == GRUB_TERM_ESC) { CONTINUE_READ; @@ -606,7 +606,7 @@ grub_terminfo_getkey (struct grub_term_input *termi) &data->npending, data->readkey); #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) - if (data->npending == 1 && data->input_buf[0] == '\e' + if (data->npending == 1 && data->input_buf[0] == GRUB_TERM_ESC && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_REPEAT) && grub_get_time_ms () - data->last_key_time < 1000 && (data->last_key & GRUB_TERM_EXTENDED)) diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c index f1e21439e..baea7688a 100644 --- a/grub-core/tests/cmdline_cat_test.c +++ b/grub-core/tests/cmdline_cat_test.c @@ -103,7 +103,7 @@ cmdline_cat_test (void) '/', 't', 'e', 's', 't', '.', 't', 'x', 't', '\n', GRUB_TERM_NO_KEY, - GRUB_TERM_NO_KEY, '\e'}, + GRUB_TERM_NO_KEY, GRUB_TERM_ESC}, 23); grub_video_checksum ("cmdline_cat"); diff --git a/grub-core/tests/gfxterm_menu.c b/grub-core/tests/gfxterm_menu.c index 8f63dc27a..12836fb96 100644 --- a/grub-core/tests/gfxterm_menu.c +++ b/grub-core/tests/gfxterm_menu.c @@ -146,7 +146,7 @@ gfxterm_menu (void) return; } grub_terminal_input_fake_sequence ((int []) { -1, -1, -1, GRUB_TERM_KEY_DOWN, -1, 'e', - -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, '\e', -1, '\e' }, 14); + -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, GRUB_TERM_ESC, -1, GRUB_TERM_ESC }, 14); grub_video_checksum (tests[j].name); diff --git a/include/grub/term.h b/include/grub/term.h index 5ffb38f69..8117e2a24 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -55,7 +55,8 @@ #define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 0x52) #define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 0x4c) -#define GRUB_TERM_ESC '\e' +/* Hex value is used for ESC, since '\e' is nonstandard */ +#define GRUB_TERM_ESC 0x1b #define GRUB_TERM_TAB '\t' #define GRUB_TERM_BACKSPACE '\b' From 1deebd85ef87cc581e995ce0a51dc0802ac9c367 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 7 Aug 2017 16:23:12 +0100 Subject: [PATCH 0729/1167] io: add a GRUB_GZ prefix to gzio specific defines * This is done to avoid a conflict with a PACKED define in the EDK2 --- grub-core/io/gzio.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 0f2ea6bd8..a8e33033b 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -140,24 +140,24 @@ eat_field (grub_file_t file, int len) #define OLD_GZIP_MAGIC grub_le_to_cpu16 (0x9E1F) /* Compression methods (see algorithm.doc) */ -#define STORED 0 -#define COMPRESSED 1 -#define PACKED 2 -#define LZHED 3 +#define GRUB_GZ_STORED 0 +#define GRUB_GZ_COMPRESSED 1 +#define GRUB_GZ_PACKED 2 +#define GRUB_GZ_LZHED 3 /* methods 4 to 7 reserved */ -#define DEFLATED 8 -#define MAX_METHODS 9 +#define GRUB_GZ_DEFLATED 8 +#define GRUB_GZ_MAX_METHODS 9 /* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ -#define RESERVED 0xC0 /* bit 6,7: reserved */ +#define GRUB_GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define GRUB_GZ_CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ +#define GRUB_GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define GRUB_GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define GRUB_GZ_COMMENT 0x10 /* bit 4 set: file comment present */ +#define GRUB_GZ_ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ +#define GRUB_GZ_RESERVED 0xC0 /* bit 6,7: reserved */ -#define UNSUPPORTED_FLAGS (CONTINUATION | ENCRYPTED | RESERVED) +#define GRUB_GZ_UNSUPPORTED_FLAGS (GRUB_GZ_CONTINUATION | GRUB_GZ_ENCRYPTED | GRUB_GZ_RESERVED) /* inflate block codes */ #define INFLATE_STORED 0 @@ -201,14 +201,14 @@ test_gzip_header (grub_file_t file) * problem occurs from here on, then we have corrupt or otherwise * bad data, and the error should be reported to the user. */ - if (hdr.method != DEFLATED - || (hdr.flags & UNSUPPORTED_FLAGS) - || ((hdr.flags & EXTRA_FIELD) + if (hdr.method != GRUB_GZ_DEFLATED + || (hdr.flags & GRUB_GZ_UNSUPPORTED_FLAGS) + || ((hdr.flags & GRUB_GZ_EXTRA_FIELD) && (grub_file_read (gzio->file, &extra_len, 2) != 2 || eat_field (gzio->file, grub_le_to_cpu16 (extra_len)))) - || ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1)) - || ((hdr.flags & COMMENT) && eat_field (gzio->file, -1))) + || ((hdr.flags & GRUB_GZ_ORIG_NAME) && eat_field (gzio->file, -1)) + || ((hdr.flags & GRUB_GZ_COMMENT) && eat_field (gzio->file, -1))) return 0; gzio->data_offset = grub_file_tell (gzio->file); @@ -1183,7 +1183,7 @@ test_zlib_header (grub_gzio_t gzio) flg = get_byte (gzio); /* Check that compression method is DEFLATE. */ - if ((cmf & 0xf) != DEFLATED) + if ((cmf & 0xf) != GRUB_GZ_DEFLATED) { /* TRANSLATORS: It's about given file having some strange format, not complete lack of gzip support. */ From 7108c0c86ea26f75dfba4e21e78bf8464c433143 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 11:36:50 +0200 Subject: [PATCH 0730/1167] grub.texi: Fix typo Reported by: Ori Avtalion --- docs/grub.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index a0c4b9e4e..137b894fa 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4643,7 +4643,7 @@ range 0-0xFF (prefix with @samp{0x} to enter it in hexadecimal). When enabled, this hides the selected partition by setting the @dfn{hidden} bit in its partition type code; when disabled, unhides the selected partition by clearing this bit. This is useful only when booting DOS or -Wwindows and multiple primary FAT partitions exist in one disk. See also +Windows and multiple primary FAT partitions exist in one disk. See also @ref{DOS/Windows}. @end table @end deffn From 6662372053bb7f580cf1b6a56b11e1190d81a40c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 12:48:58 +0200 Subject: [PATCH 0731/1167] hdparm: Depend on hexdump rather than having a second copy of hexdump. --- grub-core/Makefile.core.def | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a65c27f7f..8d57a59a0 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -902,7 +902,6 @@ module = { module = { name = hdparm; common = commands/hdparm.c; - common = lib/hexdump.c; enable = pci; enable = mips_qemu_mips; }; From 21e4a6fa039bb7dc6be42e1e4c171ddc398b8431 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 12:51:26 +0200 Subject: [PATCH 0732/1167] multiboot: disentangle multiboot and multiboot2. Previously we had multiboot and multiboot2 declaring the same symbols. This can potentially lead to aliasing and strange behaviours when e.g. module instead of module2 is used with multiboot2. Bug: #51137 --- grub-core/loader/i386/multiboot_mbi.c | 4 +- grub-core/loader/multiboot.c | 66 +++++++++++++++----------- grub-core/loader/multiboot_elfxx.c | 14 +++--- grub-core/loader/multiboot_mbi2.c | 68 +++++++++++++-------------- include/grub/i386/multiboot.h | 9 +++- include/grub/mips/multiboot.h | 4 +- include/grub/multiboot.h | 11 +---- include/multiboot2.h | 4 +- 8 files changed, 95 insertions(+), 85 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index fd7b41b0c..dc98dbcae 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -239,7 +239,7 @@ grub_multiboot_get_mbi_size (void) ret = sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4) + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd + ALIGN_UP (sizeof(PACKAGE_STRING), 4) - + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry) + + grub_multiboot_get_mmap_count () * sizeof (struct multiboot_mmap_entry) + elf_sec_entsize * elf_sec_num + 256 * sizeof (struct multiboot_color) #if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT @@ -542,7 +542,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) mbi->mods_count = 0; } - mmap_size = grub_get_multiboot_mmap_count () + mmap_size = grub_multiboot_get_mmap_count () * sizeof (struct multiboot_mmap_entry); grub_fill_multiboot_mmap ((struct multiboot_mmap_entry *) ptrorig); mbi->mmap_length = mmap_size; diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index bd9d5b3e6..bd3dc1990 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -28,7 +28,15 @@ #include #include +#ifdef GRUB_USE_MULTIBOOT2 +#include +#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER +#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT +#define GRUB_MULTIBOOT(x) grub_multiboot2_ ## x +#else #include +#define GRUB_MULTIBOOT(x) grub_multiboot_ ## x +#endif #include #include #include @@ -49,8 +57,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); #include #endif -struct grub_relocator *grub_multiboot_relocator = NULL; -grub_uint32_t grub_multiboot_payload_eip; +struct grub_relocator *GRUB_MULTIBOOT (relocator) = NULL; +grub_uint32_t GRUB_MULTIBOOT (payload_eip); #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) #define DEFAULT_VIDEO_MODE "text" #else @@ -78,7 +86,7 @@ count_hook (grub_uint64_t addr __attribute__ ((unused)), /* Return the length of the Multiboot mmap that will be needed to allocate our platform's map. */ grub_uint32_t -grub_get_multiboot_mmap_count (void) +GRUB_MULTIBOOT (get_mmap_count) (void) { grub_size_t count = 0; @@ -88,7 +96,7 @@ grub_get_multiboot_mmap_count (void) } grub_err_t -grub_multiboot_set_video_mode (void) +GRUB_MULTIBOOT (set_video_mode) (void) { grub_err_t err; const char *modevar; @@ -164,19 +172,23 @@ static grub_err_t grub_multiboot_boot (void) { grub_err_t err; + +#ifdef GRUB_USE_MULTIBOOT2 + struct grub_relocator32_state state = MULTIBOOT2_INITIAL_STATE; +#else struct grub_relocator32_state state = MULTIBOOT_INITIAL_STATE; +#endif + state.MULTIBOOT_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip); - state.MULTIBOOT_ENTRY_REGISTER = grub_multiboot_payload_eip; - - err = grub_multiboot_make_mbi (&state.MULTIBOOT_MBI_REGISTER); + err = GRUB_MULTIBOOT (make_mbi) (&state.MULTIBOOT_MBI_REGISTER); if (err) return err; if (grub_efi_is_finished) - normal_boot (grub_multiboot_relocator, state); + normal_boot (GRUB_MULTIBOOT (relocator), state); else - efi_boot (grub_multiboot_relocator, state.MULTIBOOT_MBI_REGISTER); + efi_boot (GRUB_MULTIBOOT (relocator), state.MULTIBOOT_MBI_REGISTER); /* Not reached. */ return GRUB_ERR_NONE; @@ -185,10 +197,10 @@ grub_multiboot_boot (void) static grub_err_t grub_multiboot_unload (void) { - grub_multiboot_free_mbi (); + GRUB_MULTIBOOT (free_mbi) (); - grub_relocator_unload (grub_multiboot_relocator); - grub_multiboot_relocator = NULL; + grub_relocator_unload (GRUB_MULTIBOOT (relocator)); + GRUB_MULTIBOOT (relocator) = NULL; grub_dl_unref (my_mod); @@ -207,7 +219,7 @@ static grub_uint64_t highest_load; /* Load ELF32 or ELF64. */ grub_err_t -grub_multiboot_load_elf (mbi_load_data_t *mld) +GRUB_MULTIBOOT (load_elf) (mbi_load_data_t *mld) { if (grub_multiboot_is_elf32 (mld->buffer)) return grub_multiboot_load_elf32 (mld); @@ -218,9 +230,9 @@ grub_multiboot_load_elf (mbi_load_data_t *mld) } grub_err_t -grub_multiboot_set_console (int console_type, int accepted_consoles, - int width, int height, int depth, - int console_req) +GRUB_MULTIBOOT (set_console) (int console_type, int accepted_consoles, + int width, int height, int depth, + int console_req) { console_required = console_req; if (!(accepted_consoles @@ -313,19 +325,19 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), grub_dl_ref (my_mod); /* Skip filename. */ - grub_multiboot_init_mbi (argc - 1, argv + 1); + GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1); - grub_relocator_unload (grub_multiboot_relocator); - grub_multiboot_relocator = grub_relocator_new (); + grub_relocator_unload (GRUB_MULTIBOOT (relocator)); + GRUB_MULTIBOOT (relocator) = grub_relocator_new (); - if (!grub_multiboot_relocator) + if (!GRUB_MULTIBOOT (relocator)) goto fail; - err = grub_multiboot_load (file, argv[0]); + err = GRUB_MULTIBOOT (load) (file, argv[0]); if (err) goto fail; - grub_multiboot_set_bootdev (); + GRUB_MULTIBOOT (set_bootdev) (); grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0); @@ -335,8 +347,8 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), if (grub_errno != GRUB_ERR_NONE) { - grub_relocator_unload (grub_multiboot_relocator); - grub_multiboot_relocator = NULL; + grub_relocator_unload (GRUB_MULTIBOOT (relocator)); + GRUB_MULTIBOOT (relocator) = NULL; grub_dl_unref (my_mod); } @@ -368,7 +380,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - if (!grub_multiboot_relocator) + if (!GRUB_MULTIBOOT (relocator)) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); @@ -389,7 +401,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), if (size) { grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, lowest_addr, (0xffffffff - size) + 1, size, MULTIBOOT_MOD_ALIGN, GRUB_RELOCATOR_PREFERENCE_NONE, 1); @@ -407,7 +419,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), target = 0; } - err = grub_multiboot_add_module (target, size, argc - 1, argv + 1); + err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1); if (err) { grub_file_close (file); diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 5e649ed25..67daf5944 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -104,13 +104,13 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, mld->min_addr, mld->max_addr - load_size, load_size, mld->align ? mld->align : 1, mld->preference, mld->avoid_efi_boot_services); } else - err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, &ch, + err = grub_relocator_alloc_chunk_addr (GRUB_MULTIBOOT (relocator), &ch, mld->link_base_addr, load_size); if (err) @@ -167,7 +167,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) if (phdr(i)->p_vaddr <= ehdr->e_entry && phdr(i)->p_vaddr + phdr(i)->p_memsz > ehdr->e_entry) { - grub_multiboot_payload_eip = (ehdr->e_entry - phdr(i)->p_vaddr) + GRUB_MULTIBOOT (payload_eip) = (ehdr->e_entry - phdr(i)->p_vaddr) + phdr(i)->p_paddr; #ifdef MULTIBOOT_LOAD_ELF64 # ifdef __mips @@ -191,7 +191,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) #if defined (__i386__) || defined (__x86_64__) #elif defined (__mips) - grub_multiboot_payload_eip |= 0x80000000; + GRUB_MULTIBOOT (payload_eip) |= 0x80000000; #else #error Please complete this #endif @@ -238,7 +238,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) if (sh->sh_size == 0) continue; - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, 0, + err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, 0, (0xffffffff - sh->sh_size) + 1, sh->sh_size, sh->sh_addralign, GRUB_RELOCATOR_PREFERENCE_NONE, @@ -264,8 +264,8 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) } sh->sh_addr = target; } - grub_multiboot_add_elfsyms (ehdr->e_shnum, ehdr->e_shentsize, - ehdr->e_shstrndx, shdr); + GRUB_MULTIBOOT (add_elfsyms) (ehdr->e_shnum, ehdr->e_shentsize, + ehdr->e_shstrndx, shdr); } #undef phdr diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index b0679a9f6..4df659595 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -22,7 +22,7 @@ #include #include #endif -#include +#include #include #include #include @@ -71,7 +71,7 @@ static int keep_bs = 0; static grub_uint32_t load_base_addr; void -grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, +grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize, unsigned shndx, void *data) { elf_sec_num = num; @@ -90,17 +90,17 @@ find_header (grub_properly_aligned_t *buffer, grub_ssize_t len) ((char *) header <= (char *) buffer + len - 12); header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) { - if (header->magic == MULTIBOOT_HEADER_MAGIC + if (header->magic == MULTIBOOT2_HEADER_MAGIC && !(header->magic + header->architecture + header->header_length + header->checksum) - && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) + && header->architecture == MULTIBOOT2_ARCHITECTURE_CURRENT) return header; } return NULL; } grub_err_t -grub_multiboot_load (grub_file_t file, const char *filename) +grub_multiboot2_load (grub_file_t file, const char *filename) { grub_ssize_t len; struct multiboot_header *header; @@ -112,7 +112,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) grub_addr_t entry = 0, efi_entry = 0; grub_uint32_t console_required = 0; struct multiboot_header_tag_framebuffer *fbtag = NULL; - int accepted_consoles = GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; + int accepted_consoles = GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT; mbi_load_data_t mld; mld.mbi_ver = 2; @@ -210,7 +210,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS: if (!(((struct multiboot_header_tag_console_flags *) tag)->console_flags & MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED)) - accepted_consoles &= ~GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; + accepted_consoles &= ~GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT; if (((struct multiboot_header_tag_console_flags *) tag)->console_flags & MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED) console_required = 1; @@ -218,7 +218,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_HEADER_TAG_FRAMEBUFFER: fbtag = (struct multiboot_header_tag_framebuffer *) tag; - accepted_consoles |= GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER; + accepted_consoles |= GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER; break; case MULTIBOOT_HEADER_TAG_RELOCATABLE: @@ -295,13 +295,13 @@ grub_multiboot_load (grub_file_t file, const char *filename) return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); } - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, mld.min_addr, mld.max_addr - code_size, code_size, mld.align ? mld.align : 1, mld.preference, keep_bs); } else - err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, + err = grub_relocator_alloc_chunk_addr (grub_multiboot2_relocator, &ch, load_addr, code_size); if (err) { @@ -343,7 +343,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) mld.file = file; mld.filename = filename; mld.avoid_efi_boot_services = keep_bs; - err = grub_multiboot_load_elf (&mld); + err = grub_multiboot2_load_elf (&mld); if (err) { grub_free (mld.buffer); @@ -354,9 +354,9 @@ grub_multiboot_load (grub_file_t file, const char *filename) load_base_addr = mld.load_base_addr; if (keep_bs && efi_entry_specified) - grub_multiboot_payload_eip = efi_entry; + grub_multiboot2_payload_eip = efi_entry; else if (entry_specified) - grub_multiboot_payload_eip = entry; + grub_multiboot2_payload_eip = entry; if (mld.relocatable) { @@ -370,20 +370,20 @@ grub_multiboot_load (grub_file_t file, const char *filename) * 64-bit int here. */ if (mld.load_base_addr >= mld.link_base_addr) - grub_multiboot_payload_eip += mld.load_base_addr - mld.link_base_addr; + grub_multiboot2_payload_eip += mld.load_base_addr - mld.link_base_addr; else - grub_multiboot_payload_eip -= mld.link_base_addr - mld.load_base_addr; + grub_multiboot2_payload_eip -= mld.link_base_addr - mld.load_base_addr; } if (fbtag) - err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER, - accepted_consoles, - fbtag->width, fbtag->height, - fbtag->depth, console_required); + err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER, + accepted_consoles, + fbtag->width, fbtag->height, + fbtag->depth, console_required); else - err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_EGA_TEXT, - accepted_consoles, - 0, 0, 0, console_required); + err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT, + accepted_consoles, + 0, 0, 0, console_required); return err; } @@ -459,7 +459,7 @@ net_size (void) } static grub_size_t -grub_multiboot_get_mbi_size (void) +grub_multiboot2_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI if (!keep_bs && !efi_mmap_size) @@ -478,7 +478,7 @@ grub_multiboot_get_mbi_size (void) + ALIGN_UP (sizeof (struct multiboot_tag_elf_sections), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (elf_sec_entsize * elf_sec_num, MULTIBOOT_TAG_ALIGN) + ALIGN_UP ((sizeof (struct multiboot_tag_mmap) - + grub_get_multiboot_mmap_count () + + grub_multiboot2_get_mmap_count () * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) @@ -522,7 +522,7 @@ grub_fill_multiboot_mmap (struct multiboot_tag_mmap *tag) tag->type = MULTIBOOT_TAG_TYPE_MMAP; tag->size = sizeof (struct multiboot_tag_mmap) - + sizeof (struct multiboot_mmap_entry) * grub_get_multiboot_mmap_count (); + + sizeof (struct multiboot_mmap_entry) * grub_multiboot2_get_mmap_count (); tag->entry_size = sizeof (struct multiboot_mmap_entry); tag->entry_version = 0; @@ -588,7 +588,7 @@ retrieve_video_parameters (grub_properly_aligned_t **ptrorig) struct multiboot_tag_framebuffer *tag = (struct multiboot_tag_framebuffer *) *ptrorig; - err = grub_multiboot_set_video_mode (); + err = grub_multiboot2_set_video_mode (); if (err) { grub_print_error (); @@ -731,7 +731,7 @@ retrieve_video_parameters (grub_properly_aligned_t **ptrorig) } grub_err_t -grub_multiboot_make_mbi (grub_uint32_t *target) +grub_multiboot2_make_mbi (grub_uint32_t *target) { grub_properly_aligned_t *ptrorig; grub_properly_aligned_t *mbistart; @@ -739,11 +739,11 @@ grub_multiboot_make_mbi (grub_uint32_t *target) grub_size_t bufsize; grub_relocator_chunk_t ch; - bufsize = grub_multiboot_get_mbi_size (); + bufsize = grub_multiboot2_get_mbi_size (); COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); - err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, + err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, 0, 0xffffffff - bufsize, bufsize, MULTIBOOT_TAG_ALIGN, GRUB_RELOCATOR_PREFERENCE_NONE, 1); @@ -1039,7 +1039,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) } void -grub_multiboot_free_mbi (void) +grub_multiboot2_free_mbi (void) { struct module *cur, *next; @@ -1061,11 +1061,11 @@ grub_multiboot_free_mbi (void) } grub_err_t -grub_multiboot_init_mbi (int argc, char *argv[]) +grub_multiboot2_init_mbi (int argc, char *argv[]) { grub_ssize_t len = 0; - grub_multiboot_free_mbi (); + grub_multiboot2_free_mbi (); len = grub_loader_cmdline_size (argc, argv); @@ -1081,7 +1081,7 @@ grub_multiboot_init_mbi (int argc, char *argv[]) } grub_err_t -grub_multiboot_add_module (grub_addr_t start, grub_size_t size, +grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, int argc, char *argv[]) { struct module *newmod; @@ -1119,7 +1119,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, } void -grub_multiboot_set_bootdev (void) +grub_multiboot2_set_bootdev (void) { grub_device_t dev; diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h index 807a1de27..9cd97dfce 100644 --- a/include/grub/i386/multiboot.h +++ b/include/grub/i386/multiboot.h @@ -19,6 +19,13 @@ #ifndef GRUB_MULTIBOOT_CPU_HEADER #define GRUB_MULTIBOOT_CPU_HEADER 1 +#define MULTIBOOT2_INITIAL_STATE { .eax = MULTIBOOT2_BOOTLOADER_MAGIC, \ + .ecx = 0, \ + .edx = 0, \ + /* Set esp to some random location in low memory to avoid breaking */ \ + /* non-compliant kernels. */ \ + .esp = 0x7ff00 \ + } #define MULTIBOOT_INITIAL_STATE { .eax = MULTIBOOT_BOOTLOADER_MAGIC, \ .ecx = 0, \ .edx = 0, \ @@ -28,7 +35,7 @@ } #define MULTIBOOT_ENTRY_REGISTER eip #define MULTIBOOT_MBI_REGISTER ebx -#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386 +#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT2_ARCHITECTURE_I386 #ifdef GRUB_MACHINE_EFI #ifdef __x86_64__ diff --git a/include/grub/mips/multiboot.h b/include/grub/mips/multiboot.h index 4aebf29e7..c4eee2dd0 100644 --- a/include/grub/mips/multiboot.h +++ b/include/grub/mips/multiboot.h @@ -19,11 +19,11 @@ #ifndef GRUB_MULTIBOOT_CPU_HEADER #define GRUB_MULTIBOOT_CPU_HEADER 1 -#define MULTIBOOT_INITIAL_STATE { .gpr[4] = MULTIBOOT_BOOTLOADER_MAGIC, \ +#define MULTIBOOT2_INITIAL_STATE { .gpr[4] = MULTIBOOT2_BOOTLOADER_MAGIC, \ .jumpreg = 1 } #define MULTIBOOT_ENTRY_REGISTER gpr[1] #define MULTIBOOT_MBI_REGISTER gpr[5] -#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32 +#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32 #define MULTIBOOT_ELF32_MACHINE EM_MIPS #define MULTIBOOT_ELF64_MACHINE EM_MIPS diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index c96492bb5..bd0a9873e 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -22,19 +22,11 @@ #include -#ifdef GRUB_USE_MULTIBOOT2 -#include -/* Same thing as far as our loader is concerned. */ -#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC -#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC -#else #include -#endif #include #include -#ifndef GRUB_USE_MULTIBOOT2 typedef enum { GRUB_MULTIBOOT_QUIRKS_NONE = 0, @@ -42,7 +34,6 @@ typedef enum GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL = 2 } grub_multiboot_quirks_t; extern grub_multiboot_quirks_t grub_multiboot_quirks; -#endif extern struct grub_relocator *grub_multiboot_relocator; @@ -60,7 +51,7 @@ void grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, unsigned shndx, void *data); -grub_uint32_t grub_get_multiboot_mmap_count (void); +grub_uint32_t grub_multiboot_get_mmap_count (void); grub_err_t grub_multiboot_set_video_mode (void); /* FIXME: support coreboot as well. */ diff --git a/include/multiboot2.h b/include/multiboot2.h index 5a3db5a7c..5693923c0 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -75,8 +75,8 @@ #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 #define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 -#define MULTIBOOT_ARCHITECTURE_I386 0 -#define MULTIBOOT_ARCHITECTURE_MIPS32 4 +#define MULTIBOOT2_ARCHITECTURE_I386 0 +#define MULTIBOOT2_ARCHITECTURE_MIPS32 4 #define MULTIBOOT_HEADER_TAG_OPTIONAL 1 #define MULTIBOOT_LOAD_PREFERENCE_NONE 0 From 26e5aea9418aab83df0debd0c672086fa9f2d9c8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 14:09:30 +0200 Subject: [PATCH 0733/1167] Fix symbols appearing in several modules in linux*. If same symbol is provided by 2 modules its semantics are undefined. Avoid this by depending rather than double-including files. --- grub-core/Makefile.core.def | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 8d57a59a0..66144222c 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -770,6 +770,7 @@ module = { module = { name = boot; common = commands/boot.c; + common = lib/cmdline.c; i386_pc = lib/i386/pc/biosnum.c; enable = x86; enable = emu; @@ -1630,8 +1631,6 @@ module = { module = { name = linux16; common = loader/i386/pc/linux.c; - common = loader/linux.c; - common = lib/cmdline.c; enable = x86; }; @@ -1666,7 +1665,6 @@ module = { cppflags = "-DGRUB_USE_MULTIBOOT2"; common = loader/multiboot.c; - common = lib/cmdline.c; common = loader/multiboot_mbi2.c; enable = x86; enable = mips; @@ -1675,7 +1673,6 @@ module = { module = { name = multiboot; common = loader/multiboot.c; - common = lib/cmdline.c; x86 = loader/i386/multiboot_mbi.c; extra_dist = loader/multiboot_elfxx.c; enable = x86; @@ -1683,7 +1680,6 @@ module = { module = { name = xen_boot; - common = lib/cmdline.c; arm64 = loader/arm64/xen_boot.c; enable = arm64; }; @@ -1700,7 +1696,6 @@ module = { arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; common = loader/linux.c; - common = lib/cmdline.c; enable = noemu; }; From 3732816bc08ef605ed3b6c016ff0ed562829f243 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 14:10:48 +0200 Subject: [PATCH 0734/1167] genmoddep: Check that no modules provide the same symbol. The semantics of 2 modules providing the same symbol are undefined. So ensure that it doesn't happen. --- grub-core/genmoddep.awk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk index bd98d84cd..8976beb91 100644 --- a/grub-core/genmoddep.awk +++ b/grub-core/genmoddep.awk @@ -18,6 +18,10 @@ BEGIN { { if ($1 == "defined") { + if ($3 in symtab) { + printf "%s in %s is duplicated in %s\n", $3, $2, symtab[$3] >"/dev/stderr"; + error++; + } symtab[$3] = $2; modtab[$2] = "" modtab[$2] } else if ($1 == "undefined") { From c36c2a86404f373100775305f532c09d46f3c6ce Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 14:11:43 +0200 Subject: [PATCH 0735/1167] yylex: Explicilty cast fprintf to void. It's needed to avoid warning on recent GCC. --- grub-core/script/yylex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l index 95b219170..7b44c37b7 100644 --- a/grub-core/script/yylex.l +++ b/grub-core/script/yylex.l @@ -91,7 +91,7 @@ typedef size_t yy_size_t; #define stdin 0 #define stdout 0 -#define fprintf(...) 0 +#define fprintf(...) (void)0 #define exit(...) grub_fatal("fatal error in lexer") #endif From 6cc79ec10ccafc5935d776e4a396193b93d7e842 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 16:23:52 +0200 Subject: [PATCH 0736/1167] linux fixup --- grub-core/Makefile.core.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 66144222c..6edf68286 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -770,7 +770,6 @@ module = { module = { name = boot; common = commands/boot.c; - common = lib/cmdline.c; i386_pc = lib/i386/pc/biosnum.c; enable = x86; enable = emu; @@ -1696,6 +1695,7 @@ module = { arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; common = loader/linux.c; + common = lib/cmdline.c; enable = noemu; }; From 4bfd26623f590c8f19c516f4edd342ff18f07bc1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 16:24:05 +0200 Subject: [PATCH 0737/1167] multiboot fixup --- grub-core/loader/multiboot.c | 5 ++++- include/grub/mips/multiboot.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index bd3dc1990..3b57cb132 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -138,8 +138,11 @@ static void efi_boot (struct grub_relocator *rel, grub_uint32_t target) { +#ifdef GRUB_USE_MULTIBOOT2 + struct grub_relocator_efi_state state_efi = MULTIBOOT2_EFI_INITIAL_STATE; +#else struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE; - +#endif state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip; state_efi.MULTIBOOT_EFI_MBI_REGISTER = target; diff --git a/include/grub/mips/multiboot.h b/include/grub/mips/multiboot.h index c4eee2dd0..cdfb41e31 100644 --- a/include/grub/mips/multiboot.h +++ b/include/grub/mips/multiboot.h @@ -23,7 +23,7 @@ .jumpreg = 1 } #define MULTIBOOT_ENTRY_REGISTER gpr[1] #define MULTIBOOT_MBI_REGISTER gpr[5] -#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32 +#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT2_ARCHITECTURE_MIPS32 #define MULTIBOOT_ELF32_MACHINE EM_MIPS #define MULTIBOOT_ELF64_MACHINE EM_MIPS From 6ccb2d54bce2eef8e71b93b467c0f49253835c74 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Aug 2017 16:27:10 +0200 Subject: [PATCH 0738/1167] enforcing fixup --- grub-core/genmoddep.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk index 8976beb91..04c2863e5 100644 --- a/grub-core/genmoddep.awk +++ b/grub-core/genmoddep.awk @@ -18,7 +18,7 @@ BEGIN { { if ($1 == "defined") { - if ($3 in symtab) { + if ($3 !~ /^\.refptr\./ && $3 in symtab) { printf "%s in %s is duplicated in %s\n", $3, $2, symtab[$3] >"/dev/stderr"; error++; } From 5435aaac3c8bfb14bb01a826ec747b783947c86f Mon Sep 17 00:00:00 2001 From: Xuan Guo Date: Mon, 14 Aug 2017 16:27:53 +0200 Subject: [PATCH 0739/1167] Set have_exec to y on cygwin so we have grub_mkrescue. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 571f7a0b5..c7888e40f 100644 --- a/configure.ac +++ b/configure.ac @@ -204,7 +204,8 @@ case "$host_os" in esac case "$host_os" in - cygwin | windows* | mingw32*) have_exec=n ;; + cygwin) have_exec=y ;; + windows* | mingw32*) have_exec=n ;; aros*) have_exec=n ;; *) have_exec=y;; esac From 3d86efda0074285fb86aa6ffe5d97327ebd134a4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 15:18:24 +0200 Subject: [PATCH 0740/1167] arc: Do not create spurious variable grub_arc_memory_type_t. --- include/grub/arc/arc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/arc/arc.h b/include/grub/arc/arc.h index 7615a49a9..999de7196 100644 --- a/include/grub/arc/arc.h +++ b/include/grub/arc/arc.h @@ -53,7 +53,7 @@ enum grub_arc_memory_type #ifndef GRUB_CPU_WORDS_BIGENDIAN GRUB_ARC_MEMORY_FREE_CONTIGUOUS, #endif - } grub_arc_memory_type_t; + }; struct grub_arc_timeinfo { From e75cf4a58b5eaf482804e5e1b2cc7d4399df350e Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 28 Aug 2017 20:57:19 +0200 Subject: [PATCH 0741/1167] unix exec: avoid atexit handlers when child exits The `grub_util_exec_redirect_all` helper function can be used to spawn an executable and redirect its output to some files. After calling `fork()`, the parent will wait for the child to terminate with `waitpid()` while the child prepares its file descriptors, environment and finally calls `execvp()`. If something in the children's setup fails, it will stop by calling `exit(127)`. Calling `exit()` will cause any function registered via `atexit()` to be executed, which is usually the wrong thing to do in a child. And actually, one can easily observe faulty behaviour on musl-based systems without modprobe(8) installed: executing `grub-install --help` will call `grub_util_exec_redirect_all` with "modprobe", which obviously fails if modprobe(8) is not installed. Due to the child now exiting and invoking the `atexit()` handlers, it will clean up some data structures of the parent and cause it to be deadlocked in the `waitpid()` syscall. The issue can easily be fixed by calling `_exit(127)` instead, which is especially designed to be called when the atexit-handlers should not be executed. Signed-off-by: Patrick Steinhardt --- grub-core/osdep/unix/exec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/osdep/unix/exec.c b/grub-core/osdep/unix/exec.c index 935ff120e..db3259f65 100644 --- a/grub-core/osdep/unix/exec.c +++ b/grub-core/osdep/unix/exec.c @@ -99,7 +99,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, { fd = open (stdin_file, O_RDONLY); if (fd < 0) - exit (127); + _exit (127); dup2 (fd, STDIN_FILENO); close (fd); } @@ -108,7 +108,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, { fd = open (stdout_file, O_WRONLY | O_CREAT, 0700); if (fd < 0) - exit (127); + _exit (127); dup2 (fd, STDOUT_FILENO); close (fd); } @@ -117,7 +117,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, { fd = open (stderr_file, O_WRONLY | O_CREAT, 0700); if (fd < 0) - exit (127); + _exit (127); dup2 (fd, STDERR_FILENO); close (fd); } @@ -126,7 +126,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, setenv ("LC_ALL", "C", 1); execvp ((char *) argv[0], (char **) argv); - exit (127); + _exit (127); } waitpid (pid, &status, 0); if (!WIFEXITED (status)) From c42acc23ff91ea0170eab5f1e10499dcfc4e0c92 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 15:56:19 +0200 Subject: [PATCH 0742/1167] xfs: Don't attempt to iterate over empty directory. Reported by: Tuomas Tynkkynen --- grub-core/fs/xfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 9f66dd6e4..c6031bd3f 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -828,6 +828,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, entries = (grub_be_to_cpu32 (tail->leaf_count) - grub_be_to_cpu32 (tail->leaf_stale)); + if (!entries) + continue; + /* Iterate over all entries within this block. */ while ((char *)direntry < (char *)tail) { From b18ce97c672615bb5ac44883676b37a9ec758d83 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sun, 1 May 2016 14:32:30 +0200 Subject: [PATCH 0743/1167] Implement checksum verification for gunzip This implements the crc32 check for the gzip format. Support for zlib's adler checksum is not included, yet. --- grub-core/io/gzio.c | 46 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index a8e33033b..dcf3a8701 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -43,6 +43,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -94,6 +95,14 @@ struct grub_gzio struct huft *tl; /* The distance code table. */ struct huft *td; + /* The checksum algorithm */ + const gcry_md_spec_t *hdesc; + /* The wanted checksum */ + grub_uint32_t orig_checksum; + /* The uncompressed length */ + grub_size_t orig_len; + /* Context for checksum calculation */ + grub_uint8_t *hcontext; /* The lookup bits for the literal/length code table. */ int bl; /* The lookup bits for the distance code table. */ @@ -180,7 +189,7 @@ test_gzip_header (grub_file_t file) grub_uint8_t os_type; } hdr; grub_uint16_t extra_len; - grub_uint32_t orig_len; + grub_uint32_t crc32; grub_gzio_t gzio = file->data; if (grub_file_tell (gzio->file) != 0) @@ -215,12 +224,15 @@ test_gzip_header (grub_file_t file) /* FIXME: don't do this on not easily seekable files. */ { - grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4); - if (grub_file_read (gzio->file, &orig_len, 4) != 4) + grub_file_seek (gzio->file, grub_file_size (gzio->file) - 8); + if (grub_file_read (gzio->file, &crc32, 4) != 4) + return 0; + gzio->orig_checksum = grub_le_to_cpu32 (crc32); + if (grub_file_read (gzio->file, &gzio->orig_len, 4) != 4) return 0; /* FIXME: this does not handle files whose original size is over 4GB. But how can we know the real original size? */ - file->size = grub_le_to_cpu32 (orig_len); + file->size = grub_le_to_cpu32 (gzio->orig_len); } initialize_tables (gzio); @@ -1095,7 +1107,23 @@ inflate_window (grub_gzio_t gzio) gzio->saved_offset += gzio->wp; - /* XXX do CRC calculation here! */ + if (gzio->hcontext) + { + gzio->hdesc->write (gzio->hcontext, gzio->slide, gzio->wp); + + if (gzio->saved_offset == gzio->orig_len) + { + grub_uint32_t csum; + + gzio->hdesc->final (gzio->hcontext); + csum = *(grub_uint32_t *)gzio->hdesc->read (gzio->hcontext); + csum = grub_be_to_cpu32 (csum); + if (csum != gzio->orig_checksum) + grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, + "checksum mismatch %08x/%08x", + gzio->orig_checksum, csum); + } + } } @@ -1118,6 +1146,9 @@ initialize_tables (grub_gzio_t gzio) huft_free (gzio->td); gzio->tl = NULL; gzio->td = NULL; + + if (gzio->hcontext) + gzio->hdesc->init(gzio->hcontext); } @@ -1143,6 +1174,9 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) gzio->file = io; + gzio->hdesc = GRUB_MD_CRC32; + gzio->hcontext = grub_malloc(gzio->hdesc->contextsize); + file->device = io->device; file->data = gzio; file->fs = &grub_gzio_fs; @@ -1151,6 +1185,7 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) if (! test_gzip_header (file)) { grub_errno = GRUB_ERR_NONE; + grub_free (gzio->hcontext); grub_free (gzio); grub_free (file); grub_file_seek (io, 0); @@ -1287,6 +1322,7 @@ grub_gzio_close (grub_file_t file) grub_file_close (gzio->file); huft_free (gzio->tl); huft_free (gzio->td); + grub_free (gzio->hcontext); grub_free (gzio); /* No need to close the same device twice. */ From ec763ed00ac55deb1c429bda5057bd5a147183d1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 16:29:59 +0200 Subject: [PATCH 0744/1167] qemu, coreboot, multiboot: Change linking address to 0x9000. It's common for distros to use a defective ld which links at 0x9000. Instead of fighting it, just move link target to 0x9000. --- grub-core/Makefile.core.def | 6 +++--- include/grub/offsets.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6edf68286..d90ad6220 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -68,11 +68,11 @@ kernel = { i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)'; - i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; + i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; i386_coreboot_ldflags = '$(TARGET_IMG_LDFLAGS)'; - i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; + i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; i386_multiboot_ldflags = '$(TARGET_IMG_LDFLAGS)'; - i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; + i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; i386_ieee1275_ldflags = '$(TARGET_IMG_LDFLAGS)'; i386_ieee1275_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x10000'; i386_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; diff --git a/include/grub/offsets.h b/include/grub/offsets.h index bf0689fc9..330e4c707 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -50,7 +50,7 @@ /* The offset of GRUB_CORE_ENTRY_ADDR. */ #define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8 -#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200 +#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x9000 /* The offset of GRUB_TOTAL_MODULE_SIZE. */ #define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8 @@ -91,7 +91,7 @@ #define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08 -#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200 +#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x9000 #define GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR 0x100000 #define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000 From 32099228e6ccf209f64d509cd7e13413ea10778e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 16:59:25 +0200 Subject: [PATCH 0745/1167] printf_unit_test: Disable Wformat-truncation on GCC >= 7 We intentionally pass NULL as argument to format, hence disable the warning. --- tests/printf_unit_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c index d7b12c6db..098c29fd9 100644 --- a/tests/printf_unit_test.c +++ b/tests/printf_unit_test.c @@ -23,6 +23,10 @@ #define MSG "printf test failed: %s, %s", real, expected +#if defined(__GNUC__) && __GNUC__ >= 7 +#pragma GCC diagnostic ignored "-Wformat-truncation=" +#endif + static void printf_test (void) { From 061258a05edd7077f3cb15f51bda2823f513d261 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 17:12:04 +0200 Subject: [PATCH 0746/1167] Regenerate checksum.h with newer unifont. Old link is broken. New unifont is http://ftp.de.debian.org/debian/pool/main/u/unifont/xfonts-unifont_9.0.06-2_all.deb --- grub-core/tests/checksums.h | 258 ++++++++++++++++++------------------ 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index 921e57ff4..8273bd105 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,129 +1,129 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x8851b0ee, 0x8851b0ee, 0xafb59f0b, 0xafb59f0b, 0x8c9b72f1, 0x8c9b72f1, 0x6eec5116, 0x6eec5116, 0xad82053e, 0xad82053e, 0x2eeae2ae, 0x2eeae2ae, 0x58cf8def, 0x58cf8def, 0x926f4d2f, 0x926f4d2f, 0xbd1c3236, 0xbd1c3236, 0x56012a95, 0x56012a95, 0x6d7c40ae, 0x6d7c40ae, 0xef750bc8, 0xef750bc8, 0x1080dd4a, 0x1080dd4a, 0xd7f9e5af, 0xd7f9e5af, 0x80b1b4a9, 0x80b1b4a9, 0x2c99415e, 0x2c99415e, 0x8d5761ff, 0x8d5761ff, 0xb964b489, 0xb964b489, 0x88a51f74, 0x88a51f74, 0x1da6c458, 0x1da6c458, 0x85e94025, 0x206ea54f, 0x7ee6c8fd, 0x7ee6c8fd, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x834b70a0, 0x834b70a0, 0xe7cc129f, 0xe7cc129f, 0x5ee2edc, 0x5ee2edc, 0xa1135cd7, 0xa1135cd7, 0xf7ce1f26, 0xf7ce1f26, 0xe9f803e8, 0xe9f803e8, 0x4b8f9724, 0x4b8f9724, 0x3fe3771a, 0x3fe3771a, 0x5584ee63, 0x5584ee63, 0xac193250, 0xac193250, 0x801f25f4, 0x801f25f4, 0x8d33aece, 0x8d33aece, 0xc6d95edc, 0xc6d95edc, 0xf121dee2, 0xf121dee2, 0x6ab10812, 0x6ab10812, 0x41a5b112, 0x41a5b112, 0xac6f712b, 0xac6f712b, 0x8aee7a19, 0x8aee7a19, 0xfe37c0ad, 0xfe37c0ad, 0x99c6a336, 0x99c6a336, 0x53b844c6, 0x73015447, 0x7a1a2254, 0x7a1a2254, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb121c912, 0xb121c912, 0x635a8739, 0x635a8739, 0x8288cba6, 0x8288cba6, 0xf5589d0, 0xf5589d0, 0x471642b3, 0x471642b3, 0xfb4826cf, 0xfb4826cf, 0x8b1083cf, 0x8b1083cf, 0x738b0c94, 0x738b0c94, 0x859c41b0, 0x859c41b0, 0x7c8d1be9, 0x7c8d1be9, 0x5b685e40, 0x5b685e40, 0x9cf80d95, 0x9cf80d95, 0x3541f915, 0x3541f915, 0x582b8557, 0x582b8557, 0x24cf88f7, 0x24cf88f7, 0x9e0af23, 0x9e0af23, 0x1033164b, 0x1033164b, 0x70ba51e2, 0x70ba51e2, 0xb051585c, 0xb051585c, 0xe1389f04, 0xe1389f04, 0x308bbb74, 0xdc9e6805, 0x4ddcff9f, 0x4ddcff9f, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xac16e832, 0xac16e832, 0xbf6ab9c6, 0xbf6ab9c6, 0x1063e15a, 0x1063e15a, 0xf908e3ff, 0xf908e3ff, 0xcb37d841, 0xcb37d841, 0x9b8ffa7d, 0x9b8ffa7d, 0x38d2a26c, 0x38d2a26c, 0x6989f09b, 0x6989f09b, 0x481451e, 0x481451e, 0x17b3177, 0x17b3177, 0x3ea52aeb, 0x3ea52aeb, 0xc24de674, 0xc24de674, 0x4ab163cc, 0x4ab163cc, 0xc482b092, 0xc482b092, 0x55ffc7e2, 0x55ffc7e2, 0x3b4b34dd, 0x3b4b34dd, 0x9b1f047f, 0x9b1f047f, 0x3d42e414, 0x3d42e414, 0x35b2fb06, 0x35b2fb06, 0xb813b35f, 0xb813b35f, 0xc3ede6e0, 0xc35214c3, 0x340f0107, 0x340f0107, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9c47caee, 0x9c47caee, 0x6c9c4f38, 0x6c9c4f38, 0x79c49615, 0x79c49615, 0x70fe9708, 0x70fe9708, 0x8e90c077, 0x8e90c077, 0xd8205b47, 0xd8205b47, 0xa34337e2, 0xa34337e2, 0xf4dffa53, 0xf4dffa53, 0x90a0779c, 0x90a0779c, 0x322820bb, 0x322820bb, 0x50e3383f, 0x50e3383f, 0x4a976e3e, 0x4a976e3e, 0x90b6f8d9, 0x90b6f8d9, 0x4058c301, 0x4058c301, 0x221a6810, 0x221a6810, 0x1f78a00e, 0x1f78a00e, 0x6a633d2c, 0x6a633d2c, 0xca177c65, 0xca177c65, 0xabb6c7f9, 0xabb6c7f9, 0x635a35e8, 0x635a35e8, 0x6da78f10, 0x53467ff8, 0xd037fdfa, 0xd037fdfa, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2b6b8225, 0x2b6b8225, 0x83df9995, 0x83df9995, 0x5165ad0b, 0x5165ad0b, 0xe5a6f96d, 0xe5a6f96d, 0x798df957, 0x798df957, 0x8c0567e2, 0x8c0567e2, 0x5e5d7389, 0x5e5d7389, 0x47a39dd, 0x47a39dd, 0x894f44af, 0x894f44af, 0x1dff0a6, 0x1dff0a6, 0xf496e67b, 0xf496e67b, 0x29cb5702, 0x29cb5702, 0xeaf1387d, 0xeaf1387d, 0x4a9bf7, 0x4a9bf7, 0x11d20bee, 0x11d20bee, 0xa103dc2d, 0xa103dc2d, 0xd0265db9, 0xd0265db9, 0x42267334, 0x42267334, 0x96f85e8c, 0x96f85e8c, 0xa28eac49, 0xa28eac49, 0x4e660ae7, 0x70741b3, 0x183f2f2e, 0x183f2f2e, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x77b51f44, 0x77b51f44, 0xc8097569, 0xc8097569, 0x769aee5f, 0x769aee5f, 0xa35e159, 0xa35e159, 0x87a6341f, 0x87a6341f, 0xb61d944b, 0xb61d944b, 0x8b109cb3, 0x8b109cb3, 0xed3fb3e, 0xed3fb3e, 0xd7cc6c3, 0xd7cc6c3, 0x52077f0d, 0x52077f0d, 0x9d86d17e, 0x9d86d17e, 0x5e487bb, 0x5e487bb, 0x3a00041b, 0x3a00041b, 0xcfdeaf9e, 0xcfdeaf9e, 0x3e40af89, 0x3e40af89, 0x5ec41ea9, 0x5ec41ea9, 0x6298e4e7, 0x6298e4e7, 0xfd67f90e, 0xfd67f90e, 0x5ab5dc32, 0x5ab5dc32, 0xdd3ad694, 0xdd3ad694, 0x391222b4, 0xd4a98b43, 0xeaa2f62, 0xeaa2f62, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x45b0713c, 0x237f9dbf, 0x45b0713c, 0x646bc7b, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0x646bc7b, 0x646bc7b, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x84abc7db, 0x20814063, 0x84abc7db, 0xaaae42a4, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0xaaae42a4, 0xaaae42a4, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5b85371a, 0xe10968c2, 0x5b85371a, 0x6925a9e, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0x6925a9e, 0x6925a9e, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9130464d, 0x22904f7a, 0x9130464d, 0x3f660f95, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x3f660f95, 0x3f660f95, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5185b14e, 0x4173aa2f, 0x5185b14e, 0x272384fd, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x272384fd, 0x272384fd, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5cc0d3ef, 0x8b87731, 0x5cc0d3ef, 0x47c509e8, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0x47c509e8, 0x47c509e8, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd1338a02, 0x7aa25dbf, 0xd1338a02, 0x2e8c9182, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0x2e8c9182, 0x2e8c9182, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0x2b88b6ce, 0x2b88b6ce, 0x2b88b6ce, 0x7750400e, 0x7750400e, 0x7750400e, 0x5ec88e9c, 0x5ec88e9c, 0x5ec88e9c, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xa1b1a1b5, 0xa1b1a1b5, 0xa1b1a1b5, 0xf4ee0bbf, 0xf4ee0bbf, 0xf4ee0bbf, 0x9dddc3f6, 0x9dddc3f6, 0x9dddc3f6, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xa07e74d3, 0xa07e74d3, 0xa07e74d3, 0xdfc0d247, 0xdfc0d247, 0xdfc0d247, 0x9db4b23f, 0x9db4b23f, 0x9db4b23f, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0x84312594, 0x84312594, 0x84312594, 0x6f94cfe8, 0x6f94cfe8, 0x6f94cfe8, 0x69dfcf18, 0x69dfcf18, 0x69dfcf18, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x131c0760, 0x131c0760, 0x131c0760, 0x7c55db71, 0x7c55db71, 0x7c55db71, 0x71a34572, 0x71a34572, 0x71a34572, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0xb9092e0b, 0xb9092e0b, 0xb9092e0b, 0x7fbb6a15, 0x7fbb6a15, 0x7fbb6a15, 0x6bdebaaa, 0x6bdebaaa, 0x6bdebaaa, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x14f7c6b1, 0x14f7c6b1, 0x14f7c6b1, 0x95043060, 0x95043060, 0x95043060, 0x3a0890f, 0x3a0890f, 0x3a0890f, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x77ff5efc, 0x791fe364, 0x77ff5efc, 0x340993bb, 0x59c36f00, 0x59c36f00, 0x3908ca1e, 0x3908ca1e, 0x3908ca1e, 0x4788a778, 0x4788a778, 0x4788a778, 0x257eb2aa, 0x257eb2aa, 0x257eb2aa, 0x59c36f00, 0x340993bb, 0x340993bb, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb2d04b0f, 0x46cdbc23, 0xb2d04b0f, 0x9cd5ce70, 0xaa4593fe, 0xaa4593fe, 0x44bf6b37, 0x44bf6b37, 0x44bf6b37, 0xe24a6650, 0xe24a6650, 0xe24a6650, 0xcf72cd28, 0xcf72cd28, 0xcf72cd28, 0xaa4593fe, 0x9cd5ce70, 0x9cd5ce70, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4bb823b8, 0x59349835, 0x4bb823b8, 0x16af4e3c, 0xc9cbf769, 0xc9cbf769, 0x2784b68e, 0x2784b68e, 0x2784b68e, 0xd95c7742, 0xd95c7742, 0xd95c7742, 0x3016c84a, 0x3016c84a, 0x3016c84a, 0xc9cbf769, 0x16af4e3c, 0x16af4e3c, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb821e44, 0x16b3ac05, 0xb821e44, 0xa5d4579c, 0x9813a416, 0x9813a416, 0xca80d730, 0xca80d730, 0xca80d730, 0x5b5b5103, 0x5b5b5103, 0x5b5b5103, 0x42e16cd3, 0x42e16cd3, 0x42e16cd3, 0x9813a416, 0xa5d4579c, 0xa5d4579c, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbe0b9671, 0x7f6e98d0, 0xbe0b9671, 0xc8ada3c2, 0x5fcf013d, 0x5fcf013d, 0x57a0c67d, 0x57a0c67d, 0x57a0c67d, 0x85b0de0b, 0x85b0de0b, 0x85b0de0b, 0x93c3e194, 0x93c3e194, 0x93c3e194, 0x5fcf013d, 0xc8ada3c2, 0xc8ada3c2, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9f18b29e, 0x50e7d383, 0x9f18b29e, 0x841d6899, 0xdd28f52b, 0xdd28f52b, 0xd12092dc, 0xd12092dc, 0xd12092dc, 0xf01c6b38, 0xf01c6b38, 0xf01c6b38, 0x8da4a0b4, 0x8da4a0b4, 0x8da4a0b4, 0xdd28f52b, 0x841d6899, 0x841d6899, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4e8d4d8c, 0x3f32cb90, 0x4e8d4d8c, 0xb132560c, 0x43d1f34, 0x43d1f34, 0x1e7f303c, 0x1e7f303c, 0x1e7f303c, 0x61759994, 0x61759994, 0x61759994, 0xf8249c12, 0xf8249c12, 0xf8249c12, 0x43d1f34, 0xb132560c, 0xb132560c, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4f39b2c5, 0x37084023, 0x4f39b2c5, 0xccf7f82, 0x59c36f00, 0x59c36f00, 0xb5dad2e, 0xb5dad2e, 0xb5dad2e, 0x75ddc048, 0x75ddc048, 0x75ddc048, 0x172bd59a, 0x172bd59a, 0x172bd59a, 0x59c36f00, 0xccf7f82, 0xccf7f82, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5f24f8e, 0x76463f82, 0xd5f24f8e, 0xfbf7caf1, 0xaa4593fe, 0xaa4593fe, 0xb897c475, 0xb897c475, 0xb897c475, 0x1e62c912, 0x1e62c912, 0x1e62c912, 0x335a626a, 0x335a626a, 0x335a626a, 0xaa4593fe, 0xfbf7caf1, 0xfbf7caf1, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8aa7c8c3, 0x28620e7e, 0x8aa7c8c3, 0xd7b0a547, 0xc9cbf769, 0xc9cbf769, 0x860f1899, 0x860f1899, 0x860f1899, 0x78d7d955, 0x78d7d955, 0x78d7d955, 0x919d665d, 0x919d665d, 0x919d665d, 0xc9cbf769, 0xd7b0a547, 0xd7b0a547, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x89654b6, 0x26bab4dd, 0x89654b6, 0xa6c01d6e, 0x9813a416, 0x9813a416, 0xc67652d9, 0xc67652d9, 0xc67652d9, 0x57add4ea, 0x57add4ea, 0x57add4ea, 0x4e17e93a, 0x4e17e93a, 0x4e17e93a, 0x9813a416, 0xa6c01d6e, 0xa6c01d6e, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x77945f28, 0xec3ce845, 0x77945f28, 0x1326a9b, 0x5fcf013d, 0x5fcf013d, 0xc8e6e12c, 0xc8e6e12c, 0xc8e6e12c, 0x1af6f95a, 0x1af6f95a, 0x1af6f95a, 0xc85c6c5, 0xc85c6c5, 0xc85c6c5, 0x5fcf013d, 0x1326a9b, 0x1326a9b, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4450a5dc, 0xda479f49, 0x4450a5dc, 0x5f557fdb, 0xdd28f52b, 0xdd28f52b, 0xddfe9197, 0xddfe9197, 0xddfe9197, 0xfcc26873, 0xfcc26873, 0xfcc26873, 0x817aa3ff, 0x817aa3ff, 0x817aa3ff, 0xdd28f52b, 0x5f557fdb, 0x5f557fdb, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x409098da, 0x2e0890e, 0x409098da, 0xbf2f835a, 0x43d1f34, 0x43d1f34, 0x253d050e, 0x253d050e, 0x253d050e, 0x5a37aca6, 0x5a37aca6, 0x5a37aca6, 0xc366a920, 0xc366a920, 0xc366a920, 0x43d1f34, 0xbf2f835a, 0xbf2f835a, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x546aa9f1, 0x56bf26d0, 0x546aa9f1, 0x179c64b6, 0x59c36f00, 0x59c36f00, 0xa98ad4a1, 0xa98ad4a1, 0xa98ad4a1, 0xd70ab9c7, 0xd70ab9c7, 0xd70ab9c7, 0xb5fcac15, 0xb5fcac15, 0xb5fcac15, 0x59c36f00, 0x179c64b6, 0x179c64b6, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x12592c97, 0xa10f7034, 0x12592c97, 0x3c5ca9e8, 0xaa4593fe, 0xaa4593fe, 0x2c3e194, 0x2c3e194, 0x2c3e194, 0xa436ecf3, 0xa436ecf3, 0xa436ecf3, 0x890e478b, 0x890e478b, 0x890e478b, 0xaa4593fe, 0x3c5ca9e8, 0x3c5ca9e8, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xed5de42a, 0x5cf94e51, 0xed5de42a, 0xb04a89ae, 0xc9cbf769, 0xc9cbf769, 0xdd578210, 0xdd578210, 0xdd578210, 0x238f43dc, 0x238f43dc, 0x238f43dc, 0xcac5fcd4, 0xcac5fcd4, 0xcac5fcd4, 0xc9cbf769, 0xb04a89ae, 0xb04a89ae, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbbc56f90, 0x4f643bbb, 0xbbc56f90, 0x15932648, 0x9813a416, 0x9813a416, 0x28aba4d1, 0x28aba4d1, 0x28aba4d1, 0xb97022e2, 0xb97022e2, 0xb97022e2, 0xa0ca1f32, 0xa0ca1f32, 0xa0ca1f32, 0x9813a416, 0x15932648, 0x15932648, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x43465d8c, 0x6399888a, 0x43465d8c, 0x35e0683f, 0x5fcf013d, 0x5fcf013d, 0x4895c207, 0x4895c207, 0x4895c207, 0x9a85da71, 0x9a85da71, 0x9a85da71, 0x8cf6e5ee, 0x8cf6e5ee, 0x8cf6e5ee, 0x5fcf013d, 0x35e0683f, 0x35e0683f, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd1e7f231, 0xe67e195e, 0xd1e7f231, 0xcae22836, 0xdd28f52b, 0xdd28f52b, 0xe7ae9f08, 0xe7ae9f08, 0xe7ae9f08, 0xc69266ec, 0xc69266ec, 0xc69266ec, 0xbb2aad60, 0xbb2aad60, 0xbb2aad60, 0xdd28f52b, 0xcae22836, 0xcae22836, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x793e58f4, 0x5f939386, 0x793e58f4, 0x86814374, 0x43d1f34, 0x43d1f34, 0x12b2b9c1, 0x12b2b9c1, 0x12b2b9c1, 0x6db81069, 0x6db81069, 0x6db81069, 0xf4e915ef, 0xf4e915ef, 0xf4e915ef, 0x43d1f34, 0x86814374, 0x86814374, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x226c0d75, 0x9e291f4f, 0x226c0d75, 0x619ac032, 0x59c36f00, 0x59c36f00, 0x6fb6253, 0x6fb6253, 0x6fb6253, 0x787b0f35, 0x787b0f35, 0x787b0f35, 0x1a8d1ae7, 0x1a8d1ae7, 0x1a8d1ae7, 0x59c36f00, 0x619ac032, 0x619ac032, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8355045, 0xfe058b68, 0x8355045, 0x2630d53a, 0xaa4593fe, 0xaa4593fe, 0x290a3822, 0x290a3822, 0x290a3822, 0x8fff3545, 0x8fff3545, 0x8fff3545, 0xa2c79e3d, 0xa2c79e3d, 0xa2c79e3d, 0xaa4593fe, 0x2630d53a, 0x2630d53a, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc702fa59, 0x74086887, 0xc702fa59, 0x9a1597dd, 0xc9cbf769, 0xc9cbf769, 0x60295baa, 0x60295baa, 0x60295baa, 0x9ef19a66, 0x9ef19a66, 0x9ef19a66, 0x77bb256e, 0x77bb256e, 0x77bb256e, 0xc9cbf769, 0x9a1597dd, 0x9a1597dd, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x82385331, 0xf77eda42, 0x82385331, 0x2c6e1ae9, 0x9813a416, 0x9813a416, 0x140c0d1f, 0x140c0d1f, 0x140c0d1f, 0x85d78b2c, 0x85d78b2c, 0x85d78b2c, 0x9c6db6fc, 0x9c6db6fc, 0x9c6db6fc, 0x9813a416, 0x2c6e1ae9, 0x2c6e1ae9, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x565d2d38, 0x34f757ec, 0x565d2d38, 0x20fb188b, 0x5fcf013d, 0x5fcf013d, 0x230bf123, 0x230bf123, 0x230bf123, 0xf11be955, 0xf11be955, 0xf11be955, 0xe768d6ca, 0xe768d6ca, 0xe768d6ca, 0x5fcf013d, 0x20fb188b, 0x20fb188b, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x632132a4, 0x4a8c90b2, 0x632132a4, 0x7824e8a3, 0xdd28f52b, 0xdd28f52b, 0xef2bffce, 0xef2bffce, 0xef2bffce, 0xce17062a, 0xce17062a, 0xce17062a, 0xb3afcda6, 0xb3afcda6, 0xb3afcda6, 0xdd28f52b, 0x7824e8a3, 0x7824e8a3, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x461d4cfa, 0xfd3492c2, 0x461d4cfa, 0xb9a2577a, 0x43d1f34, 0x43d1f34, 0xfb72301f, 0xfb72301f, 0xfb72301f, 0x847899b7, 0x847899b7, 0x847899b7, 0x1d299c31, 0x1d299c31, 0x1d299c31, 0x43d1f34, 0xb9a2577a, 0xb9a2577a, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x82758f66, 0xbac387fd, 0x82758f66, 0xc1834221, 0x59c36f00, 0x59c36f00, 0x4877befe, 0x4877befe, 0x4877befe, 0x36f7d398, 0x36f7d398, 0x36f7d398, 0x5401c64a, 0x5401c64a, 0x5401c64a, 0x59c36f00, 0xc1834221, 0xc1834221, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4500a591, 0x9a40cbd8, 0x4500a591, 0x6b0520ee, 0xaa4593fe, 0xaa4593fe, 0x16db2902, 0x16db2902, 0x16db2902, 0xb02e2465, 0xb02e2465, 0xb02e2465, 0x9d168f1d, 0x9d168f1d, 0x9d168f1d, 0xaa4593fe, 0x6b0520ee, 0x6b0520ee, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x3cd9ea11, 0x1244c852, 0x3cd9ea11, 0x61ce8795, 0xc9cbf769, 0xc9cbf769, 0x6b15d6f0, 0x6b15d6f0, 0x6b15d6f0, 0x95cd173c, 0x95cd173c, 0x95cd173c, 0x7c87a834, 0x7c87a834, 0x7c87a834, 0xc9cbf769, 0x61ce8795, 0x61ce8795, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc818f15f, 0xbaf13382, 0xc818f15f, 0x664eb887, 0x9813a416, 0x9813a416, 0x350fe990, 0x350fe990, 0x350fe990, 0xa4d46fa3, 0xa4d46fa3, 0xa4d46fa3, 0xbd6e5273, 0xbd6e5273, 0xbd6e5273, 0x9813a416, 0x664eb887, 0x664eb887, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xaa1dc81, 0x234341dd, 0xaa1dc81, 0x7c07e932, 0x5fcf013d, 0x5fcf013d, 0x969354c5, 0x969354c5, 0x969354c5, 0x44834cb3, 0x44834cb3, 0x44834cb3, 0x52f0732c, 0x52f0732c, 0x52f0732c, 0x5fcf013d, 0x7c07e932, 0x7c07e932, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd9aa4b29, 0x555fdda0, 0xd9aa4b29, 0xc2af912e, 0xdd28f52b, 0xdd28f52b, 0xe82cbfd, 0xe82cbfd, 0xe82cbfd, 0x2fbe3219, 0x2fbe3219, 0x2fbe3219, 0x5206f995, 0x5206f995, 0x5206f995, 0xdd28f52b, 0xc2af912e, 0xc2af912e, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfd4e19ff, 0x42807b86, 0xfd4e19ff, 0x2f1027f, 0x43d1f34, 0x43d1f34, 0x924dc5be, 0x924dc5be, 0x924dc5be, 0xed476c16, 0xed476c16, 0xed476c16, 0x74166990, 0x74166990, 0x74166990, 0x43d1f34, 0x2f1027f, 0x2f1027f, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3a63a2e6, 0x118487d4, 0x3a63a2e6, 0x79956fa1, 0x59c36f00, 0x59c36f00, 0x389f4d2d, 0x389f4d2d, 0x389f4d2d, 0x461f204b, 0x461f204b, 0x461f204b, 0x24e93599, 0x24e93599, 0x24e93599, 0x59c36f00, 0x79956fa1, 0x79956fa1, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x62d33f4d, 0x9544a8f4, 0x62d33f4d, 0x4cd6ba32, 0xaa4593fe, 0xaa4593fe, 0xfb86a3a4, 0xfb86a3a4, 0xfb86a3a4, 0x5d73aec3, 0x5d73aec3, 0x5d73aec3, 0x704b05bb, 0x704b05bb, 0x704b05bb, 0xaa4593fe, 0x4cd6ba32, 0x4cd6ba32, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8cc4b6dc, 0x1042c383, 0x8cc4b6dc, 0xd1d3db58, 0xc9cbf769, 0xc9cbf769, 0xeba8a32b, 0xeba8a32b, 0xeba8a32b, 0x157062e7, 0x157062e7, 0x157062e7, 0xfc3addef, 0xfc3addef, 0xfc3addef, 0xc9cbf769, 0xd1d3db58, 0xd1d3db58, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x23f9afd, 0x465f5ecc, 0x23f9afd, 0xac69d325, 0x9813a416, 0x9813a416, 0xccf7a1e3, 0xccf7a1e3, 0xccf7a1e3, 0x5d2c27d0, 0x5d2c27d0, 0x5d2c27d0, 0x44961a00, 0x44961a00, 0x44961a00, 0x9813a416, 0xac69d325, 0xac69d325, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xed796a26, 0x3132d083, 0xed796a26, 0x9bdf5f95, 0x5fcf013d, 0x5fcf013d, 0x42f66a49, 0x42f66a49, 0x42f66a49, 0x90e6723f, 0x90e6723f, 0x90e6723f, 0x86954da0, 0x86954da0, 0x86954da0, 0x5fcf013d, 0x9bdf5f95, 0x9bdf5f95, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x54b28785, 0x7fbbe762, 0x54b28785, 0x4fb75d82, 0xdd28f52b, 0xdd28f52b, 0x14b1cf29, 0x14b1cf29, 0x14b1cf29, 0x358d36cd, 0x358d36cd, 0x358d36cd, 0x4835fd41, 0x4835fd41, 0x4835fd41, 0xdd28f52b, 0x4fb75d82, 0x4fb75d82, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7acc2669, 0xbf1a1d96, 0x7acc2669, 0x85733de9, 0x43d1f34, 0x43d1f34, 0x2cc1e8f4, 0x2cc1e8f4, 0x2cc1e8f4, 0x53cb415c, 0x53cb415c, 0x53cb415c, 0xca9a44da, 0xca9a44da, 0xca9a44da, 0x43d1f34, 0x85733de9, 0x85733de9, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xf9511593, 0x9f9ef910, 0xf9511593, 0xbaa7d8d4, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0xbaa7d8d4, 0xbaa7d8d4, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3dcbe25f, 0x99e165e7, 0x3dcbe25f, 0x13ce6720, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0x13ce6720, 0x13ce6720, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdbedc74c, 0x61619894, 0xdbedc74c, 0x86faaac8, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0x86faaac8, 0x86faaac8, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2411f56f, 0x97b1fc58, 0x2411f56f, 0x8a47bcb7, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x8a47bcb7, 0x8a47bcb7, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x13a65fb6, 0x35044d7, 0x13a65fb6, 0x65006a05, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x65006a05, 0x65006a05, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc8f05290, 0x9c88f64e, 0xc8f05290, 0xd3f58897, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0xd3f58897, 0xd3f58897, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9cfbc80f, 0x376a1fb2, 0x9cfbc80f, 0x6344d38f, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0x6344d38f, 0x6344d38f, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd327ca68, 0x9c977e8c, 0xd327ca68, 0x90d1072f, 0x59c36f00, 0x59c36f00, 0x71c9d9, 0x71c9d9, 0x71c9d9, 0x7ef1a4bf, 0x7ef1a4bf, 0x7ef1a4bf, 0x1c07b16d, 0x1c07b16d, 0x1c07b16d, 0x59c36f00, 0x90d1072f, 0x90d1072f, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2da3855b, 0x24c7b138, 0x2da3855b, 0x3a60024, 0xaa4593fe, 0xaa4593fe, 0x147ff249, 0x147ff249, 0x147ff249, 0xb28aff2e, 0xb28aff2e, 0xb28aff2e, 0x9fb25456, 0x9fb25456, 0x9fb25456, 0xaa4593fe, 0x3a60024, 0x3a60024, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x660ab3d9, 0xa75b45c4, 0x660ab3d9, 0x3b1dde5d, 0xc9cbf769, 0xc9cbf769, 0x5ff884f5, 0x5ff884f5, 0x5ff884f5, 0xa1204539, 0xa1204539, 0xa1204539, 0x486afa31, 0x486afa31, 0x486afa31, 0xc9cbf769, 0x3b1dde5d, 0x3b1dde5d, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x920957ee, 0xceebfd42, 0x920957ee, 0x3c5f1e36, 0x9813a416, 0x9813a416, 0xa917dbef, 0xa917dbef, 0xa917dbef, 0x38cc5ddc, 0x38cc5ddc, 0x38cc5ddc, 0x2176600c, 0x2176600c, 0x2176600c, 0x9813a416, 0x3c5f1e36, 0x3c5f1e36, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8298cd03, 0xfb88293a, 0x8298cd03, 0xf43ef8b0, 0x5fcf013d, 0x5fcf013d, 0x8f57f36b, 0x8f57f36b, 0x8f57f36b, 0x5d47eb1d, 0x5d47eb1d, 0x5d47eb1d, 0x4b34d482, 0x4b34d482, 0x4b34d482, 0x5fcf013d, 0xf43ef8b0, 0xf43ef8b0, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd8bbc577, 0xb2c37549, 0xd8bbc577, 0xc3be1f70, 0xdd28f52b, 0xdd28f52b, 0xd8b598e, 0xd8b598e, 0xd8b598e, 0x2cb7a06a, 0x2cb7a06a, 0x2cb7a06a, 0x510f6be6, 0x510f6be6, 0x510f6be6, 0xdd28f52b, 0xc3be1f70, 0xc3be1f70, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d7993a1, 0xbeefcd88, 0x4d7993a1, 0xb2c68821, 0x43d1f34, 0x43d1f34, 0x1dbc7020, 0x1dbc7020, 0x1dbc7020, 0x62b6d988, 0x62b6d988, 0x62b6d988, 0xfbe7dc0e, 0xfbe7dc0e, 0xfbe7dc0e, 0x43d1f34, 0xb2c68821, 0xb2c68821, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x628b6f61, 0x50f94215, 0x628b6f61, 0x217da226, 0x59c36f00, 0x59c36f00, 0x5755be7f, 0x5755be7f, 0x5755be7f, 0x29d5d319, 0x29d5d319, 0x29d5d319, 0x4b23c6cb, 0x4b23c6cb, 0x4b23c6cb, 0x59c36f00, 0x217da226, 0x217da226, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9f82cd08, 0xbc67f78d, 0x9f82cd08, 0xb1874877, 0xaa4593fe, 0xaa4593fe, 0x4749512e, 0x4749512e, 0x4749512e, 0xe1bc5c49, 0xe1bc5c49, 0xe1bc5c49, 0xcc84f731, 0xcc84f731, 0xcc84f731, 0xaa4593fe, 0xb1874877, 0xb1874877, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xbee47cfb, 0x88e98534, 0xbee47cfb, 0xe3f3117f, 0xc9cbf769, 0xc9cbf769, 0xe2396b15, 0xe2396b15, 0xe2396b15, 0x1ce1aad9, 0x1ce1aad9, 0x1ce1aad9, 0xf5ab15d1, 0xf5ab15d1, 0xf5ab15d1, 0xc9cbf769, 0xe3f3117f, 0xe3f3117f, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2bfd5a83, 0xbe3c6f2f, 0x2bfd5a83, 0x85ab135b, 0x9813a416, 0x9813a416, 0xce30693b, 0xce30693b, 0xce30693b, 0x5febef08, 0x5febef08, 0x5febef08, 0x4651d2d8, 0x4651d2d8, 0x4651d2d8, 0x9813a416, 0x85ab135b, 0x85ab135b, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1456f321, 0xc3a55992, 0x1456f321, 0x62f0c692, 0x5fcf013d, 0x5fcf013d, 0xbe3d534a, 0xbe3d534a, 0xbe3d534a, 0x6c2d4b3c, 0x6c2d4b3c, 0x6c2d4b3c, 0x7a5e74a3, 0x7a5e74a3, 0x7a5e74a3, 0x5fcf013d, 0x62f0c692, 0x62f0c692, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdcac6945, 0x43fbdf5a, 0xdcac6945, 0xc7a9b342, 0xdd28f52b, 0xdd28f52b, 0x274da20b, 0x274da20b, 0x274da20b, 0x6715bef, 0x6715bef, 0x6715bef, 0x7bc99063, 0x7bc99063, 0x7bc99063, 0xdd28f52b, 0xc7a9b342, 0xc7a9b342, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x571e16b1, 0xb9f25c2, 0x571e16b1, 0xa8a10d31, 0x43d1f34, 0x43d1f34, 0x25dfb69d, 0x25dfb69d, 0x25dfb69d, 0x5ad51f35, 0x5ad51f35, 0x5ad51f35, 0xc3841ab3, 0xc3841ab3, 0xc3841ab3, 0x43d1f34, 0xa8a10d31, 0xa8a10d31, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xec987771, 0x8a579bf2, 0xec987771, 0xbbb5c9af, 0x59c36f00, 0x59c36f00, 0x16780f43, 0x16780f43, 0x16780f43, 0x68f86225, 0x68f86225, 0x68f86225, 0xa0e77f7, 0xa0e77f7, 0xa0e77f7, 0x59c36f00, 0xbbb5c9af, 0xbbb5c9af, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x97994d2c, 0x33b3ca94, 0x97994d2c, 0x273e977a, 0xaa4593fe, 0xaa4593fe, 0xa592c9d5, 0xa592c9d5, 0xa592c9d5, 0x367c4b2, 0x367c4b2, 0x367c4b2, 0x2e5f6fca, 0x2e5f6fca, 0x2e5f6fca, 0xaa4593fe, 0x273e977a, 0x273e977a, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5d2416aa, 0xe7a84972, 0x5d2416aa, 0x4d010804, 0xc9cbf769, 0xc9cbf769, 0x4e3a88a0, 0x4e3a88a0, 0x4e3a88a0, 0xb0e2496c, 0xb0e2496c, 0xb0e2496c, 0x59a8f664, 0x59a8f664, 0x59a8f664, 0xc9cbf769, 0x4d010804, 0x4d010804, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1da65b43, 0xae065274, 0x1da65b43, 0x2dd7a76c, 0x9813a416, 0x9813a416, 0xf81d19f, 0xf81d19f, 0xf81d19f, 0x9e5a57ac, 0x9e5a57ac, 0x9e5a57ac, 0x87e06a7c, 0x87e06a7c, 0x87e06a7c, 0x9813a416, 0x2dd7a76c, 0x2dd7a76c, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xea8a940e, 0xfa7c8f6f, 0xea8a940e, 0x448d7bfb, 0x5fcf013d, 0x5fcf013d, 0x47c22fa0, 0x47c22fa0, 0x47c22fa0, 0x95d237d6, 0x95d237d6, 0x95d237d6, 0x83a10849, 0x83a10849, 0x83a10849, 0x5fcf013d, 0x448d7bfb, 0x448d7bfb, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc0ac44fa, 0x94d4e024, 0xc0ac44fa, 0x4ec88f20, 0xdd28f52b, 0xdd28f52b, 0x2422f542, 0x2422f542, 0x2422f542, 0x51e0ca6, 0x51e0ca6, 0x51e0ca6, 0x78a6c72a, 0x78a6c72a, 0x78a6c72a, 0xdd28f52b, 0x4ec88f20, 0x4ec88f20, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x248f7655, 0x8f1ea1e8, 0x248f7655, 0xb3d7f0f5, 0x43d1f34, 0x43d1f34, 0x8c408c04, 0x8c408c04, 0x8c408c04, 0xf34a25ac, 0xf34a25ac, 0xf34a25ac, 0x6a1b202a, 0x6a1b202a, 0x6a1b202a, 0x43d1f34, 0xb3d7f0f5, 0xb3d7f0f5, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd6ba8f78, 0xb07563fb, 0xd6ba8f78, 0x6ef020b2, 0x59c36f00, 0x59c36f00, 0x7fd94135, 0x7fd94135, 0x7fd94135, 0x1592c53, 0x1592c53, 0x1592c53, 0x63af3981, 0x63af3981, 0x63af3981, 0x59c36f00, 0x6ef020b2, 0x6ef020b2, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf5257f70, 0x510ff8c8, 0xf5257f70, 0x36a3b7ff, 0xaa4593fe, 0xaa4593fe, 0x2e88732f, 0x2e88732f, 0x2e88732f, 0x887d7e48, 0x887d7e48, 0x887d7e48, 0xa545d530, 0xa545d530, 0xa545d530, 0xaa4593fe, 0x36a3b7ff, 0x36a3b7ff, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f8effb3, 0x2502a06b, 0x9f8effb3, 0xddeb038e, 0xc9cbf769, 0xc9cbf769, 0xda1c9f17, 0xda1c9f17, 0xda1c9f17, 0x24c45edb, 0x24c45edb, 0x24c45edb, 0xcd8ee1d3, 0xcd8ee1d3, 0xcd8ee1d3, 0xc9cbf769, 0xddeb038e, 0xddeb038e, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6aa72774, 0xd9072e43, 0x6aa72774, 0x24b4853d, 0x9813a416, 0x9813a416, 0xfb08d7cf, 0xfb08d7cf, 0xfb08d7cf, 0x6ad351fc, 0x6ad351fc, 0x6ad351fc, 0x73696c2c, 0x73696c2c, 0x73696c2c, 0x9813a416, 0x24b4853d, 0x24b4853d, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x936eb1d8, 0x8398aab9, 0x936eb1d8, 0x8beef, 0x5fcf013d, 0x5fcf013d, 0x9e56a9e0, 0x9e56a9e0, 0x9e56a9e0, 0x4c46b196, 0x4c46b196, 0x4c46b196, 0x5a358e09, 0x5a358e09, 0x5a358e09, 0x5fcf013d, 0x8beef, 0x8beef, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd4b9ec3, 0x89333a1d, 0xdd4b9ec3, 0x3acd5a9d, 0xdd28f52b, 0xdd28f52b, 0xe1579057, 0xe1579057, 0xe1579057, 0xc06b69b3, 0xc06b69b3, 0xc06b69b3, 0xbdd3a23f, 0xbdd3a23f, 0xbdd3a23f, 0xdd28f52b, 0x3acd5a9d, 0x3acd5a9d, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x89f37601, 0x2262a1bc, 0x89f37601, 0xf17b28ae, 0x43d1f34, 0x43d1f34, 0x6486f7c4, 0x6486f7c4, 0x6486f7c4, 0x1b8c5e6c, 0x1b8c5e6c, 0x1b8c5e6c, 0x82dd5bea, 0x82dd5bea, 0x82dd5bea, 0x43d1f34, 0xf17b28ae, 0xf17b28ae, 0x43d1f34, }, 20 }, - { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, - { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, - { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, - { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, - { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, - { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, - { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc69be699, 0xc69be699, 0xe17fc97c, 0xe17fc97c, 0xc2512486, 0xc2512486, 0x20260761, 0x20260761, 0xe3485349, 0xe3485349, 0x6020b4d9, 0x6020b4d9, 0x1605db98, 0x1605db98, 0xdca51b58, 0xdca51b58, 0xf3d66441, 0xf3d66441, 0x18cb7ce2, 0x18cb7ce2, 0x23b616d9, 0x23b616d9, 0xa1bf5dbf, 0xa1bf5dbf, 0x5e4a8b3d, 0x5e4a8b3d, 0x9933b3d8, 0x9933b3d8, 0xce7be2de, 0xce7be2de, 0x62531729, 0x62531729, 0xc39d3788, 0xc39d3788, 0xf7aee2fe, 0xf7aee2fe, 0xc66f4903, 0xc66f4903, 0x536c922f, 0x536c922f, 0xcb231652, 0x4ae07b67, 0x146816d5, 0x146816d5, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x29d0cfb7, 0x29d0cfb7, 0x4d57ad88, 0x4d57ad88, 0xaf7591cb, 0xaf7591cb, 0xb88e3c0, 0xb88e3c0, 0x5d55a031, 0x5d55a031, 0x4363bcff, 0x4363bcff, 0xe1142833, 0xe1142833, 0x9578c80d, 0x9578c80d, 0xff1f5174, 0xff1f5174, 0x6828d47, 0x6828d47, 0x2a849ae3, 0x2a849ae3, 0x27a811d9, 0x27a811d9, 0x6c42e1cb, 0x6c42e1cb, 0x5bba61f5, 0x5bba61f5, 0xc02ab705, 0xc02ab705, 0xeb3e0e05, 0xeb3e0e05, 0x6f4ce3c, 0x6f4ce3c, 0x2075c50e, 0x2075c50e, 0x54ac7fba, 0x54ac7fba, 0x335d1c21, 0x335d1c21, 0xf923fbd1, 0x1b489d4d, 0x1253eb5e, 0x1253eb5e, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6ff92a98, 0x6ff92a98, 0xbd8264b3, 0xbd8264b3, 0x5c50282c, 0x5c50282c, 0xd18d6a5a, 0xd18d6a5a, 0x99cea139, 0x99cea139, 0x2590c545, 0x2590c545, 0x55c86045, 0x55c86045, 0xad53ef1e, 0xad53ef1e, 0x5b44a23a, 0x5b44a23a, 0xa255f863, 0xa255f863, 0x85b0bdca, 0x85b0bdca, 0x4220ee1f, 0x4220ee1f, 0xeb991a9f, 0xeb991a9f, 0x86f366dd, 0x86f366dd, 0xfa176b7d, 0xfa176b7d, 0xd7384ca9, 0xd7384ca9, 0xceebf5c1, 0xceebf5c1, 0xae62b268, 0xae62b268, 0x6e89bbd6, 0x6e89bbd6, 0x3fe07c8e, 0x3fe07c8e, 0xee5358fe, 0x162d1a8a, 0x876f8d10, 0x876f8d10, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb96afaea, 0xb96afaea, 0xaa16ab1e, 0xaa16ab1e, 0x51ff382, 0x51ff382, 0xec74f127, 0xec74f127, 0xde4bca99, 0xde4bca99, 0x8ef3e8a5, 0x8ef3e8a5, 0x2daeb0b4, 0x2daeb0b4, 0x7cf5e243, 0x7cf5e243, 0x11fd57c6, 0x11fd57c6, 0x140723af, 0x140723af, 0x2bd93833, 0x2bd93833, 0xd731f4ac, 0xd731f4ac, 0x5fcd7114, 0x5fcd7114, 0xd1fea24a, 0xd1fea24a, 0x4083d53a, 0x4083d53a, 0x2e372605, 0x2e372605, 0x8e6316a7, 0x8e6316a7, 0x283ef6cc, 0x283ef6cc, 0x20cee9de, 0x20cee9de, 0xad6fa187, 0xad6fa187, 0xd691f438, 0xf3257e63, 0x4786ba7, 0x4786ba7, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x48acf1bf, 0x48acf1bf, 0xb8777469, 0xb8777469, 0xad2fad44, 0xad2fad44, 0xa415ac59, 0xa415ac59, 0x5a7bfb26, 0x5a7bfb26, 0xccb6016, 0xccb6016, 0x77a80cb3, 0x77a80cb3, 0x2034c102, 0x2034c102, 0x444b4ccd, 0x444b4ccd, 0xe6c31bea, 0xe6c31bea, 0x8408036e, 0x8408036e, 0x9e7c556f, 0x9e7c556f, 0x445dc388, 0x445dc388, 0x94b3f850, 0x94b3f850, 0xf6f15341, 0xf6f15341, 0xcb939b5f, 0xcb939b5f, 0xbe88067d, 0xbe88067d, 0x1efc4734, 0x1efc4734, 0x7f5dfca8, 0x7f5dfca8, 0xb7b10eb9, 0xb7b10eb9, 0xb94cb441, 0x9571329, 0x8a26912b, 0x8a26912b, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc508d04e, 0xc508d04e, 0x6dbccbfe, 0x6dbccbfe, 0xbf06ff60, 0xbf06ff60, 0xbc5ab06, 0xbc5ab06, 0x97eeab3c, 0x97eeab3c, 0x62663589, 0x62663589, 0xb03e21e2, 0xb03e21e2, 0xea196bb6, 0xea196bb6, 0x672c16c4, 0x672c16c4, 0xefbca2cd, 0xefbca2cd, 0x1af5b410, 0x1af5b410, 0xc7a80569, 0xc7a80569, 0x4926a16, 0x4926a16, 0xee29c99c, 0xee29c99c, 0xffb15985, 0xffb15985, 0x4f608e46, 0x4f608e46, 0x3e450fd2, 0x3e450fd2, 0xac45215f, 0xac45215f, 0x789b0ce7, 0x789b0ce7, 0x4cedfe22, 0x4cedfe22, 0xa005588c, 0x701da05c, 0x6f25cec1, 0x6f25cec1, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29e7a7f, 0x29e7a7f, 0xbd221052, 0xbd221052, 0x3b18b64, 0x3b18b64, 0x7f1e8462, 0x7f1e8462, 0xf28d5124, 0xf28d5124, 0xc336f170, 0xc336f170, 0xfe3bf988, 0xfe3bf988, 0x7bf89e05, 0x7bf89e05, 0x7857a3f8, 0x7857a3f8, 0x272c1a36, 0x272c1a36, 0xe8adb445, 0xe8adb445, 0x70cfe280, 0x70cfe280, 0x4f2b6120, 0x4f2b6120, 0xbaf5caa5, 0xbaf5caa5, 0x4b6bcab2, 0x4b6bcab2, 0x2bef7b92, 0x2bef7b92, 0x17b381dc, 0x17b381dc, 0x884c9c35, 0x884c9c35, 0x2f9eb909, 0x2f9eb909, 0xa811b3af, 0xa811b3af, 0x4c39478f, 0x5a72c3ab, 0x8071678a, 0x8071678a, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd9f04953, 0xbf3fa5d0, 0xd9f04953, 0x9a068414, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x9a068414, 0x9a068414, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9254157f, 0x367e92c7, 0x9254157f, 0xbc519000, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0xbc519000, 0xbc519000, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x354b1976, 0x8fc746ae, 0x354b1976, 0x685c74f2, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x685c74f2, 0x685c74f2, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1c9ec014, 0xaf3ec923, 0x1c9ec014, 0x43f5296, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0x43f5296, 0x43f5296, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa704f7ea, 0xb7f2ec8b, 0xa704f7ea, 0xb279bf59, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xb279bf59, 0xb279bf59, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf293ce36, 0xa6eb6ae8, 0xf293ce36, 0xcd87647e, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xcd87647e, 0xcd87647e, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x31e75bd7, 0x9a768c6a, 0x31e75bd7, 0xa8fc31a6, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xa8fc31a6, 0xa8fc31a6, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1ce7bd78, 0x682580f5, 0x1ce7bd78, 0x490ad6fe, 0x9a2e0d26, 0x64eb71ba, 0x64eb71ba, 0x64eb71ba, 0x3833877a, 0x3833877a, 0x3833877a, 0xcfc14f0a, 0xcfc14f0a, 0xcfc14f0a, 0x59c36f00, 0x490ad6fe, 0x490ad6fe, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b6ff87d, 0x63ce2ca2, 0x2b6ff87d, 0xf00f044e, 0xa9d58ccd, 0xe2c46577, 0xe2c46577, 0xe2c46577, 0xb79bcf7d, 0xb79bcf7d, 0xb79bcf7d, 0xbc30ed71, 0xbc30ed71, 0xbc30ed71, 0xaa4593fe, 0xf00f044e, 0xf00f044e, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe61cadba, 0x9880b727, 0xe61cadba, 0xdf5f2fc0, 0x5411be8b, 0x4449774e, 0x4449774e, 0x4449774e, 0x3bf7d1da, 0x3bf7d1da, 0x3bf7d1da, 0xd2ddee01, 0xd2ddee01, 0xd2ddee01, 0xc9cbf769, 0xdf5f2fc0, 0xdf5f2fc0, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xbe54acf7, 0x9b4ce770, 0xbe54acf7, 0x3111489, 0x740d78cf, 0x314c4c59, 0x314c4c59, 0x314c4c59, 0xdae9a625, 0xdae9a625, 0xdae9a625, 0xcbf8af57, 0xcbf8af57, 0xcbf8af57, 0x1c3742c9, 0x3111489, 0x3111489, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xee571de5, 0x568aaeff, 0xee571de5, 0xe328b7a7, 0xbcda144c, 0xf56e1b60, 0xf56e1b60, 0xf56e1b60, 0x9a27c771, 0x9a27c771, 0x9a27c771, 0xd6d05397, 0xd6d05397, 0xd6d05397, 0xcc5a7bed, 0xe328b7a7, 0xe328b7a7, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x1db9877c, 0x7e1afeae, 0x1db9877c, 0x8fc0c430, 0x5d55a141, 0x96f335c6, 0x96f335c6, 0x96f335c6, 0x504171d8, 0x504171d8, 0x504171d8, 0x69f71c0, 0x69f71c0, 0x69f71c0, 0xef4a3312, 0x8fc0c430, 0x8fc0c430, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x151819bd, 0xea8d4865, 0x151819bd, 0x11d75fd2, 0x6d6bb4bc, 0x650ccd09, 0x650ccd09, 0x650ccd09, 0xe4ff3bd8, 0xe4ff3bd8, 0xe4ff3bd8, 0xc5308b73, 0xc5308b73, 0xc5308b73, 0x54e48d80, 0x11d75fd2, 0x11d75fd2, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd0b06c3d, 0xde50d1a5, 0xd0b06c3d, 0x9346a17a, 0x59c36f00, 0x59c36f00, 0xacff5d47, 0xacff5d47, 0xacff5d47, 0xd27f3021, 0xd27f3021, 0xd27f3021, 0xdd5cd33, 0xdd5cd33, 0xdd5cd33, 0x59c36f00, 0x9346a17a, 0x9346a17a, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf32d50c1, 0x730a7ed, 0xf32d50c1, 0xdd28d5be, 0xaa4593fe, 0xaa4593fe, 0xba8a2d4c, 0xba8a2d4c, 0xba8a2d4c, 0x1c7f202b, 0x1c7f202b, 0x1c7f202b, 0x4df6782, 0x4df6782, 0x4df6782, 0xaa4593fe, 0xdd28d5be, 0xdd28d5be, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x711a4ac1, 0x6396f14c, 0x711a4ac1, 0x2c0d2745, 0xc9cbf769, 0xc9cbf769, 0x6b6ccbb0, 0x6b6ccbb0, 0x6b6ccbb0, 0x95b40a7c, 0x95b40a7c, 0x95b40a7c, 0xc97c723, 0xc97c723, 0xc97c723, 0xc9cbf769, 0x2c0d2745, 0x2c0d2745, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x29baad6a, 0x348b1f2b, 0x29baad6a, 0x311b3fe8, 0x9813a416, 0x9813a416, 0xe8e982cc, 0xe8e982cc, 0xe8e982cc, 0x793204ff, 0x793204ff, 0x793204ff, 0xddb20d3c, 0xddb20d3c, 0xddb20d3c, 0x9813a416, 0x311b3fe8, 0x311b3fe8, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf834b3bb, 0x3951bd1a, 0xf834b3bb, 0xed49fb08, 0x5fcf013d, 0x5fcf013d, 0x5aefa2a7, 0x5aefa2a7, 0x5aefa2a7, 0x88ffbad1, 0x88ffbad1, 0x88ffbad1, 0x35c61ecb, 0x35c61ecb, 0x35c61ecb, 0x5fcf013d, 0xed49fb08, 0xed49fb08, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7e9a7a47, 0xb1651b5a, 0x7e9a7a47, 0x418ed00f, 0xdd28f52b, 0xdd28f52b, 0x83f9db69, 0x83f9db69, 0x83f9db69, 0xa2c5228d, 0xa2c5228d, 0xa2c5228d, 0xe1656ac7, 0xe1656ac7, 0xe1656ac7, 0xdd28f52b, 0x418ed00f, 0x418ed00f, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc6a0340, 0x7dd5855c, 0xc6a0340, 0x95716931, 0x43d1f34, 0x43d1f34, 0x5f1c24c0, 0x5f1c24c0, 0x5f1c24c0, 0x20168d68, 0x20168d68, 0x20168d68, 0x7137c7da, 0x7137c7da, 0x7137c7da, 0x43d1f34, 0x95716931, 0x95716931, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3798aaa, 0xab48784c, 0xd3798aaa, 0x908f47ed, 0x59c36f00, 0x59c36f00, 0x1688ec7c, 0x1688ec7c, 0x1688ec7c, 0x6808811a, 0x6808811a, 0x6808811a, 0xb7a27c08, 0xb7a27c08, 0xb7a27c08, 0x59c36f00, 0x908f47ed, 0x908f47ed, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc30d9d2a, 0x60b9ed26, 0xc30d9d2a, 0xed081855, 0xaa4593fe, 0xaa4593fe, 0x3eba2192, 0x3eba2192, 0x3eba2192, 0x984f2cf5, 0x984f2cf5, 0x984f2cf5, 0x80ef6b5c, 0x80ef6b5c, 0x80ef6b5c, 0xaa4593fe, 0xed081855, 0xed081855, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe469e6af, 0x46ac2012, 0xe469e6af, 0xb97e8b2b, 0xc9cbf769, 0xc9cbf769, 0x60f0d993, 0x60f0d993, 0x60f0d993, 0x9e28185f, 0x9e28185f, 0x9e28185f, 0x70bd500, 0x70bd500, 0x70bd500, 0xc9cbf769, 0xb97e8b2b, 0xb97e8b2b, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8538d2ef, 0xab143284, 0x8538d2ef, 0x9d99406d, 0x9813a416, 0x9813a416, 0x7e8326ec, 0x7e8326ec, 0x7e8326ec, 0xef58a0df, 0xef58a0df, 0xef58a0df, 0x4bd8a91c, 0x4bd8a91c, 0x4bd8a91c, 0x9813a416, 0x9d99406d, 0x9d99406d, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8115198c, 0x1abdaee1, 0x8115198c, 0x9468513f, 0x5fcf013d, 0x5fcf013d, 0xa5e86484, 0xa5e86484, 0xa5e86484, 0x77f87cf2, 0x77f87cf2, 0x77f87cf2, 0xcac1d8e8, 0xcac1d8e8, 0xcac1d8e8, 0x5fcf013d, 0x9468513f, 0x9468513f, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xea03b805, 0x74148290, 0xea03b805, 0xd517124d, 0xdd28f52b, 0xdd28f52b, 0x8f6eee40, 0x8f6eee40, 0x8f6eee40, 0xae5217a4, 0xae5217a4, 0xae5217a4, 0xedf25fee, 0xedf25fee, 0xedf25fee, 0xdd28f52b, 0xd517124d, 0xd517124d, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa044490f, 0xe23458db, 0xa044490f, 0x395f237e, 0x43d1f34, 0x43d1f34, 0xe1ca82c2, 0xe1ca82c2, 0xe1ca82c2, 0x9ec02b6a, 0x9ec02b6a, 0x9ec02b6a, 0xcfe161d8, 0xcfe161d8, 0xcfe161d8, 0x43d1f34, 0x395f237e, 0x395f237e, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xf3259b30, 0xf1f01411, 0xf3259b30, 0xb0d35677, 0x59c36f00, 0x59c36f00, 0x97895f8e, 0x97895f8e, 0x97895f8e, 0xe90932e8, 0xe90932e8, 0xe90932e8, 0x36a3cffa, 0x36a3cffa, 0x36a3cffa, 0x59c36f00, 0xb0d35677, 0xb0d35677, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53a43759, 0xe0f26bfa, 0x53a43759, 0x7da1b226, 0xaa4593fe, 0xaa4593fe, 0xbf482a4e, 0xbf482a4e, 0xbf482a4e, 0x19bd2729, 0x19bd2729, 0x19bd2729, 0x11d6080, 0x11d6080, 0x11d6080, 0xaa4593fe, 0x7da1b226, 0x7da1b226, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd7ff8d53, 0x665b2728, 0xd7ff8d53, 0x8ae8e0d7, 0xc9cbf769, 0xc9cbf769, 0x5a693e73, 0x5a693e73, 0x5a693e73, 0xa4b1ffbf, 0xa4b1ffbf, 0xa4b1ffbf, 0x3d9232e0, 0x3d9232e0, 0x3d9232e0, 0xc9cbf769, 0x8ae8e0d7, 0x8ae8e0d7, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x99fddcbe, 0x6d5c8895, 0x99fddcbe, 0x815c4e3c, 0x9813a416, 0x9813a416, 0x9bcf9821, 0x9bcf9821, 0x9bcf9821, 0xa141e12, 0xa141e12, 0xa141e12, 0xae9417d1, 0xae9417d1, 0xae9417d1, 0x9813a416, 0x815c4e3c, 0x815c4e3c, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5797846, 0x25a6ad40, 0x5797846, 0x100430f5, 0x5fcf013d, 0x5fcf013d, 0xddc86daf, 0xddc86daf, 0xddc86daf, 0xfd875d9, 0xfd875d9, 0xfd875d9, 0xb2e1d1c3, 0xb2e1d1c3, 0xb2e1d1c3, 0x5fcf013d, 0x100430f5, 0x100430f5, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x30653ae8, 0x7fcd187, 0x30653ae8, 0xf7190a0, 0xdd28f52b, 0xdd28f52b, 0x24c3d325, 0x24c3d325, 0x24c3d325, 0x5ff2ac1, 0x5ff2ac1, 0x5ff2ac1, 0x465f628b, 0x465f628b, 0x465f628b, 0xdd28f52b, 0xf7190a0, 0xf7190a0, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3bd91638, 0x1d74dd4a, 0x3bd91638, 0xa2c27c49, 0x43d1f34, 0x43d1f34, 0x53d1ad3d, 0x53d1ad3d, 0x53d1ad3d, 0x2cdb0495, 0x2cdb0495, 0x2cdb0495, 0x7dfa4e27, 0x7dfa4e27, 0x7dfa4e27, 0x43d1f34, 0xa2c27c49, 0xa2c27c49, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe2c351a, 0x2692720, 0xbe2c351a, 0xfddaf85d, 0x59c36f00, 0x59c36f00, 0x1b2e2301, 0x1b2e2301, 0x1b2e2301, 0x65ae4e67, 0x65ae4e67, 0x65ae4e67, 0xba04b375, 0xba04b375, 0xba04b375, 0x59c36f00, 0xfddaf85d, 0xfddaf85d, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1eca82e1, 0xe8fa59cc, 0x1eca82e1, 0x30cf079e, 0xaa4593fe, 0xaa4593fe, 0xaf27ddc5, 0xaf27ddc5, 0xaf27ddc5, 0x9d2d0a2, 0x9d2d0a2, 0x9d2d0a2, 0x1172970b, 0x1172970b, 0x1172970b, 0xaa4593fe, 0x30cf079e, 0x30cf079e, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa9ccd435, 0x1ac646eb, 0xa9ccd435, 0xf4dbb9b1, 0xc9cbf769, 0xc9cbf769, 0x86d69aa0, 0x86d69aa0, 0x86d69aa0, 0x780e5b6c, 0x780e5b6c, 0x780e5b6c, 0xe12d9633, 0xe12d9633, 0xe12d9633, 0xc9cbf769, 0xf4dbb9b1, 0xf4dbb9b1, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf96d568, 0x7ad05c1b, 0xf96d568, 0x173747ea, 0x9813a416, 0x9813a416, 0xacf9792a, 0xacf9792a, 0xacf9792a, 0x3d22ff19, 0x3d22ff19, 0x3d22ff19, 0x99a2f6da, 0x99a2f6da, 0x99a2f6da, 0x9813a416, 0x173747ea, 0x173747ea, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa0dc6b9c, 0xc2761148, 0xa0dc6b9c, 0xb5a1232f, 0x5fcf013d, 0x5fcf013d, 0x4e05748b, 0x4e05748b, 0x4e05748b, 0x9c156cfd, 0x9c156cfd, 0x9c156cfd, 0x212cc8e7, 0x212cc8e7, 0x212cc8e7, 0x5fcf013d, 0xb5a1232f, 0xb5a1232f, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcd722f7d, 0xe4df8d6b, 0xcd722f7d, 0xf2668535, 0xdd28f52b, 0xdd28f52b, 0xbdbb8019, 0xbdbb8019, 0xbdbb8019, 0x9c8779fd, 0x9c8779fd, 0x9c8779fd, 0xdf2731b7, 0xdf2731b7, 0xdf2731b7, 0xdd28f52b, 0xf2668535, 0xf2668535, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa6c99d2f, 0x1de04317, 0xa6c99d2f, 0x3fd2f75e, 0x43d1f34, 0x43d1f34, 0x3f85b7d3, 0x3f85b7d3, 0x3f85b7d3, 0x408f1e7b, 0x408f1e7b, 0x408f1e7b, 0x11ae54c9, 0x11ae54c9, 0x11ae54c9, 0x43d1f34, 0x3fd2f75e, 0x3fd2f75e, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1e35b709, 0x2683bf92, 0x1e35b709, 0x5dc37a4e, 0x59c36f00, 0x59c36f00, 0xd697967f, 0xd697967f, 0xd697967f, 0xa817fb19, 0xa817fb19, 0xa817fb19, 0x77bd060b, 0x77bd060b, 0x77bd060b, 0x59c36f00, 0x5dc37a4e, 0x5dc37a4e, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53ff7735, 0x8cbf197c, 0x53ff7735, 0x7dfaf24a, 0xaa4593fe, 0xaa4593fe, 0x389a922, 0x389a922, 0x389a922, 0xa57ca445, 0xa57ca445, 0xa57ca445, 0xbddce3ec, 0xbddce3ec, 0xbddce3ec, 0xaa4593fe, 0x7dfaf24a, 0x7dfaf24a, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5217c47d, 0x7c8ae63e, 0x5217c47d, 0xf00a9f9, 0xc9cbf769, 0xc9cbf769, 0x3995409, 0x3995409, 0x3995409, 0xfd4195c5, 0xfd4195c5, 0xfd4195c5, 0x6462589a, 0x6462589a, 0x6462589a, 0xc9cbf769, 0xf00a9f9, 0xf00a9f9, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x45b67706, 0x375fb5db, 0x45b67706, 0x5d17e584, 0x9813a416, 0x9813a416, 0x8195719b, 0x8195719b, 0x8195719b, 0x104ef7a8, 0x104ef7a8, 0x104ef7a8, 0xb4cefe6b, 0xb4cefe6b, 0xb4cefe6b, 0x9813a416, 0x5d17e584, 0x5d17e584, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xfc209a25, 0xd5c20779, 0xfc209a25, 0xe95dd296, 0x5fcf013d, 0x5fcf013d, 0xe5699efe, 0xe5699efe, 0xe5699efe, 0x37798688, 0x37798688, 0x37798688, 0x8a402292, 0x8a402292, 0x8a402292, 0x5fcf013d, 0xe95dd296, 0xe95dd296, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x77f956f0, 0xfb0cc079, 0x77f956f0, 0x48edfcb8, 0xdd28f52b, 0xdd28f52b, 0xd51b1dc9, 0xd51b1dc9, 0xd51b1dc9, 0xf427e42d, 0xf427e42d, 0xf427e42d, 0xb787ac67, 0xb787ac67, 0xb787ac67, 0xdd28f52b, 0x48edfcb8, 0x48edfcb8, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x1d9ac82a, 0xa254aa53, 0x1d9ac82a, 0x8481a25b, 0x43d1f34, 0x43d1f34, 0xc304df68, 0xc304df68, 0xc304df68, 0xbc0e76c0, 0xbc0e76c0, 0xbc0e76c0, 0xed2f3c72, 0xed2f3c72, 0xed2f3c72, 0x43d1f34, 0x8481a25b, 0x8481a25b, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa6239a89, 0x8dc4bfbb, 0xa6239a89, 0xe5d557ce, 0x59c36f00, 0x59c36f00, 0x244cf807, 0x244cf807, 0x244cf807, 0x5acc9561, 0x5acc9561, 0x5acc9561, 0x85666873, 0x85666873, 0x85666873, 0x59c36f00, 0xe5d557ce, 0xe5d557ce, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x742cede9, 0x83bb7a50, 0x742cede9, 0x5a296896, 0xaa4593fe, 0xaa4593fe, 0xd83f8aeb, 0xd83f8aeb, 0xd83f8aeb, 0x7eca878c, 0x7eca878c, 0x7eca878c, 0x666ac025, 0x666ac025, 0x666ac025, 0xaa4593fe, 0x5a296896, 0x5a296896, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe20a98b0, 0x7e8cedef, 0xe20a98b0, 0xbf1df534, 0xc9cbf769, 0xc9cbf769, 0x2748b88c, 0x2748b88c, 0x2748b88c, 0xd9907940, 0xd9907940, 0xd9907940, 0x40b3b41f, 0x40b3b41f, 0x40b3b41f, 0xc9cbf769, 0xbf1df534, 0xbf1df534, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8f911ca4, 0xcbf1d895, 0x8f911ca4, 0x97308e26, 0x9813a416, 0x9813a416, 0x5b359bf4, 0x5b359bf4, 0x5b359bf4, 0xcaee1dc7, 0xcaee1dc7, 0xcaee1dc7, 0x6e6e1404, 0x6e6e1404, 0x6e6e1404, 0x9813a416, 0x97308e26, 0x97308e26, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1bf82c82, 0xc7b39627, 0x1bf82c82, 0xe856431, 0x5fcf013d, 0x5fcf013d, 0xa9dbae99, 0xa9dbae99, 0xa9dbae99, 0x7bcbb6ef, 0x7bcbb6ef, 0x7bcbb6ef, 0xc6f212f5, 0xc6f212f5, 0xc6f212f5, 0x5fcf013d, 0xe856431, 0xe856431, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfae19a5c, 0xd1e8fabb, 0xfae19a5c, 0xc5f53014, 0xdd28f52b, 0xdd28f52b, 0xfa2c5565, 0xfa2c5565, 0xfa2c5565, 0xdb10ac81, 0xdb10ac81, 0xdb10ac81, 0x98b0e4cb, 0x98b0e4cb, 0x98b0e4cb, 0xdd28f52b, 0xc5f53014, 0xc5f53014, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9a18f7bc, 0x5fcecc43, 0x9a18f7bc, 0x3039dcd, 0x43d1f34, 0x43d1f34, 0x287a2b96, 0x287a2b96, 0x287a2b96, 0x5770823e, 0x5770823e, 0x5770823e, 0x651c88c, 0x651c88c, 0x651c88c, 0x43d1f34, 0x3039dcd, 0x3039dcd, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x65112dfc, 0x3dec17f, 0x65112dfc, 0x26e7e0bb, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x26e7e0bb, 0x26e7e0bb, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b3430fb, 0x8f1eb743, 0x2b3430fb, 0x531b584, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x531b584, 0x531b584, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb523e920, 0xfafb6f8, 0xb523e920, 0xe83484a4, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0xe83484a4, 0xe83484a4, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa9bf7336, 0x1a1f7a01, 0xa9bf7336, 0xb11ee1b4, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xb11ee1b4, 0xb11ee1b4, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe5271912, 0xf5d10273, 0xe5271912, 0xf05a51a1, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xf05a51a1, 0xf05a51a1, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x66a34f49, 0x32dbeb97, 0x66a34f49, 0x59b7e501, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0x59b7e501, 0x59b7e501, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7c2f19da, 0xd7bece67, 0x7c2f19da, 0xe53473ab, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xe53473ab, 0xe53473ab, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x37943894, 0x78248c70, 0x37943894, 0x7462f5d3, 0x59c36f00, 0x59c36f00, 0xf4be229a, 0xf4be229a, 0xf4be229a, 0x8a3e4ffc, 0x8a3e4ffc, 0x8a3e4ffc, 0x5594b2ee, 0x5594b2ee, 0x5594b2ee, 0x59c36f00, 0x7462f5d3, 0x7462f5d3, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5158e6c, 0xdc71ba0f, 0xd5158e6c, 0xfb100b13, 0xaa4593fe, 0xaa4593fe, 0xd3ed72a3, 0xd3ed72a3, 0xd3ed72a3, 0x75187fc4, 0x75187fc4, 0x75187fc4, 0x6db8386d, 0x6db8386d, 0x6db8386d, 0xaa4593fe, 0xfb100b13, 0xfb100b13, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6277a9e6, 0xa3265ffb, 0x6277a9e6, 0x3f60c462, 0xc9cbf769, 0xc9cbf769, 0x2dcf8a8d, 0x2dcf8a8d, 0x2dcf8a8d, 0xd3174b41, 0xd3174b41, 0xd3174b41, 0x4a34861e, 0x4a34861e, 0x4a34861e, 0xc9cbf769, 0x3f60c462, 0x3f60c462, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x81115dc4, 0xddf3f768, 0x81115dc4, 0x99b0cf46, 0x9813a416, 0x9813a416, 0x9b9d96df, 0x9b9d96df, 0x9b9d96df, 0xa4610ec, 0xa4610ec, 0xa4610ec, 0xaec6192f, 0xaec6192f, 0xaec6192f, 0x9813a416, 0x99b0cf46, 0x99b0cf46, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e96a904, 0x27864d3d, 0x5e96a904, 0x4bebe1b7, 0x5fcf013d, 0x5fcf013d, 0x18cae7f4, 0x18cae7f4, 0x18cae7f4, 0xcadaff82, 0xcadaff82, 0xcadaff82, 0x77e35b98, 0x77e35b98, 0x77e35b98, 0x5fcf013d, 0x4bebe1b7, 0x4bebe1b7, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd00b19f8, 0xba73a9c6, 0xd00b19f8, 0xef1fb3b0, 0xdd28f52b, 0xdd28f52b, 0xb660046d, 0xb660046d, 0xb660046d, 0x975cfd89, 0x975cfd89, 0x975cfd89, 0xd4fcb5c3, 0xd4fcb5c3, 0xd4fcb5c3, 0xdd28f52b, 0xef1fb3b0, 0xef1fb3b0, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8b4b98cd, 0x78ddc6e4, 0x8b4b98cd, 0x1250f2bc, 0x43d1f34, 0x43d1f34, 0x4889d3fd, 0x4889d3fd, 0x4889d3fd, 0x37837a55, 0x37837a55, 0x37837a55, 0x66a230e7, 0x66a230e7, 0x66a230e7, 0x43d1f34, 0x1250f2bc, 0x1250f2bc, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfecb570e, 0xccb97a7a, 0xfecb570e, 0xbd3d9a49, 0x59c36f00, 0x59c36f00, 0x40281258, 0x40281258, 0x40281258, 0x3ea87f3e, 0x3ea87f3e, 0x3ea87f3e, 0xe102822c, 0xe102822c, 0xe102822c, 0x59c36f00, 0xbd3d9a49, 0xbd3d9a49, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x897d1fac, 0xaa982529, 0x897d1fac, 0xa7789ad3, 0xaa4593fe, 0xaa4593fe, 0xa482510, 0xa482510, 0xa482510, 0xacbd2877, 0xacbd2877, 0xacbd2877, 0xb41d6fde, 0xb41d6fde, 0xb41d6fde, 0xaa4593fe, 0xa7789ad3, 0xa7789ad3, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd02a5297, 0xe627ab58, 0xd02a5297, 0x8d3d3f13, 0xc9cbf769, 0xc9cbf769, 0xbf0a8b7f, 0xbf0a8b7f, 0xbf0a8b7f, 0x41d24ab3, 0x41d24ab3, 0x41d24ab3, 0xd8f187ec, 0xd8f187ec, 0xd8f187ec, 0xc9cbf769, 0x8d3d3f13, 0x8d3d3f13, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa653dcda, 0x3392e976, 0xa653dcda, 0xbef24e58, 0x9813a416, 0x9813a416, 0x4f2bc106, 0x4f2bc106, 0x4f2bc106, 0xdef04735, 0xdef04735, 0xdef04735, 0x7a704ef6, 0x7a704ef6, 0x7a704ef6, 0x9813a416, 0xbef24e58, 0xbef24e58, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe2d7b585, 0x35241f36, 0xe2d7b585, 0xf7aafd36, 0x5fcf013d, 0x5fcf013d, 0xf2bd04db, 0xf2bd04db, 0xf2bd04db, 0x20ad1cad, 0x20ad1cad, 0x20ad1cad, 0x9d94b8b7, 0x9d94b8b7, 0x9d94b8b7, 0x5fcf013d, 0xf7aafd36, 0xf7aafd36, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x72ff749c, 0xeda8c283, 0x72ff749c, 0x4debded4, 0xdd28f52b, 0xdd28f52b, 0xb8c9cc22, 0xb8c9cc22, 0xb8c9cc22, 0x99f535c6, 0x99f535c6, 0x99f535c6, 0xda557d8c, 0xda557d8c, 0xda557d8c, 0xdd28f52b, 0x4debded4, 0x4debded4, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb7cac764, 0xeb4bf417, 0xb7cac764, 0x2ed1ad15, 0x43d1f34, 0x43d1f34, 0xce718801, 0xce718801, 0xce718801, 0xb17b21a9, 0xb17b21a9, 0xb17b21a9, 0xe05a6b1b, 0xe05a6b1b, 0xe05a6b1b, 0x43d1f34, 0x2ed1ad15, 0x2ed1ad15, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x930e8e13, 0xf5c16290, 0x930e8e13, 0x27f5f1c0, 0x59c36f00, 0x59c36f00, 0xbad4e11, 0xbad4e11, 0xbad4e11, 0x752d2377, 0x752d2377, 0x752d2377, 0xaa87de65, 0xaa87de65, 0xaa87de65, 0x59c36f00, 0x27f5f1c0, 0x27f5f1c0, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xff9301f2, 0x5bb9864a, 0xff9301f2, 0x31c145de, 0xaa4593fe, 0xaa4593fe, 0x23bf2c32, 0x23bf2c32, 0x23bf2c32, 0x854a2155, 0x854a2155, 0x854a2155, 0x9dea66fc, 0x9dea66fc, 0x9dea66fc, 0xaa4593fe, 0x31c145de, 0x31c145de, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfc5938ef, 0x46d56737, 0xfc5938ef, 0x23cf2668, 0xc9cbf769, 0xc9cbf769, 0xa8c549aa, 0xa8c549aa, 0xa8c549aa, 0x561d8866, 0x561d8866, 0x561d8866, 0xcf3e4539, 0xcf3e4539, 0xcf3e4539, 0xc9cbf769, 0x23cf2668, 0x23cf2668, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe7160822, 0x54b60115, 0xe7160822, 0x168efa6f, 0x9813a416, 0x9813a416, 0xb774a5aa, 0xb774a5aa, 0xb774a5aa, 0x26af2399, 0x26af2399, 0x26af2399, 0x822f2a5a, 0x822f2a5a, 0x822f2a5a, 0x9813a416, 0x168efa6f, 0x168efa6f, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf655f9b2, 0xe6a3e2d3, 0xf655f9b2, 0xd1d7405f, 0x5fcf013d, 0x5fcf013d, 0x2accaa08, 0x2accaa08, 0x2accaa08, 0xf8dcb27e, 0xf8dcb27e, 0xf8dcb27e, 0x45e51664, 0x45e51664, 0x45e51664, 0x5fcf013d, 0xd1d7405f, 0xd1d7405f, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d85ebdc, 0x79fd4f02, 0x2d85ebdc, 0xc48ae2b6, 0xdd28f52b, 0xdd28f52b, 0x76b28a95, 0x76b28a95, 0x76b28a95, 0x578e7371, 0x578e7371, 0x578e7371, 0x142e3b3b, 0x142e3b3b, 0x142e3b3b, 0xdd28f52b, 0xc48ae2b6, 0xc48ae2b6, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29c00f98, 0x8251d825, 0x29c00f98, 0x35a750d1, 0x43d1f34, 0x43d1f34, 0x48b70bc8, 0x48b70bc8, 0x48b70bc8, 0x37bda260, 0x37bda260, 0x37bda260, 0x669ce8d2, 0x669ce8d2, 0x669ce8d2, 0x43d1f34, 0x35a750d1, 0x35a750d1, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4afab717, 0x2c355b94, 0x4afab717, 0x1166d9d0, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x1166d9d0, 0x1166d9d0, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe3daadd4, 0x47f02a6c, 0xe3daadd4, 0x5ea9fb21, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x5ea9fb21, 0x5ea9fb21, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf140d1df, 0x4bcc8e07, 0xf140d1df, 0x7c962dcb, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x7c962dcb, 0x7c962dcb, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe709a12d, 0x54a9a81a, 0xe709a12d, 0xde04d65c, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xde04d65c, 0xde04d65c, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x65eff77c, 0x7519ec1d, 0x65eff77c, 0x1cd7d353, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0x1cd7d353, 0x1cd7d353, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7318831a, 0x276027c4, 0x7318831a, 0xd7e4f5bb, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xd7e4f5bb, 0xd7e4f5bb, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6927a7d4, 0xc2b67069, 0x6927a7d4, 0xfc345163, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xfc345163, 0xfc345163, 0x43d1f34, }, 20 }, + { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, }, 5 }, + { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, }, 5 }, + { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x8f20afbb, 0xd8f7abc, 0x8f937344, 0xd3ca643, 0x8e471645, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xdca764da, 0x9f76da9a, 0x5b04185a, 0x18d5a61a, 0xd60deb2b, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x7b87af36, 0x7cb96093, 0x75fa307c, 0x72c4ffd9, 0x677c91a2, }, 5 }, + { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x72981c65, 0x50120635, 0x378c28c5, 0x15063295, 0xf8b07525, }, 5 }, + { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, }, 5 }, + { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, }, 5 }, + { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0xe56cf615, 0xcd2be572, 0xb5e2d0db, 0x9da5c3bc, 0x4470bb89, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x2a25b871, 0x4bf85361, 0xe99e6e51, 0x88438541, 0xa8be62c0, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x81523037, 0xd8c0bfd3, 0x32772fff, 0x6be5a01b, 0xe2f47956, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x770da211, 0x8ef2528e, 0x811e35de, 0x78e1c541, 0x9ec6fb7e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xeb181fbc, 0xae648cc1, 0x61e13946, 0x249daa3b, 0xfb0624b9, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x2b6f64dc, 0xc25f8431, 0xfce2d3f7, 0x15d2331a, 0x81987c7b, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xa260f7dd, 0x3e2f4980, 0x9f13fd96, 0x35c43cb, 0xd886e34b, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x41a9bff8, 0xa0d3f7c3, 0x86b1597f, 0x67cb1144, 0xca740407, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x8f7a3b6d, 0xcb84c6e3, 0x687c071, 0x42793dff, 0x996dbba4, }, 5 }, From 4f31bfe1d36e95ca3b1cdaf6a9d45d1e3722ad2f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 17:22:58 +0200 Subject: [PATCH 0747/1167] grub-fs-tester: Fix bashism --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index fd7e0f14b..15969d796 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -957,7 +957,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do esac # Make sure file is not exact multiple of block size. This helps to force # tail packing in case of squash4. - : $((BLOCKCNT--)) + BLOCKCNT="$((BLOCKCNT-1))" case x"$fs" in x"ntfscomp") setfattr -h -v 0x00000800 -n system.ntfs_attrib_be "$MNTPOINTRW/$OSDIR";; From 95acd4cbdac495c088fc3401fa365455f7039151 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Aug 2017 20:46:14 +0200 Subject: [PATCH 0748/1167] gzio: fix unaligned access --- grub-core/io/gzio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index dcf3a8701..86ea8cfde 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1116,7 +1116,7 @@ inflate_window (grub_gzio_t gzio) grub_uint32_t csum; gzio->hdesc->final (gzio->hcontext); - csum = *(grub_uint32_t *)gzio->hdesc->read (gzio->hcontext); + csum = grub_get_unaligned32 (gzio->hdesc->read (gzio->hcontext)); csum = grub_be_to_cpu32 (csum); if (csum != gzio->orig_checksum) grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, From 1b18d6b0d34872ced6b3dbfc3e7957c80efbcb7a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Sep 2017 23:13:55 +0200 Subject: [PATCH 0749/1167] Add a file missing in multiboot2 commit. --- include/grub/multiboot2.h | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 include/grub/multiboot2.h diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h new file mode 100644 index 000000000..502d34ef1 --- /dev/null +++ b/include/grub/multiboot2.h @@ -0,0 +1,104 @@ +/* multiboot.h - multiboot header file with grub definitions. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003,2007,2008,2010 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 . + */ + +#ifndef GRUB_MULTIBOOT2_HEADER +#define GRUB_MULTIBOOT2_HEADER 1 + +#include + +#include + +#include +#include + +extern struct grub_relocator *grub_multiboot2_relocator; + +void grub_multiboot2 (int argc, char *argv[]); +void grub_module2 (int argc, char *argv[]); + +void grub_multiboot2_set_accepts_video (int val); +grub_err_t grub_multiboot2_make_mbi (grub_uint32_t *target); +void grub_multiboot2_free_mbi (void); +grub_err_t grub_multiboot2_init_mbi (int argc, char *argv[]); +grub_err_t grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, + int argc, char *argv[]); +void grub_multiboot2_set_bootdev (void); +void +grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize, + unsigned shndx, void *data); + +grub_uint32_t grub_multiboot2_get_mmap_count (void); +grub_err_t grub_multiboot2_set_video_mode (void); + +/* FIXME: support coreboot as well. */ +#if defined (GRUB_MACHINE_PCBIOS) +#define GRUB_MACHINE_HAS_VBE 1 +#else +#define GRUB_MACHINE_HAS_VBE 0 +#endif + +#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU) +#define GRUB_MACHINE_HAS_VGA_TEXT 1 +#else +#define GRUB_MACHINE_HAS_VGA_TEXT 0 +#endif + +#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) +#define GRUB_MACHINE_HAS_ACPI 1 +#else +#define GRUB_MACHINE_HAS_ACPI 0 +#endif + +#define GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT 1 +#define GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER 2 + +grub_err_t +grub_multiboot2_set_console (int console_type, int accepted_consoles, + int width, int height, int depth, + int console_required); +grub_err_t +grub_multiboot2_load (grub_file_t file, const char *filename); + +struct mbi_load_data +{ + grub_file_t file; + const char *filename; + void *buffer; + unsigned int mbi_ver; + int relocatable; + grub_uint32_t min_addr; + grub_uint32_t max_addr; + grub_size_t align; + grub_uint32_t preference; + grub_uint32_t link_base_addr; + grub_uint32_t load_base_addr; + int avoid_efi_boot_services; +}; +typedef struct mbi_load_data mbi_load_data_t; + +/* Load ELF32 or ELF64. */ +grub_err_t +grub_multiboot2_load_elf (mbi_load_data_t *mld); + +extern grub_size_t grub_multiboot2_pure_size; +extern grub_size_t grub_multiboot2_alloc_mbi; +extern grub_uint32_t grub_multiboot2_payload_eip; + + +#endif /* ! GRUB_MULTIBOOT_HEADER */ From 78d2b81bd1af0a3a84d0c23c9ff4af3caa2df23b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Sep 2017 13:55:22 +0200 Subject: [PATCH 0750/1167] Fix compilation for x86_64-efi. --- grub-core/loader/multiboot.c | 2 +- include/grub/i386/multiboot.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 3b57cb132..40c67e824 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -143,7 +143,7 @@ efi_boot (struct grub_relocator *rel, #else struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE; #endif - state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip; + state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip); state_efi.MULTIBOOT_EFI_MBI_REGISTER = target; grub_relocator_efi_boot (rel, state_efi); diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h index 9cd97dfce..0b596fc20 100644 --- a/include/grub/i386/multiboot.h +++ b/include/grub/i386/multiboot.h @@ -43,6 +43,10 @@ .rcx = 0, \ .rdx = 0, \ } +#define MULTIBOOT2_EFI_INITIAL_STATE { .rax = MULTIBOOT2_BOOTLOADER_MAGIC, \ + .rcx = 0, \ + .rdx = 0, \ + } #define MULTIBOOT_EFI_ENTRY_REGISTER rip #define MULTIBOOT_EFI_MBI_REGISTER rbx #endif From a8e0f1adf7019238fff263111794c86f4eea79ac Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Tue, 29 Aug 2017 16:40:52 -0400 Subject: [PATCH 0751/1167] Fix util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64 Commit d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe introduced the support for this, but it does not work under x86 (as it stops 20_linux_xen from running). The 20_linux_xen is run under a shell and any exits from within it: (For example on x86): + /usr/bin/grub2-file --is-arm64-efi /boot/xen-4.9.0.gz [root@tst063 grub]# echo $? 1 will result in 20_linux_xen exiting without continuing and also causing grub2-mkconfig to stop processing. As in: [root@tst063 grub]# ./grub-mkconfig | tail Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.13.0-0.rc5.git1.1.fc27.x86_64 Found initrd image: /boot/initramfs-4.13.0-0.rc5.git1.1.fc27.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 Found initrd image: /boot/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img echo 'Loading Linux 0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 ...' linux /vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 root=/dev/mapper/fedora_tst063-root ro single echo 'Loading initial ramdisk ...' initrd /initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img } } ### END /usr/local/etc/grub.d/10_linux ### ### BEGIN /usr/local/etc/grub.d/20_linux_xen ### root@tst063 grub]# And no more. This patch wraps the invocation of grub-file to be a in subshell and to process the return value in a conditional. That fixes the issue. RH-BZ 1486002: grub2-mkconfig does not work if xen.gz is installed. CC: Fu Wei Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Daniel Kiper --- util/grub.d/20_linux_xen.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index c002fc9f9..083bcef5d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -206,13 +206,12 @@ while [ "x${xen_list}" != "x" ] ; do if [ "x$is_top_level" != xtrue ]; then echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {" fi - $grub_file --is-arm64-efi $current_xen - if [ $? -ne 0 ]; then - xen_loader="multiboot" - module_loader="module" - else + if ($grub_file --is-arm64-efi $current_xen); then xen_loader="xen_hypervisor" module_loader="xen_module" + else + xen_loader="multiboot" + module_loader="module" fi while [ "x$list" != "x" ] ; do linux=`version_find_latest $list` From b4d709b6ee789cdaf3fa7a80fd90c721a16f48c2 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Tue, 29 Aug 2017 16:40:53 -0400 Subject: [PATCH 0752/1167] Use grub-file to figure out whether multiboot2 should be used for Xen.gz The multiboot2 is much more preferable than multiboot. Especiall if booting under EFI where multiboot does not have the functionality to pass ImageHandler. Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Daniel Kiper --- util/grub.d/20_linux_xen.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 083bcef5d..0cb0f4e49 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -210,8 +210,13 @@ while [ "x${xen_list}" != "x" ] ; do xen_loader="xen_hypervisor" module_loader="xen_module" else - xen_loader="multiboot" - module_loader="module" + if ($grub_file --is-x86-multiboot2 $current_xen); then + xen_loader="multiboot2" + module_loader="module2" + else + xen_loader="multiboot" + module_loader="module" + fi fi while [ "x$list" != "x" ] ; do linux=`version_find_latest $list` From 0ba90a7f017889d32a47897d9107ef45cc50a049 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 31 Aug 2017 16:40:18 +0200 Subject: [PATCH 0753/1167] efi: Move grub_reboot() into kernel The reboot function calls machine_fini() and then reboots the system. Currently it lives in lib/ which means it gets compiled into the reboot module which lives on the heap. In a following patch, I want to free the heap on machine_fini() though, so we would free the memory that the code is running in. That obviously breaks with smarter UEFI implementations. So this patch moves it into the core. That way we ensure that all code running after machine_fini() in the UEFI case is running from memory that got allocated (and gets deallocated) by the UEFI core. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 4 ---- grub-core/kern/efi/efi.c | 9 +++++++++ grub-core/lib/efi/reboot.c | 33 --------------------------------- include/grub/misc.h | 3 ++- 4 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 grub-core/lib/efi/reboot.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d90ad6220..2c1d62cee 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -872,10 +872,6 @@ module = { name = reboot; i386 = lib/i386/reboot.c; i386 = lib/i386/reboot_trampoline.S; - ia64_efi = lib/efi/reboot.c; - x86_64_efi = lib/efi/reboot.c; - arm_efi = lib/efi/reboot.c; - arm64_efi = lib/efi/reboot.c; powerpc_ieee1275 = lib/ieee1275/reboot.c; sparc64_ieee1275 = lib/ieee1275/reboot.c; mips_arc = lib/mips/arc/reboot.c; diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index d467785fc..708581fcb 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -154,6 +154,15 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); } +void +grub_reboot (void) +{ + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); + efi_call_4 (grub_efi_system_table->runtime_services->reset_system, + GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); + for (;;) ; +} + void grub_exit (void) { diff --git a/grub-core/lib/efi/reboot.c b/grub-core/lib/efi/reboot.c deleted file mode 100644 index 7de8bcb5d..000000000 --- a/grub-core/lib/efi/reboot.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2011 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 . - */ - -#include -#include -#include -#include -#include -#include - -void -grub_reboot (void) -{ - grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); - efi_call_4 (grub_efi_system_table->runtime_services->reset_system, - GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); - for (;;) ; -} diff --git a/include/grub/misc.h b/include/grub/misc.h index 2a9f87cc2..372f009e8 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -396,7 +396,8 @@ grub_abs (int x) } /* Reboot the machine. */ -#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) +#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) || \ + defined (GRUB_MACHINE_EFI) void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn)); #else void grub_reboot (void) __attribute__ ((noreturn)); From 92bfc33db984eec22966a163eed7b6f2ab0266bf Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 31 Aug 2017 16:40:19 +0200 Subject: [PATCH 0754/1167] efi: Free malloc regions on exit When we exit grub, we don't free all the memory that we allocated earlier for our heap region. This can cause problems with setups where you try to descend the boot order using "exit" entries, such as PXE -> HD boot scenarios. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/kern/efi/init.c | 1 + grub-core/kern/efi/mm.c | 82 +++++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 1 + 3 files changed, 84 insertions(+) diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index 2c31847bf..3dfdf2d22 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -80,4 +80,5 @@ grub_efi_fini (void) { grub_efidisk_fini (); grub_console_fini (); + grub_efi_memory_fini (); } diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index ac2a4c556..c48e9b5c7 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -49,6 +49,70 @@ static grub_efi_uintn_t finish_desc_size; static grub_efi_uint32_t finish_desc_version; int grub_efi_is_finished = 0; +/* + * We need to roll back EFI allocations on exit. Remember allocations that + * we'll free on exit. + */ +struct efi_allocation; +struct efi_allocation { + grub_efi_physical_address_t address; + grub_efi_uint64_t pages; + struct efi_allocation *next; +}; +static struct efi_allocation *efi_allocated_memory; + +static void +grub_efi_store_alloc (grub_efi_physical_address_t address, + grub_efi_uintn_t pages) +{ + grub_efi_boot_services_t *b; + struct efi_allocation *alloc; + grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, + sizeof(*alloc), (void**)&alloc); + + if (status == GRUB_EFI_SUCCESS) + { + alloc->next = efi_allocated_memory; + alloc->address = address; + alloc->pages = pages; + efi_allocated_memory = alloc; + } + else + grub_printf ("Could not malloc memory to remember EFI allocation. " + "Exiting GRUB won't free all memory.\n"); +} + +static void +grub_efi_drop_alloc (grub_efi_physical_address_t address, + grub_efi_uintn_t pages) +{ + struct efi_allocation *ea, *eap; + grub_efi_boot_services_t *b; + + b = grub_efi_system_table->boot_services; + + for (eap = NULL, ea = efi_allocated_memory; ea; eap = ea, ea = ea->next) + { + if (ea->address != address || ea->pages != pages) + continue; + + /* Remove the current entry from the list. */ + if (eap) + eap->next = ea->next; + else + efi_allocated_memory = ea->next; + + /* Then free the memory backing it. */ + efi_call_1 (b->free_pool, ea); + + /* And leave, we're done. */ + break; + } +} + /* Allocate pages. Return the pointer to the first of allocated pages. */ void * grub_efi_allocate_pages_real (grub_efi_physical_address_t address, @@ -79,6 +143,8 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, return 0; } + grub_efi_store_alloc (address, pages); + return (void *) ((grub_addr_t) address); } @@ -108,6 +174,8 @@ grub_efi_free_pages (grub_efi_physical_address_t address, b = grub_efi_system_table->boot_services; efi_call_2 (b->free_pages, address, pages); + + grub_efi_drop_alloc (address, pages); } #if defined (__i386__) || defined (__x86_64__) @@ -422,6 +490,20 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, grub_fatal ("too little memory"); } +void +grub_efi_memory_fini (void) +{ + /* + * Free all stale allocations. grub_efi_free_pages() will remove + * the found entry from the list and it will always find the first + * list entry (efi_allocated_memory is the list start). Hence we + * remove all entries from the list until none is left altogether. + */ + while (efi_allocated_memory) + grub_efi_free_pages (efi_allocated_memory->address, + efi_allocated_memory->pages); +} + #if 0 /* Print the memory map. */ static void diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 3fa082816..c996913e5 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -55,6 +55,7 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, grub_efi_uintn_t *map_key, grub_efi_uintn_t *descriptor_size, grub_efi_uint32_t *descriptor_version); +void grub_efi_memory_fini (void); grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle); void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); From 446794de8da4329ea532cbee4ca877bcafd0e534 Mon Sep 17 00:00:00 2001 From: "David E. Box" Date: Fri, 15 Sep 2017 15:37:05 -0700 Subject: [PATCH 0755/1167] tsc: Change default tsc calibration method to pmtimer on EFI systems On efi systems, make pmtimer based tsc calibration the default over the pit. This prevents Grub from hanging on Intel SoC systems that power gate the pit. Signed-off-by: David E. Box Reviewed-by: Daniel Kiper --- grub-core/kern/i386/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index 2e85289d8..f266eb131 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -68,7 +68,7 @@ grub_tsc_init (void) #ifdef GRUB_MACHINE_XEN (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); #elif defined (GRUB_MACHINE_EFI) - (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); + (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); #elif defined (GRUB_MACHINE_COREBOOT) (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); #else From 3d8df86d825ff07a8eeb202329b8731fd1a4a24e Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 13 Nov 2017 08:27:28 -0800 Subject: [PATCH 0756/1167] ls: prevent double open Prevent a double open. This can cause problems with some ieee1275 devices, causing the system to hang. The double open can occur as follows: grub_ls_list_files (char *dirname, int longlist, int all, int human) dev = grub_device_open (device_name); dev remains open while: grub_normal_print_device_info (device_name); dev = grub_device_open (name); Signed-off-by: Eric Snowberg Signed-off-by: Daniel Kiper Reviewed-by: Daniel Kiper --- grub-core/commands/ls.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index 0eaf83652..c25161cc4 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -201,6 +201,15 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) if (grub_errno == GRUB_ERR_UNKNOWN_FS) grub_errno = GRUB_ERR_NONE; +#ifdef GRUB_MACHINE_IEEE1275 + /* + * Close device to prevent a double open in grub_normal_print_device_info(). + * Otherwise it may lead to hangs on some IEEE 1275 platforms. + */ + grub_device_close (dev); + dev = NULL; +#endif + grub_normal_print_device_info (device_name); } else if (fs) From 2a8856401774d86ec78481e2188a54bbf689f25e Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 27 Nov 2017 09:12:49 -0800 Subject: [PATCH 0757/1167] grub-install: Fix memory leak Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- util/grub-install.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-install.c b/util/grub-install.c index 75e3e5ba6..5e4cdfd2b 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1472,6 +1472,7 @@ main (int argc, char *argv[]) { grub_util_fprint_full_disk_name (load_cfg_f, g, dev); fprintf (load_cfg_f, " "); + free (g); } if (dev != grub_dev) grub_device_close (dev); From 2dc163bf692c18275de7b0d6716138c676e3bf92 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 28 Nov 2017 11:51:39 -0800 Subject: [PATCH 0758/1167] ieee1275: Fix segfault in grub-ofpathname Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- util/ieee1275/grub-ofpathname.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/ieee1275/grub-ofpathname.c b/util/ieee1275/grub-ofpathname.c index 8e5d766cb..300fbddad 100644 --- a/util/ieee1275/grub-ofpathname.c +++ b/util/ieee1275/grub-ofpathname.c @@ -46,7 +46,9 @@ int main(int argc, char **argv) } of_path = grub_util_devname_to_ofpath (argv[1]); - printf("%s\n", of_path); + + if (of_path) + printf ("%s\n", of_path); free (of_path); From 5033080eb6cb784a3d7f36b3d66b71f4603bf0aa Mon Sep 17 00:00:00 2001 From: Jordan Glover Date: Wed, 29 Nov 2017 08:35:37 -0500 Subject: [PATCH 0759/1167] grub-mkconfig: Fix detecting .sig files as system images grub-mkconfig detects detached RSA signatures for kernel images used for signature checking as valid images and adds them to grub.cfg as separate menu entries. This patch adds .sig extension to common blacklist. Signed-off-by: Jordan Glover Reviewed-by: Daniel Kiper --- util/grub-mkconfig_lib.in | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 60b31cadd..0f801cab3 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -188,6 +188,7 @@ grub_file_is_not_garbage () *.dpkg-*) return 1 ;; # debian dpkg *.rpmsave|*.rpmnew) return 1 ;; README*|*/README*) return 1 ;; # documentation + *.sig) return 1 ;; # signatures esac else return 1 From d34977cb662d9d3c74532dc175103758c47f552f Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Wed, 29 Nov 2017 17:08:12 +0000 Subject: [PATCH 0760/1167] arm64/xen: Add missing #address-cells and #size-cells properties The properties #address-cells and #size-cells are used to know the number of cells for ranges provided by "regs". If they don't exist, the value are resp. 2 and 1. Currently, when multiboot nodes are created it is assumed that #address-cells and #size-cells are exactly 2. However, they are never set by GRUB and will result to later failure when the device-tree is generated by GRUB or contain different values. To prevent this failure, create the both properties in the chosen nodes. Signed-off-by: Julien Grall Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/xen_boot.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index c95d6c5a8..6780b1f0c 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -115,6 +115,17 @@ prepare_xen_hypervisor_params (void *xen_boot_fdt) if (chosen_node < 1) return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); + /* + * The address and size are always written using 64-bits value. Set + * #address-cells and #size-cells accordingly. + */ + retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#address-cells", 2); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to set #address-cells"); + retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#size-cells", 2); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to set #size-cells"); + grub_dprintf ("xen_loader", "Xen Hypervisor cmdline : %s @ %p size:%d\n", xen_hypervisor->cmdline, xen_hypervisor->cmdline, From 52ef7b23f528ce844716661d586497a177e80d5b Mon Sep 17 00:00:00 2001 From: dann frazier Date: Thu, 18 Jan 2018 11:57:26 -0700 Subject: [PATCH 0761/1167] Keep the native terminal active when enabling gfxterm grub-mkconfig will set GRUB_TERMINAL_OUTPUT to "gfxterm" unless the user has overridden it. On EFI systems, this will stop output from going to the default "console" terminal. When the EFI fw console is configured to output to both serial and video, this will cause GRUB to only display on video - while continuing to accept input from both video and serial. Instead of switching from "console" to "gfxterm", let's output to both. Reviewed-by: Daniel Kiper --- util/grub.d/00_header.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 93a90233e..8d46fc973 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -221,7 +221,7 @@ case x${GRUB_TERMINAL_OUTPUT} in ;; x*) cat << EOF -terminal_output ${GRUB_TERMINAL_OUTPUT} +terminal_output --append ${GRUB_TERMINAL_OUTPUT} EOF ;; esac From 566a03a623ca5ec07c815683625aecc410dc3095 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Fri, 19 Jan 2018 14:13:29 +0100 Subject: [PATCH 0762/1167] ahci: Improve error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the error bits in the interrupt status register. According to the AHCI 1.2 spec, "Interrupt sources that are disabled (‘0’) are still reflected in the status registers.", so this should work even though grub uses polling This fixes the following problem on a Fujitsu E744 laptop: Sometimes there is a very long delay (up to several minutes) when booting from hard disk. It seems accessing the DVD drive (which has no disk inserted) sometimes fails with some errors, which leads to each access being stalled until the 20s timeout triggers. This seems to happen when grub is trying to read filesystem/partition data. The problem is that the command_issue bit that is checked in the loop is only reset if the "HBA receives a FIS which clears the BSY, DRQ, and ERR bits for the command", but the ERR bit is never cleared. Therefore command_issue is never reset and grub waits for the timeout. The relevant bit in our case is the Task File Error Status (TFES), which is equivalent to the ERR bit 0 in tfd. But this patch also checks the other error bits except for the "Interface non-fatal error status" bit. Signed-off-by: Stefan Fritsch Reviewed-by: Daniel Kiper --- grub-core/disk/ahci.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 494a1b773..f2f606423 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -82,6 +82,20 @@ enum grub_ahci_hba_port_command GRUB_AHCI_HBA_PORT_CMD_FR = 0x4000, }; +enum grub_ahci_hba_port_int_status + { + GRUB_AHCI_HBA_PORT_IS_IFS = (1UL << 27), + GRUB_AHCI_HBA_PORT_IS_HBDS = (1UL << 28), + GRUB_AHCI_HBA_PORT_IS_HBFS = (1UL << 29), + GRUB_AHCI_HBA_PORT_IS_TFES = (1UL << 30), + }; + +#define GRUB_AHCI_HBA_PORT_IS_FATAL_MASK ( \ + GRUB_AHCI_HBA_PORT_IS_IFS | \ + GRUB_AHCI_HBA_PORT_IS_HBDS | \ + GRUB_AHCI_HBA_PORT_IS_HBFS | \ + GRUB_AHCI_HBA_PORT_IS_TFES) + struct grub_ahci_hba { grub_uint32_t cap; @@ -1026,7 +1040,8 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, endtime = grub_get_time_ms () + (spinup ? 20000 : 20000); while ((dev->hba->ports[dev->port].command_issue & 1)) - if (grub_get_time_ms () > endtime) + if (grub_get_time_ms () > endtime || + (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK)) { grub_dprintf ("ahci", "AHCI status <%x %x %x %x>\n", dev->hba->ports[dev->port].command_issue, @@ -1034,7 +1049,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, dev->hba->ports[dev->port].intstatus, dev->hba->ports[dev->port].task_file_data); dev->hba->ports[dev->port].command_issue = 0; - err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out"); + if (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK) + err = grub_error (GRUB_ERR_IO, "AHCI transfer error"); + else + err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out"); if (!reset) grub_ahci_reset_port (dev, 1); break; From 69e0a67bfb419a8d6c905fb23330a8afc2435de6 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 11 May 2017 18:25:24 -0700 Subject: [PATCH 0763/1167] sparc64: Add blocklist GPT support for SPARC Add block-list GPT support for SPARC. The OBP "load" and "boot" methods are partition aware and neither command can see the partition table. Also neither command can address the entire physical disk. When the install happens, grub generates the block-list entries based on the beginning of the physical disk, not the beginning of the partition. This patch fixes the block-list entries so they match what OBP expects during boot for a GPT disk. T5 and above now supports GPT as well as VTOC. This patch has been tested on T5-2 and newer SPARC systems. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- util/setup.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/util/setup.c b/util/setup.c index 8aa5a39a7..80363075d 100644 --- a/util/setup.c +++ b/util/setup.c @@ -137,6 +137,9 @@ struct blocklists struct grub_boot_blocklist *first_block, *block; #ifdef GRUB_SETUP_BIOS grub_uint16_t current_segment; +#endif +#ifdef GRUB_SETUP_SPARC64 + grub_uint64_t gpt_offset; #endif grub_uint16_t last_length; grub_disk_addr_t first_sector; @@ -151,6 +154,10 @@ save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length, struct grub_boot_blocklist *prev = bl->block + 1; grub_uint64_t seclen; +#ifdef GRUB_SETUP_SPARC64 + sector -= bl->gpt_offset; +#endif + grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>", (unsigned long long) sector, offset, length); @@ -662,6 +669,16 @@ unable_to_embed: bl.block = bl.first_block; +#ifdef GRUB_SETUP_SPARC64 + { + grub_partition_t container = root_dev->disk->partition; + bl.gpt_offset = 0; + + if (grub_strstr (container->partmap->name, "gpt")) + bl.gpt_offset = grub_partition_get_start (container); + } +#endif + grub_install_get_blocklist (root_dev, core_path, core_img, core_size, save_blocklists, &bl); @@ -721,15 +738,18 @@ unable_to_embed: { char *buf, *ptr = core_img; size_t len = core_size; - grub_uint64_t blk; + grub_uint64_t blk, offset = 0; grub_partition_t container = core_dev->disk->partition; grub_err_t err; core_dev->disk->partition = 0; +#ifdef GRUB_SETUP_SPARC64 + offset = bl.gpt_offset; +#endif buf = xmalloc (core_size); blk = bl.first_sector; - err = grub_disk_read (core_dev->disk, blk, 0, GRUB_DISK_SECTOR_SIZE, buf); + err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf); if (err) grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name, grub_errmsg); @@ -748,7 +768,7 @@ unable_to_embed: if (cur > len) cur = len; - err = grub_disk_read (core_dev->disk, blk, 0, cur, buf); + err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf); if (err) grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name, grub_errmsg); From d85c76b501edda038b68bc23eee946e6cc600513 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 30 Jan 2018 20:49:48 -0800 Subject: [PATCH 0764/1167] sparc64: fix OF path names for sun4v systems Fix the Open Firmware (OF) path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA. It looks that this functionality will not work if you try to cross-install SPARC GRUB2 binary using e.g. x86 grub-install. By default it should work. However, we will also have other issues here, like lack of access to OF firmware/paths, which make such configs unusable anyway. So, let's leave this patch as is for time being. If somebody cares then he/she should fix the issue(s) at some point. Signed-off-by: Eric Snowberg Signed-off-by: Daniel Kiper Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 147 ++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 3 deletions(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index dce4e59d0..8d7d6837f 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -38,6 +38,46 @@ #include #include +#ifdef __sparc__ +typedef enum + { + GRUB_OFPATH_SPARC_WWN_ADDR = 1, + GRUB_OFPATH_SPARC_TGT_LUN, + } ofpath_sparc_addressing; + +struct ofpath_sparc_hba +{ + grub_uint32_t device_id; + ofpath_sparc_addressing addressing; +}; + +static struct ofpath_sparc_hba sparc_lsi_hba[] = { + /* Rhea, Jasper 320, LSI53C1020/1030. */ + {0x30, GRUB_OFPATH_SPARC_TGT_LUN}, + /* SAS-1068E. */ + {0x50, GRUB_OFPATH_SPARC_TGT_LUN}, + /* SAS-1064E. */ + {0x56, GRUB_OFPATH_SPARC_TGT_LUN}, + /* Pandora SAS-1068E. */ + {0x58, GRUB_OFPATH_SPARC_TGT_LUN}, + /* Aspen, Invader, LSI SAS-3108. */ + {0x5d, GRUB_OFPATH_SPARC_TGT_LUN}, + /* Niwot, SAS 2108. */ + {0x79, GRUB_OFPATH_SPARC_TGT_LUN}, + /* Erie, Falcon, LSI SAS 2008. */ + {0x72, GRUB_OFPATH_SPARC_WWN_ADDR}, + /* LSI WarpDrive 6203. */ + {0x7e, GRUB_OFPATH_SPARC_WWN_ADDR}, + /* LSI SAS 2308. */ + {0x87, GRUB_OFPATH_SPARC_WWN_ADDR}, + /* LSI SAS 3008. */ + {0x97, GRUB_OFPATH_SPARC_WWN_ADDR}, + {0, 0} +}; + +static const int LSI_VENDOR_ID = 0x1000; +#endif + #ifdef OFPATH_STANDALONE #define xmalloc malloc void @@ -338,6 +378,64 @@ vendor_is_ATA(const char *path) return (memcmp(bufcont, "ATA", 3) == 0); } +#ifdef __sparc__ +static void +check_hba_identifiers (const char *sysfs_path, int *vendor, int *device_id) +{ + char *ed = strstr (sysfs_path, "host"); + size_t path_size; + char *p, *path; + char buf[8]; + int fd; + + if (!ed) + return; + + p = xstrdup (sysfs_path); + ed = strstr (p, "host"); + + *ed = '\0'; + + path_size = (strlen (p) + sizeof ("vendor")); + path = xmalloc (path_size); + + if (!path) + goto out; + + snprintf (path, path_size, "%svendor", p); + fd = open (path, O_RDONLY); + + if (fd < 0) + goto out; + + memset (buf, 0, sizeof (buf)); + + if (read (fd, buf, sizeof (buf) - 1) < 0) + goto out; + + close (fd); + sscanf (buf, "%x", vendor); + + snprintf (path, path_size, "%sdevice", p); + fd = open (path, O_RDONLY); + + if (fd < 0) + goto out; + + memset (buf, 0, sizeof (buf)); + + if (read (fd, buf, sizeof (buf) - 1) < 0) + goto out; + + close (fd); + sscanf (buf, "%x", device_id); + + out: + free (path); + free (p); +} +#endif + static void check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) { @@ -399,7 +497,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev { const char *p, *digit_string, *disk_name; int host, bus, tgt, lun; - unsigned long int sas_address; + unsigned long int sas_address = 0; char *sysfs_path, disk[MAX_DISK_CAT - sizeof ("/fp@0,0")]; char *of_path; @@ -416,9 +514,8 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev } of_path = find_obppath(sysfs_path); - free (sysfs_path); if (!of_path) - return NULL; + goto out; if (strstr (of_path, "qlc")) strcat (of_path, "/fp@0,0"); @@ -447,6 +544,46 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev } else { +#ifdef __sparc__ + ofpath_sparc_addressing addressing = GRUB_OFPATH_SPARC_TGT_LUN; + int vendor = 0, device_id = 0; + char *optr = disk; + + check_hba_identifiers (sysfs_path, &vendor, &device_id); + + if (vendor == LSI_VENDOR_ID) + { + struct ofpath_sparc_hba *lsi_hba; + + /* + * Over time different OF addressing schemes have been supported. + * There is no generic addressing scheme that works across + * every HBA. + */ + for (lsi_hba = sparc_lsi_hba; lsi_hba->device_id; lsi_hba++) + if (lsi_hba->device_id == device_id) + { + addressing = lsi_hba->addressing; + break; + } + } + + if (addressing == GRUB_OFPATH_SPARC_WWN_ADDR) + optr += snprintf (disk, sizeof (disk), "/%s@w%lx,%x", disk_name, + sas_address, lun); + else + optr += snprintf (disk, sizeof (disk), "/%s@%x,%x", disk_name, tgt, + lun); + + if (*digit_string != '\0') + { + int part; + + sscanf (digit_string, "%d", &part); + snprintf (optr, sizeof (disk) - (optr - disk - 1), ":%c", 'a' + + (part - 1)); + } +#else if (lun == 0) { int sas_id = 0; @@ -494,8 +631,12 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev } free (lunstr); } +#endif } strcat(of_path, disk); + + out: + free (sysfs_path); return of_path; } From 6400613ad0b463abc93362086a491cd2a5e99b0d Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Wed, 31 Jan 2018 21:49:36 +0000 Subject: [PATCH 0765/1167] Make grub-install check for errors from efibootmgr Code is currently ignoring errors from efibootmgr, giving users clearly bogus output like: Setting up grub-efi-amd64 (2.02~beta3-4) ... Installing for x86_64-efi platform. Could not delete variable: No space left on device Could not prepare Boot variable: No space left on device Installation finished. No error reported. and then potentially unbootable systems. If efibootmgr fails, grub-install should know that and report it! We've been using similar patch in Debian now for some time, with no ill effects. Signed-off-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Daniel Kiper --- grub-core/osdep/unix/platform.c | 24 +++++++++++++++--------- include/grub/util/install.h | 2 +- util/grub-install.c | 18 +++++++++++++----- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c index a3fcfcaca..ca448bc11 100644 --- a/grub-core/osdep/unix/platform.c +++ b/grub-core/osdep/unix/platform.c @@ -78,19 +78,20 @@ get_ofpathname (const char *dev) dev); } -static void +static int grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) { int fd; pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd); char *line = NULL; size_t len = 0; + int rc; if (!pid) { grub_util_warn (_("Unable to open stream from %s: %s"), "efibootmgr", strerror (errno)); - return; + return errno; } FILE *fp = fdopen (fd, "r"); @@ -98,7 +99,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) { grub_util_warn (_("Unable to open stream from %s: %s"), "efibootmgr", strerror (errno)); - return; + return errno; } line = xmalloc (80); @@ -119,23 +120,25 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) bootnum = line + sizeof ("Boot") - 1; bootnum[4] = '\0'; if (!verbosity) - grub_util_exec ((const char * []){ "efibootmgr", "-q", + rc = grub_util_exec ((const char * []){ "efibootmgr", "-q", "-b", bootnum, "-B", NULL }); else - grub_util_exec ((const char * []){ "efibootmgr", + rc = grub_util_exec ((const char * []){ "efibootmgr", "-b", bootnum, "-B", NULL }); } free (line); + return rc; } -void +int grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor) { const char * efidir_disk; int efidir_part; + int ret; efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk); efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1; @@ -151,23 +154,26 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL }); #endif /* Delete old entries from the same distributor. */ - grub_install_remove_efi_entries_by_distributor (efi_distributor); + ret = grub_install_remove_efi_entries_by_distributor (efi_distributor); + if (ret) + return ret; char *efidir_part_str = xasprintf ("%d", efidir_part); if (!verbosity) - grub_util_exec ((const char * []){ "efibootmgr", "-q", + ret = grub_util_exec ((const char * []){ "efibootmgr", "-q", "-c", "-d", efidir_disk, "-p", efidir_part_str, "-w", "-L", efi_distributor, "-l", efifile_path, NULL }); else - grub_util_exec ((const char * []){ "efibootmgr", + ret = grub_util_exec ((const char * []){ "efibootmgr", "-c", "-d", efidir_disk, "-p", efidir_part_str, "-w", "-L", efi_distributor, "-l", efifile_path, NULL }); free (efidir_part_str); + return ret; } void diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 5910b0c09..0dba8b67f 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -210,7 +210,7 @@ grub_install_create_envblk_file (const char *name); const char * grub_install_get_default_x86_platform (void); -void +int grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor); diff --git a/util/grub-install.c b/util/grub-install.c index 5e4cdfd2b..690f180c5 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1848,9 +1848,13 @@ main (int argc, char *argv[]) if (!removable && update_nvram) { /* Try to make this image bootable using the EFI Boot Manager, if available. */ - grub_install_register_efi (efidir_grub_dev, - "\\System\\Library\\CoreServices", - efi_distributor); + int ret; + ret = grub_install_register_efi (efidir_grub_dev, + "\\System\\Library\\CoreServices", + efi_distributor); + if (ret) + grub_util_error (_("efibootmgr failed to register the boot entry: %s"), + strerror (ret)); } grub_device_close (ins_dev); @@ -1871,6 +1875,7 @@ main (int argc, char *argv[]) { char * efifile_path; char * part; + int ret; /* Try to make this image bootable using the EFI Boot Manager, if available. */ if (!efi_distributor || efi_distributor[0] == '\0') @@ -1887,8 +1892,11 @@ main (int argc, char *argv[]) efidir_grub_dev->disk->name, (part ? ",": ""), (part ? : "")); grub_free (part); - grub_install_register_efi (efidir_grub_dev, - efifile_path, efi_distributor); + ret = grub_install_register_efi (efidir_grub_dev, + efifile_path, efi_distributor); + if (ret) + grub_util_error (_("efibootmgr failed to register the boot entry: %s"), + strerror (ret)); } break; From 842c390469e2c2e10b5aa36700324cd3bde25875 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 17 Feb 2018 06:47:28 -0800 Subject: [PATCH 0766/1167] x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32 Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for 32-bit PC-relative branches. Grub2 should treat R_X86_64_PLT32 as R_X86_64_PC32. Signed-off-by: H.J. Lu Reviewed-by: Daniel Kiper --- grub-core/efiemu/i386/loadcore64.c | 1 + grub-core/kern/x86_64/dl.c | 1 + util/grub-mkimagexx.c | 1 + util/grub-module-verifier.c | 1 + 4 files changed, 4 insertions(+) diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c index e49d0b6ff..18facf47f 100644 --- a/grub-core/efiemu/i386/loadcore64.c +++ b/grub-core/efiemu/i386/loadcore64.c @@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs, break; case R_X86_64_PC32: + case R_X86_64_PLT32: err = grub_efiemu_write_value (addr, *addr32 + rel->r_addend + sym.off diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c index 440690673..3a73e6e6c 100644 --- a/grub-core/kern/x86_64/dl.c +++ b/grub-core/kern/x86_64/dl.c @@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, break; case R_X86_64_PC32: + case R_X86_64_PLT32: { grub_int64_t value; value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value - diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a2bb05439..39d7efb91 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -841,6 +841,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, break; case R_X86_64_PC32: + case R_X86_64_PLT32: { grub_uint32_t *t32 = (grub_uint32_t *) target; *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 9179285a5..a79271f66 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = { -1 }, (int[]){ R_X86_64_PC32, + R_X86_64_PLT32, -1 } }, From ae2a2745185c08d194775f28588f58ac90ae4351 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 23 Feb 2018 22:32:55 +0100 Subject: [PATCH 0767/1167] chainloader: Fix wrong break condition (must be AND not, OR) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The definition of bpb's num_total_sectors_16 and num_total_sectors_32 is that either the 16-bit field is non-zero and is used (in which case eg mkfs.fat sets the 32-bit field to zero), or it is zero and the 32-bit field is used. Therefore, a BPB is invalid only if *both* fields are zero; having one field as zero and the other as non-zero is the case to be expected. (Indeed, according to Microsoft's specification one of the fields *must* be zero, and the other non-zero.) This affects all users of grub_chainloader_patch_bpb which are in chainloader.c, freedos.c, and ntldr.c Some descriptions of the semantics of these two fields: https://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html The old 2-byte fields "total number of sectors" and "number of sectors per FAT" are now zero; this information is now found in the new 4-byte fields. (Here given in the FAT32 EBPB section but the total sectors 16/32 bit fields semantic is true of FAT12 and FAT16 too.) https://wiki.osdev.org/FAT#BPB_.28BIOS_Parameter_Block.29 19 | 2 | The total sectors in the logical volume. If this value is 0, it means there are more than 65535 sectors in the volume, and the actual count is stored in "Large Sectors (bytes 32-35). 32 | 4 | Large amount of sector on media. This field is set if there are more than 65535 sectors in the volume. (Doesn't specify what the "large" field is set to when unused, but as mentioned mkfs.fat sets it to zero then.) https://technet.microsoft.com/en-us/library/cc976796.aspx 0x13 | WORD | 0x0000 | Small Sectors . The number of sectors on the volume represented in 16 bits (< 65,536). For volumes larger than 65,536 sectors, this field has a value of zero and the Large Sectors field is used instead. 0x20 | DWORD | 0x01F03E00 | Large Sectors . If the value of the Small Sectors field is zero, this field contains the total number of sectors in the FAT16 volume. If the value of the Small Sectors field is not zero, the value of this field is zero. https://staff.washington.edu/dittrich/misc/fatgen103.pdf page 10 BPB_TotSec16 | 19 | 2 | This field is the old 16-bit total count of sectors on the volume. This count includes the count of all sectors in all four regions of the volume. This field can be 0; if it is 0, then BPB_TotSec32 must be non-zero. For FAT32 volumes, this field must be 0. For FAT12 and FAT16 volumes, this field contains the sector count, and BPB_TotSec32 is 0 if the total sector count “fits†(is less than 0x10000). BPB_TotSec32 | 32 | 4 | This field is the new 32-bit total count of sectors on the volume. This count includes the count of all sectors in all four regions of the volume. This field can be 0; if it is 0, then BPB_TotSec16 must be non-zero. For FAT32 volumes, this field must be non-zero. For FAT12/FAT16 volumes, this field contains the sector count if BPB_TotSec16 is 0 (count is greater than or equal to 0x10000). (This specifies that an unused BPB_TotSec32 field is set to zero.) By the way fix offsets in include/grub/fat.h. Tested with lDebug booted in qemu via grub2's FreeDOS direct loading support, refer to https://bitbucket.org/ecm/ldosboot + https://bitbucket.org/ecm/ldebug Signed-off-by: C. Masloch Reviewed-by: Daniel Kiper --- grub-core/loader/i386/pc/chainloader.c | 2 +- include/grub/fat.h | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index c79c4fe0f..18220b7aa 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -117,7 +117,7 @@ grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) if (bpb->num_reserved_sectors == 0) break; - if (bpb->num_total_sectors_16 == 0 || bpb->num_total_sectors_32 == 0) + if (bpb->num_total_sectors_16 == 0 && bpb->num_total_sectors_32 == 0) break; if (bpb->num_fats == 0) diff --git a/include/grub/fat.h b/include/grub/fat.h index 4a5aab793..8d7e4a1e5 100644 --- a/include/grub/fat.h +++ b/include/grub/fat.h @@ -28,20 +28,15 @@ struct grub_fat_bpb grub_uint16_t bytes_per_sector; grub_uint8_t sectors_per_cluster; grub_uint16_t num_reserved_sectors; - grub_uint8_t num_fats; - /* 0x10 */ + grub_uint8_t num_fats; /* 0x10 */ grub_uint16_t num_root_entries; grub_uint16_t num_total_sectors_16; - grub_uint8_t media; - /*0 x15 */ + grub_uint8_t media; /* 0x15 */ grub_uint16_t sectors_per_fat_16; - grub_uint16_t sectors_per_track; - /*0 x19 */ - grub_uint16_t num_heads; - /*0 x1b */ - grub_uint32_t num_hidden_sectors; - /* 0x1f */ - grub_uint32_t num_total_sectors_32; + grub_uint16_t sectors_per_track; /* 0x18 */ + grub_uint16_t num_heads; /* 0x1A */ + grub_uint32_t num_hidden_sectors; /* 0x1C */ + grub_uint32_t num_total_sectors_32; /* 0x20 */ union { struct From 2391d579094cfab65a0fd89a3c617cb3a33fb715 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 20 Feb 2018 09:57:14 -0800 Subject: [PATCH 0768/1167] ieee1275: add nvme support within ofpath Add NVMe support within ofpath. The Open Firmware text representation for a NVMe device contains the Namespace ID. An invalid namespace ID is one whose value is zero or whose value is greater than the value reported by the Number of Namespaces (NN) field in the Identify Controller data structure. At the moment only a single Namespace is supported, therefore the value is currently hard coded to one. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 8d7d6837f..4308fceda 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -350,6 +350,50 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi return ret; } +static char * +of_path_of_nvme(const char *sys_devname __attribute__((unused)), + const char *device, + const char *devnode __attribute__((unused)), + const char *devicenode) +{ + char *sysfs_path, *of_path, disk[MAX_DISK_CAT]; + const char *digit_string, *part_end; + + digit_string = trailing_digits (device); + part_end = devicenode + strlen (devicenode) - 1; + + if ((digit_string != '\0') && (*part_end == 'p')) + { + /* We have a partition number, strip it off. */ + int part; + char *nvmedev, *end; + + nvmedev = strdup (devicenode); + + if (!nvmedev) + return NULL; + + end = nvmedev + strlen (nvmedev) - 1; + /* Remove the p. */ + *end = '\0'; + sscanf (digit_string, "%d", &part); + snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1)); + sysfs_path = block_device_get_sysfs_path_and_link (nvmedev); + free (nvmedev); + } + else + { + /* We do not have the parition. */ + snprintf (disk, sizeof (disk), "/disk@1"); + sysfs_path = block_device_get_sysfs_path_and_link (device); + } + + of_path = find_obppath (sysfs_path); + free (sysfs_path); + strcat (of_path, disk); + return of_path; +} + static int vendor_is_ATA(const char *path) { @@ -681,6 +725,9 @@ grub_util_devname_to_ofpath (const char *sys_devname) /* All the models I've seen have a devalias "floppy". New models have no floppy at all. */ ofpath = xstrdup ("floppy"); + else if (device[0] == 'n' && device[1] == 'v' && device[2] == 'm' + && device[3] == 'e') + ofpath = of_path_of_nvme (name_buf, device, devnode, devicenode); else { grub_util_warn (_("unknown device type %s"), device); From e5ba6b26181b8e3ffb09232a935a60e3b733bfac Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 11 Feb 2018 00:18:12 +0000 Subject: [PATCH 0769/1167] libgcrypt: Import replacement CRC operations The CRC implementation imported from libgcrypt 1.5.3 is arguably non-free, due to being encumbered by the restrictive Internet Society licence on RFCs (see e.g. https://wiki.debian.org/NonFreeIETFDocuments). Fortunately, libgcrypt has since replaced it with a version that is both reportedly better-optimised and doesn't suffer from this encumbrance. The ideal solution would be to update to a new version of libgcrypt, and I spent some time trying to do that. However, util/import_gcry.py requires complex modifications to cope with the new version, and I stalled part-way through; furthermore, GRUB's libgcrypt tree already contains some backports of upstream changes. Rather than allowing the perfect to be the enemy of the good, I think it's best to backport this single change to at least sort out the licensing situation. Doing so won't make things any harder for a future wholesale upgrade. This commit is mostly a straightforward backport of https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=06e122baa3321483a47bbf82fd2a4540becfa0c9, but I also imported bufhelp.h from libgcrypt 1.7.0 (newer versions required further changes elsewhere). I've tested that "hashsum -h crc32" still produces correct output for a variety of files on both i386-pc and x86_64-emu targets. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/lib/libgcrypt/cipher/bufhelp.h | 432 ++++++++++++ grub-core/lib/libgcrypt/cipher/crc.c | 821 ++++++++++++++++++----- 2 files changed, 1091 insertions(+), 162 deletions(-) create mode 100644 grub-core/lib/libgcrypt/cipher/bufhelp.h diff --git a/grub-core/lib/libgcrypt/cipher/bufhelp.h b/grub-core/lib/libgcrypt/cipher/bufhelp.h new file mode 100644 index 000000000..df3559472 --- /dev/null +++ b/grub-core/lib/libgcrypt/cipher/bufhelp.h @@ -0,0 +1,432 @@ +/* bufhelp.h - Some buffer manipulation helpers + * Copyright (C) 2012 Jussi Kivilinna + * + * This file is part of Libgcrypt. + * + * Libgcrypt is free software; you can redistribute it and/or modify + * it 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. + * + * Libgcrypt 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + */ +#ifndef GCRYPT_BUFHELP_H +#define GCRYPT_BUFHELP_H + + +#include "bithelp.h" + + +#undef BUFHELP_FAST_UNALIGNED_ACCESS +#if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \ + defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \ + (defined(__i386__) || defined(__x86_64__) || \ + (defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \ + defined(__aarch64__)) +/* These architectures are able of unaligned memory accesses and can + handle those fast. + */ +# define BUFHELP_FAST_UNALIGNED_ACCESS 1 +#endif + + +#ifdef BUFHELP_FAST_UNALIGNED_ACCESS +/* Define type with one-byte alignment on architectures with fast unaligned + memory accesses. + */ +typedef struct bufhelp_int_s +{ + uintptr_t a; +} __attribute__((packed, aligned(1))) bufhelp_int_t; +#else +/* Define type with default alignment for other architectures (unaligned + accessed handled in per byte loops). + */ +typedef struct bufhelp_int_s +{ + uintptr_t a; +} bufhelp_int_t; +#endif + + +/* Optimized function for small buffer copying */ +static inline void +buf_cpy(void *_dst, const void *_src, size_t len) +{ +#if __GNUC__ >= 4 && (defined(__x86_64__) || defined(__i386__)) + /* For AMD64 and i386, memcpy is faster. */ + memcpy(_dst, _src, len); +#else + byte *dst = _dst; + const byte *src = _src; + bufhelp_int_t *ldst; + const bufhelp_int_t *lsrc; +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + const unsigned int longmask = sizeof(bufhelp_int_t) - 1; + + /* Skip fast processing if buffers are unaligned. */ + if (((uintptr_t)dst | (uintptr_t)src) & longmask) + goto do_bytes; +#endif + + ldst = (bufhelp_int_t *)(void *)dst; + lsrc = (const bufhelp_int_t *)(const void *)src; + + for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) + (ldst++)->a = (lsrc++)->a; + + dst = (byte *)ldst; + src = (const byte *)lsrc; + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS +do_bytes: +#endif + /* Handle tail. */ + for (; len; len--) + *dst++ = *src++; +#endif /*__GNUC__ >= 4 && (__x86_64__ || __i386__)*/ +} + + +/* Optimized function for buffer xoring */ +static inline void +buf_xor(void *_dst, const void *_src1, const void *_src2, size_t len) +{ + byte *dst = _dst; + const byte *src1 = _src1; + const byte *src2 = _src2; + bufhelp_int_t *ldst; + const bufhelp_int_t *lsrc1, *lsrc2; +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + const unsigned int longmask = sizeof(bufhelp_int_t) - 1; + + /* Skip fast processing if buffers are unaligned. */ + if (((uintptr_t)dst | (uintptr_t)src1 | (uintptr_t)src2) & longmask) + goto do_bytes; +#endif + + ldst = (bufhelp_int_t *)(void *)dst; + lsrc1 = (const bufhelp_int_t *)(const void *)src1; + lsrc2 = (const bufhelp_int_t *)(const void *)src2; + + for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) + (ldst++)->a = (lsrc1++)->a ^ (lsrc2++)->a; + + dst = (byte *)ldst; + src1 = (const byte *)lsrc1; + src2 = (const byte *)lsrc2; + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS +do_bytes: +#endif + /* Handle tail. */ + for (; len; len--) + *dst++ = *src1++ ^ *src2++; +} + + +/* Optimized function for in-place buffer xoring. */ +static inline void +buf_xor_1(void *_dst, const void *_src, size_t len) +{ + byte *dst = _dst; + const byte *src = _src; + bufhelp_int_t *ldst; + const bufhelp_int_t *lsrc; +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + const unsigned int longmask = sizeof(bufhelp_int_t) - 1; + + /* Skip fast processing if buffers are unaligned. */ + if (((uintptr_t)dst | (uintptr_t)src) & longmask) + goto do_bytes; +#endif + + ldst = (bufhelp_int_t *)(void *)dst; + lsrc = (const bufhelp_int_t *)(const void *)src; + + for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) + (ldst++)->a ^= (lsrc++)->a; + + dst = (byte *)ldst; + src = (const byte *)lsrc; + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS +do_bytes: +#endif + /* Handle tail. */ + for (; len; len--) + *dst++ ^= *src++; +} + + +/* Optimized function for buffer xoring with two destination buffers. Used + mainly by CFB mode encryption. */ +static inline void +buf_xor_2dst(void *_dst1, void *_dst2, const void *_src, size_t len) +{ + byte *dst1 = _dst1; + byte *dst2 = _dst2; + const byte *src = _src; + bufhelp_int_t *ldst1, *ldst2; + const bufhelp_int_t *lsrc; +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + const unsigned int longmask = sizeof(bufhelp_int_t) - 1; + + /* Skip fast processing if buffers are unaligned. */ + if (((uintptr_t)src | (uintptr_t)dst1 | (uintptr_t)dst2) & longmask) + goto do_bytes; +#endif + + ldst1 = (bufhelp_int_t *)(void *)dst1; + ldst2 = (bufhelp_int_t *)(void *)dst2; + lsrc = (const bufhelp_int_t *)(const void *)src; + + for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) + (ldst1++)->a = ((ldst2++)->a ^= (lsrc++)->a); + + dst1 = (byte *)ldst1; + dst2 = (byte *)ldst2; + src = (const byte *)lsrc; + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS +do_bytes: +#endif + /* Handle tail. */ + for (; len; len--) + *dst1++ = (*dst2++ ^= *src++); +} + + +/* Optimized function for combined buffer xoring and copying. Used by mainly + CBC mode decryption. */ +static inline void +buf_xor_n_copy_2(void *_dst_xor, const void *_src_xor, void *_srcdst_cpy, + const void *_src_cpy, size_t len) +{ + byte *dst_xor = _dst_xor; + byte *srcdst_cpy = _srcdst_cpy; + const byte *src_xor = _src_xor; + const byte *src_cpy = _src_cpy; + byte temp; + bufhelp_int_t *ldst_xor, *lsrcdst_cpy; + const bufhelp_int_t *lsrc_cpy, *lsrc_xor; + uintptr_t ltemp; +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + const unsigned int longmask = sizeof(bufhelp_int_t) - 1; + + /* Skip fast processing if buffers are unaligned. */ + if (((uintptr_t)src_cpy | (uintptr_t)src_xor | (uintptr_t)dst_xor | + (uintptr_t)srcdst_cpy) & longmask) + goto do_bytes; +#endif + + ldst_xor = (bufhelp_int_t *)(void *)dst_xor; + lsrc_xor = (const bufhelp_int_t *)(void *)src_xor; + lsrcdst_cpy = (bufhelp_int_t *)(void *)srcdst_cpy; + lsrc_cpy = (const bufhelp_int_t *)(const void *)src_cpy; + + for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) + { + ltemp = (lsrc_cpy++)->a; + (ldst_xor++)->a = (lsrcdst_cpy)->a ^ (lsrc_xor++)->a; + (lsrcdst_cpy++)->a = ltemp; + } + + dst_xor = (byte *)ldst_xor; + src_xor = (const byte *)lsrc_xor; + srcdst_cpy = (byte *)lsrcdst_cpy; + src_cpy = (const byte *)lsrc_cpy; + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS +do_bytes: +#endif + /* Handle tail. */ + for (; len; len--) + { + temp = *src_cpy++; + *dst_xor++ = *srcdst_cpy ^ *src_xor++; + *srcdst_cpy++ = temp; + } +} + + +/* Optimized function for combined buffer xoring and copying. Used by mainly + CFB mode decryption. */ +static inline void +buf_xor_n_copy(void *_dst_xor, void *_srcdst_cpy, const void *_src, size_t len) +{ + buf_xor_n_copy_2(_dst_xor, _src, _srcdst_cpy, _src, len); +} + + +/* Constant-time compare of two buffers. Returns 1 if buffers are equal, + and 0 if buffers differ. */ +static inline int +buf_eq_const(const void *_a, const void *_b, size_t len) +{ + const byte *a = _a; + const byte *b = _b; + size_t diff, i; + + /* Constant-time compare. */ + for (i = 0, diff = 0; i < len; i++) + diff -= !!(a[i] - b[i]); + + return !diff; +} + + +#ifndef BUFHELP_FAST_UNALIGNED_ACCESS + +/* Functions for loading and storing unaligned u32 values of different + endianness. */ +static inline u32 buf_get_be32(const void *_buf) +{ + const byte *in = _buf; + return ((u32)in[0] << 24) | ((u32)in[1] << 16) | \ + ((u32)in[2] << 8) | (u32)in[3]; +} + +static inline u32 buf_get_le32(const void *_buf) +{ + const byte *in = _buf; + return ((u32)in[3] << 24) | ((u32)in[2] << 16) | \ + ((u32)in[1] << 8) | (u32)in[0]; +} + +static inline void buf_put_be32(void *_buf, u32 val) +{ + byte *out = _buf; + out[0] = val >> 24; + out[1] = val >> 16; + out[2] = val >> 8; + out[3] = val; +} + +static inline void buf_put_le32(void *_buf, u32 val) +{ + byte *out = _buf; + out[3] = val >> 24; + out[2] = val >> 16; + out[1] = val >> 8; + out[0] = val; +} + + +/* Functions for loading and storing unaligned u64 values of different + endianness. */ +static inline u64 buf_get_be64(const void *_buf) +{ + const byte *in = _buf; + return ((u64)in[0] << 56) | ((u64)in[1] << 48) | \ + ((u64)in[2] << 40) | ((u64)in[3] << 32) | \ + ((u64)in[4] << 24) | ((u64)in[5] << 16) | \ + ((u64)in[6] << 8) | (u64)in[7]; +} + +static inline u64 buf_get_le64(const void *_buf) +{ + const byte *in = _buf; + return ((u64)in[7] << 56) | ((u64)in[6] << 48) | \ + ((u64)in[5] << 40) | ((u64)in[4] << 32) | \ + ((u64)in[3] << 24) | ((u64)in[2] << 16) | \ + ((u64)in[1] << 8) | (u64)in[0]; +} + +static inline void buf_put_be64(void *_buf, u64 val) +{ + byte *out = _buf; + out[0] = val >> 56; + out[1] = val >> 48; + out[2] = val >> 40; + out[3] = val >> 32; + out[4] = val >> 24; + out[5] = val >> 16; + out[6] = val >> 8; + out[7] = val; +} + +static inline void buf_put_le64(void *_buf, u64 val) +{ + byte *out = _buf; + out[7] = val >> 56; + out[6] = val >> 48; + out[5] = val >> 40; + out[4] = val >> 32; + out[3] = val >> 24; + out[2] = val >> 16; + out[1] = val >> 8; + out[0] = val; +} + +#else /*BUFHELP_FAST_UNALIGNED_ACCESS*/ + +typedef struct bufhelp_u32_s +{ + u32 a; +} __attribute__((packed, aligned(1))) bufhelp_u32_t; + +/* Functions for loading and storing unaligned u32 values of different + endianness. */ +static inline u32 buf_get_be32(const void *_buf) +{ + return be_bswap32(((const bufhelp_u32_t *)_buf)->a); +} + +static inline u32 buf_get_le32(const void *_buf) +{ + return le_bswap32(((const bufhelp_u32_t *)_buf)->a); +} + +static inline void buf_put_be32(void *_buf, u32 val) +{ + bufhelp_u32_t *out = _buf; + out->a = be_bswap32(val); +} + +static inline void buf_put_le32(void *_buf, u32 val) +{ + bufhelp_u32_t *out = _buf; + out->a = le_bswap32(val); +} + + +typedef struct bufhelp_u64_s +{ + u64 a; +} __attribute__((packed, aligned(1))) bufhelp_u64_t; + +/* Functions for loading and storing unaligned u64 values of different + endianness. */ +static inline u64 buf_get_be64(const void *_buf) +{ + return be_bswap64(((const bufhelp_u64_t *)_buf)->a); +} + +static inline u64 buf_get_le64(const void *_buf) +{ + return le_bswap64(((const bufhelp_u64_t *)_buf)->a); +} + +static inline void buf_put_be64(void *_buf, u64 val) +{ + bufhelp_u64_t *out = _buf; + out->a = be_bswap64(val); +} + +static inline void buf_put_le64(void *_buf, u64 val) +{ + bufhelp_u64_t *out = _buf; + out->a = le_bswap64(val); +} + + +#endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/ + +#endif /*GCRYPT_BUFHELP_H*/ diff --git a/grub-core/lib/libgcrypt/cipher/crc.c b/grub-core/lib/libgcrypt/cipher/crc.c index 9e406f1b1..28454f8ab 100644 --- a/grub-core/lib/libgcrypt/cipher/crc.c +++ b/grub-core/lib/libgcrypt/cipher/crc.c @@ -28,116 +28,8 @@ #include "cipher.h" #include "bithelp.h" +#include "bufhelp.h" -/* Table of CRCs of all 8-bit messages. Generated by running code - from RFC 1952 modified to print out the table. */ -static u32 crc32_table[256] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -/* - * The following function was extracted from RFC 1952 by Simon - * Josefsson, for the Shishi project, and modified to be compatible - * with the modified CRC-32 used by RFC 1510, and subsequently - * modified for GNU Libgcrypt to allow it to be used for calculating - * both unmodified CRC-32 and modified CRC-32 values. Original - * copyright and notice from the document follows: - * - * Copyright (c) 1996 L. Peter Deutsch - * - * Permission is granted to copy and distribute this document for - * any purpose and without charge, including translations into - * other languages and incorporation into compilations, provided - * that the copyright notice and this notice are preserved, and - * that any substantive changes or deletions from the original are - * clearly marked. - * - * The copyright on RFCs, and consequently the function below, are - * supposedly also retroactively claimed by the Internet Society - * (according to rfc-editor@rfc-editor.org), with the following - * copyright notice: - * - * Copyright (C) The Internet Society. All Rights Reserved. - * - * This document and translations of it may be copied and furnished - * to others, and derivative works that comment on or otherwise - * explain it or assist in its implementation may be prepared, - * copied, published and distributed, in whole or in part, without - * restriction of any kind, provided that the above copyright - * notice and this paragraph are included on all such copies and - * derivative works. However, this document itself may not be - * modified in any way, such as by removing the copyright notice or - * references to the Internet Society or other Internet - * organizations, except as needed for the purpose of developing - * Internet standards in which case the procedures for copyrights - * defined in the Internet Standards process must be followed, or - * as required to translate it into languages other than English. - * - * The limited permissions granted above are perpetual and will not be - * revoked by the Internet Society or its successors or assigns. - * - * This document and the information contained herein is provided - * on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET - * ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE - * OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A - * PARTICULAR PURPOSE. - * - */ -static u32 -update_crc32 (u32 crc, const void *buf_arg, size_t len) -{ - const char *buf = buf_arg; - size_t n; - - for (n = 0; n < len; n++) - crc = crc32_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); - - return crc; -} typedef struct { @@ -146,8 +38,302 @@ typedef struct } CRC_CONTEXT; + +/* + * Code generated by universal_crc by Danjel McGougan + * + * CRC parameters used: + * bits: 32 + * poly: 0x04c11db7 + * init: 0xffffffff + * xor: 0xffffffff + * reverse: true + * non-direct: false + * + * CRC of the string "123456789" is 0xcbf43926 + */ + +static const u32 crc32_table[1024] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, + 0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, + 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, + 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, + 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf, + 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, + 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, + 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, + 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, + 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, + 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, + 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, + 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, + 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, + 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, + 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, + 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, + 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, + 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2, + 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce, + 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, + 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, + 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93, + 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, + 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b, + 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, + 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, + 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c, + 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, + 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35, + 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, + 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539, + 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88, + 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c, + 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, + 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, + 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, + 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd, + 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1, + 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, + 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, + 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, + 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522, + 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, + 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, + 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, + 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773, + 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277, + 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, + 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, + 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, + 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, + 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, + 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, + 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, + 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, + 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, + 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, + 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, + 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, + 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, + 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, + 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, + 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72, + 0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, + 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, + 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, + 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d, + 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, + 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, + 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, + 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, + 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, + 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, + 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, + 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, + 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, + 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, + 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, + 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, + 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399, + 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, + 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, + 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, + 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835, + 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, + 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d, + 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, + 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, + 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, + 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, + 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609, + 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, + 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, + 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, + 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, + 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, + 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, + 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, + 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, + 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75, + 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, + 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, + 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, + 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, + 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281, + 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, + 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, + 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, + 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, + 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, + 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, + 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, + 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, + 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, + 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, + 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, + 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, + 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, + 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, + 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, + 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, + 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, + 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, + 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, + 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed, + 0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, + 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, + 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, + 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056, + 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, + 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, + 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, + 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, + 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, + 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, + 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, + 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, + 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, + 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, + 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, + 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, + 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, + 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084, + 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, + 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, + 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, + 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b, + 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, + 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, + 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, + 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, + 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002, + 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, + 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72, + 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, + 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca, + 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, + 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82, + 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, + 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, + 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a, + 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, + 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5, + 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, + 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, + 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, + 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04, + 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, + 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, + 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, + 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, + 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc, + 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, + 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, + 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, + 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, + 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, + 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, + 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, + 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, + 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, + 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, + 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, + 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, + 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, + 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, + 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, + 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1 +}; + /* CRC32 */ +static inline u32 +crc32_next (u32 crc, byte data) +{ + return (crc >> 8) ^ crc32_table[(crc & 0xff) ^ data]; +} + +/* + * Process 4 bytes in one go + */ +static inline u32 +crc32_next4 (u32 crc, u32 data) +{ + crc ^= data; + crc = crc32_table[(crc & 0xff) + 0x300] ^ + crc32_table[((crc >> 8) & 0xff) + 0x200] ^ + crc32_table[((crc >> 16) & 0xff) + 0x100] ^ + crc32_table[(crc >> 24) & 0xff]; + return crc; +} + static void crc32_init (void *context) { @@ -156,12 +342,40 @@ crc32_init (void *context) } static void -crc32_write (void *context, const void *inbuf, size_t inlen) +crc32_write (void *context, const void *inbuf_arg, size_t inlen) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; - if (!inbuf) + const byte *inbuf = inbuf_arg; + u32 crc; + + if (!inbuf || !inlen) return; - ctx->CRC = update_crc32 (ctx->CRC, inbuf, inlen); + + crc = ctx->CRC; + + while (inlen >= 16) + { + inlen -= 16; + crc = crc32_next4(crc, buf_get_le32(&inbuf[0])); + crc = crc32_next4(crc, buf_get_le32(&inbuf[4])); + crc = crc32_next4(crc, buf_get_le32(&inbuf[8])); + crc = crc32_next4(crc, buf_get_le32(&inbuf[12])); + inbuf += 16; + } + + while (inlen >= 4) + { + inlen -= 4; + crc = crc32_next4(crc, buf_get_le32(inbuf)); + inbuf += 4; + } + + while (inlen--) + { + crc = crc32_next(crc, *inbuf++); + } + + ctx->CRC = crc; } static byte * @@ -176,13 +390,12 @@ crc32_final (void *context) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; ctx->CRC ^= 0xffffffffL; - ctx->buf[0] = (ctx->CRC >> 24) & 0xFF; - ctx->buf[1] = (ctx->CRC >> 16) & 0xFF; - ctx->buf[2] = (ctx->CRC >> 8) & 0xFF; - ctx->buf[3] = (ctx->CRC ) & 0xFF; + buf_put_be32 (ctx->buf, ctx->CRC); } /* CRC32 a'la RFC 1510 */ +/* CRC of the string "123456789" is 0x2dfd2d88 */ + static void crc32rfc1510_init (void *context) { @@ -194,82 +407,366 @@ static void crc32rfc1510_final (void *context) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; - ctx->buf[0] = (ctx->CRC >> 24) & 0xFF; - ctx->buf[1] = (ctx->CRC >> 16) & 0xFF; - ctx->buf[2] = (ctx->CRC >> 8) & 0xFF; - ctx->buf[3] = (ctx->CRC ) & 0xFF; + buf_put_be32(ctx->buf, ctx->CRC); } /* CRC24 a'la RFC 2440 */ /* - * The following CRC 24 routines are adapted from RFC 2440, which has - * the following copyright notice: + * Code generated by universal_crc by Danjel McGougan * - * Copyright (C) The Internet Society (1998). All Rights Reserved. + * CRC parameters used: + * bits: 24 + * poly: 0x864cfb + * init: 0xb704ce + * xor: 0x000000 + * reverse: false + * non-direct: false * - * This document and translations of it may be copied and furnished - * to others, and derivative works that comment on or otherwise - * explain it or assist in its implementation may be prepared, - * copied, published and distributed, in whole or in part, without - * restriction of any kind, provided that the above copyright notice - * and this paragraph are included on all such copies and derivative - * works. However, this document itself may not be modified in any - * way, such as by removing the copyright notice or references to - * the Internet Society or other Internet organizations, except as - * needed for the purpose of developing Internet standards in which - * case the procedures for copyrights defined in the Internet - * Standards process must be followed, or as required to translate - * it into languages other than English. - * - * The limited permissions granted above are perpetual and will not be - * revoked by the Internet Society or its successors or assigns. - * - * This document and the information contained herein is provided on - * an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET - * ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE - * OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR - * PURPOSE. + * CRC of the string "123456789" is 0x21cf02 */ -#define CRC24_INIT 0xb704ceL -#define CRC24_POLY 0x1864cfbL +static const u32 crc24_table[1024] = +{ + 0x00000000, 0x00fb4c86, 0x000dd58a, 0x00f6990c, + 0x00e1e693, 0x001aaa15, 0x00ec3319, 0x00177f9f, + 0x003981a1, 0x00c2cd27, 0x0034542b, 0x00cf18ad, + 0x00d86732, 0x00232bb4, 0x00d5b2b8, 0x002efe3e, + 0x00894ec5, 0x00720243, 0x00849b4f, 0x007fd7c9, + 0x0068a856, 0x0093e4d0, 0x00657ddc, 0x009e315a, + 0x00b0cf64, 0x004b83e2, 0x00bd1aee, 0x00465668, + 0x005129f7, 0x00aa6571, 0x005cfc7d, 0x00a7b0fb, + 0x00e9d10c, 0x00129d8a, 0x00e40486, 0x001f4800, + 0x0008379f, 0x00f37b19, 0x0005e215, 0x00feae93, + 0x00d050ad, 0x002b1c2b, 0x00dd8527, 0x0026c9a1, + 0x0031b63e, 0x00cafab8, 0x003c63b4, 0x00c72f32, + 0x00609fc9, 0x009bd34f, 0x006d4a43, 0x009606c5, + 0x0081795a, 0x007a35dc, 0x008cacd0, 0x0077e056, + 0x00591e68, 0x00a252ee, 0x0054cbe2, 0x00af8764, + 0x00b8f8fb, 0x0043b47d, 0x00b52d71, 0x004e61f7, + 0x00d2a319, 0x0029ef9f, 0x00df7693, 0x00243a15, + 0x0033458a, 0x00c8090c, 0x003e9000, 0x00c5dc86, + 0x00eb22b8, 0x00106e3e, 0x00e6f732, 0x001dbbb4, + 0x000ac42b, 0x00f188ad, 0x000711a1, 0x00fc5d27, + 0x005beddc, 0x00a0a15a, 0x00563856, 0x00ad74d0, + 0x00ba0b4f, 0x004147c9, 0x00b7dec5, 0x004c9243, + 0x00626c7d, 0x009920fb, 0x006fb9f7, 0x0094f571, + 0x00838aee, 0x0078c668, 0x008e5f64, 0x007513e2, + 0x003b7215, 0x00c03e93, 0x0036a79f, 0x00cdeb19, + 0x00da9486, 0x0021d800, 0x00d7410c, 0x002c0d8a, + 0x0002f3b4, 0x00f9bf32, 0x000f263e, 0x00f46ab8, + 0x00e31527, 0x001859a1, 0x00eec0ad, 0x00158c2b, + 0x00b23cd0, 0x00497056, 0x00bfe95a, 0x0044a5dc, + 0x0053da43, 0x00a896c5, 0x005e0fc9, 0x00a5434f, + 0x008bbd71, 0x0070f1f7, 0x008668fb, 0x007d247d, + 0x006a5be2, 0x00911764, 0x00678e68, 0x009cc2ee, + 0x00a44733, 0x005f0bb5, 0x00a992b9, 0x0052de3f, + 0x0045a1a0, 0x00beed26, 0x0048742a, 0x00b338ac, + 0x009dc692, 0x00668a14, 0x00901318, 0x006b5f9e, + 0x007c2001, 0x00876c87, 0x0071f58b, 0x008ab90d, + 0x002d09f6, 0x00d64570, 0x0020dc7c, 0x00db90fa, + 0x00ccef65, 0x0037a3e3, 0x00c13aef, 0x003a7669, + 0x00148857, 0x00efc4d1, 0x00195ddd, 0x00e2115b, + 0x00f56ec4, 0x000e2242, 0x00f8bb4e, 0x0003f7c8, + 0x004d963f, 0x00b6dab9, 0x004043b5, 0x00bb0f33, + 0x00ac70ac, 0x00573c2a, 0x00a1a526, 0x005ae9a0, + 0x0074179e, 0x008f5b18, 0x0079c214, 0x00828e92, + 0x0095f10d, 0x006ebd8b, 0x00982487, 0x00636801, + 0x00c4d8fa, 0x003f947c, 0x00c90d70, 0x003241f6, + 0x00253e69, 0x00de72ef, 0x0028ebe3, 0x00d3a765, + 0x00fd595b, 0x000615dd, 0x00f08cd1, 0x000bc057, + 0x001cbfc8, 0x00e7f34e, 0x00116a42, 0x00ea26c4, + 0x0076e42a, 0x008da8ac, 0x007b31a0, 0x00807d26, + 0x009702b9, 0x006c4e3f, 0x009ad733, 0x00619bb5, + 0x004f658b, 0x00b4290d, 0x0042b001, 0x00b9fc87, + 0x00ae8318, 0x0055cf9e, 0x00a35692, 0x00581a14, + 0x00ffaaef, 0x0004e669, 0x00f27f65, 0x000933e3, + 0x001e4c7c, 0x00e500fa, 0x001399f6, 0x00e8d570, + 0x00c62b4e, 0x003d67c8, 0x00cbfec4, 0x0030b242, + 0x0027cddd, 0x00dc815b, 0x002a1857, 0x00d154d1, + 0x009f3526, 0x006479a0, 0x0092e0ac, 0x0069ac2a, + 0x007ed3b5, 0x00859f33, 0x0073063f, 0x00884ab9, + 0x00a6b487, 0x005df801, 0x00ab610d, 0x00502d8b, + 0x00475214, 0x00bc1e92, 0x004a879e, 0x00b1cb18, + 0x00167be3, 0x00ed3765, 0x001bae69, 0x00e0e2ef, + 0x00f79d70, 0x000cd1f6, 0x00fa48fa, 0x0001047c, + 0x002ffa42, 0x00d4b6c4, 0x00222fc8, 0x00d9634e, + 0x00ce1cd1, 0x00355057, 0x00c3c95b, 0x003885dd, + 0x00000000, 0x00488f66, 0x00901ecd, 0x00d891ab, + 0x00db711c, 0x0093fe7a, 0x004b6fd1, 0x0003e0b7, + 0x00b6e338, 0x00fe6c5e, 0x0026fdf5, 0x006e7293, + 0x006d9224, 0x00251d42, 0x00fd8ce9, 0x00b5038f, + 0x006cc771, 0x00244817, 0x00fcd9bc, 0x00b456da, + 0x00b7b66d, 0x00ff390b, 0x0027a8a0, 0x006f27c6, + 0x00da2449, 0x0092ab2f, 0x004a3a84, 0x0002b5e2, + 0x00015555, 0x0049da33, 0x00914b98, 0x00d9c4fe, + 0x00d88ee3, 0x00900185, 0x0048902e, 0x00001f48, + 0x0003ffff, 0x004b7099, 0x0093e132, 0x00db6e54, + 0x006e6ddb, 0x0026e2bd, 0x00fe7316, 0x00b6fc70, + 0x00b51cc7, 0x00fd93a1, 0x0025020a, 0x006d8d6c, + 0x00b44992, 0x00fcc6f4, 0x0024575f, 0x006cd839, + 0x006f388e, 0x0027b7e8, 0x00ff2643, 0x00b7a925, + 0x0002aaaa, 0x004a25cc, 0x0092b467, 0x00da3b01, + 0x00d9dbb6, 0x009154d0, 0x0049c57b, 0x00014a1d, + 0x004b5141, 0x0003de27, 0x00db4f8c, 0x0093c0ea, + 0x0090205d, 0x00d8af3b, 0x00003e90, 0x0048b1f6, + 0x00fdb279, 0x00b53d1f, 0x006dacb4, 0x002523d2, + 0x0026c365, 0x006e4c03, 0x00b6dda8, 0x00fe52ce, + 0x00279630, 0x006f1956, 0x00b788fd, 0x00ff079b, + 0x00fce72c, 0x00b4684a, 0x006cf9e1, 0x00247687, + 0x00917508, 0x00d9fa6e, 0x00016bc5, 0x0049e4a3, + 0x004a0414, 0x00028b72, 0x00da1ad9, 0x009295bf, + 0x0093dfa2, 0x00db50c4, 0x0003c16f, 0x004b4e09, + 0x0048aebe, 0x000021d8, 0x00d8b073, 0x00903f15, + 0x00253c9a, 0x006db3fc, 0x00b52257, 0x00fdad31, + 0x00fe4d86, 0x00b6c2e0, 0x006e534b, 0x0026dc2d, + 0x00ff18d3, 0x00b797b5, 0x006f061e, 0x00278978, + 0x002469cf, 0x006ce6a9, 0x00b47702, 0x00fcf864, + 0x0049fbeb, 0x0001748d, 0x00d9e526, 0x00916a40, + 0x00928af7, 0x00da0591, 0x0002943a, 0x004a1b5c, + 0x0096a282, 0x00de2de4, 0x0006bc4f, 0x004e3329, + 0x004dd39e, 0x00055cf8, 0x00ddcd53, 0x00954235, + 0x002041ba, 0x0068cedc, 0x00b05f77, 0x00f8d011, + 0x00fb30a6, 0x00b3bfc0, 0x006b2e6b, 0x0023a10d, + 0x00fa65f3, 0x00b2ea95, 0x006a7b3e, 0x0022f458, + 0x002114ef, 0x00699b89, 0x00b10a22, 0x00f98544, + 0x004c86cb, 0x000409ad, 0x00dc9806, 0x00941760, + 0x0097f7d7, 0x00df78b1, 0x0007e91a, 0x004f667c, + 0x004e2c61, 0x0006a307, 0x00de32ac, 0x0096bdca, + 0x00955d7d, 0x00ddd21b, 0x000543b0, 0x004dccd6, + 0x00f8cf59, 0x00b0403f, 0x0068d194, 0x00205ef2, + 0x0023be45, 0x006b3123, 0x00b3a088, 0x00fb2fee, + 0x0022eb10, 0x006a6476, 0x00b2f5dd, 0x00fa7abb, + 0x00f99a0c, 0x00b1156a, 0x006984c1, 0x00210ba7, + 0x00940828, 0x00dc874e, 0x000416e5, 0x004c9983, + 0x004f7934, 0x0007f652, 0x00df67f9, 0x0097e89f, + 0x00ddf3c3, 0x00957ca5, 0x004ded0e, 0x00056268, + 0x000682df, 0x004e0db9, 0x00969c12, 0x00de1374, + 0x006b10fb, 0x00239f9d, 0x00fb0e36, 0x00b38150, + 0x00b061e7, 0x00f8ee81, 0x00207f2a, 0x0068f04c, + 0x00b134b2, 0x00f9bbd4, 0x00212a7f, 0x0069a519, + 0x006a45ae, 0x0022cac8, 0x00fa5b63, 0x00b2d405, + 0x0007d78a, 0x004f58ec, 0x0097c947, 0x00df4621, + 0x00dca696, 0x009429f0, 0x004cb85b, 0x0004373d, + 0x00057d20, 0x004df246, 0x009563ed, 0x00ddec8b, + 0x00de0c3c, 0x0096835a, 0x004e12f1, 0x00069d97, + 0x00b39e18, 0x00fb117e, 0x002380d5, 0x006b0fb3, + 0x0068ef04, 0x00206062, 0x00f8f1c9, 0x00b07eaf, + 0x0069ba51, 0x00213537, 0x00f9a49c, 0x00b12bfa, + 0x00b2cb4d, 0x00fa442b, 0x0022d580, 0x006a5ae6, + 0x00df5969, 0x0097d60f, 0x004f47a4, 0x0007c8c2, + 0x00042875, 0x004ca713, 0x009436b8, 0x00dcb9de, + 0x00000000, 0x00d70983, 0x00555f80, 0x00825603, + 0x0051f286, 0x0086fb05, 0x0004ad06, 0x00d3a485, + 0x0059a88b, 0x008ea108, 0x000cf70b, 0x00dbfe88, + 0x00085a0d, 0x00df538e, 0x005d058d, 0x008a0c0e, + 0x00491c91, 0x009e1512, 0x001c4311, 0x00cb4a92, + 0x0018ee17, 0x00cfe794, 0x004db197, 0x009ab814, + 0x0010b41a, 0x00c7bd99, 0x0045eb9a, 0x0092e219, + 0x0041469c, 0x00964f1f, 0x0014191c, 0x00c3109f, + 0x006974a4, 0x00be7d27, 0x003c2b24, 0x00eb22a7, + 0x00388622, 0x00ef8fa1, 0x006dd9a2, 0x00bad021, + 0x0030dc2f, 0x00e7d5ac, 0x006583af, 0x00b28a2c, + 0x00612ea9, 0x00b6272a, 0x00347129, 0x00e378aa, + 0x00206835, 0x00f761b6, 0x007537b5, 0x00a23e36, + 0x00719ab3, 0x00a69330, 0x0024c533, 0x00f3ccb0, + 0x0079c0be, 0x00aec93d, 0x002c9f3e, 0x00fb96bd, + 0x00283238, 0x00ff3bbb, 0x007d6db8, 0x00aa643b, + 0x0029a4ce, 0x00fead4d, 0x007cfb4e, 0x00abf2cd, + 0x00785648, 0x00af5fcb, 0x002d09c8, 0x00fa004b, + 0x00700c45, 0x00a705c6, 0x002553c5, 0x00f25a46, + 0x0021fec3, 0x00f6f740, 0x0074a143, 0x00a3a8c0, + 0x0060b85f, 0x00b7b1dc, 0x0035e7df, 0x00e2ee5c, + 0x00314ad9, 0x00e6435a, 0x00641559, 0x00b31cda, + 0x003910d4, 0x00ee1957, 0x006c4f54, 0x00bb46d7, + 0x0068e252, 0x00bfebd1, 0x003dbdd2, 0x00eab451, + 0x0040d06a, 0x0097d9e9, 0x00158fea, 0x00c28669, + 0x001122ec, 0x00c62b6f, 0x00447d6c, 0x009374ef, + 0x001978e1, 0x00ce7162, 0x004c2761, 0x009b2ee2, + 0x00488a67, 0x009f83e4, 0x001dd5e7, 0x00cadc64, + 0x0009ccfb, 0x00dec578, 0x005c937b, 0x008b9af8, + 0x00583e7d, 0x008f37fe, 0x000d61fd, 0x00da687e, + 0x00506470, 0x00876df3, 0x00053bf0, 0x00d23273, + 0x000196f6, 0x00d69f75, 0x0054c976, 0x0083c0f5, + 0x00a9041b, 0x007e0d98, 0x00fc5b9b, 0x002b5218, + 0x00f8f69d, 0x002fff1e, 0x00ada91d, 0x007aa09e, + 0x00f0ac90, 0x0027a513, 0x00a5f310, 0x0072fa93, + 0x00a15e16, 0x00765795, 0x00f40196, 0x00230815, + 0x00e0188a, 0x00371109, 0x00b5470a, 0x00624e89, + 0x00b1ea0c, 0x0066e38f, 0x00e4b58c, 0x0033bc0f, + 0x00b9b001, 0x006eb982, 0x00ecef81, 0x003be602, + 0x00e84287, 0x003f4b04, 0x00bd1d07, 0x006a1484, + 0x00c070bf, 0x0017793c, 0x00952f3f, 0x004226bc, + 0x00918239, 0x00468bba, 0x00c4ddb9, 0x0013d43a, + 0x0099d834, 0x004ed1b7, 0x00cc87b4, 0x001b8e37, + 0x00c82ab2, 0x001f2331, 0x009d7532, 0x004a7cb1, + 0x00896c2e, 0x005e65ad, 0x00dc33ae, 0x000b3a2d, + 0x00d89ea8, 0x000f972b, 0x008dc128, 0x005ac8ab, + 0x00d0c4a5, 0x0007cd26, 0x00859b25, 0x005292a6, + 0x00813623, 0x00563fa0, 0x00d469a3, 0x00036020, + 0x0080a0d5, 0x0057a956, 0x00d5ff55, 0x0002f6d6, + 0x00d15253, 0x00065bd0, 0x00840dd3, 0x00530450, + 0x00d9085e, 0x000e01dd, 0x008c57de, 0x005b5e5d, + 0x0088fad8, 0x005ff35b, 0x00dda558, 0x000aacdb, + 0x00c9bc44, 0x001eb5c7, 0x009ce3c4, 0x004bea47, + 0x00984ec2, 0x004f4741, 0x00cd1142, 0x001a18c1, + 0x009014cf, 0x00471d4c, 0x00c54b4f, 0x001242cc, + 0x00c1e649, 0x0016efca, 0x0094b9c9, 0x0043b04a, + 0x00e9d471, 0x003eddf2, 0x00bc8bf1, 0x006b8272, + 0x00b826f7, 0x006f2f74, 0x00ed7977, 0x003a70f4, + 0x00b07cfa, 0x00677579, 0x00e5237a, 0x00322af9, + 0x00e18e7c, 0x003687ff, 0x00b4d1fc, 0x0063d87f, + 0x00a0c8e0, 0x0077c163, 0x00f59760, 0x00229ee3, + 0x00f13a66, 0x002633e5, 0x00a465e6, 0x00736c65, + 0x00f9606b, 0x002e69e8, 0x00ac3feb, 0x007b3668, + 0x00a892ed, 0x007f9b6e, 0x00fdcd6d, 0x002ac4ee, + 0x00000000, 0x00520936, 0x00a4126c, 0x00f61b5a, + 0x004825d8, 0x001a2cee, 0x00ec37b4, 0x00be3e82, + 0x006b0636, 0x00390f00, 0x00cf145a, 0x009d1d6c, + 0x002323ee, 0x00712ad8, 0x00873182, 0x00d538b4, + 0x00d60c6c, 0x0084055a, 0x00721e00, 0x00201736, + 0x009e29b4, 0x00cc2082, 0x003a3bd8, 0x006832ee, + 0x00bd0a5a, 0x00ef036c, 0x00191836, 0x004b1100, + 0x00f52f82, 0x00a726b4, 0x00513dee, 0x000334d8, + 0x00ac19d8, 0x00fe10ee, 0x00080bb4, 0x005a0282, + 0x00e43c00, 0x00b63536, 0x00402e6c, 0x0012275a, + 0x00c71fee, 0x009516d8, 0x00630d82, 0x003104b4, + 0x008f3a36, 0x00dd3300, 0x002b285a, 0x0079216c, + 0x007a15b4, 0x00281c82, 0x00de07d8, 0x008c0eee, + 0x0032306c, 0x0060395a, 0x00962200, 0x00c42b36, + 0x00111382, 0x00431ab4, 0x00b501ee, 0x00e708d8, + 0x0059365a, 0x000b3f6c, 0x00fd2436, 0x00af2d00, + 0x00a37f36, 0x00f17600, 0x00076d5a, 0x0055646c, + 0x00eb5aee, 0x00b953d8, 0x004f4882, 0x001d41b4, + 0x00c87900, 0x009a7036, 0x006c6b6c, 0x003e625a, + 0x00805cd8, 0x00d255ee, 0x00244eb4, 0x00764782, + 0x0075735a, 0x00277a6c, 0x00d16136, 0x00836800, + 0x003d5682, 0x006f5fb4, 0x009944ee, 0x00cb4dd8, + 0x001e756c, 0x004c7c5a, 0x00ba6700, 0x00e86e36, + 0x005650b4, 0x00045982, 0x00f242d8, 0x00a04bee, + 0x000f66ee, 0x005d6fd8, 0x00ab7482, 0x00f97db4, + 0x00474336, 0x00154a00, 0x00e3515a, 0x00b1586c, + 0x006460d8, 0x003669ee, 0x00c072b4, 0x00927b82, + 0x002c4500, 0x007e4c36, 0x0088576c, 0x00da5e5a, + 0x00d96a82, 0x008b63b4, 0x007d78ee, 0x002f71d8, + 0x00914f5a, 0x00c3466c, 0x00355d36, 0x00675400, + 0x00b26cb4, 0x00e06582, 0x00167ed8, 0x004477ee, + 0x00fa496c, 0x00a8405a, 0x005e5b00, 0x000c5236, + 0x0046ff6c, 0x0014f65a, 0x00e2ed00, 0x00b0e436, + 0x000edab4, 0x005cd382, 0x00aac8d8, 0x00f8c1ee, + 0x002df95a, 0x007ff06c, 0x0089eb36, 0x00dbe200, + 0x0065dc82, 0x0037d5b4, 0x00c1ceee, 0x0093c7d8, + 0x0090f300, 0x00c2fa36, 0x0034e16c, 0x0066e85a, + 0x00d8d6d8, 0x008adfee, 0x007cc4b4, 0x002ecd82, + 0x00fbf536, 0x00a9fc00, 0x005fe75a, 0x000dee6c, + 0x00b3d0ee, 0x00e1d9d8, 0x0017c282, 0x0045cbb4, + 0x00eae6b4, 0x00b8ef82, 0x004ef4d8, 0x001cfdee, + 0x00a2c36c, 0x00f0ca5a, 0x0006d100, 0x0054d836, + 0x0081e082, 0x00d3e9b4, 0x0025f2ee, 0x0077fbd8, + 0x00c9c55a, 0x009bcc6c, 0x006dd736, 0x003fde00, + 0x003cead8, 0x006ee3ee, 0x0098f8b4, 0x00caf182, + 0x0074cf00, 0x0026c636, 0x00d0dd6c, 0x0082d45a, + 0x0057ecee, 0x0005e5d8, 0x00f3fe82, 0x00a1f7b4, + 0x001fc936, 0x004dc000, 0x00bbdb5a, 0x00e9d26c, + 0x00e5805a, 0x00b7896c, 0x00419236, 0x00139b00, + 0x00ada582, 0x00ffacb4, 0x0009b7ee, 0x005bbed8, + 0x008e866c, 0x00dc8f5a, 0x002a9400, 0x00789d36, + 0x00c6a3b4, 0x0094aa82, 0x0062b1d8, 0x0030b8ee, + 0x00338c36, 0x00618500, 0x00979e5a, 0x00c5976c, + 0x007ba9ee, 0x0029a0d8, 0x00dfbb82, 0x008db2b4, + 0x00588a00, 0x000a8336, 0x00fc986c, 0x00ae915a, + 0x0010afd8, 0x0042a6ee, 0x00b4bdb4, 0x00e6b482, + 0x00499982, 0x001b90b4, 0x00ed8bee, 0x00bf82d8, + 0x0001bc5a, 0x0053b56c, 0x00a5ae36, 0x00f7a700, + 0x00229fb4, 0x00709682, 0x00868dd8, 0x00d484ee, + 0x006aba6c, 0x0038b35a, 0x00cea800, 0x009ca136, + 0x009f95ee, 0x00cd9cd8, 0x003b8782, 0x00698eb4, + 0x00d7b036, 0x0085b900, 0x0073a25a, 0x0021ab6c, + 0x00f493d8, 0x00a69aee, 0x005081b4, 0x00028882, + 0x00bcb600, 0x00eebf36, 0x0018a46c, 0x004aad5a +}; + +static inline +u32 crc24_init (void) +{ + return 0xce04b7; +} + +static inline +u32 crc24_next (u32 crc, byte data) +{ + return (crc >> 8) ^ crc24_table[(crc & 0xff) ^ data]; +} + +/* + * Process 4 bytes in one go + */ +static inline +u32 crc24_next4 (u32 crc, u32 data) +{ + crc ^= data; + crc = crc24_table[(crc & 0xff) + 0x300] ^ + crc24_table[((crc >> 8) & 0xff) + 0x200] ^ + crc24_table[((crc >> 16) & 0xff) + 0x100] ^ + crc24_table[(crc >> 24) & 0xff]; + return crc; +} + +static inline +u32 crc24_final (u32 crc) +{ + return crc & 0xffffff; +} static void crc24rfc2440_init (void *context) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; - ctx->CRC = CRC24_INIT; + ctx->CRC = crc24_init(); } static void crc24rfc2440_write (void *context, const void *inbuf_arg, size_t inlen) { const unsigned char *inbuf = inbuf_arg; - int i; CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + u32 crc; - if (!inbuf) + if (!inbuf || !inlen) return; - while (inlen--) { - ctx->CRC ^= (*inbuf++) << 16; - for (i = 0; i < 8; i++) { - ctx->CRC <<= 1; - if (ctx->CRC & 0x1000000) - ctx->CRC ^= CRC24_POLY; + crc = ctx->CRC; + + while (inlen >= 16) + { + inlen -= 16; + crc = crc24_next4(crc, buf_get_le32(&inbuf[0])); + crc = crc24_next4(crc, buf_get_le32(&inbuf[4])); + crc = crc24_next4(crc, buf_get_le32(&inbuf[8])); + crc = crc24_next4(crc, buf_get_le32(&inbuf[12])); + inbuf += 16; } - } + + while (inlen >= 4) + { + inlen -= 4; + crc = crc24_next4(crc, buf_get_le32(inbuf)); + inbuf += 4; + } + + while (inlen--) + { + crc = crc24_next(crc, *inbuf++); + } + + ctx->CRC = crc; } static void crc24rfc2440_final (void *context) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; - ctx->buf[0] = (ctx->CRC >> 16) & 0xFF; - ctx->buf[1] = (ctx->CRC >> 8) & 0xFF; - ctx->buf[2] = (ctx->CRC ) & 0xFF; + ctx->CRC = crc24_final(ctx->CRC); + buf_put_le32 (ctx->buf, ctx->CRC); } gcry_md_spec_t _gcry_digest_spec_crc32 = From 083c6e2455dcd4aafb6062d89fd6029dd3adddb6 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:49 +0000 Subject: [PATCH 0770/1167] arm64/efi: move EFI_PAGE definitions to efi/memory.h The EFI page definitions and macros are generic and should not be confined to arm64 headers - so move to efi/memory.h. Also add EFI_PAGE_SIZE macro. Update loader sources to reflect new header location. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 1 + grub-core/loader/arm64/xen_boot.c | 1 + grub-core/loader/efi/fdt.c | 1 + include/grub/efi/fdtload.h | 3 --- include/grub/efi/memory.h | 7 +++++++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 746edd104..ca01a2349 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 6780b1f0c..0a40e16be 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -30,6 +30,7 @@ #include #include #include +#include #include /* required by struct xen_hypervisor_header */ #include #include diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index 17212c38d..c0c6800f7 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -24,6 +24,7 @@ #include #include #include +#include static void *loaded_fdt; static void *fdt; diff --git a/include/grub/efi/fdtload.h b/include/grub/efi/fdtload.h index 7b9ddba91..713c9424d 100644 --- a/include/grub/efi/fdtload.h +++ b/include/grub/efi/fdtload.h @@ -29,7 +29,4 @@ grub_fdt_unload (void); grub_err_t grub_fdt_install (void); -#define GRUB_EFI_PAGE_SHIFT 12 -#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) - #endif diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h index 20526b146..08fe62277 100644 --- a/include/grub/efi/memory.h +++ b/include/grub/efi/memory.h @@ -22,6 +22,13 @@ #include #include +/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of + memory. It is not concerned with underlying translation management concepts, + but only used as the granule for memory allocations. */ +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_PAGE_SIZE (1 << GRUB_EFI_PAGE_SHIFT) +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + #define GRUB_MMAP_REGISTER_BY_FIRMWARE 1 grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size, From 8776e5a942582adaadc67865ed74cdd199e56a16 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:50 +0000 Subject: [PATCH 0771/1167] Make arch-specific linux.h include guards architecture unique Replace uses of GRUB_LINUX_MACHINE_HEADER and GRUB_LINUX_CPU_HEADER with GRUB__LINUX_HEADER include guards to prevent issues when including more than one of them. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- include/grub/arm/linux.h | 6 +++--- include/grub/arm64/linux.h | 6 +++--- include/grub/i386/linux.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index f217f8281..3706c46c6 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -17,8 +17,8 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_LINUX_CPU_HEADER -#define GRUB_LINUX_CPU_HEADER 1 +#ifndef GRUB_ARM_LINUX_HEADER +#define GRUB_ARM_LINUX_HEADER 1 #define LINUX_ZIMAGE_OFFSET 0x24 #define LINUX_ZIMAGE_MAGIC 0x016f2818 @@ -66,4 +66,4 @@ grub_arm_firmware_get_machine_type (void) #define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 -#endif /* ! GRUB_LINUX_CPU_HEADER */ +#endif /* ! GRUB_ARM_LINUX_HEADER */ diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index a981df5d1..a8edf50dc 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_LINUX_CPU_HEADER -#define GRUB_LINUX_CPU_HEADER 1 +#ifndef GRUB_ARM64_LINUX_HEADER +#define GRUB_ARM64_LINUX_HEADER 1 #include @@ -43,4 +43,4 @@ grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args); -#endif /* ! GRUB_LINUX_CPU_HEADER */ +#endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index da0ca3b83..2ff1621a4 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_LINUX_MACHINE_HEADER -#define GRUB_LINUX_MACHINE_HEADER 1 +#ifndef GRUB_I386_LINUX_HEADER +#define GRUB_I386_LINUX_HEADER 1 #define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4 @@ -312,4 +312,4 @@ struct linux_kernel_params } GRUB_PACKED; #endif /* ! ASM_FILE */ -#endif /* ! GRUB_LINUX_MACHINE_HEADER */ +#endif /* ! GRUB_I386_LINUX_HEADER */ From 3245f02d9d7274e942426541cf73dc73e7298f02 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:51 +0000 Subject: [PATCH 0772/1167] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE, to be usable in code that supports more than one image type. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/file.c | 4 ++-- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/linux.c | 6 +++--- grub-core/loader/i386/xen_file.c | 2 +- include/grub/i386/linux.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 12fba99e0..474666d3a 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -508,7 +508,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: some really old kernels (< 1.3.73) will fail this. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) break; @@ -521,7 +521,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) break; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 083f9417c..9bd5afb65 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -721,7 +721,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) { grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot" diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index a293b17aa..31a687644 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), maximal_cmdline_size = 256; - if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh.version) >= 0x0200) { grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); @@ -322,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) /* Clear the heap space. */ grub_memset (grub_linux_real_chunk @@ -407,7 +407,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), lh = (struct linux_kernel_header *) grub_linux_real_chunk; - if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) { grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 99fad4cad..6e76e16aa 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -43,7 +43,7 @@ grub_xen_file (grub_file_t file) goto fail; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55) - || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0208) { grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot"); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 2ff1621a4..3ff432be9 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -19,7 +19,7 @@ #ifndef GRUB_I386_LINUX_HEADER #define GRUB_I386_LINUX_HEADER 1 -#define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ +#define GRUB_LINUX_I386_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4 #define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF #define GRUB_LINUX_MAX_SETUP_SECTS 64 From 7d36709d5e769eb49b41cca709bd64336b47ab4f Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:52 +0000 Subject: [PATCH 0773/1167] i386: make struct linux_kernel_header architecture specific struct linux_kernel_header -> struct linux_i386_kernel_header Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/file.c | 2 +- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/linux.c | 6 +++--- grub-core/loader/i386/xen_file.c | 2 +- include/grub/i386/linux.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 474666d3a..63c84499b 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -497,7 +497,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) case IS_X86_LINUX32: case IS_X86_LINUX: { - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 9bd5afb65..44301e126 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -678,7 +678,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size, prot_size, prot_file_size; grub_ssize_t len; diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 31a687644..b69cb7a3a 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -121,7 +121,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size; grub_ssize_t len; @@ -387,7 +387,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_size_t size = 0; grub_addr_t addr_max, addr_min; - struct linux_kernel_header *lh; + struct linux_i386_kernel_header *lh; grub_uint8_t *initrd_chunk; grub_addr_t initrd_addr; grub_err_t err; @@ -405,7 +405,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - lh = (struct linux_kernel_header *) grub_linux_real_chunk; + lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk; if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 6e76e16aa..77a93e7b2 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -26,7 +26,7 @@ grub_elf_t grub_xen_file (grub_file_t file) { grub_elf_t elf; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_file_t off_file; grub_uint32_t payload_offset, payload_length; grub_uint8_t magic[6]; diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 3ff432be9..0bd758817 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -85,7 +85,7 @@ enum }; /* For the Linux/i386 boot protocol version 2.10. */ -struct linux_kernel_header +struct linux_i386_kernel_header { grub_uint8_t code1[0x0020]; grub_uint16_t cl_magic; /* Magic number 0xA33F */ From ff1cf2548a3f33da19278829687d074ad746dd0a Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:53 +0000 Subject: [PATCH 0774/1167] arm64: align linux kernel header struct naming with i386 Rename struct grub_arm64_linux_kernel_header -> linux_arm64_kernel_header. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 4 ++-- grub-core/loader/arm64/xen_boot.c | 4 ++-- include/grub/arm64/linux.h | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index ca01a2349..79f25a711 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,7 +48,7 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) +grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh) { if (lh->magic != GRUB_ARM64_LINUX_MAGIC) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); @@ -249,7 +249,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct grub_arm64_linux_kernel_header lh; + struct linux_arm64_kernel_header lh; grub_dl_ref (my_mod); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 0a40e16be..258264c79 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -67,7 +67,7 @@ typedef enum module_type module_type_t; struct xen_hypervisor_header { - struct grub_arm64_linux_kernel_header efi_head; + struct linux_arm64_kernel_header efi_head; /* This is always PE\0\0. */ grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; @@ -469,7 +469,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) goto fail; if (grub_arm64_uefi_check_image - ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) + ((struct linux_arm64_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index a8edf50dc..abe7e9cc3 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -24,7 +24,7 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ -struct grub_arm64_linux_kernel_header +struct linux_arm64_kernel_header { grub_uint32_t code0; /* Executable code */ grub_uint32_t code1; /* Executable code */ @@ -38,8 +38,7 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header - *lh); +grub_err_t grub_arm64_uefi_check_image (struct linux_arm64_kernel_header *lh); grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args); From 7fd9722d0c5e9c5a85b782ef435c80085da308b2 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:54 +0000 Subject: [PATCH 0775/1167] arm64: align linux kernel magic macro naming with i386 Change GRUB_ARM64_LINUX_MAGIC to GRUB_LINUX_ARM64_MAGIC_SIGNATURE. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 2 +- include/grub/arm64/linux.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 79f25a711..ebe1e730d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -50,7 +50,7 @@ static grub_addr_t initrd_end; grub_err_t grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh) { - if (lh->magic != GRUB_ARM64_LINUX_MAGIC) + if (lh->magic != GRUB_LINUX_ARM64_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index abe7e9cc3..b06347624 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -21,7 +21,7 @@ #include -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ +#define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ struct linux_arm64_kernel_header From cda033298680b6984044563b2ef6374a725b8aac Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:55 +0000 Subject: [PATCH 0776/1167] arm: switch linux loader to linux_arm_kernel_header struct Use kernel header struct and magic definition to align (and coexist) with i386/arm64 ports. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm/linux.c | 11 +++++------ include/grub/arm/linux.h | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index e64c79a95..9f43e41bb 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -46,9 +46,6 @@ static const void *current_fdt; typedef void (*kernel_entry_t) (int, unsigned long, void *); -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #define LINUX_PHYS_OFFSET (0x00008000) #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) @@ -315,6 +312,7 @@ linux_boot (void) static grub_err_t linux_load (const char *filename, grub_file_t file) { + struct linux_arm_kernel_header *lh; int size; size = grub_file_size (file); @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file) return grub_errno; } - if (size > LINUX_ZIMAGE_OFFSET + 4 - && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET) - == LINUX_ZIMAGE_MAGIC) + lh = (void *) linux_addr; + + if ((grub_size_t) size > sizeof (*lh) && + lh->magic == GRUB_LINUX_ARM_MAGIC_SIGNATURE) ; else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006 && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 3706c46c6..64dd3173c 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,11 +20,20 @@ #ifndef GRUB_ARM_LINUX_HEADER #define GRUB_ARM_LINUX_HEADER 1 -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #include "system.h" +#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 + +struct linux_arm_kernel_header { + grub_uint32_t code0; + grub_uint32_t reserved1[8]; + grub_uint32_t magic; + grub_uint32_t start; /* _start */ + grub_uint32_t end; /* _edata */ + grub_uint32_t reserved2[4]; + grub_uint32_t hdr_offset; +}; + #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000) From a244d9ebc7547f7ed373d9796a3bf186e7c035a1 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Feb 2018 18:18:56 +0000 Subject: [PATCH 0777/1167] arm: make linux.h safe to include for non-native builds (for machine arm/efi) and (for machine arm/coreboot) will not always resolve (and will likely not be valid to) if pulled in when building non-native commands, such as host tools or the "file" command. So explicitly include them with their expanded pathnames. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- include/grub/arm/linux.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 64dd3173c..cceb9c4a9 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -43,7 +43,7 @@ struct linux_arm_kernel_header { # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type #elif defined GRUB_MACHINE_EFI # include -# include +# include /* On UEFI platforms - load the images at the lowest available address not less than *_PHYS_OFFSET from the first available memory location. */ # define LINUX_PHYS_OFFSET (0x00008000) @@ -57,7 +57,7 @@ grub_arm_firmware_get_machine_type (void) } #elif defined (GRUB_MACHINE_COREBOOT) #include -#include +#include # define LINUX_ADDRESS (start_of_ram + 0x8000) # define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) From 72b425b640f67ad7e6e0056a7a793bddc9997985 Mon Sep 17 00:00:00 2001 From: Joakim Bech Date: Mon, 26 Feb 2018 09:57:34 +0100 Subject: [PATCH 0778/1167] ieee1275: fix build regression in of_path_of_nvme The of_path_of_nvme function (commit 2391d57, ieee1275: add nvme support within ofpath) introduced a build regression: grub-core/osdep/linux/ofpath.c:365:21: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if ((digit_string != '\0') && (*part_end == 'p')) Update digit_string to compare against the char instead of the pointer. Signed-off-by: Joakim Bech Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 4308fceda..1c30e7233 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -362,7 +362,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)), digit_string = trailing_digits (device); part_end = devicenode + strlen (devicenode) - 1; - if ((digit_string != '\0') && (*part_end == 'p')) + if ((*digit_string != '\0') && (*part_end == 'p')) { /* We have a partition number, strip it off. */ int part; From e1ead149efadf420fe16d2ce0b109a6982b8a5f6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:23 -0500 Subject: [PATCH 0779/1167] aout.h: Fix missing include. grub_aout_load() has a grub_file_t parameter, and depending on what order includes land in, it's sometimes not defined. This patch explicitly adds file.h to aout.h so that it will always be defined. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- include/grub/aout.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grub/aout.h b/include/grub/aout.h index 10d7dde61..c8c1d94ec 100644 --- a/include/grub/aout.h +++ b/include/grub/aout.h @@ -52,6 +52,7 @@ #define GRUB_AOUT_HEADER 1 #include +#include struct grub_aout32_header { From 352868d1234c94393e84871072372d73cb1166fa Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:24 -0500 Subject: [PATCH 0780/1167] mkimage: make it easier to run syntax checkers on grub-mkimagexx.c This makes it so you can treat grub-mkimagexx.c as a file you can build directly, so syntax checkers like vim's "syntastic" plugin, which uses "gcc -x c -fsyntax-only" to build it, will work. One still has to do whatever setup is required to make it pick the right include dirs, which -W options we use, etc., but this makes it so you can do the checking on the file you're editing, rather than on a different file. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- util/grub-mkimage32.c | 2 ++ util/grub-mkimage64.c | 2 ++ util/grub-mkimagexx.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c index 9b31397bc..1f2ccccd2 100644 --- a/util/grub-mkimage32.c +++ b/util/grub-mkimage32.c @@ -19,4 +19,6 @@ # define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) #define XEN_NOTE_SIZE 132 +#ifndef GRUB_MKIMAGEXX #include "grub-mkimagexx.c" +#endif diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c index d83345924..4ff72a625 100644 --- a/util/grub-mkimage64.c +++ b/util/grub-mkimage64.c @@ -19,4 +19,6 @@ # define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) #define XEN_NOTE_SIZE 120 +#ifndef GRUB_MKIMAGEXX #include "grub-mkimagexx.c" +#endif diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 39d7efb91..97ff599f0 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -50,6 +50,15 @@ #pragma GCC diagnostic ignored "-Wcast-align" +#define GRUB_MKIMAGEXX +#if !defined(MKIMAGE_ELF32) && !defined(MKIMAGE_ELF64) +#if __SIZEOF_POINTER__ == 8 +#include "grub-mkimage64.c" +#else +#include "grub-mkimage32.c" +#endif +#endif + /* These structures are defined according to the CHRP binding to IEEE1275, "Client Program Format" section. */ From 594ac31571970611958b00284f9ca4c6f6c1286d Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:25 -0500 Subject: [PATCH 0781/1167] mkimage: rename a couple of things to be less confusing later. This renames some things: - the "strtab" and "strtab_section" in relocate_symbols are changed to "symtab" instead, so as to be less confusing when "strtab" is moved to a struct in a later patch. - The places where we pass section_vaddresses to functions are changed to also be called section_vaddresses"inside those functions, so I get less confused when I put addresses and vaddresses in a struct in a later patch. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 97ff599f0..85753448e 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -509,7 +509,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc Return the address of a start symbol. */ static Elf_Addr SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Shdr *symtab_section, Elf_Addr *section_addresses, + Elf_Shdr *symtab_section, Elf_Addr *section_vaddresses, Elf_Half section_entsize, Elf_Half num_sections, void *jumpers, Elf_Addr jumpers_addr, Elf_Addr bss_start, Elf_Addr end, @@ -520,15 +520,15 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Addr start_address = (Elf_Addr) -1; Elf_Sym *sym; Elf_Word i; - Elf_Shdr *strtab_section; - const char *strtab; + Elf_Shdr *symtab_link_section; + const char *symtab; grub_uint64_t *jptr = jumpers; - strtab_section + symtab_link_section = (Elf_Shdr *) ((char *) sections + (grub_target_to_host32 (symtab_section->sh_link) * section_entsize)); - strtab = (char *) e + grub_target_to_host (strtab_section->sh_offset); + symtab = (char *) e + grub_target_to_host (symtab_link_section->sh_offset); symtab_size = grub_target_to_host (symtab_section->sh_size); sym_size = grub_target_to_host (symtab_section->sh_entsize); @@ -542,7 +542,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Section cur_index; const char *name; - name = strtab + grub_target_to_host32 (sym->st_name); + name = symtab + grub_target_to_host32 (sym->st_name); cur_index = grub_target_to_host16 (sym->st_shndx); if (cur_index == STN_ABS) @@ -565,7 +565,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, else { sym->st_value = (grub_target_to_host (sym->st_value) - + section_addresses[cur_index]); + + section_vaddresses[cur_index]); } if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info) @@ -580,7 +580,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, grub_util_info ("locating %s at 0x%" GRUB_HOST_PRIxLONG_LONG " (0x%" GRUB_HOST_PRIxLONG_LONG ")", name, (unsigned long long) sym->st_value, - (unsigned long long) section_addresses[cur_index]); + (unsigned long long) section_vaddresses[cur_index]); if (start_address == (Elf_Addr)-1) if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) @@ -1644,7 +1644,7 @@ create_u64_fixups (struct translate_context *ctx, /* Make a .reloc section. */ static void make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, - Elf_Addr *section_addresses, Elf_Shdr *sections, + Elf_Addr *section_vaddresses, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, const struct grub_install_image_target_desc *image_target) @@ -1674,7 +1674,7 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, rtab_offset = grub_target_to_host (s->sh_offset); num_rs = rtab_size / r_size; - section_address = section_addresses[grub_le_to_cpu32 (s->sh_info)]; + section_address = section_vaddresses[grub_le_to_cpu32 (s->sh_info)]; for (j = 0, r = (Elf_Rel *) ((char *) e + rtab_offset); j < num_rs; From e30de94926ec5250d7a0a091aef38b9071c97f6a Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:26 -0500 Subject: [PATCH 0782/1167] mkimage: make locate_sections() set up vaddresses as well. This puts both kinds of address initialization at the same place, and also lets us iterate through the section list one time fewer. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 85753448e..851339bec 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1784,18 +1784,19 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, return current_address; } -/* Locate section addresses by merging code sections and data sections - into .text and .data, respectively. Return the array of section - addresses. */ -static Elf_Addr * +/* + * Locate section addresses by merging code sections and data sections + * into .text and .data, respectively. + */ +static void SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, Elf_Shdr *sections, Elf_Half section_entsize, - Elf_Half num_sections, const char *strtab, + Elf_Half num_sections, Elf_Addr *section_addresses, + Elf_Addr *section_vaddresses, const char *strtab, struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { int i; - Elf_Addr *section_addresses; Elf_Shdr *s; layout->align = 1; @@ -1803,8 +1804,6 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, if (image_target->elf_target == EM_AARCH64) layout->align = 4096; - section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); - memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); layout->kernel_size = 0; @@ -1880,12 +1879,16 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) - if (SUFFIX (is_bss_section) (s, image_target)) - layout->end = SUFFIX (put_section) (s, i, - layout->end, - section_addresses, - strtab, - image_target); + { + if (SUFFIX (is_bss_section) (s, image_target)) + layout->end = SUFFIX (put_section) (s, i, layout->end, + section_addresses, strtab, + image_target); + /* + * This must to be in the last time this function passes through the loop. + */ + section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; + } layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; @@ -1896,8 +1899,6 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, */ if (image_target->id == IMAGE_EFI || !is_relocatable (image_target)) layout->kernel_size = layout->end; - - return section_addresses; } char * @@ -1946,16 +1947,14 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + grub_host_to_target16 (e->e_shstrndx) * section_entsize); strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - section_addresses = SUFFIX (locate_sections) (e, kernel_path, - sections, section_entsize, - num_sections, strtab, - layout, - image_target); + section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); + memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); + section_vaddresses = xmalloc (sizeof (*section_vaddresses) * num_sections); + memset (section_vaddresses, 0, sizeof (*section_vaddresses) * num_sections); - section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections); - - for (i = 0; i < num_sections; i++) - section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; + SUFFIX (locate_sections) (e, kernel_path, sections, section_entsize, num_sections, + section_addresses, section_vaddresses, strtab, layout, + image_target); if (!is_relocatable (image_target)) { From 7542af695f338a2b5b86d8cab5cac0d235d47c38 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:27 -0500 Subject: [PATCH 0783/1167] mkimage: refactor a bunch of section data into a struct. This basically moves a bunch of the section information we pass around a lot into a struct, and passes a pointer to a single one of those instead. This shouldn't change the binary file output or the "grub-mkimage -v" output in any way. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 261 +++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 146 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 851339bec..5de34d53c 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -93,6 +93,17 @@ struct fixup_block_list #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) +struct section_metadata +{ + Elf_Half num_sections; + Elf_Shdr *sections; + Elf_Addr *addrs; + Elf_Addr *vaddrs; + Elf_Half section_entsize; + Elf_Shdr *symtab; + const char *strtab; +}; + static int is_relocatable (const struct grub_install_image_target_desc *image_target) { @@ -508,9 +519,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc /* Relocate symbols; note that this function overwrites the symbol table. Return the address of a start symbol. */ static Elf_Addr -SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Shdr *symtab_section, Elf_Addr *section_vaddresses, - Elf_Half section_entsize, Elf_Half num_sections, +SUFFIX (relocate_symbols) (Elf_Ehdr *e, struct section_metadata *smd, void *jumpers, Elf_Addr jumpers_addr, Elf_Addr bss_start, Elf_Addr end, const struct grub_install_image_target_desc *image_target) @@ -520,19 +529,18 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Addr start_address = (Elf_Addr) -1; Elf_Sym *sym; Elf_Word i; - Elf_Shdr *symtab_link_section; + Elf_Shdr *symtab_section; const char *symtab; grub_uint64_t *jptr = jumpers; - symtab_link_section - = (Elf_Shdr *) ((char *) sections - + (grub_target_to_host32 (symtab_section->sh_link) - * section_entsize)); - symtab = (char *) e + grub_target_to_host (symtab_link_section->sh_offset); + symtab_section = (Elf_Shdr *) ((char *) smd->sections + + grub_target_to_host32 (smd->symtab->sh_link) + * smd->section_entsize); + symtab = (char *) e + grub_target_to_host (symtab_section->sh_offset); - symtab_size = grub_target_to_host (symtab_section->sh_size); - sym_size = grub_target_to_host (symtab_section->sh_entsize); - symtab_offset = grub_target_to_host (symtab_section->sh_offset); + symtab_size = grub_target_to_host (smd->symtab->sh_size); + sym_size = grub_target_to_host (smd->symtab->sh_entsize); + symtab_offset = grub_target_to_host (smd->symtab->sh_offset); num_syms = symtab_size / sym_size; for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset); @@ -560,12 +568,12 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, else continue; } - else if (cur_index >= num_sections) + else if (cur_index >= smd->num_sections) grub_util_error ("section %d does not exist", cur_index); else { sym->st_value = (grub_target_to_host (sym->st_value) - + section_vaddresses[cur_index]); + + smd->vaddrs[cur_index]); } if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info) @@ -580,7 +588,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, grub_util_info ("locating %s at 0x%" GRUB_HOST_PRIxLONG_LONG " (0x%" GRUB_HOST_PRIxLONG_LONG ")", name, (unsigned long long) sym->st_value, - (unsigned long long) section_vaddresses[cur_index]); + (unsigned long long) smd->vaddrs[cur_index]); if (start_address == (Elf_Addr)-1) if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) @@ -722,12 +730,8 @@ arm_get_trampoline_size (Elf_Ehdr *e, addresses can be fully resolved. Absolute addresses must be relocated again by a PE32 relocator when loaded. */ static void -SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Addr *section_addresses, - Elf_Half section_entsize, Elf_Half num_sections, - const char *strtab, - char *pe_target, Elf_Addr tramp_off, - Elf_Addr got_off, +SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, + char *pe_target, Elf_Addr tramp_off, Elf_Addr got_off, const struct grub_install_image_target_desc *image_target) { Elf_Half i; @@ -741,33 +745,29 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_uint32_t *tr = (void *) (pe_target + tramp_off); #endif - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd->sections; + i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) if ((s->sh_type == grub_host_to_target32 (SHT_REL)) || (s->sh_type == grub_host_to_target32 (SHT_RELA))) { Elf_Rela *r; Elf_Word rtab_size, r_size, num_rs; Elf_Off rtab_offset; - Elf_Shdr *symtab_section; Elf_Word target_section_index; Elf_Addr target_section_addr; Elf_Shdr *target_section; Elf_Word j; - symtab_section = (Elf_Shdr *) ((char *) sections - + (grub_target_to_host32 (s->sh_link) - * section_entsize)); target_section_index = grub_target_to_host32 (s->sh_info); - target_section_addr = section_addresses[target_section_index]; - target_section = (Elf_Shdr *) ((char *) sections + target_section_addr = smd->addrs[target_section_index]; + target_section = (Elf_Shdr *) ((char *) smd->sections + (target_section_index - * section_entsize)); + * smd->section_entsize)); grub_util_info ("dealing with the relocation section %s for %s", - strtab + grub_target_to_host32 (s->sh_name), - strtab + grub_target_to_host32 (target_section->sh_name)); + smd->strtab + grub_target_to_host32 (s->sh_name), + smd->strtab + grub_target_to_host32 (target_section->sh_name)); rtab_size = grub_target_to_host (s->sh_size); r_size = grub_target_to_host (s->sh_entsize); @@ -788,7 +788,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, target = SUFFIX (get_target_address) (e, target_section, offset, image_target); info = grub_target_to_host (r->r_info); - sym_addr = SUFFIX (get_symbol_address) (e, symtab_section, + sym_addr = SUFFIX (get_symbol_address) (e, smd->symtab, ELF_R_SYM (info), image_target); addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ? @@ -919,8 +919,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Sym *sym; sym = (Elf_Sym *) ((char *) e - + grub_target_to_host (symtab_section->sh_offset) - + ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize)); + + grub_target_to_host (smd->symtab->sh_offset) + + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize)); if (ELF_ST_TYPE (sym->st_info) == STT_FUNC) sym_addr = grub_target_to_host64 (*(grub_uint64_t *) (pe_target + sym->st_value @@ -1105,8 +1105,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - (char *) e), sym_addr); sym = (Elf_Sym *) ((char *) e - + grub_target_to_host (symtab_section->sh_offset) - + ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize)); + + grub_target_to_host (smd->symtab->sh_offset) + + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize)); if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) sym_addr |= 1; if (!(sym_addr & 1)) @@ -1644,9 +1644,7 @@ create_u64_fixups (struct translate_context *ctx, /* Make a .reloc section. */ static void make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, - Elf_Addr *section_vaddresses, Elf_Shdr *sections, - Elf_Half section_entsize, Elf_Half num_sections, - const char *strtab, + struct section_metadata *smd, const struct grub_install_image_target_desc *image_target) { unsigned i; @@ -1655,8 +1653,8 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, translate_reloc_start (&ctx, image_target); - for (i = 0, s = sections; i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd->sections; i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) if ((grub_target_to_host32 (s->sh_type) == SHT_REL) || (grub_target_to_host32 (s->sh_type) == SHT_RELA)) { @@ -1667,14 +1665,14 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Word j; grub_util_info ("translating the relocation section %s", - strtab + grub_le_to_cpu32 (s->sh_name)); + smd->strtab + grub_le_to_cpu32 (s->sh_name)); rtab_size = grub_target_to_host (s->sh_size); r_size = grub_target_to_host (s->sh_entsize); rtab_offset = grub_target_to_host (s->sh_offset); num_rs = rtab_size / r_size; - section_address = section_vaddresses[grub_le_to_cpu32 (s->sh_info)]; + section_address = smd->vaddrs[grub_le_to_cpu32 (s->sh_info)]; for (j = 0, r = (Elf_Rel *) ((char *) e + rtab_offset); j < num_rs; @@ -1761,12 +1759,11 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i static Elf_Addr SUFFIX (put_section) (Elf_Shdr *s, int i, Elf_Addr current_address, - Elf_Addr *section_addresses, - const char *strtab, + struct section_metadata *smd, const struct grub_install_image_target_desc *image_target) { Elf_Word align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); + const char *name = smd->strtab + grub_host_to_target32 (s->sh_name); if (align) current_address = ALIGN_UP (current_address + image_target->vaddr_offset, @@ -1778,8 +1775,8 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, name, (unsigned long long) current_address); if (!is_relocatable (image_target)) current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - section_addresses[i] = current_address; + - image_target->link_addr; + smd->addrs[i] = current_address; current_address += grub_host_to_target_addr (s->sh_size); return current_address; } @@ -1790,9 +1787,7 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, */ static void SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - Elf_Shdr *sections, Elf_Half section_entsize, - Elf_Half num_sections, Elf_Addr *section_addresses, - Elf_Addr *section_vaddresses, const char *strtab, + struct section_metadata *smd, struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { @@ -1804,28 +1799,23 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, if (image_target->elf_target == EM_AARCH64) layout->align = 4096; - layout->kernel_size = 0; - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) - if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) + for (i = 0, s = smd->sections; + i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) + if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) && grub_host_to_target32 (s->sh_addralign) > layout->align) layout->align = grub_host_to_target32 (s->sh_addralign); - /* .text */ - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd->sections; + i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) if (SUFFIX (is_text_section) (s, image_target)) { - layout->kernel_size = SUFFIX (put_section) (s, i, - layout->kernel_size, - section_addresses, - strtab, - image_target); + layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, + smd, image_target); if (!is_relocatable (image_target) && grub_host_to_target_addr (s->sh_addr) != image_target->link_addr) { @@ -1845,15 +1835,12 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, layout->exec_size = layout->kernel_size; /* .data */ - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd->sections; + i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) if (SUFFIX (is_data_section) (s, image_target)) - layout->kernel_size = SUFFIX (put_section) (s, i, - layout->kernel_size, - section_addresses, - strtab, - image_target); + layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, smd, + image_target); #ifdef MKIMAGE_ELF32 if (image_target->elf_target == EM_ARM) @@ -1864,8 +1851,8 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - tramp = arm_get_trampoline_size (e, sections, section_entsize, - num_sections, image_target); + tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize, + smd->num_sections, image_target); layout->tramp_off = layout->kernel_size; layout->kernel_size += ALIGN_UP (tramp, 16); @@ -1876,18 +1863,17 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, layout->end = layout->kernel_size; /* .bss */ - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd->sections; + i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) { if (SUFFIX (is_bss_section) (s, image_target)) - layout->end = SUFFIX (put_section) (s, i, layout->end, - section_addresses, strtab, - image_target); + layout->end = SUFFIX (put_section) (s, i, layout->end, smd, image_target); + /* * This must to be in the last time this function passes through the loop. */ - section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; + smd->vaddrs[i] = smd->addrs[i] + image_target->vaddr_offset; } layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset, @@ -1908,18 +1894,12 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; - const char *strtab; + struct section_metadata smd = { 0, }; Elf_Ehdr *e; - Elf_Shdr *sections; - Elf_Addr *section_addresses; - Elf_Addr *section_vaddresses; int i; Elf_Shdr *s; - Elf_Half num_sections; Elf_Off section_offset; - Elf_Half section_entsize; grub_size_t kernel_size; - Elf_Shdr *symtab_section = 0; grub_memset (layout, 0, sizeof (*layout)); @@ -1934,46 +1914,45 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, grub_util_error ("invalid ELF header"); section_offset = grub_target_to_host (e->e_shoff); - section_entsize = grub_target_to_host16 (e->e_shentsize); - num_sections = grub_target_to_host16 (e->e_shnum); + smd.section_entsize = grub_target_to_host16 (e->e_shentsize); + smd.num_sections = grub_target_to_host16 (e->e_shnum); - if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections) + if (kernel_size < section_offset + + (grub_uint32_t) smd.section_entsize * smd.num_sections) grub_util_error (_("premature end of file %s"), kernel_path); - sections = (Elf_Shdr *) (kernel_img + section_offset); + smd.sections = (Elf_Shdr *) (kernel_img + section_offset); /* Relocate sections then symbols in the virtual address space. */ - s = (Elf_Shdr *) ((char *) sections - + grub_host_to_target16 (e->e_shstrndx) * section_entsize); - strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); + s = (Elf_Shdr *) ((char *) smd.sections + + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize); + smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); - memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); - section_vaddresses = xmalloc (sizeof (*section_vaddresses) * num_sections); - memset (section_vaddresses, 0, sizeof (*section_vaddresses) * num_sections); + smd.addrs = xmalloc (sizeof (*smd.addrs) * smd.num_sections); + memset (smd.addrs, 0, sizeof (*smd.addrs) * smd.num_sections); + smd.vaddrs = xmalloc (sizeof (*smd.vaddrs) * smd.num_sections); + memset (smd.vaddrs, 0, sizeof (*smd.vaddrs) * smd.num_sections); - SUFFIX (locate_sections) (e, kernel_path, sections, section_entsize, num_sections, - section_addresses, section_vaddresses, strtab, layout, - image_target); + SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target); if (!is_relocatable (image_target)) { Elf_Addr current_address = layout->kernel_size; - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd.sections; + i < smd.num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) { Elf_Word sec_align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); + const char *name = smd.strtab + grub_host_to_target32 (s->sh_name); if (sec_align) current_address = ALIGN_UP (current_address + image_target->vaddr_offset, sec_align) - image_target->vaddr_offset; - + grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); @@ -1981,7 +1960,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; - section_vaddresses[i] = current_address + smd.vaddrs[i] = current_address + image_target->vaddr_offset; current_address += grub_host_to_target_addr (s->sh_size); } @@ -2002,16 +1981,16 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (is_relocatable (image_target)) { - symtab_section = NULL; - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + smd.symtab = NULL; + for (i = 0, s = smd.sections; + i < smd.num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) if (s->sh_type == grub_host_to_target32 (SHT_SYMTAB)) { - symtab_section = s; + smd.symtab = s; break; } - if (! symtab_section) + if (! smd.symtab) grub_util_error ("%s", _("no symbol table")); #ifdef MKIMAGE_ELF64 if (image_target->elf_target == EM_IA_64) @@ -2026,7 +2005,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->kernel_size += ALIGN_UP (tramp, 16); layout->ia64jmp_off = layout->kernel_size; - layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, + layout->ia64jmpnum = SUFFIX (count_funcs) (e, smd.symtab, image_target); layout->kernel_size += 16 * layout->ia64jmpnum; @@ -2057,31 +2036,19 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (is_relocatable (image_target)) { - layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, - section_vaddresses, section_entsize, - num_sections, - (char *) out_img + layout->ia64jmp_off, - layout->ia64jmp_off - + image_target->vaddr_offset, - layout->bss_start, - layout->end, - image_target); + layout->start_address = SUFFIX (relocate_symbols) (e, &smd, + (char *) out_img + layout->ia64jmp_off, + layout->ia64jmp_off + image_target->vaddr_offset, + layout->bss_start, layout->end, image_target); + if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); - /* Resolve addresses in the virtual address space. */ - SUFFIX (relocate_addresses) (e, sections, section_addresses, - section_entsize, - num_sections, strtab, - out_img, layout->tramp_off, - layout->got_off, - image_target); + /* Resolve addrs in the virtual address space. */ + SUFFIX (relocate_addrs) (e, &smd, out_img, layout->tramp_off, + layout->got_off, image_target); - make_reloc_section (e, layout, - section_vaddresses, sections, - section_entsize, num_sections, - strtab, - image_target); + make_reloc_section (e, layout, &smd, image_target); if (image_target->id != IMAGE_EFI) { out_img = xrealloc (out_img, layout->kernel_size + total_module_size @@ -2093,9 +2060,9 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, } } - for (i = 0, s = sections; - i < num_sections; - i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + for (i = 0, s = smd.sections; + i < smd.num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) if (SUFFIX (is_data_section) (s, image_target) /* Explicitly initialize BSS when producing PE32 to avoid a bug in EFI implementations. @@ -2106,17 +2073,19 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, || SUFFIX (is_text_section) (s, image_target)) { if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) - memset (out_img + section_addresses[i], 0, + memset (out_img + smd.addrs[i], 0, grub_host_to_target_addr (s->sh_size)); else - memcpy (out_img + section_addresses[i], + memcpy (out_img + smd.addrs[i], kernel_img + grub_host_to_target_addr (s->sh_offset), grub_host_to_target_addr (s->sh_size)); } free (kernel_img); - free (section_vaddresses); - free (section_addresses); + free (smd.vaddrs); + smd.vaddrs = NULL; + free (smd.addrs); + smd.addrs = NULL; return out_img; } From ebc825b5491185b39ecd24b1674a76f60492dc60 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:28 -0500 Subject: [PATCH 0784/1167] mkimage: avoid copying relocations for sections that won't be copied. Some versions of gcc include a plugin called "annobin", and in some build systems this is enabled by default. This plugin creates special ELF note sections to track which ABI-breaking features are used by a binary, as well as a series of relocations to annotate where. If grub is compiled with this feature, then when grub-mkimage translates the binary to another file format which does not strongly associate relocation data with sections (i.e. when platform is *-efi), these relocations appear to be against the .text section rather than the original note section. When the binary is loaded by the PE runtime loader, hilarity ensues. This issue is not necessarily limited to the annobin, but could arise any time there are relocations in sections that are not represented in grub-mkimage's output. This patch seeks to avoid this issue by only including relocations that refer to sections which will be included in the final binary. As an aside, this should also obviate the need to avoid -funwind-tables, -fasynchronous-unwind-tables, and any sections similar to .eh_frame in the future. I've tested it on x86-64-efi with the following gcc command line options (as recorded by -grecord-gcc-flags), but I still need to test the result on some other platforms that have been problematic in the past (especially ARM Aarch64) before I feel comfortable making changes to the configure.ac bits: GNU C11 7.2.1 20180116 (Red Hat 7.2.1-7) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -mno-stack-arg-probe -mcmodel=large -mno-red-zone -m64 -mtune=generic -march=x86-64 -g3 -Os -freg-struct-return -fno-stack-protector -ffreestanding -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -fstack-clash-protection -fno-ident -fplugin=annobin Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 80 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 5de34d53c..11d05d7a8 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -725,6 +725,12 @@ arm_get_trampoline_size (Elf_Ehdr *e, } #endif +static int +SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target); +static int +SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target, + struct section_metadata *smd); + /* Deal with relocation information. This function relocates addresses within the virtual address space starting from 0. So only relative addresses can be fully resolved. Absolute addresses must be relocated @@ -759,6 +765,14 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, Elf_Shdr *target_section; Elf_Word j; + if (!SUFFIX (is_kept_section) (s, image_target) && + !SUFFIX (is_kept_reloc_section) (s, image_target, smd)) + { + grub_util_info ("not translating relocations for omitted section %s", + smd->strtab + grub_le_to_cpu32 (s->sh_name)); + continue; + } + target_section_index = grub_target_to_host32 (s->sh_info); target_section_addr = smd->addrs[target_section_index]; target_section = (Elf_Shdr *) ((char *) smd->sections @@ -1664,6 +1678,13 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Addr section_address; Elf_Word j; + if (!SUFFIX (is_kept_reloc_section) (s, image_target, smd)) + { + grub_util_info ("not translating the skipped relocation section %s", + smd->strtab + grub_le_to_cpu32 (s->sh_name)); + continue; + } + grub_util_info ("translating the relocation section %s", smd->strtab + grub_le_to_cpu32 (s->sh_name)); @@ -1739,6 +1760,56 @@ SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_des == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS); } +/* Determine if a section is going to be in the final output */ +static int +SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) +{ + /* We keep .text and .data */ + if (SUFFIX (is_text_section) (s, image_target) + || SUFFIX (is_data_section) (s, image_target)) + return 1; + + /* + * And we keep .bss if we're producing PE binaries or the target doesn't + * have a relocating loader. Platforms other than EFI and U-boot shouldn't + * have .bss in their binaries as we build with -Wl,-Ttext. + */ + if (SUFFIX (is_bss_section) (s, image_target) + && (image_target->id == IMAGE_EFI || !is_relocatable (image_target))) + return 1; + + /* Otherwise this is not a section we're keeping in the final output. */ + return 0; +} + +static int +SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target, + struct section_metadata *smd) +{ + int i; + int r = 0; + const char *name = smd->strtab + grub_host_to_target32 (s->sh_name); + + if (!strncmp (name, ".rela.", 6)) + name += 5; + else if (!strncmp (name, ".rel.", 5)) + name += 4; + else + return 1; + + for (i = 0, s = smd->sections; i < smd->num_sections; + i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) + { + const char *sname = smd->strtab + grub_host_to_target32 (s->sh_name); + if (strcmp (sname, name)) + continue; + + return SUFFIX (is_kept_section) (s, image_target); + } + + return r; +} + /* Return if the ELF header is valid. */ static int SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_image_target_desc *image_target) @@ -2063,14 +2134,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, for (i = 0, s = smd.sections; i < smd.num_sections; i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) - if (SUFFIX (is_data_section) (s, image_target) - /* Explicitly initialize BSS - when producing PE32 to avoid a bug in EFI implementations. - Platforms other than EFI and U-boot shouldn't have .bss in - their binaries as we build with -Wl,-Ttext. - */ - || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id == IMAGE_EFI || !is_relocatable (image_target))) - || SUFFIX (is_text_section) (s, image_target)) + if (SUFFIX (is_kept_section) (s, image_target)) { if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) memset (out_img + smd.addrs[i], 0, From 413f1e13e69e1df130e9f39684fb7c0c216e5035 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 21 Feb 2018 15:20:29 -0500 Subject: [PATCH 0785/1167] .mod files: Strip annobin annotations and .eh_frame, and their relocations This way debuginfo built from the .module will still include this information, but the final result won't have the data we don't actually need in the modules, either on-disk, loaded at runtime, or in prebuilt images. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- grub-core/genmod.sh.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 3de06ee01..1250589b3 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -58,6 +58,10 @@ if test x@TARGET_APPLE_LINKER@ != x1; then -K grub_mod_init -K grub_mod_fini \ -K _grub_mod_init -K _grub_mod_fini \ -R .note.gnu.gold-version -R .note.GNU-stack \ + -R .gnu.build.attributes \ + -R .rel.gnu.build.attributes \ + -R .rela.gnu.build.attributes \ + -R .eh_frame -R .rela.eh_frame -R .rel.eh_frame \ -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1 fi if ! test -z "${TARGET_OBJ2ELF}"; then From 25b2b22d5457b21ccd764c4e5af6ce37ba25b975 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Thu, 1 Mar 2018 23:34:53 +0100 Subject: [PATCH 0786/1167] ieee1275: Fix crash in of_path_of_nvme when of_path is empty The of_path_of_nvme function (commit 2391d57, ieee1275: add nvme support within ofpath) introduced a functional regression: On systems which are not based on Open Firmware but have at least one NVME device, find_obppath will return NULL and thus trying to append the disk name to of_path will result in a crash. The proper behavior of of_path_of_nvme is, however, to just return NULL in such cases, like other users of find_obppath, such as of_path_of_scsi. Signed-off-by: John Paul Adrian Glaubitz Reviewed-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 1c30e7233..61806212e 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -389,8 +389,11 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)), } of_path = find_obppath (sysfs_path); + + if (of_path) + strcat (of_path, disk); + free (sysfs_path); - strcat (of_path, disk); return of_path; } From f35826423ed9e7618696c382e062de60bb655569 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 1 Mar 2018 19:25:09 -0800 Subject: [PATCH 0787/1167] sparc64: Limit nvme of_path_of_nvme to just SPARC Limit NVMe of_path_of_nvme to just SPARC hardware for now. It has been found that non-Open Firmware hardware platforms can some how access this function. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/ofpath.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 61806212e..a6153d359 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -350,6 +350,7 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi return ret; } +#ifdef __sparc__ static char * of_path_of_nvme(const char *sys_devname __attribute__((unused)), const char *device, @@ -396,6 +397,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)), free (sysfs_path); return of_path; } +#endif static int vendor_is_ATA(const char *path) @@ -728,9 +730,11 @@ grub_util_devname_to_ofpath (const char *sys_devname) /* All the models I've seen have a devalias "floppy". New models have no floppy at all. */ ofpath = xstrdup ("floppy"); +#ifdef __sparc__ else if (device[0] == 'n' && device[1] == 'v' && device[2] == 'm' && device[3] == 'e') ofpath = of_path_of_nvme (name_buf, device, devnode, devicenode); +#endif else { grub_util_warn (_("unknown device type %s"), device); From 6003eb2feabdae1a79b496c3d010b6d1363f1fac Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:14 -0800 Subject: [PATCH 0788/1167] ieee1275: decode-unit command for 4 addr cell devs decode-unit ( addr len -- phys.lo ... phys.hi ) Convert text unit-string to physical address. Convert unit-string, the text string representation, to phys.lo ... phys.hi, the numerical representation of a physical address within the address space defined by this device node. The number of cells in the list phys.lo ... phys.hi is determined by the value of the #address-cells property of this node. This function is for devices with #address-cells == 4 Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/ieee1275.c | 41 ++++++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 7 ++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index 98217029f..b0ac6f9f9 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -482,6 +482,47 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) return 0; } +int +grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle, + void *addr, grub_size_t size, + grub_uint32_t *phy_lo, grub_uint32_t *phy_hi, + grub_uint32_t *lun_lo, grub_uint32_t *lun_hi) +{ + struct decode_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t addr; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t tgt_h; + grub_ieee1275_cell_t tgt_l; + grub_ieee1275_cell_t lun_h; + grub_ieee1275_cell_t lun_l; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 5); + args.method = (grub_ieee1275_cell_t) "decode-unit"; + args.ihandle = ihandle; + args.size = size; + args.addr = (grub_ieee1275_cell_t) addr; + args.catch_result = 1; + + if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result)) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, "decode-unit failed\n"); + return -1; + } + + *phy_lo = args.tgt_l; + *phy_hi = args.tgt_h; + *lun_lo = args.lun_l; + *lun_hi = args.lun_h; + return 0; +} + int grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, grub_addr_t *result) diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 8e4251303..534406458 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -210,7 +210,12 @@ int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, int index, int r, int g, int b); int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); - +int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle, + void *addr, grub_size_t size, + grub_uint32_t *phy_lo, + grub_uint32_t *phy_hi, + grub_uint32_t *lun_lo, + grub_uint32_t *lun_hi); grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); From 820c64e4c002090bcd9df10ab79d5851b28ac503 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:15 -0800 Subject: [PATCH 0789/1167] ieee1275: encode-unit command for 4 addr cell devs Convert physical address to text unit-string. Convert phys.lo ... phys-high, the numerical representation, to unit-string, the text string representation of a physical address within the address space defined by this device node. The number of cells in the list phys.lo ... phys.hi is determined by the value of the #address-cells property of this node. This function is for devices with #address-cells == 4 Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/ieee1275.c | 45 ++++++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 6 ++++ 2 files changed, 51 insertions(+) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index b0ac6f9f9..41503ead0 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -19,6 +19,7 @@ #include #include +#include #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_cell_t) -1) #define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0) @@ -523,6 +524,50 @@ grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle, return 0; } +char * +grub_ieee1275_encode_uint4 (grub_ieee1275_ihandle_t ihandle, + grub_uint32_t phy_lo, grub_uint32_t phy_hi, + grub_uint32_t lun_lo, grub_uint32_t lun_hi, + grub_size_t *size) +{ + char *addr; + struct encode_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t tgt_h; + grub_ieee1275_cell_t tgt_l; + grub_ieee1275_cell_t lun_h; + grub_ieee1275_cell_t lun_l; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t size; + grub_ieee1275_cell_t addr; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 3); + args.method = (grub_ieee1275_cell_t) "encode-unit"; + args.ihandle = ihandle; + + args.tgt_l = phy_lo; + args.tgt_h = phy_hi; + args.lun_l = lun_lo; + args.lun_h = lun_hi; + args.catch_result = 1; + + if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result)) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, "encode-unit failed\n"); + return 0; + } + + addr = (void *)args.addr; + *size = args.size; + addr = grub_strdup ((char *)args.addr); + return addr; +} + int grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, grub_addr_t *result) diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 534406458..c93a97e69 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -216,6 +216,12 @@ int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle, grub_uint32_t *phy_hi, grub_uint32_t *lun_lo, grub_uint32_t *lun_hi); +char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle, + grub_uint32_t phy_lo, + grub_uint32_t phy_hi, + grub_uint32_t lun_lo, + grub_uint32_t lun_hi, + grub_size_t *size); grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); From f02037afe363f31218b4e0c63ef3a1176f51c232 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:16 -0800 Subject: [PATCH 0790/1167] ieee1275: set-address bus specific method IEEE 1275-1994 Standard for Boot (Initialization Configuration) Firmware: Core Requirements and Practices E.3.2.2 Bus-specific methods for bus nodes A package implementing the scsi-2 device type shall implement the following bus-specific method: set-address ( unit# target# -- ) Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which subsequent commands apply. This function is for devices with #address-cells == 2 Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/ieee1275.c | 40 ++++++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 3 +++ 2 files changed, 43 insertions(+) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index 41503ead0..497f170fb 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -693,3 +693,43 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs) *msecs = args.msecs; return 0; } + +int +grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle, + grub_uint32_t target, grub_uint32_t lun) +{ + struct set_address + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t tgt; + grub_ieee1275_cell_t lun; + grub_ieee1275_cell_t catch_result; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 1); + + /* + * IEEE 1275-1994 Standard for Boot (Initialization Configuration) + * Firmware: Core Requirements and Practices + * E.3.2.2 Bus-specific methods for bus nodes + * + * A package implementing the scsi-2 device type shall implement the + * following bus-specific method: + * + * set-address ( unit# target# -- ) + * Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which + * subsequent commands apply. + */ + args.method = (grub_ieee1275_cell_t) "set-address"; + args.ihandle = ihandle; + args.tgt = target; + args.lun = lun; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + return args.catch_result; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index c93a97e69..55e920e81 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -210,6 +210,9 @@ int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, int index, int r, int g, int b); int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); +int EXPORT_FUNC(grub_ieee1275_set_address) (grub_ieee1275_ihandle_t ihandle, + grub_uint32_t target, + grub_uint32_t lun); int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle, void *addr, grub_size_t size, grub_uint32_t *phy_lo, From c422bb60193512663c4854ee1ac6c1217f5e3178 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 5 Mar 2018 15:11:18 +0100 Subject: [PATCH 0791/1167] ieee1275: no-data-command bus specific method IEEE 1275-1994 Standard for Boot (Initialization Configuration) Firmware: Core Requirements and Practices E.3.2.2 Bus-specific methods for bus nodes A package implementing the scsi-2 device type shall implement the following bus-specific method: no-data-command ( cmd-addr -- error? ) Executes a simple SCSI command, automatically retrying under certain conditions. cmd-addr is the address of a 6-byte command buffer containing an SCSI command that does not have a data transfer phase. Executes the command, retrying indefinitely with the same retry criteria as retry-command. error? is nonzero if an error occurred, zero otherwise. NOTE no-data-command is a convenience function. It provides no capabilities that are not present in retry-command, but for those commands that meet its restrictions, it is easier to use. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/ieee1275.c | 51 ++++++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 3 ++ 2 files changed, 54 insertions(+) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index 497f170fb..cd2dead83 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -733,3 +733,54 @@ grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle, return args.catch_result; } + +int +grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle, + const void *cmd_addr, grub_ssize_t *result) +{ + struct set_address + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t cmd_addr; + grub_ieee1275_cell_t error; + grub_ieee1275_cell_t catch_result; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2); + + /* + * IEEE 1275-1994 Standard for Boot (Initialization Configuration) + * Firmware: Core Requirements and Practices + * + * E.3.2.2 Bus-specific methods for bus nodes + * + * A package implementing the scsi-2 device type shall implement the + * following bus-specific method: + * + * no-data-command ( cmd-addr -- error? ) + * Executes a simple SCSI command, automatically retrying under + * certain conditions. cmd-addr is the address of a 6-byte command buffer + * containing an SCSI command that does not have a data transfer phase. + * Executes the command, retrying indefinitely with the same retry criteria + * as retry-command. + * + * error? is nonzero if an error occurred, zero otherwise. + * NOTE no-data-command is a convenience function. It provides + * no capabilities that are not present in retry-command, but for + * those commands that meet its restrictions, it is easier to use. + */ + args.method = (grub_ieee1275_cell_t) "no-data-command"; + args.ihandle = ihandle; + args.cmd_addr = (grub_ieee1275_cell_t) cmd_addr; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + return -1; + + if (result) + *result = args.error; + + return args.catch_result; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 55e920e81..6dfb57b8b 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -213,6 +213,9 @@ int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); int EXPORT_FUNC(grub_ieee1275_set_address) (grub_ieee1275_ihandle_t ihandle, grub_uint32_t target, grub_uint32_t lun); +int EXPORT_FUNC(grub_ieee1275_no_data_command) (grub_ieee1275_ihandle_t ihandle, + const void *cmd_addr, + grub_ssize_t *result); int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle, void *addr, grub_size_t size, grub_uint32_t *phy_lo, From ad6d8f5063a272e2f1e4857751db70058b977239 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:18 -0800 Subject: [PATCH 0792/1167] ieee1275: block-size deblocker support method IEEE Std 1275-1994 Standard for Boot (Initialization Configuration) Firmware: Core Requirements and Practices 3.8.3 deblocker support package Any package that uses the "deblocker" support package must define the following method, which the deblocker uses as a low-level interface to the device block-size ( -- block-len ) Return "granularity" for accesses to this device. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/ieee1275.c | 23 +++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 1 + 2 files changed, 24 insertions(+) diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index cd2dead83..86f81a3c4 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -784,3 +784,26 @@ grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle, return args.catch_result; } + +int +grub_ieee1275_get_block_size (grub_ieee1275_ihandle_t ihandle) +{ + struct size_args_ieee1275 + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t result; + grub_ieee1275_cell_t size; + } args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2); + args.method = (grub_ieee1275_cell_t) "block-size"; + args.ihandle = ihandle; + args.result = 1; + + if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) + return 0; + + return args.size; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 6dfb57b8b..d0dc2746e 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -228,6 +228,7 @@ char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle, grub_uint32_t lun_lo, grub_uint32_t lun_hi, grub_size_t *size); +int EXPORT_FUNC(grub_ieee1275_get_block_size) (grub_ieee1275_ihandle_t ihandle); grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); From ab4c93cb4bb443620e141cc70f274b89a51a1d05 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:19 -0800 Subject: [PATCH 0793/1167] sparc64: #blocks disk node method Return the number of blocks of storage associated with the device or instance. Where a "block" is a unit of storage consisting of the number of bytes returned by the package's "block-size" method. If the size cannot be determined, the #blocks method returns the maximum unsigned integer (which, because of Open Firmware's assumption of two's complement arithmetic, is equivalent to the signed number -1). If the number of blocks exceeds the range of an unsigned number, return 0 to alert the caller to try the #blocks64 command. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/sparc64/ieee1275/ieee1275.c | 31 ++++++++++++++++++++++ include/grub/sparc64/ieee1275/ieee1275.h | 1 + 2 files changed, 32 insertions(+) diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c index 53be692c3..67933a45b 100644 --- a/grub-core/kern/sparc64/ieee1275/ieee1275.c +++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c @@ -89,3 +89,34 @@ grub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size, return args.catch_result; } + +grub_uint64_t +grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle) +{ + struct nblocks_args_ieee1275 + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t blocks; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2); + args.method = (grub_ieee1275_cell_t) "#blocks"; + args.ihandle = ihandle; + args.catch_result = 1; + + if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0)) + return -1; + + /* + * If the number of blocks exceeds the range of an unsigned number, + * return 0 to alert the caller to try the #blocks64 command. + */ + if (args.blocks >= 0xffffffffULL) + return 0; + + return args.blocks; +} diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h index 32c77f80f..2ddf44d41 100644 --- a/include/grub/sparc64/ieee1275/ieee1275.h +++ b/include/grub/sparc64/ieee1275/ieee1275.h @@ -42,6 +42,7 @@ extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr, extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr, grub_size_t size, grub_uint32_t align); +extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks) (grub_uint32_t ihandle); extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack); From 599efeb6220d01e0b9788ba796849f945ec0d4c1 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Feb 2018 17:34:20 -0800 Subject: [PATCH 0794/1167] sparc64: #blocks64 disk node method Return the 64bit number of blocks of storage associated with the device or instance. Where a "block" is a unit of storage consisting of the number of bytes returned by the package's "block-size" method. If the size cannot be determined, or if the number of blocks exceeds the range return -1. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/sparc64/ieee1275/ieee1275.c | 25 ++++++++++++++++++++++ include/grub/sparc64/ieee1275/ieee1275.h | 1 + 2 files changed, 26 insertions(+) diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c index 67933a45b..5a59aaf06 100644 --- a/grub-core/kern/sparc64/ieee1275/ieee1275.c +++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c @@ -120,3 +120,28 @@ grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle) return args.blocks; } + +grub_uint64_t +grub_ieee1275_num_blocks64 (grub_ieee1275_ihandle_t ihandle) +{ + struct nblocks_args_ieee1275 + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t hi_blocks; + grub_ieee1275_cell_t lo_blocks; + } + args; + + INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); + args.method = (grub_ieee1275_cell_t) "#blocks64"; + args.ihandle = ihandle; + args.catch_result = 1; + + if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0)) + return -1; + + return ((args.hi_blocks << 32) | (args.lo_blocks)); +} diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h index 2ddf44d41..4b18468d8 100644 --- a/include/grub/sparc64/ieee1275/ieee1275.h +++ b/include/grub/sparc64/ieee1275/ieee1275.h @@ -43,6 +43,7 @@ extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr, grub_size_t size, grub_uint32_t align); extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks) (grub_uint32_t ihandle); +extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks64) (grub_uint32_t ihandle); extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack); From d73badfd0aa6683212136e8d6ef439070176722b Mon Sep 17 00:00:00 2001 From: dann frazier Date: Fri, 2 Mar 2018 10:02:19 -0700 Subject: [PATCH 0795/1167] Revert "Keep the native terminal active when enabling gfxterm" This can cause an issue where GRUB is trying to display both a text and graphical menu on the display at the same time, resulting in a flickering effect when e.g. scrolling quickly through a menu (LP: #1752767). Revert for now while we look for a better solution for the original issue. This reverts commit 52ef7b23f528ce844716661d586497a177e80d5b. Signed-off-by: dann frazier Reviewed-by: Daniel Kiper --- util/grub.d/00_header.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 8d46fc973..93a90233e 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -221,7 +221,7 @@ case x${GRUB_TERMINAL_OUTPUT} in ;; x*) cat << EOF -terminal_output --append ${GRUB_TERMINAL_OUTPUT} +terminal_output ${GRUB_TERMINAL_OUTPUT} EOF ;; esac From 28b0d19061d66e3633148ac8e44decda914bf266 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 6 Mar 2018 13:38:58 -0800 Subject: [PATCH 0796/1167] mkimage: fix build regression in grub_mkimage_load_image The grub_mkimage_load_image function (commit 7542af6, mkimage: refactor a bunch of section data into a struct.) introduces a build regression on SPARC: cc1: warnings being treated as errors In file included from util/grub-mkimage32.c:23: util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32': util/grub-mkimagexx.c:1968: error: missing initializer util/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections') make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1 Initialize the entire section_metadata structure. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 11d05d7a8..a483c674c 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1965,7 +1965,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; - struct section_metadata smd = { 0, }; + struct section_metadata smd = { 0, 0, 0, 0, 0, 0, 0 }; Elf_Ehdr *e; int i; Elf_Shdr *s; From a698240df0c43278b2d1d7259c8e7a6926c63112 Mon Sep 17 00:00:00 2001 From: "Matthew S. Turnbull" Date: Sat, 24 Feb 2018 17:44:58 -0500 Subject: [PATCH 0797/1167] grub-mkconfig/10_linux: Support multiple early initrd images Add support for multiple, shared, early initrd images. These early images will be loaded in the order declared, and all will be loaded before the initrd image. While many classes of data can be provided by early images, the immediate use case would be for distributions to provide CPU microcode to mitigate the Meltdown and Spectre vulnerabilities. There are two environment variables provided for declaring the early images. * GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare images that are provided by the distribution or installed packages. If undeclared, this will default to a set of common microcode image names. * GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User images will be loaded after the stock images. These separate configurations allow the distribution and user to declare different image sets without clobbering each other. This also makes a minor update to ensure that UUID partition labels stay disabled when no initrd image is found, even if early images are present. This is a continuation of a previous patch published by Christian Hesse in 2016: http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00025.html Down stream Gentoo bug: https://bugs.gentoo.org/645088 Signed-off-by: Robin H. Johnson Signed-off-by: Matthew S. Turnbull Reviewed-by: Daniel Kiper --- docs/grub.texi | 19 +++++++++++++++++++ util/grub-mkconfig.in | 8 ++++++++ util/grub.d/10_linux.in | 33 +++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 137b894fa..65b4bbeda 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1398,6 +1398,25 @@ for all respectively normal entries. The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. +@item GRUB_EARLY_INITRD_LINUX_CUSTOM +@itemx GRUB_EARLY_INITRD_LINUX_STOCK +List of space-separated early initrd images to be loaded from @samp{/boot}. +This is for loading things like CPU microcode, firmware, ACPI tables, crypto +keys, and so on. These early images will be loaded in the order declared, +and all will be loaded before the actual functional initrd image. + +@samp{GRUB_EARLY_INITRD_LINUX_STOCK} is for your distribution to declare +images that are provided by the distribution. It should not be modified +without understanding the consequences. They will be loaded first. + +@samp{GRUB_EARLY_INITRD_LINUX_CUSTOM} is for your custom created images. + +The default stock images are as follows, though they may be overridden by +your distribution: +@example +intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode.cpio +@end example + @item GRUB_DISABLE_LINUX_UUID Normally, @command{grub-mkconfig} will generate menu entries that use universally-unique identifiers (UUIDs) to identify the root filesystem to diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index f8496d28b..35ef583b0 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -147,6 +147,12 @@ if [ x"$GRUB_FS" = xunknown ]; then GRUB_FS="$(stat -f --printf=%T / || echo unknown)" fi +# Provide a default set of stock linux early initrd images. +# Define here so the list can be modified in the sourced config file. +if [ "x${GRUB_EARLY_INITRD_LINUX_STOCK}" = "x" ]; then + GRUB_EARLY_INITRD_LINUX_STOCK="intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode.cpio" +fi + if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi @@ -211,6 +217,8 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_EARLY_INITRD_LINUX_CUSTOM \ + GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \ GRUB_TERMINAL_OUTPUT \ GRUB_SERIAL_COMMAND \ diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index de9044c7f..faedf74e1 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -136,9 +136,13 @@ EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" + initrd_path= + for i in ${initrd}; do + initrd_path="${initrd_path} ${rel_dirname}/${i}" + done sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - initrd ${rel_dirname}/${initrd} + initrd $(echo $initrd_path) EOF fi sed "s/^/$submenu_indentation/" << EOF @@ -188,7 +192,15 @@ while [ "x$list" != "x" ] ; do alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" - initrd= + initrd_early= + for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ + ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do + if test -e "${dirname}/${i}" ; then + initrd_early="${initrd_early} ${i}" + fi + done + + initrd_real= for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ "initrd-${version}" "initramfs-${version}.img" \ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ @@ -198,11 +210,22 @@ while [ "x$list" != "x" ] ; do "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do if test -e "${dirname}/${i}" ; then - initrd="$i" + initrd_real="${i}" break fi done + initrd= + if test -n "${initrd_early}" || test -n "${initrd_real}"; then + initrd="${initrd_early} ${initrd_real}" + + initrd_display= + for i in ${initrd}; do + initrd_display="${initrd_display} ${dirname}/${i}" + done + gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 + fi + config= for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do if test -e "${i}" ; then @@ -216,9 +239,7 @@ while [ "x$list" != "x" ] ; do initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` fi - if test -n "${initrd}" ; then - gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 - elif test -z "${initramfs}" ; then + if test -z "${initramfs}" && test -z "${initrd_real}" ; then # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's # no initrd or builtin initramfs, it can't work here. linux_root_device_thisversion=${GRUB_DEVICE} From c225298038f0e7e7ec2d783776fba880d9965f16 Mon Sep 17 00:00:00 2001 From: "C. Masloch" Date: Thu, 1 Feb 2018 15:51:55 +0100 Subject: [PATCH 0798/1167] chainloader: patch in BPB's sectors_per_track and num_heads These fields must reflect the ROM-BIOS's geometry for CHS-based loaders to correctly load their next stage. Most loaders do not query the ROM-BIOS (Int13.08), relying on the BPB fields to hold the correct values already. Tested with lDebug booted in qemu via grub2's FreeDOS direct loading support, refer to https://bitbucket.org/ecm/ldosboot + https://bitbucket.org/ecm/ldebug (For this test, lDebug's iniload.asm must be assembled with -D_QUERY_GEOMETRY=0 to leave the BPB values provided by grub.) Signed-off-by: C. Masloch Reviewed-by: Daniel Kiper --- grub-core/loader/i386/pc/chainloader.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index 18220b7aa..ef3a322b7 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -86,9 +87,16 @@ grub_chainloader_unload (void) void grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) { - grub_uint32_t part_start = 0; + grub_uint32_t part_start = 0, heads = 0, sectors = 0; if (dev && dev->disk) - part_start = grub_partition_get_start (dev->disk->partition); + { + part_start = grub_partition_get_start (dev->disk->partition); + if (dev->disk->data) + { + heads = ((struct grub_biosdisk_data *)(dev->disk->data))->heads; + sectors = ((struct grub_biosdisk_data *)(dev->disk->data))->sectors; + } + } if (grub_memcmp ((char *) &((struct grub_ntfs_bpb *) bs)->oem_name, "NTFS", 4) == 0) { @@ -127,12 +135,20 @@ grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) { bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start); bpb->version_specific.fat12_or_fat16.num_ph_drive = dl; + if (sectors) + bpb->sectors_per_track = grub_cpu_to_le16 (sectors); + if (heads) + bpb->num_heads = grub_cpu_to_le16 (heads); return; } if (bpb->version_specific.fat32.sectors_per_fat_32) { bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start); bpb->version_specific.fat32.num_ph_drive = dl; + if (sectors) + bpb->sectors_per_track = grub_cpu_to_le16 (sectors); + if (heads) + bpb->num_heads = grub_cpu_to_le16 (heads); return; } break; From e2faabacff9eccb80a75d7e00d810cdc26b5e866 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 8 Mar 2018 20:42:22 -0800 Subject: [PATCH 0799/1167] ieee1275: split up grub_machine_get_bootlocation Split up some of the functionality in grub_machine_get_bootlocation into grub_ieee1275_get_boot_dev. This will allow for code reuse in a follow on patch. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/init.c | 20 ++------------------ grub-core/kern/ieee1275/openfw.c | 27 +++++++++++++++++++++++++++ include/grub/ieee1275/ieee1275.h | 2 ++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 12590225e..62dfb8a3b 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -94,28 +94,12 @@ void grub_machine_get_bootlocation (char **device, char **path) { char *bootpath; - grub_ssize_t bootpath_size; char *filename; char *type; - if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", - &bootpath_size) - || bootpath_size <= 0) - { - /* Should never happen. */ - grub_printf ("/chosen/bootpath property missing!\n"); - return; - } - - bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); + bootpath = grub_ieee1275_get_boot_dev (); if (! bootpath) - { - grub_print_error (); - return; - } - grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, - (grub_size_t) bootpath_size + 1, 0); - bootpath[bootpath_size] = '\0'; + return; /* Transform an OF device path to a GRUB path. */ diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index ddb778340..62929d983 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char *path) return NULL; } +char * +grub_ieee1275_get_boot_dev (void) +{ + char *bootpath; + grub_ssize_t bootpath_size; + + if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", + &bootpath_size) + || bootpath_size <= 0) + { + /* Should never happen. */ + grub_printf ("/chosen/bootpath property missing!\n"); + return NULL; + } + + bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); + if (! bootpath) + { + grub_print_error (); + return NULL; + } + grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, + (grub_size_t) bootpath_size + 1, 0); + bootpath[bootpath_size] = '\0'; + + return bootpath; +} diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index d0dc2746e..8868f3a75 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -253,6 +253,8 @@ void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *al void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, struct grub_ieee1275_devalias *alias); +char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void); + #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) #define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \ From 5ceb55b7a079cdaa61437f652e90bf2d1011ad0e Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Wed, 14 Mar 2018 08:51:17 -0700 Subject: [PATCH 0800/1167] ieee1275: NULL pointer dereference in grub_machine_get_bootlocation() Read from NULL pointer canon in function grub_machine_get_bootlocation(). Function grub_ieee1275_canonicalise_devname() may return NULL. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 62dfb8a3b..0d8ebf58b 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -110,6 +110,8 @@ grub_machine_get_bootlocation (char **device, char **path) char *ptr; dev = grub_ieee1275_get_aliasdevname (bootpath); canon = grub_ieee1275_canonicalise_devname (dev); + if (! canon) + return; ptr = canon + grub_strlen (canon) - 1; while (ptr > canon && (*ptr == ',' || *ptr == ':')) ptr--; From a537d6501871c17a7e09289ab86aeda122138a91 Mon Sep 17 00:00:00 2001 From: "mike.travis@hpe.com" Date: Wed, 28 Mar 2018 11:42:18 -0500 Subject: [PATCH 0801/1167] efi/uga: Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (Link Error Recorvery) because the MMIO memory has not been enabled before attempting access. The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits. Signed-off-by: Mike Travis Reviewed-by: Daniel Kiper --- grub-core/video/efi_uga.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c index 464ede874..044af1d20 100644 --- a/grub-core/video/efi_uga.c +++ b/grub-core/video/efi_uga.c @@ -94,10 +94,19 @@ static int find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) { struct find_framebuf_ctx *ctx = data; - grub_pci_address_t addr; + grub_pci_address_t addr, rcaddr; + grub_uint32_t subclass; addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); - if (grub_pci_read (addr) >> 24 == 0x3) + subclass = (grub_pci_read (addr) >> 16) & 0xffff; + + if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA) + return 0; + + /* Enable MEM address spaces */ + rcaddr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); + grub_pci_write_word (rcaddr, grub_pci_read_word (rcaddr) | GRUB_PCI_COMMAND_MEM_ENABLED); + { int i; From 563b1da6e6ae7af46cc8354cadb5dab416989f0a Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 26 Mar 2018 16:52:34 +0800 Subject: [PATCH 0802/1167] Fix packed-not-aligned error on GCC 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building with GCC 8, there are several errors regarding packed-not-aligned. ./include/grub/gpt_partition.h:79:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned] This patch fixes the build error by cleaning up the ambiguity of placing aligned structure in a packed one. In "struct grub_btrfs_time" and "struct grub_gpt_part_type", the aligned attribute seems to be superfluous, and also has to be packed, to ensure the structure is bit-to-bit mapped to the format laid on disk. I think we could blame to copy and paste error here for the mistake. In "struct efi_variable", we have to use grub_efi_packed_guid_t, as the name suggests. :) Signed-off-by: Michael Chang Tested-by: Michael Chang Tested-by: Paul Menzel Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 2 +- include/grub/efiemu/runtime.h | 2 +- include/grub/gpt_partition.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 4849c1ceb..be195448d 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -175,7 +175,7 @@ struct grub_btrfs_time { grub_int64_t sec; grub_uint32_t nanosec; -} __attribute__ ((aligned (4))); +} GRUB_PACKED; struct grub_btrfs_inode { diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h index 9b6b729f4..36d2dedf4 100644 --- a/include/grub/efiemu/runtime.h +++ b/include/grub/efiemu/runtime.h @@ -29,7 +29,7 @@ struct grub_efiemu_ptv_rel struct efi_variable { - grub_efi_guid_t guid; + grub_efi_packed_guid_t guid; grub_uint32_t namelen; grub_uint32_t size; grub_efi_uint32_t attributes; diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 1b32f6725..9668a68c3 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -28,7 +28,7 @@ struct grub_gpt_part_type grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; -} __attribute__ ((aligned(8))); +} GRUB_PACKED; typedef struct grub_gpt_part_type grub_gpt_part_type_t; #define GRUB_GPT_PARTITION_TYPE_EMPTY \ From 71f9e4ac44142af52c3fc1860436cf9e432bf764 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 29 Mar 2018 16:37:39 +0100 Subject: [PATCH 0803/1167] fs: Add F2FS support "F2FS (Flash-Friendly File System) is flash-friendly file system which was merged into Linux kernel v3.8 in 2013. The motive for F2FS was to build a file system that from the start, takes into account the characteristics of NAND flash memory-based storage devices (such as solid-state disks, eMMC, and SD cards). F2FS was designed on a basis of a log-structured file system approach, which remedies some known issues of the older log structured file systems, such as the snowball effect of wandering trees and high cleaning overhead. In addition, since a NAND-based storage device shows different characteristics according to its internal geometry or flash memory management scheme (such as the Flash Translation Layer or FTL), it supports various parameters not only for configuring on-disk layout, but also for selecting allocation and cleaning algorithm.", quote by https://en.wikipedia.org/wiki/F2FS. The source codes for F2FS are available from: http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git This patch has been integrated in OpenMandriva Lx 3. https://www.openmandriva.org/ Signed-off-by: Jaegeuk Kim Signed-off-by: Pete Batard Signed-off-by: Daniel Kiper Reviewed-by: Daniel Kiper --- Makefile.util.def | 7 + docs/grub.texi | 7 +- grub-core/Makefile.core.def | 5 + grub-core/fs/f2fs.c | 1314 ++++++++++++++++++++++++++++++++++ po/exclude.pot | 1 + tests/f2fs_test.in | 19 + tests/util/grub-fs-tester.in | 10 +- 7 files changed, 1358 insertions(+), 5 deletions(-) create mode 100644 grub-core/fs/f2fs.c create mode 100644 tests/f2fs_test.in diff --git a/Makefile.util.def b/Makefile.util.def index f9caccb97..3180ac880 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -99,6 +99,7 @@ library = { common = grub-core/fs/ext2.c; common = grub-core/fs/fat.c; common = grub-core/fs/exfat.c; + common = grub-core/fs/f2fs.c; common = grub-core/fs/fshelp.c; common = grub-core/fs/hfs.c; common = grub-core/fs/hfsplus.c; @@ -774,6 +775,12 @@ script = { common = tests/xfs_test.in; }; +script = { + testcase; + name = f2fs_test; + common = tests/f2fs_test.in; +}; + script = { testcase; name = nilfs2_test; diff --git a/docs/grub.texi b/docs/grub.texi index 65b4bbeda..0f2ab91fc 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -360,8 +360,9 @@ blocklist notation. The currently supported filesystem types are @dfn{Amiga Fast FileSystem (AFFS)}, @dfn{AtheOS fs}, @dfn{BeFS}, @dfn{BtrFS} (including raid0, raid1, raid10, gzip and lzo), @dfn{cpio} (little- and big-endian bin, odc and newc variants), -@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{exFAT}, @dfn{HFS}, -@dfn{HFS+}, @dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files), +@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, +@dfn{exFAT}, @dfn{F2FS}, @dfn{HFS}, @dfn{HFS+}, +@dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files), @dfn{JFS}, @dfn{Minix fs} (versions 1, 2 and 3), @dfn{nilfs2}, @dfn{NTFS} (including compression), @dfn{ReiserFS}, @dfn{ROMFS}, @dfn{Amiga Smart FileSystem (SFS)}, @dfn{Squash4}, @dfn{tar}, @dfn{UDF}, @@ -5375,7 +5376,7 @@ NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix, minix2, minix3, ROMFS, ReiserFS, XFS, ext2, ext3, ext4, FAT (short names), -RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed +F2FS, RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed to be UTF-8. This might be false on systems configured with legacy charset but as long as the charset used is superset of ASCII you should be able to access ASCII-named files. And it's recommended to configure your system to use diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2c1d62cee..fc4767f19 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1314,6 +1314,11 @@ module = { common = fs/exfat.c; }; +module = { + name = f2fs; + common = fs/f2fs.c; +}; + module = { name = fshelp; common = fs/fshelp.c; diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c new file mode 100644 index 000000000..1cad2615f --- /dev/null +++ b/grub-core/fs/f2fs.c @@ -0,0 +1,1314 @@ +/* + * f2fs.c - Flash-Friendly File System + * + * Written by Jaegeuk Kim + * + * Copyright (C) 2015 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +/* F2FS Magic Number. */ +#define F2FS_SUPER_MAGIC 0xf2f52010 + +#define CHECKSUM_OFFSET 4092 /* Must be aligned 4 bytes. */ +#define U32_CHECKSUM_OFFSET (CHECKSUM_OFFSET >> 2) +#define CRCPOLY_LE 0xedb88320 + +/* Byte-size offset. */ +#define F2FS_SUPER_OFFSET ((grub_disk_addr_t)1024) +#define F2FS_SUPER_OFFSET0 (F2FS_SUPER_OFFSET >> GRUB_DISK_SECTOR_BITS) +#define F2FS_SUPER_OFFSET1 ((F2FS_SUPER_OFFSET + F2FS_BLKSIZE) >> \ + GRUB_DISK_SECTOR_BITS) + +/* 9 bits for 512 bytes. */ +#define F2FS_MIN_LOG_SECTOR_SIZE 9 + +/* Support only 4KB block. */ +#define F2FS_BLK_BITS 12 +#define F2FS_BLKSIZE (1 << F2FS_BLK_BITS) +#define F2FS_BLK_SEC_BITS (F2FS_BLK_BITS - GRUB_DISK_SECTOR_BITS) + +#define VERSION_LEN 256 +#define F2FS_MAX_EXTENSION 64 + +#define CP_COMPACT_SUM_FLAG 0x00000004 +#define CP_UMOUNT_FLAG 0x00000001 + +#define MAX_ACTIVE_LOGS 16 +#define MAX_ACTIVE_NODE_LOGS 8 +#define MAX_ACTIVE_DATA_LOGS 8 +#define NR_CURSEG_DATA_TYPE 3 +#define NR_CURSEG_NODE_TYPE 3 +#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) + +#define ENTRIES_IN_SUM 512 +#define SUMMARY_SIZE 7 +#define SUM_FOOTER_SIZE 5 +#define JENTRY_SIZE (sizeof(struct grub_f2fs_nat_jent)) +#define SUM_ENTRIES_SIZE (SUMMARY_SIZE * ENTRIES_IN_SUM) +#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE - SUM_ENTRIES_SIZE) +#define NAT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) / JENTRY_SIZE) +#define NAT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) % JENTRY_SIZE) + +#define NAT_ENTRY_SIZE (sizeof(struct grub_f2fs_nat_entry)) +#define NAT_ENTRY_PER_BLOCK (F2FS_BLKSIZE / NAT_ENTRY_SIZE) + +#define F2FS_NAME_LEN 255 +#define F2FS_SLOT_LEN 8 +#define NR_DENTRY_IN_BLOCK 214 +#define SIZE_OF_DIR_ENTRY 11 /* By byte. */ +#define BITS_PER_BYTE 8 +#define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \ + BITS_PER_BYTE) +#define SIZE_OF_RESERVED (F2FS_BLKSIZE - \ + ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ + NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP)) + +#define F2FS_INLINE_XATTR_ADDRS 50 /* 200 bytes for inline xattrs. */ +#define DEF_ADDRS_PER_INODE 923 /* Address Pointers in an Inode. */ + +#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block. */ +#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block. */ +#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1) +#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2) +#define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3) +#define NODE_IND2_BLOCK (DEF_ADDRS_PER_INODE + 4) +#define NODE_DIND_BLOCK (DEF_ADDRS_PER_INODE + 5) + +#define MAX_INLINE_DATA (4 * (DEF_ADDRS_PER_INODE - \ + F2FS_INLINE_XATTR_ADDRS - 1)) +#define NR_INLINE_DENTRY (MAX_INLINE_DATA * BITS_PER_BYTE / \ + ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ + BITS_PER_BYTE + 1)) +#define INLINE_DENTRY_BITMAP_SIZE ((NR_INLINE_DENTRY + BITS_PER_BYTE - 1) / \ + BITS_PER_BYTE) +#define INLINE_RESERVED_SIZE (MAX_INLINE_DATA - \ + ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ + NR_INLINE_DENTRY + \ + INLINE_DENTRY_BITMAP_SIZE)) +#define CURSEG_HOT_DATA 0 + +#define CKPT_FLAG_SET(ckpt, f) (ckpt)->ckpt_flags & \ + grub_cpu_to_le32_compile_time (f) + +#define F2FS_INLINE_XATTR 0x01 /* File inline xattr flag. */ +#define F2FS_INLINE_DATA 0x02 /* File inline data flag. */ +#define F2FS_INLINE_DENTRY 0x04 /* File inline dentry flag. */ +#define F2FS_DATA_EXIST 0x08 /* File inline data exist flag. */ +#define F2FS_INLINE_DOTS 0x10 /* File having implicit dot dentries. */ + +#define MAX_VOLUME_NAME 512 + +enum FILE_TYPE +{ + F2FS_FT_UNKNOWN, + F2FS_FT_REG_FILE = 1, + F2FS_FT_DIR = 2, + F2FS_FT_SYMLINK = 7 +}; + +struct grub_f2fs_superblock +{ + grub_uint32_t magic; + grub_uint16_t dummy1[2]; + grub_uint32_t log_sectorsize; + grub_uint32_t log_sectors_per_block; + grub_uint32_t log_blocksize; + grub_uint32_t log_blocks_per_seg; + grub_uint32_t segs_per_sec; + grub_uint32_t secs_per_zone; + grub_uint32_t checksum_offset; + grub_uint8_t dummy2[40]; + grub_uint32_t cp_blkaddr; + grub_uint32_t sit_blkaddr; + grub_uint32_t nat_blkaddr; + grub_uint32_t ssa_blkaddr; + grub_uint32_t main_blkaddr; + grub_uint32_t root_ino; + grub_uint32_t node_ino; + grub_uint32_t meta_ino; + grub_uint8_t uuid[16]; + grub_uint16_t volume_name[MAX_VOLUME_NAME]; + grub_uint32_t extension_count; + grub_uint8_t extension_list[F2FS_MAX_EXTENSION][8]; + grub_uint32_t cp_payload; + grub_uint8_t version[VERSION_LEN]; + grub_uint8_t init_version[VERSION_LEN]; +} GRUB_PACKED; + +struct grub_f2fs_checkpoint +{ + grub_uint64_t checkpoint_ver; + grub_uint64_t user_block_count; + grub_uint64_t valid_block_count; + grub_uint32_t rsvd_segment_count; + grub_uint32_t overprov_segment_count; + grub_uint32_t free_segment_count; + grub_uint32_t cur_node_segno[MAX_ACTIVE_NODE_LOGS]; + grub_uint16_t cur_node_blkoff[MAX_ACTIVE_NODE_LOGS]; + grub_uint32_t cur_data_segno[MAX_ACTIVE_DATA_LOGS]; + grub_uint16_t cur_data_blkoff[MAX_ACTIVE_DATA_LOGS]; + grub_uint32_t ckpt_flags; + grub_uint32_t cp_pack_total_block_count; + grub_uint32_t cp_pack_start_sum; + grub_uint32_t valid_node_count; + grub_uint32_t valid_inode_count; + grub_uint32_t next_free_nid; + grub_uint32_t sit_ver_bitmap_bytesize; + grub_uint32_t nat_ver_bitmap_bytesize; + grub_uint32_t checksum_offset; + grub_uint64_t elapsed_time; + grub_uint8_t alloc_type[MAX_ACTIVE_LOGS]; + grub_uint8_t sit_nat_version_bitmap[3900]; + grub_uint32_t checksum; +} GRUB_PACKED; + +struct grub_f2fs_nat_entry { + grub_uint8_t version; + grub_uint32_t ino; + grub_uint32_t block_addr; +} GRUB_PACKED; + +struct grub_f2fs_nat_jent +{ + grub_uint32_t nid; + struct grub_f2fs_nat_entry ne; +} GRUB_PACKED; + +struct grub_f2fs_nat_journal { + grub_uint16_t n_nats; + struct grub_f2fs_nat_jent entries[NAT_JOURNAL_ENTRIES]; + grub_uint8_t reserved[NAT_JOURNAL_RESERVED]; +} GRUB_PACKED; + +struct grub_f2fs_nat_block { + struct grub_f2fs_nat_entry ne[NAT_ENTRY_PER_BLOCK]; +} GRUB_PACKED; + +struct grub_f2fs_dir_entry +{ + grub_uint32_t hash_code; + grub_uint32_t ino; + grub_uint16_t name_len; + grub_uint8_t file_type; +} GRUB_PACKED; + +struct grub_f2fs_inline_dentry +{ + grub_uint8_t dentry_bitmap[INLINE_DENTRY_BITMAP_SIZE]; + grub_uint8_t reserved[INLINE_RESERVED_SIZE]; + struct grub_f2fs_dir_entry dentry[NR_INLINE_DENTRY]; + grub_uint8_t filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN]; +} GRUB_PACKED; + +struct grub_f2fs_dentry_block { + grub_uint8_t dentry_bitmap[SIZE_OF_DENTRY_BITMAP]; + grub_uint8_t reserved[SIZE_OF_RESERVED]; + struct grub_f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK]; + grub_uint8_t filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; +} GRUB_PACKED; + +struct grub_f2fs_inode +{ + grub_uint16_t i_mode; + grub_uint8_t i_advise; + grub_uint8_t i_inline; + grub_uint32_t i_uid; + grub_uint32_t i_gid; + grub_uint32_t i_links; + grub_uint64_t i_size; + grub_uint64_t i_blocks; + grub_uint64_t i_atime; + grub_uint64_t i_ctime; + grub_uint64_t i_mtime; + grub_uint32_t i_atime_nsec; + grub_uint32_t i_ctime_nsec; + grub_uint32_t i_mtime_nsec; + grub_uint32_t i_generation; + grub_uint32_t i_current_depth; + grub_uint32_t i_xattr_nid; + grub_uint32_t i_flags; + grub_uint32_t i_pino; + grub_uint32_t i_namelen; + grub_uint8_t i_name[F2FS_NAME_LEN]; + grub_uint8_t i_dir_level; + grub_uint8_t i_ext[12]; + grub_uint32_t i_addr[DEF_ADDRS_PER_INODE]; + grub_uint32_t i_nid[5]; +} GRUB_PACKED; + +struct grub_direct_node { + grub_uint32_t addr[ADDRS_PER_BLOCK]; +} GRUB_PACKED; + +struct grub_indirect_node { + grub_uint32_t nid[NIDS_PER_BLOCK]; +} GRUB_PACKED; + +struct grub_f2fs_node +{ + union + { + struct grub_f2fs_inode i; + struct grub_direct_node dn; + struct grub_indirect_node in; + /* Should occupy F2FS_BLKSIZE totally. */ + char buf[F2FS_BLKSIZE - 40]; + }; + grub_uint8_t dummy[40]; +} GRUB_PACKED; + +struct grub_fshelp_node +{ + struct grub_f2fs_data *data; + struct grub_f2fs_node inode; + grub_uint32_t ino; + int inode_read; +}; + +struct grub_f2fs_data +{ + struct grub_f2fs_superblock sblock; + struct grub_f2fs_checkpoint ckpt; + + grub_uint32_t root_ino; + grub_uint32_t blocks_per_seg; + grub_uint32_t cp_blkaddr; + grub_uint32_t nat_blkaddr; + + struct grub_f2fs_nat_journal nat_j; + char *nat_bitmap; + + grub_disk_t disk; + struct grub_f2fs_node *inode; + struct grub_fshelp_node diropen; +}; + +struct grub_f2fs_dir_iter_ctx +{ + struct grub_f2fs_data *data; + grub_fshelp_iterate_dir_hook_t hook; + void *hook_data; + grub_uint8_t *bitmap; + grub_uint8_t (*filename)[F2FS_SLOT_LEN]; + struct grub_f2fs_dir_entry *dentry; + int max; +}; + +struct grub_f2fs_dir_ctx +{ + grub_fs_dir_hook_t hook; + void *hook_data; + struct grub_f2fs_data *data; +}; + +static grub_dl_t my_mod; + +static int +grub_f2fs_test_bit_le (int nr, const grub_uint8_t *addr) +{ + return addr[nr >> 3] & (1 << (nr & 7)); +} + +static char * +get_inline_addr (struct grub_f2fs_inode *inode) +{ + return (char *) &inode->i_addr[1]; +} + +static grub_uint64_t +grub_f2fs_file_size (struct grub_f2fs_inode *inode) +{ + return grub_le_to_cpu64 (inode->i_size); +} + +static grub_uint32_t +start_cp_addr (struct grub_f2fs_data *data) +{ + struct grub_f2fs_checkpoint *ckpt = &data->ckpt; + grub_uint32_t start_addr = data->cp_blkaddr; + + if (!(ckpt->checkpoint_ver & grub_cpu_to_le64_compile_time(1))) + return start_addr + data->blocks_per_seg; + + return start_addr; +} + +static grub_uint32_t +start_sum_block (struct grub_f2fs_data *data) +{ + struct grub_f2fs_checkpoint *ckpt = &data->ckpt; + + return start_cp_addr (data) + grub_le_to_cpu32 (ckpt->cp_pack_start_sum); +} + +static grub_uint32_t +sum_blk_addr (struct grub_f2fs_data *data, int base, int type) +{ + struct grub_f2fs_checkpoint *ckpt = &data->ckpt; + + return start_cp_addr (data) + + grub_le_to_cpu32 (ckpt->cp_pack_total_block_count) - + (base + 1) + type; +} + +static void * +nat_bitmap_ptr (struct grub_f2fs_data *data) +{ + struct grub_f2fs_checkpoint *ckpt = &data->ckpt; + grub_uint32_t offset; + + if (grub_le_to_cpu32 (data->sblock.cp_payload) > 0) + return ckpt->sit_nat_version_bitmap; + + offset = grub_le_to_cpu32 (ckpt->sit_ver_bitmap_bytesize); + + return ckpt->sit_nat_version_bitmap + offset; +} + +static grub_uint32_t +get_node_id (struct grub_f2fs_node *rn, int off, int inode_block) +{ + if (inode_block) + return grub_le_to_cpu32 (rn->i.i_nid[off - NODE_DIR1_BLOCK]); + + return grub_le_to_cpu32 (rn->in.nid[off]); +} + +static grub_err_t +grub_f2fs_block_read (struct grub_f2fs_data *data, grub_uint32_t blkaddr, + void *buf) +{ + return grub_disk_read (data->disk, + ((grub_disk_addr_t)blkaddr) << F2FS_BLK_SEC_BITS, + 0, F2FS_BLKSIZE, buf); +} + +/* CRC32 */ +static grub_uint32_t +grub_f2fs_cal_crc32 (const void *buf, const grub_uint32_t len) +{ + grub_uint32_t crc = F2FS_SUPER_MAGIC; + unsigned char *p = (unsigned char *)buf; + grub_uint32_t tmp = len; + int i; + + while (tmp--) + { + crc ^= *p++; + for (i = 0; i < 8; i++) + crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); + } + + return crc; +} + +static int +grub_f2fs_crc_valid (grub_uint32_t blk_crc, void *buf, const grub_uint32_t len) +{ + grub_uint32_t cal_crc = 0; + + cal_crc = grub_f2fs_cal_crc32 (buf, len); + + return (cal_crc == blk_crc) ? 1 : 0; +} + +static int +grub_f2fs_test_bit (grub_uint32_t nr, const char *p) +{ + int mask; + + p += (nr >> 3); + mask = 1 << (7 - (nr & 0x07)); + + return mask & *p; +} + +static int +grub_f2fs_sanity_check_sb (struct grub_f2fs_superblock *sb) +{ + grub_uint32_t log_sectorsize, log_sectors_per_block; + + if (sb->magic != grub_cpu_to_le32_compile_time (F2FS_SUPER_MAGIC)) + return -1; + + if (sb->log_blocksize != grub_cpu_to_le32_compile_time (F2FS_BLK_BITS)) + return -1; + + log_sectorsize = grub_le_to_cpu32 (sb->log_sectorsize); + log_sectors_per_block = grub_le_to_cpu32 (sb->log_sectors_per_block); + + if (log_sectorsize > F2FS_BLK_BITS) + return -1; + + if (log_sectorsize < F2FS_MIN_LOG_SECTOR_SIZE) + return -1; + + if (log_sectors_per_block + log_sectorsize != F2FS_BLK_BITS) + return -1; + + return 0; +} + +static int +grub_f2fs_read_sb (struct grub_f2fs_data *data, grub_disk_addr_t offset) +{ + grub_disk_t disk = data->disk; + grub_err_t err; + + /* Read first super block. */ + err = grub_disk_read (disk, offset, 0, sizeof (data->sblock), &data->sblock); + if (err) + return -1; + + return grub_f2fs_sanity_check_sb (&data->sblock); +} + +static void * +validate_checkpoint (struct grub_f2fs_data *data, grub_uint32_t cp_addr, + grub_uint64_t *version) +{ + grub_uint32_t *cp_page_1, *cp_page_2; + struct grub_f2fs_checkpoint *cp_block; + grub_uint64_t cur_version = 0, pre_version = 0; + grub_uint32_t crc = 0; + grub_uint32_t crc_offset; + grub_err_t err; + + /* Read the 1st cp block in this CP pack. */ + cp_page_1 = grub_malloc (F2FS_BLKSIZE); + if (!cp_page_1) + return NULL; + + err = grub_f2fs_block_read (data, cp_addr, cp_page_1); + if (err) + goto invalid_cp1; + + cp_block = (struct grub_f2fs_checkpoint *)cp_page_1; + crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset); + if (crc_offset != CHECKSUM_OFFSET) + goto invalid_cp1; + + crc = grub_le_to_cpu32 (*(cp_page_1 + U32_CHECKSUM_OFFSET)); + if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset)) + goto invalid_cp1; + + pre_version = grub_le_to_cpu64 (cp_block->checkpoint_ver); + + /* Read the 2nd cp block in this CP pack. */ + cp_page_2 = grub_malloc (F2FS_BLKSIZE); + if (!cp_page_2) + goto invalid_cp1; + + cp_addr += grub_le_to_cpu32 (cp_block->cp_pack_total_block_count) - 1; + + err = grub_f2fs_block_read (data, cp_addr, cp_page_2); + if (err) + goto invalid_cp2; + + cp_block = (struct grub_f2fs_checkpoint *)cp_page_2; + crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset); + if (crc_offset != CHECKSUM_OFFSET) + goto invalid_cp2; + + crc = grub_le_to_cpu32 (*(cp_page_2 + U32_CHECKSUM_OFFSET)); + if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset)) + goto invalid_cp2; + + cur_version = grub_le_to_cpu64 (cp_block->checkpoint_ver); + if (cur_version == pre_version) + { + *version = cur_version; + grub_free (cp_page_2); + + return cp_page_1; + } + + invalid_cp2: + grub_free (cp_page_2); + + invalid_cp1: + grub_free (cp_page_1); + + return NULL; +} + +static grub_err_t +grub_f2fs_read_cp (struct grub_f2fs_data *data) +{ + void *cp1, *cp2, *cur_page; + grub_uint64_t cp1_version = 0, cp2_version = 0; + grub_uint64_t cp_start_blk_no; + + /* + * Finding out valid cp block involves read both + * sets (cp pack1 and cp pack 2). + */ + cp_start_blk_no = data->cp_blkaddr; + cp1 = validate_checkpoint (data, cp_start_blk_no, &cp1_version); + if (!cp1 && grub_errno) + return grub_errno; + + /* The second checkpoint pack should start at the next segment. */ + cp_start_blk_no += data->blocks_per_seg; + cp2 = validate_checkpoint (data, cp_start_blk_no, &cp2_version); + if (!cp2 && grub_errno) + { + grub_free (cp1); + return grub_errno; + } + + if (cp1 && cp2) + cur_page = (cp2_version > cp1_version) ? cp2 : cp1; + else if (cp1) + cur_page = cp1; + else if (cp2) + cur_page = cp2; + else + return grub_error (GRUB_ERR_BAD_FS, "no checkpoints"); + + grub_memcpy (&data->ckpt, cur_page, F2FS_BLKSIZE); + + grub_free (cp1); + grub_free (cp2); + + return 0; +} + +static grub_err_t +get_nat_journal (struct grub_f2fs_data *data) +{ + grub_uint32_t block; + char *buf; + grub_err_t err; + + buf = grub_malloc (F2FS_BLKSIZE); + if (!buf) + return grub_errno; + + if (CKPT_FLAG_SET(&data->ckpt, CP_COMPACT_SUM_FLAG)) + block = start_sum_block (data); + else if (CKPT_FLAG_SET (&data->ckpt, CP_UMOUNT_FLAG)) + block = sum_blk_addr (data, NR_CURSEG_TYPE, CURSEG_HOT_DATA); + else + block = sum_blk_addr (data, NR_CURSEG_DATA_TYPE, CURSEG_HOT_DATA); + + err = grub_f2fs_block_read (data, block, buf); + if (err) + goto fail; + + if (CKPT_FLAG_SET (&data->ckpt, CP_COMPACT_SUM_FLAG)) + grub_memcpy (&data->nat_j, buf, SUM_JOURNAL_SIZE); + else + grub_memcpy (&data->nat_j, buf + SUM_ENTRIES_SIZE, SUM_JOURNAL_SIZE); + + fail: + grub_free (buf); + + return err; +} + +static grub_uint32_t +get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid) +{ + grub_uint16_t n = grub_le_to_cpu16 (data->nat_j.n_nats); + grub_uint32_t blkaddr = 0; + grub_uint16_t i; + + for (i = 0; i < n; i++) + { + if (grub_le_to_cpu32 (data->nat_j.entries[i].nid) == nid) + { + blkaddr = grub_le_to_cpu32 (data->nat_j.entries[i].ne.block_addr); + break; + } + } + + return blkaddr; +} + +static grub_uint32_t +get_node_blkaddr (struct grub_f2fs_data *data, grub_uint32_t nid) +{ + struct grub_f2fs_nat_block *nat_block; + grub_uint32_t seg_off, block_off, entry_off, block_addr; + grub_uint32_t blkaddr; + grub_err_t err; + + blkaddr = get_blkaddr_from_nat_journal (data, nid); + if (blkaddr) + return blkaddr; + + nat_block = grub_malloc (F2FS_BLKSIZE); + if (!nat_block) + return 0; + + block_off = nid / NAT_ENTRY_PER_BLOCK; + entry_off = nid % NAT_ENTRY_PER_BLOCK; + + seg_off = block_off / data->blocks_per_seg; + block_addr = data->nat_blkaddr + + ((seg_off * data->blocks_per_seg) << 1) + + (block_off & (data->blocks_per_seg - 1)); + + if (grub_f2fs_test_bit (block_off, data->nat_bitmap)) + block_addr += data->blocks_per_seg; + + err = grub_f2fs_block_read (data, block_addr, nat_block); + if (err) + { + grub_free (nat_block); + return 0; + } + + blkaddr = grub_le_to_cpu32 (nat_block->ne[entry_off].block_addr); + + grub_free (nat_block); + + return blkaddr; +} + +static int +grub_get_node_path (struct grub_f2fs_inode *inode, grub_uint32_t block, + grub_uint32_t offset[4], grub_uint32_t noffset[4]) +{ + grub_uint32_t direct_blks = ADDRS_PER_BLOCK; + grub_uint32_t dptrs_per_blk = NIDS_PER_BLOCK; + grub_uint32_t indirect_blks = ADDRS_PER_BLOCK * NIDS_PER_BLOCK; + grub_uint32_t dindirect_blks = indirect_blks * NIDS_PER_BLOCK; + grub_uint32_t direct_index = DEF_ADDRS_PER_INODE; + int n = 0; + int level = 0; + + if (inode->i_inline & F2FS_INLINE_XATTR) + direct_index -= F2FS_INLINE_XATTR_ADDRS; + + noffset[0] = 0; + + if (block < direct_index) + { + offset[n] = block; + goto got; + } + + block -= direct_index; + if (block < direct_blks) + { + offset[n++] = NODE_DIR1_BLOCK; + noffset[n] = 1; + offset[n] = block; + level = 1; + goto got; + } + + block -= direct_blks; + if (block < direct_blks) + { + offset[n++] = NODE_DIR2_BLOCK; + noffset[n] = 2; + offset[n] = block; + level = 1; + goto got; + } + + block -= direct_blks; + if (block < indirect_blks) + { + offset[n++] = NODE_IND1_BLOCK; + noffset[n] = 3; + offset[n++] = block / direct_blks; + noffset[n] = 4 + offset[n - 1]; + offset[n] = block % direct_blks; + level = 2; + goto got; + } + + block -= indirect_blks; + if (block < indirect_blks) + { + offset[n++] = NODE_IND2_BLOCK; + noffset[n] = 4 + dptrs_per_blk; + offset[n++] = block / direct_blks; + noffset[n] = 5 + dptrs_per_blk + offset[n - 1]; + offset[n] = block % direct_blks; + level = 2; + goto got; + } + + block -= indirect_blks; + if (block < dindirect_blks) + { + offset[n++] = NODE_DIND_BLOCK; + noffset[n] = 5 + (dptrs_per_blk * 2); + offset[n++] = block / indirect_blks; + noffset[n] = 6 + (dptrs_per_blk * 2) + + offset[n - 1] * (dptrs_per_blk + 1); + offset[n++] = (block / direct_blks) % dptrs_per_blk; + noffset[n] = 7 + (dptrs_per_blk * 2) + + offset[n - 2] * (dptrs_per_blk + 1) + offset[n - 1]; + offset[n] = block % direct_blks; + level = 3; + goto got; + } + + got: + return level; +} + +static grub_err_t +grub_f2fs_read_node (struct grub_f2fs_data *data, + grub_uint32_t nid, struct grub_f2fs_node *np) +{ + grub_uint32_t blkaddr; + + blkaddr = get_node_blkaddr (data, nid); + if (!blkaddr) + return grub_errno; + + return grub_f2fs_block_read (data, blkaddr, np); +} + +static struct grub_f2fs_data * +grub_f2fs_mount (grub_disk_t disk) +{ + struct grub_f2fs_data *data; + grub_err_t err; + + data = grub_malloc (sizeof (*data)); + if (!data) + return NULL; + + data->disk = disk; + + if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET0)) + { + if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET1)) + { + if (grub_errno == GRUB_ERR_NONE) + grub_error (GRUB_ERR_BAD_FS, + "not a F2FS filesystem (no superblock)"); + goto fail; + } + } + + data->root_ino = grub_le_to_cpu32 (data->sblock.root_ino); + data->cp_blkaddr = grub_le_to_cpu32 (data->sblock.cp_blkaddr); + data->nat_blkaddr = grub_le_to_cpu32 (data->sblock.nat_blkaddr); + data->blocks_per_seg = 1 << + grub_le_to_cpu32 (data->sblock.log_blocks_per_seg); + + err = grub_f2fs_read_cp (data); + if (err) + goto fail; + + data->nat_bitmap = nat_bitmap_ptr (data); + + err = get_nat_journal (data); + if (err) + goto fail; + + data->diropen.data = data; + data->diropen.ino = data->root_ino; + data->diropen.inode_read = 1; + data->inode = &data->diropen.inode; + + err = grub_f2fs_read_node (data, data->root_ino, data->inode); + if (err) + goto fail; + + return data; + + fail: + grub_free (data); + + return NULL; +} + +/* Guarantee inline_data was handled by caller. */ +static grub_disk_addr_t +grub_f2fs_get_block (grub_fshelp_node_t node, grub_disk_addr_t block_ofs) +{ + struct grub_f2fs_data *data = node->data; + struct grub_f2fs_inode *inode = &node->inode.i; + grub_uint32_t offset[4], noffset[4], nids[4]; + struct grub_f2fs_node *node_block; + grub_uint32_t block_addr = -1; + int level, i; + + level = grub_get_node_path (inode, block_ofs, offset, noffset); + if (level == 0) + return grub_le_to_cpu32 (inode->i_addr[offset[0]]); + + node_block = grub_malloc (F2FS_BLKSIZE); + if (!node_block) + return -1; + + nids[1] = get_node_id (&node->inode, offset[0], 1); + + /* Get indirect or direct nodes. */ + for (i = 1; i <= level; i++) + { + grub_f2fs_read_node (data, nids[i], node_block); + if (grub_errno) + goto fail; + + if (i < level) + nids[i + 1] = get_node_id (node_block, offset[i], 0); + } + + block_addr = grub_le_to_cpu32 (node_block->dn.addr[offset[level]]); + + fail: + grub_free (node_block); + + return block_addr; +} + +static grub_ssize_t +grub_f2fs_read_file (grub_fshelp_node_t node, + grub_disk_read_hook_t read_hook, void *read_hook_data, + grub_off_t pos, grub_size_t len, char *buf) +{ + struct grub_f2fs_inode *inode = &node->inode.i; + grub_off_t filesize = grub_f2fs_file_size (inode); + char *inline_addr = get_inline_addr (inode); + + if (inode->i_inline & F2FS_INLINE_DATA) + { + if (filesize > MAX_INLINE_DATA) + return -1; + + if (len > filesize - pos) + len = filesize - pos; + + grub_memcpy (buf, inline_addr + pos, len); + return len; + } + + return grub_fshelp_read_file (node->data->disk, node, + read_hook, read_hook_data, + pos, len, buf, grub_f2fs_get_block, + filesize, + F2FS_BLK_SEC_BITS, 0); +} + +static char * +grub_f2fs_read_symlink (grub_fshelp_node_t node) +{ + char *symlink; + struct grub_fshelp_node *diro = node; + grub_uint64_t filesize; + + if (!diro->inode_read) + { + grub_f2fs_read_node (diro->data, diro->ino, &diro->inode); + if (grub_errno) + return 0; + } + + filesize = grub_f2fs_file_size(&diro->inode.i); + + symlink = grub_malloc (filesize + 1); + if (!symlink) + return 0; + + grub_f2fs_read_file (diro, 0, 0, 0, filesize, symlink); + if (grub_errno) + { + grub_free (symlink); + return 0; + } + + symlink[filesize] = '\0'; + + return symlink; +} + +static int +grub_f2fs_check_dentries (struct grub_f2fs_dir_iter_ctx *ctx) +{ + struct grub_fshelp_node *fdiro; + int i; + + for (i = 0; i < ctx->max;) + { + char *filename; + enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN; + enum FILE_TYPE ftype; + int name_len; + int ret; + + if (grub_f2fs_test_bit_le (i, ctx->bitmap) == 0) + { + i++; + continue; + } + + ftype = ctx->dentry[i].file_type; + name_len = grub_le_to_cpu16 (ctx->dentry[i].name_len); + filename = grub_malloc (name_len + 1); + if (!filename) + return 0; + + grub_memcpy (filename, ctx->filename[i], name_len); + filename[name_len] = 0; + + fdiro = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!fdiro) + { + grub_free(filename); + return 0; + } + + if (ftype == F2FS_FT_DIR) + type = GRUB_FSHELP_DIR; + else if (ftype == F2FS_FT_SYMLINK) + type = GRUB_FSHELP_SYMLINK; + else if (ftype == F2FS_FT_REG_FILE) + type = GRUB_FSHELP_REG; + + fdiro->data = ctx->data; + fdiro->ino = grub_le_to_cpu32 (ctx->dentry[i].ino); + fdiro->inode_read = 0; + + ret = ctx->hook (filename, type, fdiro, ctx->hook_data); + grub_free(filename); + if (ret) + return 1; + + i += (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN; + } + + return 0; +} + +static int +grub_f2fs_iterate_inline_dir (struct grub_f2fs_inode *dir, + struct grub_f2fs_dir_iter_ctx *ctx) +{ + struct grub_f2fs_inline_dentry *de_blk; + + de_blk = (struct grub_f2fs_inline_dentry *) get_inline_addr (dir); + + ctx->bitmap = de_blk->dentry_bitmap; + ctx->dentry = de_blk->dentry; + ctx->filename = de_blk->filename; + ctx->max = NR_INLINE_DENTRY; + + return grub_f2fs_check_dentries (ctx); +} + +static int +grub_f2fs_iterate_dir (grub_fshelp_node_t dir, + grub_fshelp_iterate_dir_hook_t hook, void *hook_data) +{ + struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; + struct grub_f2fs_inode *inode; + struct grub_f2fs_dir_iter_ctx ctx = { + .data = diro->data, + .hook = hook, + .hook_data = hook_data + }; + grub_off_t fpos = 0; + + if (!diro->inode_read) + { + grub_f2fs_read_node (diro->data, diro->ino, &diro->inode); + if (grub_errno) + return 0; + } + + inode = &diro->inode.i; + + if (inode->i_inline & F2FS_INLINE_DENTRY) + return grub_f2fs_iterate_inline_dir (inode, &ctx); + + while (fpos < grub_f2fs_file_size (inode)) + { + struct grub_f2fs_dentry_block *de_blk; + char *buf; + int ret; + + buf = grub_zalloc (F2FS_BLKSIZE); + if (!buf) + return 0; + + grub_f2fs_read_file (diro, 0, 0, fpos, F2FS_BLKSIZE, buf); + if (grub_errno) + { + grub_free (buf); + return 0; + } + + de_blk = (struct grub_f2fs_dentry_block *) buf; + + ctx.bitmap = de_blk->dentry_bitmap; + ctx.dentry = de_blk->dentry; + ctx.filename = de_blk->filename; + ctx.max = NR_DENTRY_IN_BLOCK; + + ret = grub_f2fs_check_dentries (&ctx); + grub_free (buf); + if (ret) + return 1; + + fpos += F2FS_BLKSIZE; + } + + return 0; +} + +static int +grub_f2fs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype, + grub_fshelp_node_t node, void *data) +{ + struct grub_f2fs_dir_ctx *ctx = data; + struct grub_dirhook_info info; + + grub_memset (&info, 0, sizeof (info)); + if (!node->inode_read) + { + grub_f2fs_read_node (ctx->data, node->ino, &node->inode); + if (!grub_errno) + node->inode_read = 1; + grub_errno = GRUB_ERR_NONE; + } + if (node->inode_read) + { + info.mtimeset = 1; + info.mtime = grub_le_to_cpu64 (node->inode.i.i_mtime); + } + + info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); + grub_free (node); + + return ctx->hook (filename, &info, ctx->hook_data); +} + +static grub_err_t +grub_f2fs_dir (grub_device_t device, const char *path, + grub_fs_dir_hook_t hook, void *hook_data) +{ + struct grub_f2fs_dir_ctx ctx = { + .hook = hook, + .hook_data = hook_data + }; + struct grub_fshelp_node *fdiro = 0; + + grub_dl_ref (my_mod); + + ctx.data = grub_f2fs_mount (device->disk); + if (!ctx.data) + goto fail; + + grub_fshelp_find_file (path, &ctx.data->diropen, &fdiro, + grub_f2fs_iterate_dir, grub_f2fs_read_symlink, + GRUB_FSHELP_DIR); + if (grub_errno) + goto fail; + + grub_f2fs_iterate_dir (fdiro, grub_f2fs_dir_iter, &ctx); + + fail: + if (fdiro != &ctx.data->diropen) + grub_free (fdiro); + grub_free (ctx.data); + grub_dl_unref (my_mod); + + return grub_errno; +} + +/* Open a file named NAME and initialize FILE. */ +static grub_err_t +grub_f2fs_open (struct grub_file *file, const char *name) +{ + struct grub_f2fs_data *data = NULL; + struct grub_fshelp_node *fdiro = 0; + struct grub_f2fs_inode *inode; + + grub_dl_ref (my_mod); + + data = grub_f2fs_mount (file->device->disk); + if (!data) + goto fail; + + grub_fshelp_find_file (name, &data->diropen, &fdiro, + grub_f2fs_iterate_dir, grub_f2fs_read_symlink, + GRUB_FSHELP_REG); + if (grub_errno) + goto fail; + + if (!fdiro->inode_read) + { + grub_f2fs_read_node (data, fdiro->ino, &fdiro->inode); + if (grub_errno) + goto fail; + } + + grub_memcpy (data->inode, &fdiro->inode, sizeof (*data->inode)); + grub_free (fdiro); + + inode = &(data->inode->i); + file->size = grub_f2fs_file_size (inode); + file->data = data; + file->offset = 0; + + if (inode->i_inline & F2FS_INLINE_DATA && file->size > MAX_INLINE_DATA) + grub_error (GRUB_ERR_BAD_FS, "corrupted inline_data: need fsck"); + + return 0; + + fail: + if (fdiro != &data->diropen) + grub_free (fdiro); + grub_free (data); + + grub_dl_unref (my_mod); + + return grub_errno; +} + +static grub_ssize_t +grub_f2fs_read (grub_file_t file, char *buf, grub_size_t len) +{ + struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data; + + return grub_f2fs_read_file (&data->diropen, + file->read_hook, file->read_hook_data, + file->offset, len, buf); +} + +static grub_err_t +grub_f2fs_close (grub_file_t file) +{ + struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data; + + grub_free (data); + + grub_dl_unref (my_mod); + + return GRUB_ERR_NONE; +} + +static grub_uint8_t * +grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le) +{ + grub_uint16_t in_buf[MAX_VOLUME_NAME]; + grub_uint8_t *out_buf; + int len = 0; + + out_buf = grub_malloc (MAX_VOLUME_NAME * GRUB_MAX_UTF8_PER_UTF16 + 1); + if (!out_buf) + return NULL; + + while (*in_buf_le != 0 && len < MAX_VOLUME_NAME) { + in_buf[len] = grub_le_to_cpu16 (in_buf_le[len]); + len++; + } + + *grub_utf16_to_utf8 (out_buf, in_buf, len) = '\0'; + + return out_buf; +} + +static grub_err_t +grub_f2fs_label (grub_device_t device, char **label) +{ + struct grub_f2fs_data *data; + grub_disk_t disk = device->disk; + + grub_dl_ref (my_mod); + + data = grub_f2fs_mount (disk); + if (data) + *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name); + else + *label = NULL; + + grub_free (data); + grub_dl_unref (my_mod); + + return grub_errno; +} + +static grub_err_t +grub_f2fs_uuid (grub_device_t device, char **uuid) +{ + struct grub_f2fs_data *data; + grub_disk_t disk = device->disk; + + grub_dl_ref (my_mod); + + data = grub_f2fs_mount (disk); + if (data) + { + *uuid = + grub_xasprintf + ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + data->sblock.uuid[0], data->sblock.uuid[1], + data->sblock.uuid[2], data->sblock.uuid[3], + data->sblock.uuid[4], data->sblock.uuid[5], + data->sblock.uuid[6], data->sblock.uuid[7], + data->sblock.uuid[8], data->sblock.uuid[9], + data->sblock.uuid[10], data->sblock.uuid[11], + data->sblock.uuid[12], data->sblock.uuid[13], + data->sblock.uuid[14], data->sblock.uuid[15]); + } + else + *uuid = NULL; + + grub_free (data); + grub_dl_unref (my_mod); + + return grub_errno; +} + +static struct grub_fs grub_f2fs_fs = { + .name = "f2fs", + .dir = grub_f2fs_dir, + .open = grub_f2fs_open, + .read = grub_f2fs_read, + .close = grub_f2fs_close, + .label = grub_f2fs_label, + .uuid = grub_f2fs_uuid, +#ifdef GRUB_UTIL + .reserved_first_sector = 1, + .blocklist_install = 0, +#endif + .next = 0 +}; + +GRUB_MOD_INIT (f2fs) +{ + grub_fs_register (&grub_f2fs_fs); + my_mod = mod; +} + +GRUB_MOD_FINI (f2fs) +{ + grub_fs_unregister (&grub_f2fs_fs); +} diff --git a/po/exclude.pot b/po/exclude.pot index 0a9b215ea..816089c30 100644 --- a/po/exclude.pot +++ b/po/exclude.pot @@ -1214,6 +1214,7 @@ msgstr "" #: grub-core/commands/xnu_uuid.c:75 grub-core/fs/jfs.c:924 #: grub-core/fs/nilfs2.c:1135 +#: grub-core/fs/f2fs.c:1259 #, c-format msgid "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" msgstr "" diff --git a/tests/f2fs_test.in b/tests/f2fs_test.in new file mode 100644 index 000000000..1ea77c826 --- /dev/null +++ b/tests/f2fs_test.in @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +if [ "x$EUID" = "x" ] ; then + EUID=`id -u` +fi + +if [ "$EUID" != 0 ] ; then + exit 77 +fi + +if ! which mkfs.f2fs >/dev/null 2>&1; then + echo "mkfs.f2fs not installed; cannot test f2fs." + exit 77 +fi + + +"@builddir@/grub-fs-tester" f2fs diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 15969d796..26bd57a80 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -172,7 +172,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do xsquash*) MINBLKSIZE=4096 MAXBLKSIZE=1048576;; - xxfs) + xxfs|xf2fs) MINBLKSIZE=$SECSIZE # OS Limitation: GNU/Linux doesn't accept > 4096 MAXBLKSIZE=4096;; @@ -299,6 +299,10 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do x"btrfs"*) FSLABEL="grub_;/testé莭ð¯¦ðŸ˜ÐºÐ¸Ñ€Ð¸Ñ‚i urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoi";; + # FS LIMITATION: f2fs label is at most 512 UTF-16 chars + x"f2fs") + FSLABEL="grub_;/testéäŒä“ä•киритiurewfceniuewruewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoirvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoircreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoiq";; + # FS LIMITATION: exfat is at most 15 UTF-16 chars x"exfat") FSLABEL="géт ;/莭ð¯¦ðŸ˜ÐºÐ¸Ñ€";; @@ -508,7 +512,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do # FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it. # FS LIMITATION: as far as I know those FS don't store their last modification date. x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ - | x"bfs" | x"afs" \ + | x"bfs" | x"afs" | x"f2fs" \ | x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \ | x"minix3" | x"ntfs"* | x"udf" | x"sfs"*) NOFSTIME=y;; @@ -792,6 +796,8 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do MOUNTDEVICE="/dev/mapper/grub_test-testvol" MOUNTFS=ext2 "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}" ;; + xf2fs) + "mkfs.f2fs" -l "$FSLABEL" -q "${LODEVICES[0]}" ;; xnilfs2) "mkfs.nilfs2" -L "$FSLABEL" -b $BLKSIZE -q "${MOUNTDEVICE}" ;; xext2_old) From 9dcac673ed08e874d883c6dc5af2017fb28eb3d5 Mon Sep 17 00:00:00 2001 From: Cao jin Date: Wed, 11 Apr 2018 11:23:10 +0800 Subject: [PATCH 0804/1167] diskboot: Trivial correction on stale comments diskboot.img now is loaded at 0x8000 and is jumped to with 0:0x8000. Signed-off-by: Cao jin Reviewed-by: Daniel Kiper --- grub-core/boot/i386/pc/diskboot.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S index 1ee4cf5b2..c1addc0df 100644 --- a/grub-core/boot/i386/pc/diskboot.S +++ b/grub-core/boot/i386/pc/diskboot.S @@ -37,8 +37,8 @@ start: _start: /* - * _start is loaded at 0x2000 and is jumped to with - * CS:IP 0:0x2000 in kernel. + * _start is loaded at 0x8000 and is jumped to with + * CS:IP 0:0x8000 in kernel. */ /* From 3d8439da8c9a4acf9bc1c41b364ec6e1680ef052 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 13 Apr 2018 23:36:49 +0200 Subject: [PATCH 0805/1167] grub-install: Locale depends on nls With --disable-nls no locales exist. Avoid runtime error by moving code that copies locales into its own function. Return early in case nls was disabled. That way the compiler will throw away unreachable code, no need to put preprocessor conditionals everywhere to avoid warnings about unused code. Fix memleak by freeing srcf and dstf. Convert tabs to spaces in moved code. Signed-off-by: Olaf Hering Reviewed-by: Daniel Kiper --- util/grub-install-common.c | 106 ++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 9e3e358c9..0a2e24a79 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -592,6 +592,7 @@ copy_all (const char *srcd, grub_util_fd_closedir (d); } +#if !(defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS) static const char * get_localedir (void) { @@ -646,6 +647,59 @@ copy_locales (const char *dstd) } grub_util_fd_closedir (d); } +#endif + +static void +grub_install_copy_nls(const char *src __attribute__ ((unused)), + const char *dst __attribute__ ((unused))) +{ +#if !(defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS) + char *dst_locale; + + dst_locale = grub_util_path_concat (2, dst, "locale"); + grub_install_mkdir_p (dst_locale); + clean_grub_dir (dst_locale); + + if (install_locales.is_default) + { + char *srcd = grub_util_path_concat (2, src, "po"); + copy_by_ext (srcd, dst_locale, ".mo", 0); + copy_locales (dst_locale); + free (srcd); + } + else + { + size_t i; + const char *locale_dir = get_localedir (); + + for (i = 0; i < install_locales.n_entries; i++) + { + char *srcf = grub_util_path_concat_ext (3, src, "po", + install_locales.entries[i], + ".mo"); + char *dstf = grub_util_path_concat_ext (2, dst_locale, + install_locales.entries[i], + ".mo"); + if (grub_install_compress_file (srcf, dstf, 0)) + { + free (srcf); + free (dstf); + continue; + } + free (srcf); + srcf = grub_util_path_concat_ext (4, locale_dir, + install_locales.entries[i], + "LC_MESSAGES", PACKAGE, ".mo"); + if (grub_install_compress_file (srcf, dstf, 0) == 0) + grub_util_error (_("cannot find locale `%s'"), + install_locales.entries[i]); + free (srcf); + free (dstf); + } + } + free (dst_locale); +#endif +} static struct { @@ -731,7 +785,7 @@ grub_install_copy_files (const char *src, const char *dst, enum grub_install_plat platid) { - char *dst_platform, *dst_locale, *dst_fonts; + char *dst_platform, *dst_fonts; const char *pkgdatadir = grub_util_get_pkgdatadir (); char *themes_dir; @@ -742,13 +796,12 @@ grub_install_copy_files (const char *src, dst_platform = grub_util_path_concat (2, dst, platform); free (platform); } - dst_locale = grub_util_path_concat (2, dst, "locale"); dst_fonts = grub_util_path_concat (2, dst, "fonts"); grub_install_mkdir_p (dst_platform); - grub_install_mkdir_p (dst_locale); clean_grub_dir (dst); clean_grub_dir (dst_platform); - clean_grub_dir (dst_locale); + + grub_install_copy_nls(src, dst); if (install_modules.is_default) copy_by_ext (src, dst_platform, ".mod", 1); @@ -797,50 +850,6 @@ grub_install_copy_files (const char *src, free (dstf); } - if (install_locales.is_default) - { - char *srcd = grub_util_path_concat (2, src, "po"); - copy_by_ext (srcd, dst_locale, ".mo", 0); - copy_locales (dst_locale); - free (srcd); - } - else - { - const char *locale_dir = get_localedir (); - - for (i = 0; i < install_locales.n_entries; i++) - { - char *srcf = grub_util_path_concat_ext (3, src, - "po", - install_locales.entries[i], - ".mo"); - char *dstf = grub_util_path_concat_ext (2, dst_locale, - install_locales.entries[i], - ".mo"); - if (grub_install_compress_file (srcf, dstf, 0)) - { - free (srcf); - free (dstf); - continue; - } - free (srcf); - srcf = grub_util_path_concat_ext (4, - locale_dir, - install_locales.entries[i], - "LC_MESSAGES", - PACKAGE, - ".mo"); - if (grub_install_compress_file (srcf, dstf, 0)) - { - free (srcf); - free (dstf); - continue; - } - grub_util_error (_("cannot find locale `%s'"), - install_locales.entries[i]); - } - } - if (install_themes.is_default) { install_themes.is_default = 0; @@ -903,7 +912,6 @@ grub_install_copy_files (const char *src, } free (dst_platform); - free (dst_locale); free (dst_fonts); } From c2b86ae1fcd22d6d5d275306795c0645ca6cad3d Mon Sep 17 00:00:00 2001 From: Nicholas Vinson Date: Mon, 16 Apr 2018 22:36:23 -0700 Subject: [PATCH 0806/1167] grub-probe: Centralize GUID prints Define print_gpt_guid(), so there is a central function for printing GUID strings. This change is a precursor for later patches which rely on this logic. Signed-off-by: Nicholas Vinson Reviewed-by: Daniel Kiper --- util/grub-probe.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 8ac527d2f..21cb80fbe 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -129,6 +129,20 @@ get_targets_string (void) return str; } +static int +print_gpt_guid (grub_gpt_part_guid_t guid) +{ + guid.data1 = grub_le_to_cpu32 (guid.data1); + guid.data2 = grub_le_to_cpu16 (guid.data2); + guid.data3 = grub_le_to_cpu16 (guid.data3); + + return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid.data1, guid.data2, guid.data3, guid.data4[0], + guid.data4[1], guid.data4[2], guid.data4[3], + guid.data4[4], guid.data4[5], guid.data4[6], + guid.data4[7]); +} + static void do_print (const char *x, void *data) { @@ -641,21 +655,7 @@ probe (const char *path, char **device_names, char delim) if (grub_disk_read (dev->disk, p->offset, p->index, sizeof (gptdata), &gptdata) == 0) - { - grub_gpt_part_type_t gpttype; - gpttype.data1 = grub_le_to_cpu32 (gptdata.type.data1); - gpttype.data2 = grub_le_to_cpu16 (gptdata.type.data2); - gpttype.data3 = grub_le_to_cpu16 (gptdata.type.data3); - grub_memcpy (gpttype.data4, gptdata.type.data4, 8); - - grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - gpttype.data1, gpttype.data2, - gpttype.data3, gpttype.data4[0], - gpttype.data4[1], gpttype.data4[2], - gpttype.data4[3], gpttype.data4[4], - gpttype.data4[5], gpttype.data4[6], - gpttype.data4[7]); - } + print_gpt_guid(gptdata.type); dev->disk->partition = p; } putchar (delim); From a16f4a822fb528944b5dd008f97e37e0ed19a515 Mon Sep 17 00:00:00 2001 From: Nicholas Vinson Date: Mon, 16 Apr 2018 22:36:24 -0700 Subject: [PATCH 0807/1167] disk: Update grub_gpt_partentry Rename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry to use this type for both the partition type GUID string and the partition GUID string entries. This change ensures that the two GUID fields are handled more consistently and helps to simplify the changes needed to add Linux partition GUID support. Signed-off-by: Nicholas Vinson Reviewed-by: Daniel Kiper --- grub-core/disk/ldm.c | 2 +- grub-core/partmap/gpt.c | 4 ++-- include/grub/gpt_partition.h | 8 ++++---- util/grub-install.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c index 0f978ad05..2a22d2d6c 100644 --- a/grub-core/disk/ldm.c +++ b/grub-core/disk/ldm.c @@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk) return has_ldm; } -static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; +static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; /* Helper for gpt_ldm_sector. */ static int diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 83bcba779..103f6796f 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] = 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 }; -static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; +static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; #ifdef GRUB_UTIL -static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; +static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; #endif /* 512 << 7 = 65536 byte sectors. */ diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 9668a68c3..7a93f4329 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -22,14 +22,14 @@ #include #include -struct grub_gpt_part_type +struct grub_gpt_part_guid { grub_uint32_t data1; grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; } GRUB_PACKED; -typedef struct grub_gpt_part_type grub_gpt_part_type_t; +typedef struct grub_gpt_part_guid grub_gpt_part_guid_t; #define GRUB_GPT_PARTITION_TYPE_EMPTY \ { 0x0, 0x0, 0x0, \ @@ -70,8 +70,8 @@ struct grub_gpt_header struct grub_gpt_partentry { - grub_gpt_part_type_t type; - grub_uint8_t guid[16]; + grub_gpt_part_guid_t type; + grub_gpt_part_guid_t guid; grub_uint64_t start; grub_uint64_t end; grub_uint64_t attrib; diff --git a/util/grub-install.c b/util/grub-install.c index 690f180c5..78d0138cb 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -714,7 +714,7 @@ is_prep_partition (grub_device_t dev) if (grub_disk_read (dev->disk, p->offset, p->index, sizeof (gptdata), &gptdata) == 0) { - const grub_gpt_part_type_t template = { + const grub_gpt_part_guid_t template = { grub_cpu_to_le32_compile_time (0x9e1a2d38), grub_cpu_to_le16_compile_time (0xc612), grub_cpu_to_le16_compile_time (0x4316), From 0c0bcffc2378f7427f14f7f878b08ba8f1a1f508 Mon Sep 17 00:00:00 2001 From: Nicholas Vinson Date: Mon, 16 Apr 2018 22:36:25 -0700 Subject: [PATCH 0808/1167] grub-probe: Add PARTUUID detection support Add PARTUUID detection support grub-probe for MBR and GPT partition schemes. Signed-off-by: Nicholas Vinson Reviewed-by: Daniel Kiper --- util/grub-probe.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/util/grub-probe.c b/util/grub-probe.c index 21cb80fbe..e45dbf9e0 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,7 @@ enum { PRINT_DRIVE, PRINT_DEVICE, PRINT_PARTMAP, + PRINT_PARTUUID, PRINT_ABSTRACTION, PRINT_CRYPTODISK_UUID, PRINT_HINT_STR, @@ -85,6 +87,7 @@ static const char *targets[] = [PRINT_DRIVE] = "drive", [PRINT_DEVICE] = "device", [PRINT_PARTMAP] = "partmap", + [PRINT_PARTUUID] = "partuuid", [PRINT_ABSTRACTION] = "abstraction", [PRINT_CRYPTODISK_UUID] = "cryptodisk_uuid", [PRINT_HINT_STR] = "hints_string", @@ -181,6 +184,45 @@ probe_partmap (grub_disk_t disk, char delim) } } +static void +probe_partuuid (grub_disk_t disk, char delim) +{ + grub_partition_t p = disk->partition; + + /* + * Nested partitions not supported for now. + * Non-nested partitions must have disk->partition->parent == NULL + */ + if (p && p->parent == NULL) + { + disk->partition = p->parent; + + if (strcmp(p->partmap->name, "msdos") == 0) + { + /* + * The partition GUID for MSDOS is the partition number (starting + * with 1) prepended with the NT disk signature. + */ + grub_uint32_t nt_disk_sig; + + if (grub_disk_read (disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + sizeof(nt_disk_sig), &nt_disk_sig) == 0) + grub_printf ("%08x-%02x", + grub_le_to_cpu32(nt_disk_sig), 1 + p->number); + } + else if (strcmp(p->partmap->name, "gpt") == 0) + { + struct grub_gpt_partentry gptdata; + + if (grub_disk_read (disk, p->offset, p->index, + sizeof(gptdata), &gptdata) == 0) + print_gpt_guid(gptdata.guid); + } + + disk->partition = p; + } +} + static void probe_cryptodisk_uuid (grub_disk_t disk, char delim) { @@ -635,6 +677,12 @@ probe (const char *path, char **device_names, char delim) /* Check if dev->disk itself is contained in a partmap. */ probe_partmap (dev->disk, delim); + else if (print == PRINT_PARTUUID) + { + probe_partuuid (dev->disk, delim); + putchar (delim); + } + else if (print == PRINT_MSDOS_PARTTYPE) { if (dev->disk->partition From 51be3372ec8ba07ef68a409956ea0eefa89fe7c5 Mon Sep 17 00:00:00 2001 From: Nicholas Vinson Date: Mon, 16 Apr 2018 22:36:26 -0700 Subject: [PATCH 0809/1167] templates: Update grub script template files Update grub-mkconfig.in and 10_linux.in to support grub-probe's new partuuid target. Update grub.texi documentation. The following table shows how GRUB_DISABLE_LINUX_UUID, GRUB_DISABLE_LINUX_PARTUUID, and initramfs detection interact: Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root detected Set Set ID Method false false false part UUID false false true part UUID false true false dev name false true true dev name true false false fs UUID true false true part UUID true true false fs UUID true true true dev name Note: GRUB_DISABLE_LINUX_PARTUUID and GRUB_DISABLE_LINUX_UUID equate to 'false' when unset or set to any value other than 'true'. GRUB_DISABLE_LINUX_PARTUUID defaults to 'true'. Signed-off-by: Nicholas Vinson Reviewed-by: Daniel Kiper --- docs/grub.texi | 67 ++++++++++++++++++++++++++++++++++--- util/grub-mkconfig.in | 3 ++ util/grub.d/10_linux.in | 22 ++++++++++-- util/grub.d/20_linux_xen.in | 22 ++++++++++-- 4 files changed, 104 insertions(+), 10 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 0f2ab91fc..2adfa97be 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1214,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under need to write the whole thing by hand. @menu -* Simple configuration:: Recommended for most users -* Shell-like scripting:: For power users and developers -* Multi-boot manual config:: For non-standard multi-OS scenarios -* Embedded configuration:: Embedding a configuration file into GRUB +* Simple configuration:: Recommended for most users +* Root Identifcation Heuristics:: Summary on how the root file system is identified. +* Shell-like scripting:: For power users and developers +* Multi-boot manual config:: For non-standard multi-OS scenarios +* Embedded configuration:: Embedding a configuration file into GRUB @end menu @@ -1425,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To disable the use of UUIDs, set this option to @samp{true}. +@item GRUB_DISABLE_LINUX_PARTUUID +If @command{grub-mkconfig} cannot identify the root filesystem via its +universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID +of the partition containing the filesystem to identify the root filesystem to +the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not +as reliable as using the filesystem UUID, but is more reliable than using the +Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to +@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using +the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To +enable the use of partition UUIDs, set this option to @samp{false}. + @item GRUB_DISABLE_RECOVERY If this option is set to @samp{true}, disable the generation of recovery mode menu entries. @@ -1556,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. menu entries; simply type the menu entries you want to add at the end of that file, making sure to leave at least the first two lines intact. +@node Root Identifcation Heuristics +@section Root Identifcation Heuristics +If the target operating system uses the Linux kernel, @command{grub-mkconfig} +attempts to identify the root file system via a heuristic algoirthm. This +algorithm selects the identification method of the root file system by +considering three factors. The first is if an initrd for the target operating +system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set +to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file +system via the UUID of its enclosing partition. If the variables are assigned +any other value, that value is considered equivalent to @samp{false}. The +variables are also considered to be set to @samp{false} if they are not set. + +When booting, the Linux kernel will delegate the task of mounting the root +filesystem to the initrd. Most initrd images determine the root file system by +checking the Linux kernel's command-line for the @samp{root} key and use its +value as the identification method of the root file system. To improve the +reliability of booting, most initrd images also allow the root file system to be +identified by its UUID. Because of this behavior, the @command{grub-mkconfig} +command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with +the filesystem UUID of the root file system. + +If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set to @samp{true} +then @command{grub-command} will identify the root filesystem by setting the +kernel command-line variable @samp{root} to @samp{root=PARTUUID=...} unless +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If +@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, +@command{grub-command} will identify by its Linux device name. + +The following table summarizes the behavior of the @command{grub-mkconfig} +command. + +@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method +@item false @tab false @tab false @tab part UUID +@item false @tab false @tab true @tab part UUID +@item false @tab true @tab false @tab dev name +@item false @tab true @tab true @tab dev name +@item true @tab false @tab false @tab fs UUID +@item true @tab false @tab true @tab part UUID +@item true @tab true @tab false @tab fs UUID +@item true @tab true @tab true @tab dev name +@end multitable + +Remember, @samp{GRUB_DISABLE_LINUX_PARTUUID} and @samp{GRUB_DISABLE_LINUX_UUID} +are also considered to be set to @samp{false} when they are unset. @node Shell-like scripting @section Writing full configuration files directly diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 35ef583b0..33332360e 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -134,6 +134,7 @@ fi # Device containing our userland. Typically used for root= parameter. GRUB_DEVICE="`${grub_probe} --target=device /`" GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true +GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true # Device containing our /boot partition. Usually the same as GRUB_DEVICE. GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" @@ -188,6 +189,7 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub # override them. export GRUB_DEVICE \ GRUB_DEVICE_UUID \ + GRUB_DEVICE_PARTUUID \ GRUB_DEVICE_BOOT \ GRUB_DEVICE_BOOT_UUID \ GRUB_FS \ @@ -223,6 +225,7 @@ export GRUB_DEFAULT \ GRUB_TERMINAL_OUTPUT \ GRUB_SERIAL_COMMAND \ GRUB_DISABLE_LINUX_UUID \ + GRUB_DISABLE_LINUX_PARTUUID \ GRUB_DISABLE_RECOVERY \ GRUB_VIDEO_BACKEND \ GRUB_GFXMODE \ diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index faedf74e1..146499f22 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in ;; esac +# Default to disabling partition uuid support to maintian compatibility with +# older kernels. +GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} + # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter # and mounting btrfs requires user space scanning, so force UUID in this case. -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ) \ + || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ + || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} +elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then + LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi @@ -242,7 +252,13 @@ while [ "x$list" != "x" ] ; do if test -z "${initramfs}" && test -z "${initrd_real}" ; then # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's # no initrd or builtin initramfs, it can't work here. - linux_root_device_thisversion=${GRUB_DEVICE} + if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then + + linux_root_device_thisversion=${GRUB_DEVICE} + else + linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} + fi fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 0cb0f4e49..e8143b079 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in ;; esac +# Default to disabling partition uuid support to maintian compatibility with +# older kernels. +GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} + # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter # and mounting btrfs requires user space scanning, so force UUID in this case. -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ + || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ + || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} +elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then + LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi @@ -246,7 +256,13 @@ while [ "x${xen_list}" != "x" ] ; do gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 else # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. - linux_root_device_thisversion=${GRUB_DEVICE} + if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ + || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then + + linux_root_device_thisversion=${GRUB_DEVICE} + else + linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} + fi fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then From b66e364f131228f4215ff8f0b8173f14931d9b6c Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 24 Apr 2018 14:13:04 +0800 Subject: [PATCH 0810/1167] bufio: Round up block size to power of 2 Rounding up the bufio->block_size to meet power of 2 to facilitate next_buf calculation in grub_bufio_read(). Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/io/bufio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index 22438277d..dbed64744 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -61,6 +61,13 @@ grub_bufio_open (grub_file_t io, int size) size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE : io->size); + /* + * Round up size to power of 2 which the binary math to + * calculate next_buf in grub_bufio_read() requires. + */ + while (size & (size - 1)) + size = (size | (size - 1)) + 1; + bufio = grub_zalloc (sizeof (struct grub_bufio) + size); if (! bufio) { From 6d28b3bd266e1d935de5916860645ea8cabf2335 Mon Sep 17 00:00:00 2001 From: Oleg Solovyov Date: Fri, 11 May 2018 13:55:46 +0300 Subject: [PATCH 0811/1167] grub-probe: Don't skip /dev/mapper/dm-* devices This patch ensures that grub-probe will find the root device placed in /dev/mapper/dm-[0-9]+-.* e.g. device named /dev/mapper/dm-0-luks will be found and grub.cfg will be updated properly, enabling the system to boot. Signed-off-by: Oleg Solovyov Reviewed-by: Daniel Kiper --- grub-core/osdep/unix/getroot.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 4bf37b027..3046e22cc 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -428,8 +428,11 @@ grub_find_device (const char *dir, dev_t dev) { #ifdef __linux__ /* Skip device names like /dev/dm-0, which are short-hand aliases - to more descriptive device names, e.g. those under /dev/mapper */ - if (ent->d_name[0] == 'd' && + to more descriptive device names, e.g. those under /dev/mapper. + Also, don't skip devices which names start with dm-[0-9] in + directories below /dev, e.g. /dev/mapper/dm-0-luks. */ + if (strcmp (dir, "/dev") == 0 && + ent->d_name[0] == 'd' && ent->d_name[1] == 'm' && ent->d_name[2] == '-' && ent->d_name[3] >= '0' && From cda0a857dd7a27cd5d621747464bfe71e8727fff Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 29 May 2018 16:16:02 +0200 Subject: [PATCH 0812/1167] xfs: Accept filesystem with sparse inodes The sparse inode metadata format became a mkfs.xfs default in xfsprogs-4.16.0, and such filesystems are now rejected by grub as containing an incompatible feature. In essence, this feature allows xfs to allocate inodes into fragmented freespace. (Without this feature, if xfs could not allocate contiguous space for 64 new inodes, inode creation would fail.) In practice, the disk format change is restricted to the inode btree, which as far as I can tell is not used by grub. If all you're doing today is parsing a directory, reading an inode number, and converting that inode number to a disk location, then ignoring this feature should be fine, so I've added it to XFS_SB_FEAT_INCOMPAT_SUPPORTED I did some brief testing of this patch by hacking up the regression tests to completely fragment freespace on the test xfs filesystem, and then write a large-ish number of inodes to consume any existing contiguous 64-inode chunk. This way any files the grub tests add and traverse would be in such a fragmented inode allocation. Tests passed, but I'm not sure how to cleanly integrate that into the test harness. Signed-off-by: Eric Sandeen Reviewed-by: Daniel Kiper Tested-by: Chris Murphy --- grub-core/fs/xfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index c6031bd3f..3b00c744e 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -79,9 +79,18 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ -/* We do not currently verify metadata UUID so it is safe to read such filesystem */ +/* + * Directory entries with ftype are explicitly handled by GRUB code. + * + * We do not currently read the inode btrees, so it is safe to read filesystems + * with the XFS_SB_FEAT_INCOMPAT_SPINODES feature. + * + * We do not currently verify metadata UUID, so it is safe to read filesystems + * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature. + */ #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_SPINODES | \ XFS_SB_FEAT_INCOMPAT_META_UUID) struct grub_xfs_sblock From ba474d531a63850bf2e8e8c225ccd6f5e2a594e9 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 5 Jun 2018 13:04:04 +0200 Subject: [PATCH 0813/1167] templates: Add missing "]" Commit 51be337 (templates: Update grub script template files) lacked one "]", so, add it. Reported-by: Philip Signed-off-by: Daniel Kiper --- util/grub.d/10_linux.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 146499f22..61ebd7dc7 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -49,7 +49,7 @@ GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter # and mounting btrfs requires user space scanning, so force UUID in this case. -if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ) \ +if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ From 14ec665c3f36d0614cacaa757907551c5c2e6adb Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 12 Jun 2018 20:04:09 +0200 Subject: [PATCH 0814/1167] mbi: Use per segment a separate relocator chunk Instead of setting up a all comprising relocator chunk for all segments, use per segment a separate relocator chunk. Currently, if the ELF is non-relocatable, a single relocator chunk will comprise memory (between the segments) which gets overridden by the relst() invocation of the movers code in grub_relocator16/32/64_boot(). The overridden memory may contain reserved ranges like VGA memory or ACPI tables, which may lead to crashes or at least to strange boot behaviour. Signed-off-by: Alexander Boettcher Reviewed-by: Daniel Kiper --- grub-core/loader/multiboot_elfxx.c | 63 +++++++++++++++++++----------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 67daf5944..ae36d9d49 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -57,9 +57,9 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) char *phdr_base; grub_err_t err; grub_relocator_chunk_t ch; - grub_uint32_t load_offset, load_size; + grub_uint32_t load_offset = 0, load_size; int i; - void *source; + void *source = NULL; if (ehdr->e_ident[EI_MAG0] != ELFMAG0 || ehdr->e_ident[EI_MAG1] != ELFMAG1 @@ -97,10 +97,15 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border"); #endif - load_size = highest_load - mld->link_base_addr; - if (mld->relocatable) { + load_size = highest_load - mld->link_base_addr; + + grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, " + "load_size=0x%x, avoid_efi_boot_services=%d\n", + (long) mld->align, mld->preference, load_size, + mld->avoid_efi_boot_services); + if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); @@ -108,27 +113,22 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) mld->min_addr, mld->max_addr - load_size, load_size, mld->align ? mld->align : 1, mld->preference, mld->avoid_efi_boot_services); + + if (err) + { + grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); + return err; + } + + mld->load_base_addr = get_physical_target_address (ch); + source = get_virtual_current_address (ch); } else - err = grub_relocator_alloc_chunk_addr (GRUB_MULTIBOOT (relocator), &ch, - mld->link_base_addr, load_size); + mld->load_base_addr = mld->link_base_addr; - if (err) - { - grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); - return err; - } - - mld->load_base_addr = get_physical_target_address (ch); - source = get_virtual_current_address (ch); - - grub_dprintf ("multiboot_loader", "link_base_addr=0x%x, load_base_addr=0x%x, " - "load_size=0x%x, relocatable=%d\n", mld->link_base_addr, - mld->load_base_addr, load_size, mld->relocatable); - - if (mld->relocatable) - grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, avoid_efi_boot_services=%d\n", - (long) mld->align, mld->preference, mld->avoid_efi_boot_services); + grub_dprintf ("multiboot_loader", "relocatable=%d, link_base_addr=0x%x, " + "load_base_addr=0x%x\n", relocatable, + mld->link_base_addr, mld->load_base_addr); /* Load every loadable segment in memory. */ for (i = 0; i < ehdr->e_phnum; i++) @@ -139,7 +139,24 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) grub_dprintf ("multiboot_loader", "segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx\n", i, (long) phdr(i)->p_paddr, (long) phdr(i)->p_memsz, (long) phdr(i)->p_vaddr); - load_offset = phdr(i)->p_paddr - mld->link_base_addr; + if (mld->relocatable) + { + load_offset = phdr(i)->p_paddr - mld->link_base_addr; + grub_dprintf ("multiboot_loader", "segment %d: load_offset=0x%x\n", i, load_offset); + } + else + { + err = grub_relocator_alloc_chunk_addr (GRUB_MULTIBOOT (relocator), &ch, + phdr(i)->p_paddr, phdr(i)->p_memsz); + + if (err) + { + grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); + return err; + } + + source = get_virtual_current_address (ch); + } if (phdr(i)->p_filesz != 0) { From 0083541593e05704961db229aefea0542446c07c Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 15 Jun 2018 18:34:04 +0100 Subject: [PATCH 0815/1167] grub-fs-tester: Fix losetup race If something else on the system is using loopback devices, then the device that's free at the call to `losetup -f` may not be free in the following call to try to use it. Instead, find and use the first free loopback device in a single call to losetup. Signed-off-by: Will Thompson Reviewed-by: Daniel Kiper --- tests/util/grub-fs-tester.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 26bd57a80..ef65fbc93 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -616,9 +616,8 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do mkdir -p "$MNTPOINTRO" for i in $(range 0 $((NDEVICES-1)) 1); do dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 seek=$((DISKSIZE-1)) &> /dev/null - LODEVICE="$(losetup -f)" + LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img") LODEVICES="$LODEVICES $LODEVICE" - losetup "$LODEVICE" "$FSIMAGEP${i}.img" if test "$i" = 0; then MOUNTDEVICE="$LODEVICE" fi From e93fd6b776a7e6cef36c445d00436e5a23cfeba5 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 11 Jun 2018 17:24:58 +0100 Subject: [PATCH 0816/1167] fdt: Move prop_entry_size to fdt.h To be able to resuse the prop_entry_size macro, move it to and rename it grub_fdt_prop_entry_size. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/lib/fdt.c | 25 ++++++++++--------------- include/grub/fdt.h | 5 +++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 2705f2629..0d371c563 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -41,11 +41,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); (2 * sizeof(grub_uint32_t) \ + ALIGN_UP (grub_strlen (name) + 1, sizeof(grub_uint32_t))) -/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff - fields, plus the property value, plus padding if needed. */ -#define prop_entry_size(prop_len) \ - (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) - #define SKIP_NODE_NAME(name, token, end) \ name = (char *) ((token) + 1); \ while (name < (char *) end) \ @@ -86,7 +81,7 @@ static grub_uint32_t *get_next_node (const void *fdt, char *node_name) case FDT_PROP: /* Skip property token and following data (len, nameoff and property value). */ - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_NOP: @@ -150,7 +145,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name) { case FDT_PROP: /* Skip len, nameoff and property value. */ - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_BEGIN_NODE: @@ -249,12 +244,12 @@ static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset, && !grub_strcmp (name, (char *) fdt + grub_fdt_get_off_dt_strings (fdt) + nameoff)) { - if (prop + prop_entry_size(grub_be_to_cpu32(*(prop + 1))) + if (prop + grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop) >= end) return NULL; return prop; } - prop += prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); + prop += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); } else if (grub_be_to_cpu32(*prop) == FDT_NOP) prop++; @@ -319,7 +314,7 @@ advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t value). */ if (token >= end - 1) return 0; - token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) + token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) / sizeof(*token); break; case FDT_NOP: @@ -467,12 +462,12 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, unsigned int needed_space = 0; if (!prop) - needed_space = prop_entry_size(len); + needed_space = grub_fdt_prop_entry_size(len); if (!prop_name_present) needed_space += grub_strlen (name) + 1; if (needed_space > get_free_space (fdt)) return -1; - if (rearrange_blocks (fdt, !prop ? prop_entry_size(len) : 0) < 0) + if (rearrange_blocks (fdt, !prop ? grub_fdt_prop_entry_size(len) : 0) < 0) return -1; } if (!prop_name_present) { @@ -489,10 +484,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, + sizeof(grub_uint32_t)); prop = (void *) (node_name + ALIGN_UP(grub_strlen(node_name) + 1, 4)); - grub_memmove (prop + prop_entry_size(len) / sizeof(*prop), prop, + grub_memmove (prop + grub_fdt_prop_entry_size(len) / sizeof(*prop), prop, struct_end(fdt) - (grub_addr_t) prop); grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt) - + prop_entry_size(len)); + + grub_fdt_prop_entry_size(len)); *prop = grub_cpu_to_be32_compile_time (FDT_PROP); *(prop + 2) = grub_cpu_to_be32 (nameoff); } @@ -500,7 +495,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, /* Insert padding bytes at the end of the value; if they are not needed, they will be overwritten by the following memcpy. */ - *(prop + prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; + *(prop + grub_fdt_prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; grub_memcpy (prop + 3, val, len); return 0; diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 75525fa31..158b1bc4b 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -50,6 +50,11 @@ struct grub_fdt_empty_tree { #define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree) +/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff + fields, plus the property value, plus padding if needed. */ +#define grub_fdt_prop_entry_size(prop_len) \ + (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) + #define grub_fdt_get_header(fdt, field) \ grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field) #define grub_fdt_set_header(fdt, field, value) \ From 347210a5d5ce655b95315f320faa515afb723c11 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 11 Jun 2018 17:24:59 +0100 Subject: [PATCH 0817/1167] efi/fdt: Set address/size cells to 2 for empty tree When booting an arm* system on UEFI with an empty device tree (currently only when hardware description comes from ACPI), we don't currently set default to 1 cell (32 bits). Set both of these properties, to 2 cells (64 bits), to resolve issues with kexec on some platforms. This change corresponds with linux kernel commit ae8a442dfdc4 ("efi/libstub/arm*: Set default address and size cells values for an empty dtb") and ensures booting through grub does not behave differently from booting the stub loader directly. See also https://patchwork.kernel.org/patch/9561201/ Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/efi/fdt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index c0c6800f7..a4c6e8036 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -29,6 +29,12 @@ static void *loaded_fdt; static void *fdt; +#define FDT_ADDR_CELLS_STRING "#address-cells" +#define FDT_SIZE_CELLS_STRING "#size-cells" +#define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size (sizeof(grub_uint32_t))) + \ + sizeof (FDT_ADDR_CELLS_STRING) + \ + sizeof (FDT_SIZE_CELLS_STRING)) + void * grub_fdt_load (grub_size_t additional_size) { @@ -46,8 +52,11 @@ grub_fdt_load (grub_size_t additional_size) else raw_fdt = grub_efi_get_firmware_fdt(); - size = - raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; + if (raw_fdt) + size = grub_fdt_get_totalsize (raw_fdt); + else + size = GRUB_FDT_EMPTY_TREE_SZ + FDT_ADDR_SIZE_EXTRA; + size += additional_size; grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); @@ -63,6 +72,8 @@ grub_fdt_load (grub_size_t additional_size) else { grub_fdt_create_empty_tree (fdt, size); + grub_fdt_set_prop32 (fdt, 0, FDT_ADDR_CELLS_STRING, 2); + grub_fdt_set_prop32 (fdt, 0, FDT_SIZE_CELLS_STRING, 2); } return fdt; } From ec2de93f8d96b914af5834137bffdc9759c362b8 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Fri, 29 Jun 2018 14:15:11 +0200 Subject: [PATCH 0818/1167] multiboot_elfxx.c: Fix compilation by fixing undeclared variable Without that fix we have: In file included from ../../include/grub/command.h:25:0, from ../../grub-core/loader/multiboot.c:30: ../../grub-core/loader/multiboot_elfxx.c: In function 'grub_multiboot_load_elf64': ../../grub-core/loader/multiboot_elfxx.c:130:28: error: 'relocatable' undeclared (first use in this function) "load_base_addr=0x%x\n", relocatable, This happens due to mistake in the commit 14ec665 (mbi: Use per segment a separate relocator chunk). So, let's fix it. Signed-off-by: Ignat Korchagin Signed-off-by: Denis 'GNUtoo' Carikli Signed-off-by: Daniel Kiper --- grub-core/loader/multiboot_elfxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index ae36d9d49..70cd1db51 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -127,7 +127,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) mld->load_base_addr = mld->link_base_addr; grub_dprintf ("multiboot_loader", "relocatable=%d, link_base_addr=0x%x, " - "load_base_addr=0x%x\n", relocatable, + "load_base_addr=0x%x\n", mld->relocatable, mld->link_base_addr, mld->load_base_addr); /* Load every loadable segment in memory. */ From 4e9d9358e0cda6d01020005eb6343e3b69f7201a Mon Sep 17 00:00:00 2001 From: Cao jin Date: Tue, 3 Jul 2018 18:51:13 +0800 Subject: [PATCH 0819/1167] grub-setup: Debug message cleanup Variable "root" is initialized after root device probing and is null in current place, so, drop it. Signed-off-by: Cao jin Reviewed-by: Daniel Kiper --- util/setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/setup.c b/util/setup.c index 80363075d..9c1e1b7da 100644 --- a/util/setup.c +++ b/util/setup.c @@ -305,9 +305,8 @@ SETUP (const char *dir, bl.first_block = (struct grub_boot_blocklist *) (core_img + GRUB_DISK_SECTOR_SIZE - sizeof (*bl.block)); - grub_util_info ("root is `%s', dest is `%s'", root, dest); - grub_util_info ("Opening dest"); + grub_util_info ("Opening dest `%s'", dest); dest_dev = grub_device_open (dest); if (! dest_dev) grub_util_error ("%s", grub_errmsg); From edece25a77cf5f357b0912aaaf089034752a7288 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 26 Jun 2018 20:15:01 +0200 Subject: [PATCH 0820/1167] efi/console: Fix the "enter" key not working on x86 tablets Most 8" or 7" x86 Windows 10 tablets come with volume up/down buttons and a power-button. In their UEFI these are almost always mapped to arrow up/down and enter. Pressing the volume buttons (sometimes by accident) will stop the menu countdown, but the power-button / "enter" key was not being recognized as enter, so the user would be stuck at the grub menu. The problem is that these tablets send scan_code 13 or 0x0d for the power-button, which officialy maps to the F3 key. They also set unicode_char to 0x0d. This commit recognizes the special case of both scan_code and unicode_char being set to 0x0d and treats this as an enter key press. This fixes things getting stuck at the grub-menu and allows the user to choice a grub-menu entry using the buttons on the tablet. Signed-off-by: Hans de Goede Reviewed-by: Daniel Kiper --- grub-core/term/efi/console.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 02f64ea74..4840cc59d 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -122,6 +122,9 @@ grub_efi_translate_key (grub_efi_input_key_t key) else return key.unicode_char; } + /* Some devices send enter with scan_code 0x0d (F3) and unicode_char 0x0d. */ + else if (key.scan_code == '\r' && key.unicode_char == '\r') + return key.unicode_char; else if (key.scan_code < ARRAY_SIZE (efi_codes)) return efi_codes[key.scan_code]; From 40dc61ed75e08e7dc2951bdae5c59fecb15bbb72 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 25 Jun 2018 18:01:28 +0100 Subject: [PATCH 0821/1167] commands/file: Use definitions from arm/linux.h Clean up code for matching IS_ARM slightly by making use of struct linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/file.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 63c84499b..ab0c9fb96 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -383,21 +384,19 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) } case IS_ARM_LINUX: { - grub_uint32_t sig, sig_pi; - if (grub_file_read (file, &sig_pi, 4) != 4) + struct linux_arm_kernel_header lh; + + if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; - /* Raspberry pi. */ - if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006)) + /* Short forward branch in A32 state (for Raspberry pi kernels). */ + if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006)) { ret = 1; break; } - if (grub_file_seek (file, 0x24) == (grub_size_t) -1) - break; - if (grub_file_read (file, &sig, 4) != 4) - break; - if (sig == grub_cpu_to_le32_compile_time (0x016f2818)) + if (lh.magic == + grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM_MAGIC_SIGNATURE)) { ret = 1; break; From 9b37229f013db1b150082ac130be7c20b3db8cea Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 25 Jun 2018 18:01:29 +0100 Subject: [PATCH 0822/1167] commands/file: Use definitions from arm64/linux.h Clean up code for matching IS_ARM64 slightly by making use of struct linux_arm64_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/file.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index ab0c9fb96..3ff6d5522 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -405,13 +406,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) } case IS_ARM64_LINUX: { - grub_uint32_t sig; + struct linux_arm64_kernel_header lh; - if (grub_file_seek (file, 0x38) == (grub_size_t) -1) + if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; - if (grub_file_read (file, &sig, 4) != 4) - break; - if (sig == grub_cpu_to_le32_compile_time (0x644d5241)) + + if (lh.magic == + grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE)) { ret = 1; break; From 886edba8770ccbc3def0af2a7d6b346d00d0af2f Mon Sep 17 00:00:00 2001 From: Arindam Nath Date: Thu, 12 Jul 2018 19:02:49 +0530 Subject: [PATCH 0823/1167] i386/linux: Add support for ext_lfb_base The EFI Graphics Output Protocol can return a 64-bit linear frame buffer address in some firmware/BIOS implementations. We currently only store the lower 32-bits in the lfb_base. This will eventually be passed to Linux kernel and the efifb driver will incorrectly interpret the framebuffer address as 32-bit address. The Linux kernel has already added support to handle 64-bit linear framebuffer address in the efifb driver since quite some time now. This patch adds the support for 64-bit linear frame buffer address in GRUB to address the above mentioned scenario. Signed-off-by: Arindam Nath Reviewed-by: Daniel Kiper --- grub-core/loader/i386/linux.c | 6 ++++++ include/grub/i386/linux.h | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 44301e126..9b53d3168 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -306,6 +306,12 @@ grub_linux_setup_video (struct linux_kernel_params *params) params->lfb_line_len = mode_info.pitch; params->lfb_base = (grub_size_t) framebuffer; + +#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__) + params->ext_lfb_base = (grub_size_t) (((grub_uint64_t)(grub_size_t) framebuffer) >> 32); + params->capabilities |= VIDEO_CAPABILITY_64BIT_BASE; +#endif + params->lfb_size = ALIGN_UP (params->lfb_line_len * params->lfb_height, 65536); params->red_mask_size = mode_info.red_mask_size; diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 0bd758817..60c7c3b5e 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -43,6 +43,9 @@ #define GRUB_LINUX_CL_MAGIC 0xA33F +#define VIDEO_CAPABILITY_SKIP_QUIRKS (1 << 0) +#define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit. */ + #ifdef __x86_64__ #define GRUB_LINUX_EFI_SIGNATURE \ @@ -188,8 +191,9 @@ struct linux_kernel_params grub_uint16_t lfb_pages; /* 32 */ grub_uint16_t vesa_attrib; /* 34 */ grub_uint32_t capabilities; /* 36 */ + grub_uint32_t ext_lfb_base; /* 3a */ - grub_uint8_t padding3[0x40 - 0x3a]; + grub_uint8_t padding3[0x40 - 0x3e]; grub_uint16_t apm_version; /* 40 */ grub_uint16_t apm_code_segment; /* 42 */ From 8ec18d1a4c26129c0a018ee7a61739a929ee1a25 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:00 +0100 Subject: [PATCH 0824/1167] efi: Add central copy of grub_efi_find_mmap_size There are several implementations of this function in the tree. Add a central version in grub-core/efi/mm.c. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/kern/efi/mm.c | 24 ++++++++++++++++++++++++ include/grub/efi/efi.h | 1 + 2 files changed, 25 insertions(+) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index c48e9b5c7..a8e0e4a89 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -286,6 +286,30 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, return GRUB_ERR_NONE; } +/* + * To obtain the UEFI memory map, we must pass a buffer of sufficient size + * to hold the entire map. This function returns a sane start value for + * buffer size. + */ +grub_efi_uintn_t +grub_efi_find_mmap_size (void) +{ + grub_efi_uintn_t mmap_size = 0; + grub_efi_uintn_t desc_size; + + if (grub_efi_get_memory_map (&mmap_size, NULL, NULL, &desc_size, 0) < 0) + { + grub_error (GRUB_ERR_IO, "cannot get EFI memory map size"); + return 0; + } + + /* + * Add an extra page, since UEFI can alter the memory map itself on + * callbacks or explicit calls, including console output. + */ + return ALIGN_UP (mmap_size + GRUB_EFI_PAGE_SIZE, GRUB_EFI_PAGE_SIZE); +} + /* Get the memory map as defined in the EFI spec. Return 1 if successful, return 0 if partial, or return -1 if an error occurs. */ int diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index c996913e5..1021273c1 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -49,6 +49,7 @@ void * EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); +grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); int EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, grub_efi_memory_descriptor_t *memory_map, From bad144c60f664a83f5a7d3a014927bffaa2abbf1 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:01 +0100 Subject: [PATCH 0825/1167] efi: Add grub_efi_get_ram_base() function for arm64 Since ARM platforms do not have a common memory map, add a helper function that finds the lowest address region with the EFI_MEMORY_WB attribute set in the UEFI memory map. Required for the arm64 efi linux loader to restrict the initrd location to where it will be accessible by the kernel at runtime. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/kern/efi/mm.c | 31 +++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index a8e0e4a89..92e9763d2 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -633,3 +633,34 @@ grub_efi_mm_init (void) grub_efi_free_pages ((grub_addr_t) memory_map, 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } + +#if defined (__aarch64__) +grub_err_t +grub_efi_get_ram_base(grub_addr_t *base_addr) +{ + grub_efi_memory_descriptor_t *memory_map, *desc; + grub_efi_uintn_t memory_map_size, desc_size; + int ret; + + memory_map_size = grub_efi_find_mmap_size(); + + memory_map = grub_malloc (memory_map_size); + if (! memory_map) + return GRUB_ERR_OUT_OF_MEMORY; + ret = grub_efi_get_memory_map (&memory_map_size, memory_map, NULL, + &desc_size, NULL); + + if (ret < 1) + return GRUB_ERR_BUG; + + for (desc = memory_map, *base_addr = GRUB_UINT_MAX; + (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size); + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) + if (desc->attribute & GRUB_EFI_MEMORY_WB) + *base_addr = grub_min (*base_addr, desc->physical_start); + + grub_free(memory_map); + + return GRUB_ERR_NONE; +} +#endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 1021273c1..57db74b57 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -93,6 +93,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif +#if defined(__aarch64__) +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#endif grub_addr_t grub_efi_modules_addr (void); From d24dd120864ed72a80d7bb9c0288c4f29934f79d Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:02 +0100 Subject: [PATCH 0826/1167] arm64/linux/loader: Rename functions and macros and move to common headers In preparation for using the linux loader for 32-bit and 64-bit platforms, rename grub_arm64*/GRUB_ARM64* to grub_armxx*/GRUB_ARMXX*. Move prototypes for now-common functions to efi/efi.h. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 14 +++++++------- grub-core/loader/arm64/xen_boot.c | 10 +++++----- include/grub/arm64/linux.h | 9 ++++----- include/grub/efi/efi.h | 4 ++++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index ebe1e730d..f90c5f926 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,9 +48,9 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh) +grub_armxx_efi_linux_check_image (struct linux_armxx_kernel_header * lh) { - if (lh->magic != GRUB_LINUX_ARM64_MAGIC_SIGNATURE) + if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) @@ -109,7 +109,7 @@ failure: } grub_err_t -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) +grub_armxx_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; @@ -172,8 +172,8 @@ grub_linux_boot (void) if (finalize_params_linux () != GRUB_ERR_NONE) return grub_errno; - return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, - kernel_size, linux_args)); + return (grub_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); } static grub_err_t @@ -249,7 +249,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_arm64_kernel_header lh; + struct linux_armxx_kernel_header lh; grub_dl_ref (my_mod); @@ -268,7 +268,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) + if (grub_armxx_efi_linux_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 258264c79..1003a0b99 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -265,9 +265,9 @@ xen_boot (void) if (err) return err; - return grub_arm64_uefi_boot_image (xen_hypervisor->start, - xen_hypervisor->size, - xen_hypervisor->cmdline); + return grub_armxx_efi_linux_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); } static void @@ -468,8 +468,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) goto fail; - if (grub_arm64_uefi_check_image - ((struct linux_arm64_kernel_header *) &sh) != GRUB_ERR_NONE) + if (grub_armxx_efi_linux_check_image + ((struct linux_armxx_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index b06347624..8655067e0 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,8 +19,6 @@ #ifndef GRUB_ARM64_LINUX_HEADER #define GRUB_ARM64_LINUX_HEADER 1 -#include - #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ @@ -38,8 +36,9 @@ struct linux_arm64_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -grub_err_t grub_arm64_uefi_check_image (struct linux_arm64_kernel_header *lh); -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, - char *args); +#if defined(__aarch64__) +# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE +# define linux_armxx_kernel_header linux_arm64_kernel_header +#endif #endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 57db74b57..1deaa3c8f 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -95,6 +95,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif #if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#include +grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); +grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args); #endif grub_addr_t grub_efi_modules_addr (void); From d0c070179d4d78c297364e41ece54fd7755c4b58 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:03 +0100 Subject: [PATCH 0827/1167] arm/efi: Switch to arm64 linux loader The arm64 and arm linux kernel EFI-stub support presents pretty much identical interfaces, so the same linux loader source can be used for both architectures. Switch 32-bit ARM UEFI platforms over to the existing EFI-stub aware loader initially developed for arm64. This *WILL* stop non-efistub Linux kernels from booting on arm-efi. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 7 ++++--- grub-core/kern/efi/mm.c | 2 +- include/grub/arm/linux.h | 5 +++++ include/grub/efi/efi.h | 2 -- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index fc4767f19..9590e87d9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -229,7 +229,6 @@ kernel = { ia64_efi = kern/ia64/cache.c; arm_efi = kern/arm/efi/init.c; - arm_efi = kern/arm/efi/misc.c; arm_efi = kern/efi/fdt.c; arm64_efi = kern/arm64/efi/init.c; @@ -1693,7 +1692,9 @@ module = { powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; ia64_efi = loader/ia64/efi/linux.c; - arm = loader/arm/linux.c; + arm_coreboot = loader/arm/linux.c; + arm_efi = loader/arm64/linux.c; + arm_uboot = loader/arm/linux.c; arm64 = loader/arm64/linux.c; common = loader/linux.c; common = lib/cmdline.c; @@ -1702,7 +1703,7 @@ module = { module = { name = fdt; - arm64 = loader/efi/fdt.c; + efi = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 92e9763d2..42ad7c570 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -634,7 +634,7 @@ grub_efi_mm_init (void) 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } -#if defined (__aarch64__) +#if defined (__aarch64__) || defined (__arm__) grub_err_t grub_efi_get_ram_base(grub_addr_t *base_addr) { diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index cceb9c4a9..3d0d15eb4 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -34,6 +34,11 @@ struct linux_arm_kernel_header { grub_uint32_t hdr_offset; }; +#if defined(__arm__) +# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE +# define linux_armxx_kernel_header linux_arm_kernel_header +#endif + #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000) diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 1deaa3c8f..2c6648d46 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -92,8 +92,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); -#endif -#if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); From 77808dd66bda72ff14873bcd701ec25a0db1dfee Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:04 +0100 Subject: [PATCH 0828/1167] arm: Delete unused efi support from loader/arm The 32-bit arm efi port now shares the 64-bit linux loader, so delete the now unused bits from the 32-bit linux loader. This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so delete that too. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/Makefile.am | 1 - grub-core/kern/arm/efi/misc.c | 202 ---------------------------------- grub-core/loader/arm/linux.c | 28 ----- include/grub/arm/efi/loader.h | 26 ----- include/grub/arm/linux.h | 16 --- 5 files changed, 273 deletions(-) delete mode 100644 grub-core/kern/arm/efi/misc.c delete mode 100644 include/grub/arm/efi/loader.h diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 104513847..f4ff62b76 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -254,7 +254,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h endif if COND_arm_efi -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c deleted file mode 100644 index c95e8299d..000000000 --- a/grub-core/kern/arm/efi/misc.c +++ /dev/null @@ -1,202 +0,0 @@ -/* misc.c - various system functions for an arm-based EFI system */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2013 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 . - */ - -#include -#include -#include -#include -#include -#include - -static inline grub_size_t -page_align (grub_size_t size) -{ - return (size + (1 << 12) - 1) & (~((1 << 12) - 1)); -} - -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static grub_efi_uintn_t -find_mmap_size (void) -{ - static grub_efi_uintn_t mmap_size = 0; - - if (mmap_size != 0) - return mmap_size; - - mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - - mmap = grub_malloc (mmap_size); - if (! mmap) - return 0; - - ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - return 0; - } - else if (ret > 0) - break; - - mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - mmap_size += (1 << 12); - - return page_align (mmap_size); -} - -#define NEXT_MEMORY_DESCRIPTOR(desc, size) \ - ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) -#define PAGE_SHIFT 12 - -void * -grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size) -{ - grub_efi_uintn_t desc_size; - grub_efi_memory_descriptor_t *mmap, *mmap_end; - grub_efi_uintn_t mmap_size, tmp_mmap_size; - grub_efi_memory_descriptor_t *desc; - void *mem = NULL; - grub_addr_t min_start = 0; - - mmap_size = find_mmap_size(); - if (!mmap_size) - return NULL; - - mmap = grub_malloc(mmap_size); - if (!mmap) - return NULL; - - tmp_mmap_size = mmap_size; - if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <= 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - goto fail; - } - - mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size); - /* Find lowest accessible RAM location */ - { - int found = 0; - for (desc = mmap ; !found && (desc < mmap_end) ; - desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) - { - switch (desc->type) - { - case GRUB_EFI_CONVENTIONAL_MEMORY: - case GRUB_EFI_LOADER_CODE: - case GRUB_EFI_LOADER_DATA: - min_start = desc->physical_start + min_offset; - found = 1; - break; - default: - break; - } - } - } - - /* First, find free pages for the real mode code - and the memory map buffer. */ - for (desc = mmap ; desc < mmap_end ; - desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) - { - grub_uint64_t start, end; - - grub_dprintf("mm", "%s: 0x%08x bytes @ 0x%08x\n", - __FUNCTION__, - (grub_uint32_t) (desc->num_pages << PAGE_SHIFT), - (grub_uint32_t) (desc->physical_start)); - - if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY) - continue; - - start = desc->physical_start; - end = start + (desc->num_pages << PAGE_SHIFT); - grub_dprintf("mm", "%s: start=0x%016llx, end=0x%016llx\n", - __FUNCTION__, start, end); - start = start < min_start ? min_start : start; - if (start + size > end) - continue; - grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n", - __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start); - mem = grub_efi_allocate_fixed (start, (size >> PAGE_SHIFT) + 1); - grub_dprintf("mm", "%s: retval=0x%08x\n", - __FUNCTION__, (grub_addr_t) mem); - if (! mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); - goto fail; - } - break; - } - - if (! mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); - goto fail; - } - - grub_free (mmap); - return mem; - - fail: - grub_free (mmap); - return NULL; -} - -grub_err_t -grub_efi_prepare_platform (void) -{ - grub_efi_uintn_t mmap_size; - grub_efi_uintn_t map_key; - grub_efi_uintn_t desc_size; - grub_efi_uint32_t desc_version; - grub_efi_memory_descriptor_t *mmap_buf; - grub_err_t err; - - /* - * Cloned from IA64 - * Must be done after grub_machine_fini because map_key is used by - *exit_boot_services. - */ - mmap_size = find_mmap_size (); - if (! mmap_size) - return GRUB_ERR_OUT_OF_MEMORY; - mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); - if (! mmap_buf) - return GRUB_ERR_OUT_OF_MEMORY; - - err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, - &desc_size, &desc_version); - if (err != GRUB_ERR_NONE) - return err; - - return GRUB_ERR_NONE; -} diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 9f43e41bb..b4f609d2d 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -290,15 +290,6 @@ linux_boot (void) */ linuxmain = (kernel_entry_t) linux_addr; -#ifdef GRUB_MACHINE_EFI - { - grub_err_t err; - err = grub_efi_prepare_platform(); - if (err != GRUB_ERR_NONE) - return err; - } -#endif - grub_arm_disable_caches_mmu (); linuxmain (0, machine_type, target_fdt); @@ -317,13 +308,7 @@ linux_load (const char *filename, grub_file_t file) size = grub_file_size (file); -#ifdef GRUB_MACHINE_EFI - linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size); - if (!linux_addr) - return grub_errno; -#else linux_addr = LINUX_ADDRESS; -#endif grub_dprintf ("loader", "Loading Linux to 0x%08x\n", (grub_addr_t) linux_addr); @@ -428,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), size = grub_get_initrd_size (&initrd_ctx); -#ifdef GRUB_MACHINE_EFI - if (initrd_start) - grub_efi_free_pages (initrd_start, - (initrd_end - initrd_start + 0xfff) >> 12); - initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size); - - if (!initrd_start) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - goto fail; - } -#else initrd_start = LINUX_INITRD_ADDRESS; -#endif grub_dprintf ("loader", "Loading initrd to 0x%08x\n", (grub_addr_t) initrd_start); diff --git a/include/grub/arm/efi/loader.h b/include/grub/arm/efi/loader.h deleted file mode 100644 index 4bab18e83..000000000 --- a/include/grub/arm/efi/loader.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2013 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 . - */ - -#ifndef GRUB_LOADER_MACHINE_HEADER -#define GRUB_LOADER_MACHINE_HEADER 1 - -grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void); -void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t min_offset, - grub_uint32_t size); - -#endif /* ! GRUB_LOADER_MACHINE_HEADER */ diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 3d0d15eb4..712ba17b9 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -46,20 +46,6 @@ struct linux_arm_kernel_header { # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type -#elif defined GRUB_MACHINE_EFI -# include -# include -/* On UEFI platforms - load the images at the lowest available address not - less than *_PHYS_OFFSET from the first available memory location. */ -# define LINUX_PHYS_OFFSET (0x00008000) -# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) -# define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) -# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt -static inline grub_uint32_t -grub_arm_firmware_get_machine_type (void) -{ - return GRUB_ARM_MACHINE_TYPE_FDT; -} #elif defined (GRUB_MACHINE_COREBOOT) #include #include @@ -78,6 +64,4 @@ grub_arm_firmware_get_machine_type (void) } #endif -#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 - #endif /* ! GRUB_ARM_LINUX_HEADER */ From a2f26adfef2fc8a7d7392c3704031df4624c67b0 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 18:33:05 +0100 Subject: [PATCH 0829/1167] efi: Restrict arm/arm64 linux loader initrd placement The 32-bit arm Linux kernel is built as a zImage, which self-decompresses down to near start of RAM. In order for an initrd/initramfs to be accessible, it needs to be placed within the first ~768MB of RAM. The initrd loader built into the kernel EFI stub restricts this down to 512MB for simplicity - so enable the same restriction in grub. For arm64, the requirement is within a 1GB aligned 32GB window also covering the (runtime) kernel image. Since the EFI stub loader itself will attempt to relocate to near start of RAM, force initrd to be loaded completely within the first 32GB of RAM. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index f90c5f926..1f86229f8 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -193,6 +193,42 @@ grub_linux_unload (void) return GRUB_ERR_NONE; } +/* + * As per linux/Documentation/arm/Booting + * ARM initrd needs to be covered by kernel linear mapping, + * so place it in the first 512MB of DRAM. + * + * As per linux/Documentation/arm64/booting.txt + * ARM64 initrd needs to be contained entirely within a 1GB aligned window + * of up to 32GB of size that covers the kernel image as well. + * Since the EFI stub loader will attempt to load the kernel near start of + * RAM, place the buffer in the first 32GB of RAM. + */ +#ifdef __arm__ +#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024) +#else /* __aarch64__ */ +#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024) +#endif + +/* + * This function returns a pointer to a legally allocated initrd buffer, + * or NULL if unsuccessful + */ +static void * +allocate_initrd_mem (int initrd_pages) +{ + grub_addr_t max_addr; + + if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) + return NULL; + + max_addr += INITRD_MAX_ADDRESS_OFFSET - 1; + + return grub_efi_allocate_pages_real (max_addr, initrd_pages, + GRUB_EFI_ALLOCATE_MAX_ADDRESS, + GRUB_EFI_LOADER_DATA); +} + static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) @@ -221,7 +257,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); - initrd_mem = grub_efi_allocate_any_pages (initrd_pages); + initrd_mem = allocate_initrd_mem (initrd_pages); + if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); From c79ebcd18cf3e208e9dda5e2ae008f76c92fe451 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 9 Jul 2018 19:49:06 +0100 Subject: [PATCH 0830/1167] i386: Don't include lib/i386/reset.c in EFI builds Commit 0ba90a7f0178 ("efi: Move grub_reboot() into kernel") broke the build on i386-efi - genmoddep.awk bails out with message grub_reboot in reboot is duplicated in kernel This is because both lib/i386/reset.c and kern/efi/efi.c now provide this function. Rather than explicitly list each i386 platform variant in Makefile.core.def, include the contents of lib/i386/reset.c only when GRUB_MACHINE_EFI is not set. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/lib/i386/reboot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/lib/i386/reboot.c b/grub-core/lib/i386/reboot.c index a234244dc..dce0b563d 100644 --- a/grub-core/lib/i386/reboot.c +++ b/grub-core/lib/i386/reboot.c @@ -16,6 +16,8 @@ * along with GRUB. If not, see . */ +#ifndef GRUB_MACHINE_EFI + #include #include #include @@ -58,3 +60,5 @@ grub_reboot (void) while (1); } + +#endif /* GRUB_MACHINE_EFI */ From ad2bebc6fc3d77e38294aaa824362a0851239703 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 13 Jul 2018 17:34:43 +0100 Subject: [PATCH 0831/1167] loader/i386/linux: Use central copy of grub_efi_find_mmap_size() Delete local copy of function to determine required buffer size for the UEFI memory map, use helper in kern/efi/mm.c. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/i386/linux.c | 51 +---------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 9b53d3168..4eab55a2d 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -101,55 +101,6 @@ page_align (grub_size_t size) return (size + (1 << 12) - 1) & (~((1 << 12) - 1)); } -#ifdef GRUB_MACHINE_EFI -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static grub_efi_uintn_t -find_efi_mmap_size (void) -{ - static grub_efi_uintn_t mmap_size = 0; - - if (mmap_size != 0) - return mmap_size; - - mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - grub_efi_uintn_t cur_mmap_size = mmap_size; - - mmap = grub_malloc (cur_mmap_size); - if (! mmap) - return 0; - - ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - return 0; - } - else if (ret > 0) - break; - - if (mmap_size < cur_mmap_size) - mmap_size = cur_mmap_size; - mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - mmap_size += (3 << 12); - - mmap_size = page_align (mmap_size); - return mmap_size; -} - -#endif - /* Helper for find_mmap_size. */ static int count_hook (grub_uint64_t addr __attribute__ ((unused)), @@ -566,7 +517,7 @@ grub_linux_boot (void) ctx.real_size = ALIGN_UP (cl_offset + maximal_cmdline_size, 4096); #ifdef GRUB_MACHINE_EFI - efi_mmap_size = find_efi_mmap_size (); + efi_mmap_size = grub_efi_find_mmap_size (); if (efi_mmap_size == 0) return grub_errno; #endif From 9415914e0fb4d0e09f49431cfb591551bd20f63a Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 13 Jul 2018 17:34:44 +0100 Subject: [PATCH 0832/1167] loader/ia64/linux: Use central copy of grub_efi_find_mmap_size() Delete local copy of function to determine required buffer size for the UEFI memory map, use helper in kern/efi/mm.c. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/ia64/efi/linux.c | 46 ++----------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 750330d45..96fce713a 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -133,48 +133,6 @@ query_fpswa (void) } } -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static grub_efi_uintn_t -find_mmap_size (void) -{ - static grub_efi_uintn_t mmap_size = 0; - - if (mmap_size != 0) - return mmap_size; - - mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - - mmap = grub_malloc (mmap_size); - if (! mmap) - return 0; - - ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - return 0; - } - else if (ret > 0) - break; - - mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - mmap_size += (1 << 12); - - return page_align (mmap_size); -} - static void free_pages (void) { @@ -212,7 +170,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages, size = size_pages << 12; - mmap_size = find_mmap_size (); + mmap_size = grub_efi_find_mmap_size (); if (!mmap_size) return 0; @@ -323,7 +281,7 @@ grub_linux_boot (void) /* MDT. Must be done after grub_machine_fini because map_key is used by exit_boot_services. */ - mmap_size = find_mmap_size (); + mmap_size = grub_efi_find_mmap_size (); if (! mmap_size) return grub_errno; mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); From 9bfba354bbd9f1541b1e5593549809aa3e720992 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 13 Jul 2018 17:34:45 +0100 Subject: [PATCH 0833/1167] loader/multiboot_mbi2: Use central copy of grub_efi_find_mmap_size() Delete local copy of function to determine required buffer size for the UEFI memory map, use helper in kern/efi/mm.c. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/multiboot_mbi2.c | 38 +------------------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 4df659595..747e10850 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -407,42 +407,6 @@ acpiv2_size (void) static grub_efi_uintn_t efi_mmap_size = 0; -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static void -find_efi_mmap_size (void) -{ - efi_mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - grub_efi_uintn_t cur_mmap_size = efi_mmap_size; - - mmap = grub_malloc (cur_mmap_size); - if (! mmap) - return; - - ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - return; - else if (ret > 0) - break; - - if (efi_mmap_size < cur_mmap_size) - efi_mmap_size = cur_mmap_size; - efi_mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - efi_mmap_size += (3 << 12); - - efi_mmap_size = ALIGN_UP (efi_mmap_size, 4096); -} #endif static grub_size_t @@ -463,7 +427,7 @@ grub_multiboot2_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI if (!keep_bs && !efi_mmap_size) - find_efi_mmap_size (); + efi_mmap_size = grub_efi_find_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) + sizeof (struct multiboot_tag) From a6c83d4a20f4256a12422ba9592d831c9cc8e8a5 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 1 Aug 2018 12:28:43 -0400 Subject: [PATCH 0834/1167] configure: Fix an 8 year old typo Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c7888e40f..74073fbc1 100644 --- a/configure.ac +++ b/configure.ac @@ -277,7 +277,7 @@ fi AC_SUBST(bootdirname) AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname", - [Default boot directory name]") + [Default boot directory name]) AC_ARG_WITH([grubdir], AS_HELP_STRING([--with-grubdir=DIR], From 8317c9eab979fc06df7cbd37a68e321447b568fc Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 1 Aug 2018 12:23:03 -0400 Subject: [PATCH 0835/1167] grub-module-verifier: Report the filename or modname in errors Make it so that when grub-module-verifier complains of an issue, it tells you which module the issue was with. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- include/grub/module_verifier.h | 4 +-- util/grub-module-verifier.c | 6 ++-- util/grub-module-verifierXX.c | 58 ++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h index f4870cb9c..ba21c75e2 100644 --- a/include/grub/module_verifier.h +++ b/include/grub/module_verifier.h @@ -16,5 +16,5 @@ struct grub_module_verifier_arch { const int *short_relocations; }; -void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); -void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); +void grub_module_verify64(const char * const filename, void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); +void grub_module_verify32(const char * const filename, void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index a79271f66..03ba1ab43 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -157,7 +157,7 @@ main (int argc, char **argv) if (strcmp(archs[arch].name, argv[2]) == 0) break; if (arch == ARRAY_SIZE(archs)) - grub_util_error("unknown arch: %s", argv[2]); + grub_util_error("%s: unknown arch: %s", argv[1], argv[2]); for (whitelist = 0; whitelist < ARRAY_SIZE(whitelists); whitelist++) if (strcmp(whitelists[whitelist].arch, argv[2]) == 0 @@ -169,8 +169,8 @@ main (int argc, char **argv) module_size = grub_util_get_image_size (argv[1]); module_img = grub_util_read_image (argv[1]); if (archs[arch].voidp_sizeof == 8) - grub_module_verify64(module_img, module_size, &archs[arch], whitelist_empty); + grub_module_verify64(argv[1], module_img, module_size, &archs[arch], whitelist_empty); else - grub_module_verify32(module_img, module_size, &archs[arch], whitelist_empty); + grub_module_verify32(argv[1], module_img, module_size, &archs[arch], whitelist_empty); return 0; } diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 1feaafc9b..ceb24309a 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -151,14 +151,15 @@ find_section (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, const c } static void -check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +check_license (const char * const filename, + const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) { Elf_Shdr *s = find_section (arch, e, ".module_license"); if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0 || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0 || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0)) return; - grub_util_error ("incompatible license"); + grub_util_error ("%s: incompatible license", filename); } static Elf_Sym * @@ -224,10 +225,10 @@ check_symbols (const struct grub_module_verifier_arch *arch, s = find_section (arch, e, ".moddeps"); if (!s) - grub_util_error ("no symbol table and no .moddeps section"); + grub_util_error ("%s: no symbol table and no .moddeps section", modname); if (!s->sh_size) - grub_util_error ("no symbol table and empty .moddeps section"); + grub_util_error ("%s: no symbol table and empty .moddeps section", modname); return; } @@ -248,7 +249,7 @@ check_symbols (const struct grub_module_verifier_arch *arch, break; default: - return grub_util_error ("unknown symbol type `%d'", (int) type); + return grub_util_error ("%s: unknown symbol type `%d'", modname, (int) type); } } } @@ -274,7 +275,8 @@ is_symbol_local(Elf_Sym *sym) } static void -section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, +section_check_relocations (const char * const modname, + const struct grub_module_verifier_arch *arch, void *ehdr, Elf_Shdr *s, size_t target_seg_size) { Elf_Rel *rel, *max; @@ -283,7 +285,7 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); if (!symtab) - grub_util_error ("relocation without symbol table"); + grub_util_error ("%s: relocation without symbol table", modname); for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); @@ -294,7 +296,7 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e unsigned i; if (target_seg_size < grub_target_to_host (rel->r_offset)) - grub_util_error ("reloc offset is out of the segment"); + grub_util_error ("%s: reloc offset is out of the segment", modname); grub_uint32_t type = ELF_R_TYPE (grub_target_to_host (rel->r_info)); @@ -307,17 +309,17 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e if (arch->supported_relocations[i] != -1) continue; if (!arch->short_relocations) - grub_util_error ("unsupported relocation 0x%x", type); + grub_util_error ("%s: unsupported relocation 0x%x", modname, type); for (i = 0; arch->short_relocations[i] != -1; i++) if (type == arch->short_relocations[i]) break; if (arch->short_relocations[i] == -1) - grub_util_error ("unsupported relocation 0x%x", type); + grub_util_error ("%s: unsupported relocation 0x%x", modname, type); sym = (Elf_Sym *) ((char *) symtab + symtabentsize * ELF_R_SYM (grub_target_to_host (rel->r_info))); if (is_symbol_local (sym)) continue; - grub_util_error ("relocation 0x%x is not module-local", type); + grub_util_error ("%s: relocation 0x%x is not module-local", modname, type); } #if defined(MODULEVERIFIER_ELF64) if (arch->machine == EM_AARCH64) @@ -342,11 +344,11 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC) break; if (rel2 >= (Elf_Rela *) max) - grub_util_error ("ADR_GOT_PAGE without matching LD64_GOT_LO12_NC"); + grub_util_error ("%s: ADR_GOT_PAGE without matching LD64_GOT_LO12_NC", modname); break; case R_AARCH64_LD64_GOT_LO12_NC: if (unmatched_adr_got_page == 0) - grub_util_error ("LD64_GOT_LO12_NC without matching ADR_GOT_PAGE"); + grub_util_error ("%s: LD64_GOT_LO12_NC without matching ADR_GOT_PAGE", modname); unmatched_adr_got_page--; break; } @@ -356,7 +358,8 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e } static void -check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +check_relocations (const char * const modname, + const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) { Elf_Shdr *s; unsigned i; @@ -369,21 +372,22 @@ check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) Elf_Shdr *ts; if (grub_target_to_host32 (s->sh_type) == SHT_REL && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_REL)) - grub_util_error ("unsupported SHT_REL"); + grub_util_error ("%s: unsupported SHT_REL", modname); if (grub_target_to_host32 (s->sh_type) == SHT_RELA && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_RELA)) - grub_util_error ("unsupported SHT_RELA"); + grub_util_error ("%s: unsupported SHT_RELA", modname); /* Find the target segment. */ if (grub_target_to_host32 (s->sh_info) >= grub_target_to_host16 (e->e_shnum)) - grub_util_error ("orphaned reloc section"); + grub_util_error ("%s: orphaned reloc section", modname); ts = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host32 (s->sh_info) * grub_target_to_host16 (e->e_shentsize)); - section_check_relocations (arch, e, s, grub_target_to_host (ts->sh_size)); + section_check_relocations (modname, arch, e, s, grub_target_to_host (ts->sh_size)); } } void -SUFFIX(grub_module_verify) (void *module_img, size_t size, +SUFFIX(grub_module_verify) (const char * const filename, + void *module_img, size_t size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty) { @@ -391,7 +395,7 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, /* Check the header size. */ if (size < sizeof (Elf_Ehdr)) - grub_util_error ("ELF header smaller than expected"); + grub_util_error ("%s: ELF header smaller than expected", filename); /* Check the magic numbers. */ if (e->e_ident[EI_MAG0] != ELFMAG0 @@ -400,36 +404,36 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, || e->e_ident[EI_MAG3] != ELFMAG3 || e->e_ident[EI_VERSION] != EV_CURRENT || grub_target_to_host32 (e->e_version) != EV_CURRENT) - grub_util_error ("invalid arch-independent ELF magic"); + grub_util_error ("%s: invalid arch-independent ELF magic", filename); if (e->e_ident[EI_CLASS] != ELFCLASSXX || e->e_ident[EI_DATA] != (arch->bigendian ? ELFDATA2MSB : ELFDATA2LSB) || grub_target_to_host16 (e->e_machine) != arch->machine) - grub_util_error ("invalid arch-dependent ELF magic"); + grub_util_error ("%s: invalid arch-dependent ELF magic", filename); if (grub_target_to_host16 (e->e_type) != ET_REL) { - grub_util_error ("this ELF file is not of the right type"); + grub_util_error ("%s: this ELF file is not of the right type", filename); } /* Make sure that every section is within the core. */ if (size < grub_target_to_host (e->e_shoff) + (grub_uint32_t) grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) { - grub_util_error ("ELF sections outside core"); + grub_util_error ("%s: ELF sections outside core", filename); } - check_license (arch, e); + check_license (filename, arch, e); Elf_Shdr *s; const char *modname; s = find_section (arch, e, ".modname"); if (!s) - grub_util_error ("no module name found"); + grub_util_error ("%s: no module name found", filename); modname = (const char *) e + grub_target_to_host (s->sh_offset); check_symbols(arch, e, modname, whitelist_empty); - check_relocations(arch, e); + check_relocations(modname, arch, e); } From 7090b77341fbb0fd45c72a77e8508a25bf35835d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 30 Jul 2018 12:37:22 +0100 Subject: [PATCH 0836/1167] tests: Disable sercon in SeaBIOS SeaBIOS 1.11.0 added support for VGA emulation over a serial port, which interferes with grub-shell. Turn it off. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- tests/util/grub-shell.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index d690d6734..93e9f5148 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -369,6 +369,13 @@ test -z "$debug" || echo "GRUB ROM directory: ${rom_directory}" >&2 if test -z "$debug"; then qemuopts="${qemuopts} -nographic -monitor file:/dev/null" + # SeaBIOS 1.11.0 added support for VGA emulation over a serial port. If + # this is configured in SeaBIOS, then -nographic causes some extra junk to + # end up on the serial console, which interferes with our tests. This + # workaround unfortunately causes qemu to issue a warning 'externally + # provided fw_cfg item names should be prefixed with "opt/"', but there + # doesn't seem to be a better option. + qemuopts="${qemuopts} -fw_cfg name=etc/sercon-port,string=0" fi if [ x$boot != xnet ] && [ x$boot != xemu ]; then From b607d2a79ef7ddd0ba4e00ac2e0d2181b8e5d949 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 30 Jul 2018 12:37:42 +0100 Subject: [PATCH 0837/1167] tests: Fix qemu options for UHCI test qemu 2.12 removed the -usbdevice option. Use a more modern spelling instead, in line with other USB-related tests. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- tests/uhci_test.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/uhci_test.in b/tests/uhci_test.in index 4af72fd8f..f0eec5032 100644 --- a/tests/uhci_test.in +++ b/tests/uhci_test.in @@ -41,7 +41,7 @@ echo "hello" > "$outfile" tar cf "$imgfile" "$outfile" -if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-usb -usbdevice disk:$imgfile" | tail -n 1)" != "Hello World" ]; then +if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device ich9-usb-uhci1 -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then rm "$imgfile" rm "$outfile" exit 1 From 5d7d13ce44875289ac1b5034f311e047dfc62866 Mon Sep 17 00:00:00 2001 From: Cao jin Date: Tue, 7 Aug 2018 14:57:53 +0800 Subject: [PATCH 0838/1167] linux16: Code cleanup 1. move relocator related code more close to each other 2. use variable "len" since it has correct assignment, and keep coding style with upper code Signed-off-by: Cao jin Reviewed-by: Daniel Kiper --- grub-core/loader/i386/pc/linux.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index b69cb7a3a..531b58d37 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -236,10 +236,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), (unsigned) real_size, (unsigned) grub_linux16_prot_size); - relocator = grub_relocator_new (); - if (!relocator) - goto fail; - for (i = 1; i < argc; i++) if (grub_memcmp (argv[i], "vga=", 4) == 0) { @@ -299,6 +295,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } } + relocator = grub_relocator_new (); + if (!relocator) + goto fail; + { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_addr (relocator, &ch, @@ -355,8 +355,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = grub_linux16_prot_size; - if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size) - != (grub_ssize_t) grub_linux16_prot_size && !grub_errno) + if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); From d62cafcf357f9103d9aea6eb4702b862dc67659a Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Thu, 9 Aug 2018 18:10:51 +0200 Subject: [PATCH 0839/1167] ahci: Increase time-out from 10 s to 32 s This is a cryptographically signed message in MIME format. Date: Thu, 9 Aug 2018 07:27:35 +0200 Currently, the GRUB payload for coreboot does not detect the Western Digital hard disk WDC WD20EARS-60M AB51 connected to the ASRock E350M1, as that takes over ten seconds to spin up. ``` disk/ahci.c:533: port 0, err: 0 disk/ahci.c:539: port 0, err: 0 disk/ahci.c:543: port 0, err: 0 disk/ahci.c:549: port 0, offset: 120, tfd:80, CMD: 6016 disk/ahci.c:552: port 0, err: 0 disk/ahci.c:563: port 0, offset: 120, tfd:80, CMD: 6016 disk/ahci.c:566: port: 0, err: 0 disk/ahci.c:593: port 0 is busy disk/ahci.c:621: cleaning up failed devs ``` GRUB detects the drive, when either unloading the module *ahci*, and then loading it again, or when doing a warm reset. As the ten second time-out is too short, increase it to 32 seconds, used by SeaBIOS. which detects the drive successfully. The AHCI driver in libpayload uses 30 seconds, and that time-out was added in commit 354066e1 (libpayload: ahci: Increase timeout for signature reading) with the description below. > We can't read the drives signature before it's ready, i.e. spun up. > So set the timeout to the standard 30s. Also put a notice on the > console, so the user knows why the signature reading failed. Signed-off-by: Paul Menzel Reviewed-by: Daniel Kiper --- grub-core/disk/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index f2f606423..0e6d56c24 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -576,7 +576,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, grub_ahci_readwrite_real (dev, &parms2, 1, 1);*/ } - endtime = grub_get_time_ms () + 10000; + endtime = grub_get_time_ms () + 32000; while (grub_get_time_ms () < endtime) { From d2374cfb71ce56bfd13bc208c72644fb6aa5ddd1 Mon Sep 17 00:00:00 2001 From: Cao jin Date: Tue, 14 Aug 2018 15:03:25 +0800 Subject: [PATCH 0840/1167] relocator16: Comments update Signed-off-by: Cao jin Reviewed-by: Daniel Kiper --- grub-core/lib/i386/relocator16.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relocator16.S index c8d6f86d8..371a2ed69 100644 --- a/grub-core/lib/i386/relocator16.S +++ b/grub-core/lib/i386/relocator16.S @@ -204,8 +204,9 @@ LOCAL(gate_a20_check_state): ret LOCAL(gate_a20_done): - /* we are in real mode now - * set up the real mode segment registers : DS, SS, ES + /* + * We are in real mode now. Set up the real mode segment registers and + * all the other general purpose registers. cs is updated with ljmp. */ /* movw imm16, %ax. */ .byte 0xb8 @@ -298,7 +299,7 @@ LOCAL(gdt): .byte 0, 0x92, 0xCF, 0 /* -- 16 bit real mode CS -- - * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present + * base = filled by code, limit 0x0FFFF (1 B Granularity), present * type = 16 bit code execute/read only/conforming, DPL = 0 */ .word 0xFFFF From 478e54b7380f7fe53bd9a664f1496b72ce1ea9e6 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Fri, 17 Aug 2018 17:33:44 -0600 Subject: [PATCH 0841/1167] grub-reboot: Warn when "for the next boot only" promise cannot be kept The "for the next boot only" property of grub-reboot is dependent upon GRUB being able to clear the next_entry variable in the environment block. However, GRUB cannot write to devices using the diskfilter and lvm abstractions. Ref: https://lists.gnu.org/archive/html/grub-devel/2009-12/msg00276.html Ref: https://bugs.launchpad.net/bugs/788298 Signed-off-by: dann frazier Reviewed-by: Daniel Kiper --- util/grub-reboot.in | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/util/grub-reboot.in b/util/grub-reboot.in index 4d4f75704..ef3b5c049 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -20,6 +20,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ +sbindir=@sbindir@ sysconfdir="@sysconfdir@" PACKAGE_NAME=@PACKAGE_NAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ @@ -32,6 +33,7 @@ fi self=`basename $0` grub_editenv=${bindir}/@grub_editenv@ +grub_probe=${sbindir}/@grub_probe@ rootdir= bootdir= grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` @@ -56,6 +58,8 @@ submenus or sub-submenus require specifying the submenu components and then the menu item component. The titles should be separated using the greater-than character (>) with no extra spaces. Depending on your shell some characters including > may need escaping. More information about this is available in the GRUB Manual in the section about the 'default' command. "; echo + echo + gettext "NOTE: In cases where GRUB cannot write to the environment block, such as when it is stored on an MDRAID or LVM device, the chosen boot menu entry will remain the default even after reboot. "; echo echo gettext "Report bugs to ."; echo } @@ -131,6 +135,18 @@ fi grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'` +abstractions=`$grub_probe --target=abstraction ${grubdir}/grubenv` +for abstraction in $abstractions; do + case "$abstraction" in + diskfilter | lvm) + gettext_printf "\nWARNING: Detected GRUB environment block on $abstraction device\n" + gettext_printf "%s will remain the default boot entry until manually cleared with:\n" "${entry}" + gettext_printf " grub-editenv ${grubdir}/grubenv unset next_entry\n\n" + break + ;; + esac +done + # Restore saved_entry if it was set by previous version prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^prev_saved_entry=//p'` if [ "$prev_saved_entry" ]; then From a661a321c314d23cd2666c82cbb38d356c7956ba Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 3 Sep 2018 10:09:15 +0200 Subject: [PATCH 0842/1167] ofnet: Initialize structs in bootpath parser Code later on checks if variables inside the struct are 0 to see if they have been set, like if there were addresses in the bootpath. The variables were not initialized however, so the check might succeed with uninitialized data, and a new interface with random addresses and the same name is added. This causes $net_default_mac to point to the random one, so, for example, using that variable to load per-mac config files fails. Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859 Signed-off-by: Julian Andres Klode Reviewed-by: Daniel Kiper --- grub-core/net/drivers/ieee1275/ofnet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 002446be1..00abc64bb 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -153,8 +153,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, char *comma_char = 0; char *equal_char = 0; grub_size_t field_counter = 0; - grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; - grub_net_link_level_address_t hw_addr; + grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {}; + grub_net_link_level_address_t hw_addr = {}; grub_net_interface_flags_t flags = 0; struct grub_net_network_level_interface *inter = NULL; grub_uint16_t vlantag = 0; From bcfa0f08bbb1b81b9eca4aa8bba223e835618145 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 30 Jan 2018 21:58:53 +0000 Subject: [PATCH 0843/1167] build: Capitalise *freetype_* variables Using FREETYPE_CFLAGS and FREETYPE_LIBS is more in line with the naming scheme used by pkg-config macros. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- Makefile.am | 6 +++--- Makefile.util.def | 4 ++-- configure.ac | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7795baeb6..a52a998a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,7 @@ endif starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0 build-grub-mkfont$(BUILD_EXEEXT): util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs) + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS) CLEANFILES += build-grub-mkfont$(BUILD_EXEEXT) garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c @@ -80,11 +80,11 @@ CLEANFILES += garbage-gen$(BUILD_EXEEXT) EXTRA_DIST += util/garbage-gen.c build-grub-gen-asciih$(BUILD_EXEEXT): util/grub-gen-asciih.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS) -Wall -Werror CLEANFILES += build-grub-gen-asciih$(BUILD_EXEEXT) build-grub-gen-widthspec$(BUILD_EXEEXT): util/grub-gen-widthspec.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS) -Wall -Werror CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT) if COND_STARFIELD diff --git a/Makefile.util.def b/Makefile.util.def index 3180ac880..9ae45f351 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -303,14 +303,14 @@ program = { common = grub-core/kern/emu/argp_common.c; common = grub-core/osdep/init.c; - cflags = '$(freetype_cflags)'; + cflags = '$(FREETYPE_CFLAGS)'; cppflags = '-DGRUB_MKFONT=1'; ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(freetype_libs)'; + ldadd = '$(FREETYPE_LIBS)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; condition = COND_GRUB_MKFONT; }; diff --git a/configure.ac b/configure.ac index 74073fbc1..c20ecfbc6 100644 --- a/configure.ac +++ b/configure.ac @@ -1520,12 +1520,12 @@ unset ac_cv_header_ft2build_h if test x"$grub_mkfont_excuse" = x ; then # Check for freetype libraries. - freetype_cflags=`$FREETYPE --cflags` - freetype_libs=`$FREETYPE --libs` + FREETYPE_CFLAGS=`$FREETYPE --cflags` + FREETYPE_LIBS=`$FREETYPE --libs` SAVED_CPPFLAGS="$CPPFLAGS" SAVED_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $freetype_cflags" - LIBS="$LIBS $freetype_libs" + CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS" + LIBS="$LIBS $FREETYPE_LIBS" AC_CHECK_HEADERS([ft2build.h], [], [grub_mkfont_excuse=["need freetype2 headers"]]) AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]]) @@ -1542,8 +1542,8 @@ else enable_grub_mkfont=no fi AC_SUBST([enable_grub_mkfont]) -AC_SUBST([freetype_cflags]) -AC_SUBST([freetype_libs]) +AC_SUBST([FREETYPE_CFLAGS]) +AC_SUBST([FREETYPE_LIBS]) SAVED_CC="$CC" SAVED_CPP="$CPP" @@ -1581,12 +1581,12 @@ fi if test x"$grub_build_mkfont_excuse" = x ; then # Check for freetype libraries. - build_freetype_cflags=`$BUILD_FREETYPE --cflags` - build_freetype_libs=`$BUILD_FREETYPE --libs` + BUILD_FREETYPE_CFLAGS=`$BUILD_FREETYPE --cflags` + BUILD_FREETYPE_LIBS=`$BUILD_FREETYPE --libs` SAVED_CPPFLAGS_2="$CPPFLAGS" SAVED_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $build_freetype_cflags" - LIBS="$LIBS $build_freetype_libs" + CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS" + LIBS="$LIBS $BUILD_FREETYPE_LIBS" AC_CHECK_HEADERS([ft2build.h], [], [grub_build_mkfont_excuse=["need freetype2 headers"]]) AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]]) @@ -1610,8 +1610,8 @@ if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || tes fi fi -AC_SUBST([build_freetype_cflags]) -AC_SUBST([build_freetype_libs]) +AC_SUBST([BUILD_FREETYPE_CFLAGS]) +AC_SUBST([BUILD_FREETYPE_LIBS]) CC="$SAVED_CC" CPP="$SAVED_CPP" From 7e23437df3ad7572756102f3ab1063f284b57983 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 30 Jan 2018 21:59:09 +0000 Subject: [PATCH 0844/1167] build: Use pkg-config to find FreeType pkg-config is apparently preferred over freetype-config these days (see the BUGS section of freetype-config(1)). pkg-config support was added to FreeType in version 2.1.5, which was released in 2003, so it should comfortably be available everywhere by now. We no longer need to explicitly substitute FREETYPE_CFLAGS and FREETYPE_LIBS, since PKG_CHECK_MODULES does that automatically. Fixes Debian bug #887721. Reported-by: Hugh McMaster Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- INSTALL | 11 ++++---- configure.ac | 74 ++++++++++++++++++++++------------------------------ 2 files changed, 37 insertions(+), 48 deletions(-) diff --git a/INSTALL b/INSTALL index f3c20edc8..b370d7753 100644 --- a/INSTALL +++ b/INSTALL @@ -37,6 +37,7 @@ configuring the GRUB. * GNU gettext 0.17 or later * GNU binutils 2.9.1.0.23 or later * Flex 2.5.35 or later +* pkg-config * Other standard GNU/Unix tools * a libc with large file support (e.g. glibc 2.1 or later) @@ -52,7 +53,7 @@ For optional grub-emu features, you need: To build GRUB's graphical terminal (gfxterm), you need: -* FreeType 2 or later +* FreeType 2.1.5 or later * GNU Unifont If you use a development snapshot or want to hack on GRUB you may @@ -158,8 +159,8 @@ For this example the configure line might look like (more details below) (some options are optional and included here for completeness but some rarely used options are omitted): -./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu -CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config +./configure BUILD_CC=gcc BUILD_PKG_CONFIG=pkg-config --host=amd64-linux-gnu +CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" PKG_CONFIG=amd64-linux-gnu-pkg-config --target=arm --with-platform=uboot TARGET_CC=arm-elf-gcc TARGET_CFLAGS="-Os -march=armv6" TARGET_CCASFLAGS="-march=armv6" TARGET_OBJCOPY="arm-elf-objcopy" TARGET_STRIP="arm-elf-strip" @@ -176,7 +177,7 @@ corresponding platform are not needed for the platform in question. 2. BUILD_CFLAGS= for C options for build. 3. BUILD_CPPFLAGS= for C preprocessor options for build. 4. BUILD_LDFLAGS= for linker options for build. - 5. BUILD_FREETYPE= for freetype-config for build (optional). + 5. BUILD_PKG_CONFIG= for pkg-config for build (optional). - For host 1. --host= to autoconf name of host. @@ -184,7 +185,7 @@ corresponding platform are not needed for the platform in question. 3. HOST_CFLAGS= for C options for host. 4. HOST_CPPFLAGS= for C preprocessor options for host. 5. HOST_LDFLAGS= for linker options for host. - 6. FREETYPE= for freetype-config for host (optional). + 6. PKG_CONFIG= for pkg-config for host (optional). 7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional). 8. Libfuse if any must be in standard linker folders (-lfuse) (optional). 9. Libzfs if any must be in standard linker folders (-lzfs) (optional). diff --git a/configure.ac b/configure.ac index c20ecfbc6..903f58eb7 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,10 @@ AC_PREREQ(2.60) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config-util.h]) +# Explicitly check for pkg-config early on, since otherwise conditional +# calls are problematic. +PKG_PROG_PKG_CONFIG + # Program name transformations AC_ARG_PROGRAM grub_TRANSFORM([grub-bios-setup]) @@ -1508,29 +1512,22 @@ if test x"$enable_grub_mkfont" = xno ; then grub_mkfont_excuse="explicitly disabled" fi -if test x"$grub_mkfont_excuse" = x ; then - # Check for freetype libraries. - AC_CHECK_TOOLS([FREETYPE], [freetype-config]) - if test "x$FREETYPE" = x ; then - grub_mkfont_excuse=["need freetype2 library"] - fi -fi - unset ac_cv_header_ft2build_h if test x"$grub_mkfont_excuse" = x ; then # Check for freetype libraries. - FREETYPE_CFLAGS=`$FREETYPE --cflags` - FREETYPE_LIBS=`$FREETYPE --libs` - SAVED_CPPFLAGS="$CPPFLAGS" - SAVED_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS" - LIBS="$LIBS $FREETYPE_LIBS" - AC_CHECK_HEADERS([ft2build.h], [], - [grub_mkfont_excuse=["need freetype2 headers"]]) - AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]]) - CPPFLAGS="$SAVED_CPPFLAGS" - LIBS="$SAVED_LIBS" + PKG_CHECK_MODULES([FREETYPE], [freetype2], [ + SAVED_CPPFLAGS="$CPPFLAGS" + SAVED_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS" + LIBS="$LIBS $FREETYPE_LIBS" + AC_CHECK_HEADERS([ft2build.h], [], + [grub_mkfont_excuse=["need freetype2 headers"]]) + AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], + [grub_mkfont_excuse=["freetype2 library unusable"]]) + CPPFLAGS="$SAVED_CPPFLAGS" + LIBS="$SAVED_LIBS" + ], [grub_mkfont_excuse=["need freetype2 library"]]) fi if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then @@ -1542,8 +1539,6 @@ else enable_grub_mkfont=no fi AC_SUBST([enable_grub_mkfont]) -AC_SUBST([FREETYPE_CFLAGS]) -AC_SUBST([FREETYPE_LIBS]) SAVED_CC="$CC" SAVED_CPP="$CPP" @@ -1573,25 +1568,21 @@ AC_SUBST([BUILD_WORDS_BIGENDIAN]) if test x"$grub_build_mkfont_excuse" = x ; then # Check for freetype libraries. - AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config]) - if test "x$BUILD_FREETYPE" = x ; then - grub_build_mkfont_excuse=["need freetype2 library"] - fi -fi - -if test x"$grub_build_mkfont_excuse" = x ; then - # Check for freetype libraries. - BUILD_FREETYPE_CFLAGS=`$BUILD_FREETYPE --cflags` - BUILD_FREETYPE_LIBS=`$BUILD_FREETYPE --libs` - SAVED_CPPFLAGS_2="$CPPFLAGS" - SAVED_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS" - LIBS="$LIBS $BUILD_FREETYPE_LIBS" - AC_CHECK_HEADERS([ft2build.h], [], - [grub_build_mkfont_excuse=["need freetype2 headers"]]) - AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]]) - LIBS="$SAVED_LIBS" - CPPFLAGS="$SAVED_CPPFLAGS_2" + SAVED_PKG_CONFIG="$PKG_CONFIG" + test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG" + PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [ + SAVED_CPPFLAGS_2="$CPPFLAGS" + SAVED_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS" + LIBS="$LIBS $BUILD_FREETYPE_LIBS" + AC_CHECK_HEADERS([ft2build.h], [], + [grub_build_mkfont_excuse=["need freetype2 headers"]]) + AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], + [grub_build_mkfont_excuse=["freetype2 library unusable"]]) + LIBS="$SAVED_LIBS" + CPPFLAGS="$SAVED_CPPFLAGS_2" + ], [grub_build_mkfont_excuse=["need freetype2 library"]]) + PKG_CONFIG="$SAVED_PKG_CONFIG" fi if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then @@ -1610,9 +1601,6 @@ if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || tes fi fi -AC_SUBST([BUILD_FREETYPE_CFLAGS]) -AC_SUBST([BUILD_FREETYPE_LIBS]) - CC="$SAVED_CC" CPP="$SAVED_CPP" CFLAGS="$SAVED_CFLAGS" From 8b467844e11170077c8ca727c39d2bd36eeb5f08 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 4 Jul 2018 09:55:52 -0700 Subject: [PATCH 0845/1167] python: Use AM_PATH_PYTHON to determine interpreter for gentpl.py gentpl.py is python2/3-agnostic, but there's no way to cause it to be run with any interpreter other than 'python', it's just hard-coded into Makefile.common that way. Adjust that to use AM_PATH_PYTHON (provided by automake) to find an interpreter and run gentpl.py with that instead. This makes grub buildable when `python` does not exist (but rather `python3` or `python2` or `python2.7`, etc.) Minimum version is set to 2.6 as this is the first version with `__future__.print_function` available. Note, AM_PATH_PYTHON respects the PYTHON environment variable and will treat its value as the *only* candidate for a valid interpreter if it is set - when PYTHON is set, AM_PATH_PYTHON will not try to find any alternative interpreter, it will only check whether the interpreter set as the value of PYTHON meets the requirements and use it if so or fail if not. This means that when using grub's `autogen.sh`, as it too uses the value of the PYTHON environment variable (and if it is not set, just sets it to 'python') you cannot rely on AM_PATH_PYTHON interpreter discovery. If your desired Python interpreter is not just 'python', you must set the PYTHON environment variable, e.g. 'PYTHON=/usr/local/bin/python3 ./autogen.sh'. The specified interpreter will then be used both by autogen.sh itself and by the autotools-driven build scripts. Signed-off-by: Adam Williamson Reviewed-by: Daniel Kiper --- conf/Makefile.common | 4 ++-- configure.ac | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 311da61c6..f761f7224 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -128,11 +128,11 @@ BUILT_SOURCES = .PRECIOUS: $(top_srcdir)/Makefile.util.am $(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def - python $^ > $@.new || (rm -f $@.new; exit 1) + $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1) mv $@.new $@ .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am $(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi - python $^ > $@.new || (rm -f $@.new; exit 1) + $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1) mv $@.new $@ diff --git a/configure.ac b/configure.ac index 903f58eb7..5e63c4af3 100644 --- a/configure.ac +++ b/configure.ac @@ -341,6 +341,7 @@ gl_EARLY AC_PROG_CXX AM_PROG_CC_C_O AM_PROG_AS +AM_PATH_PYTHON([2.6]) # Must be GCC. test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) From 5b9308aff04594fd9f351949fdc2c7e6c2da1a2b Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Thu, 6 Sep 2018 16:16:39 +0200 Subject: [PATCH 0846/1167] osdep/linux: Convert partition start to disk sector length When reading data off a disk, sector values are based on the disk sector length. Within grub_util_fd_open_device(), the start of the partition was taken directly from grub's partition information structure, which uses the internal sector length (currently 512b), but never transformed to the disk's sector length. Subsequent calculations were all wrong for devices that have a diverging sector length and the functions eventually skipped to the wrong stream location, reading invalid data. Signed-off-by: Mihai Moldovan Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/hostdisk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 06179fca7..8b92f8528 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -374,7 +374,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f char dev[PATH_MAX]; grub_disk_addr_t part_start = 0; - part_start = grub_partition_get_start (disk->partition); + part_start = grub_partition_get_start (disk->partition) + >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1); dev[sizeof(dev) - 1] = '\0'; From 8ada906031d9bd86547db82647f91cdf7db54fbf Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 13 Sep 2018 16:08:20 +0800 Subject: [PATCH 0847/1167] msdos: Fix overflow in converting partition start and length into 512B blocks When booting from NVME SSD with 4k sector size, it fails with the message. error: attempt to read or write outside of partition. This patch fixes the problem by fixing overflow in converting partition start and length into 512B blocks. Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/partmap/msdos.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 6d4b455a1..7b8e45076 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -175,9 +175,9 @@ grub_partition_msdos_iterate (grub_disk_t disk, e = mbr.entries + p.index; p.start = p.offset - + (grub_le_to_cpu32 (e->start) + + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) - delta; - p.len = grub_le_to_cpu32 (e->length) + p.len = (grub_uint64_t)grub_le_to_cpu32 (e->length) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); p.msdostype = e->type; @@ -210,7 +210,7 @@ grub_partition_msdos_iterate (grub_disk_t disk, if (grub_msdos_partition_is_extended (e->type)) { p.offset = ext_offset - + (grub_le_to_cpu32 (e->start) + + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)); if (! ext_offset) ext_offset = p.offset; @@ -294,9 +294,9 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (!grub_msdos_partition_is_empty (e->type) && end > offset - + (grub_le_to_cpu32 (e->start) + + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS))) - end = offset + (grub_le_to_cpu32 (e->start) + end = offset + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)); /* If this is a GPT partition, this MBR is just a dummy. */ @@ -312,7 +312,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (grub_msdos_partition_is_extended (e->type)) { offset = ext_offset - + (grub_le_to_cpu32 (e->start) + + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start) << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)); if (! ext_offset) ext_offset = offset; From 81e2673fb60a200a33bb064fbffe9e3956f37974 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:31 +0200 Subject: [PATCH 0848/1167] btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile Signed-off-by: Goffredo Baroncelli Signed-off-by: Daniel Kiper Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index be195448d..d484f093e 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -119,6 +119,8 @@ struct grub_btrfs_chunk_item #define GRUB_BTRFS_CHUNK_TYPE_RAID1 0x10 #define GRUB_BTRFS_CHUNK_TYPE_DUPLICATED 0x20 #define GRUB_BTRFS_CHUNK_TYPE_RAID10 0x40 +#define GRUB_BTRFS_CHUNK_TYPE_RAID5 0x80 +#define GRUB_BTRFS_CHUNK_TYPE_RAID6 0x100 grub_uint8_t dummy2[0xc]; grub_uint16_t nstripes; grub_uint16_t nsubstripes; @@ -764,6 +766,77 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, stripe_offset = low + chunk_stripe_length * high; csize = chunk_stripe_length - low; + break; + } + case GRUB_BTRFS_CHUNK_TYPE_RAID5: + case GRUB_BTRFS_CHUNK_TYPE_RAID6: + { + grub_uint64_t nparities, stripe_nr, high, low; + + redundancy = 1; /* no redundancy for now */ + + if (grub_le_to_cpu64 (chunk->type) & GRUB_BTRFS_CHUNK_TYPE_RAID5) + { + grub_dprintf ("btrfs", "RAID5\n"); + nparities = 1; + } + else + { + grub_dprintf ("btrfs", "RAID6\n"); + nparities = 2; + } + + /* + * RAID 6 layout consists of several stripes spread over + * the disks, e.g.: + * + * Disk_0 Disk_1 Disk_2 Disk_3 + * A0 B0 P0 Q0 + * Q1 A1 B1 P1 + * P2 Q2 A2 B2 + * + * Note: placement of the parities depend on row number. + * + * Pay attention that the btrfs terminology may differ from + * terminology used in other RAID implementations, e.g. LVM, + * dm or md. The main difference is that btrfs calls contiguous + * block of data on a given disk, e.g. A0, stripe instead of chunk. + * + * The variables listed below have following meaning: + * - stripe_nr is the stripe number excluding the parities + * (A0 = 0, B0 = 1, A1 = 2, B1 = 3, etc.), + * - high is the row number (0 for A0...Q0, 1 for Q1...P1, etc.), + * - stripen is the disk number in a row (0 for A0, Q1, P2, + * 1 for B0, A1, Q2, etc.), + * - off is the logical address to read, + * - chunk_stripe_length is the size of a stripe (typically 64 KiB), + * - nstripes is the number of disks in a row, + * - low is the offset of the data inside a stripe, + * - stripe_offset is the data offset in an array, + * - csize is the "potential" data to read; it will be reduced + * to size if the latter is smaller, + * - nparities is the number of parities (1 for RAID 5, 2 for + * RAID 6); used only in RAID 5/6 code. + */ + stripe_nr = grub_divmod64 (off, chunk_stripe_length, &low); + + /* + * stripen is computed without the parities + * (0 for A0, A1, A2, 1 for B0, B1, B2, etc.). + */ + high = grub_divmod64 (stripe_nr, nstripes - nparities, &stripen); + + /* + * The stripes are spread over the disks. Every each row their + * positions are shifted by 1 place. So, the real disks number + * change. Hence, we have to take into account current row number + * modulo nstripes (0 for A0, 1 for A1, 2 for A2, etc.). + */ + grub_divmod64 (high + stripen, nstripes, &stripen); + + stripe_offset = chunk_stripe_length * high + low; + csize = chunk_stripe_length - low; + break; } default: From 846f7a8310d43637edf484ff2c3632767a15b208 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:32 +0200 Subject: [PATCH 0849/1167] btrfs: Add helper to check the btrfs header This helper is used in a few places to help the debugging. As conservative approach the error is only logged. This does not impact the error handling. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index d484f093e..af40db7ee 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -77,7 +77,8 @@ struct btrfs_header { grub_btrfs_checksum_t checksum; grub_btrfs_uuid_t uuid; - grub_uint8_t dummy[0x30]; + grub_uint64_t bytenr; + grub_uint8_t dummy[0x28]; grub_uint32_t nitems; grub_uint8_t level; } GRUB_PACKED; @@ -286,6 +287,25 @@ free_iterator (struct grub_btrfs_leaf_descriptor *desc) grub_free (desc->data); } +static grub_err_t +check_btrfs_header (struct grub_btrfs_data *data, struct btrfs_header *header, + grub_disk_addr_t addr) +{ + if (grub_le_to_cpu64 (header->bytenr) != addr) + { + grub_dprintf ("btrfs", "btrfs_header.bytenr is not equal node addr\n"); + return grub_error (GRUB_ERR_BAD_FS, + "header bytenr is not equal node addr"); + } + if (grub_memcmp (data->sblock.uuid, header->uuid, sizeof(grub_btrfs_uuid_t))) + { + grub_dprintf ("btrfs", "btrfs_header.uuid doesn't match sblock uuid\n"); + return grub_error (GRUB_ERR_BAD_FS, + "header uuid doesn't match sblock uuid"); + } + return GRUB_ERR_NONE; +} + static grub_err_t save_ref (struct grub_btrfs_leaf_descriptor *desc, grub_disk_addr_t addr, unsigned i, unsigned m, int l) @@ -341,6 +361,7 @@ next (struct grub_btrfs_data *data, err = grub_btrfs_read_logical (data, grub_le_to_cpu64 (node.addr), &head, sizeof (head), 0); + check_btrfs_header (data, &head, grub_le_to_cpu64 (node.addr)); if (err) return -err; @@ -402,6 +423,7 @@ lower_bound (struct grub_btrfs_data *data, /* FIXME: preread few nodes into buffer. */ err = grub_btrfs_read_logical (data, addr, &head, sizeof (head), recursion_depth + 1); + check_btrfs_header (data, &head, addr); if (err) return err; addr += sizeof (head); From 908cdb1d029e27f8059f9e3571e8dcbd67f74d8a Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:33 +0200 Subject: [PATCH 0850/1167] btrfs: Move the error logging from find_device() to its caller The caller knows better if this error is fatal or not, i.e. another disk is available or not. This is a preparatory patch. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index af40db7ee..9818385e1 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -603,12 +603,7 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan) if (do_rescan) grub_device_iterate (find_device_iter, &ctx); if (!ctx.dev_found) - { - grub_error (GRUB_ERR_BAD_FS, - N_("couldn't find a necessary member device " - "of multi-device filesystem")); - return NULL; - } + return NULL; data->n_devices_attached++; if (data->n_devices_attached > data->n_devices_allocated) { @@ -905,6 +900,9 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, dev = find_device (data, stripe->device_id, j); if (!dev) { + grub_dprintf ("btrfs", + "couldn't find a necessary member device " + "of multi-device filesystem\n"); err = grub_errno; grub_errno = GRUB_ERR_NONE; continue; From fd5a1d82f1d6a0482f5fe201ce646ddba8574bab Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:34 +0200 Subject: [PATCH 0851/1167] btrfs: Avoid a rescan for a device which was already not found Currently read from missing device triggers rescan. However, it is never recorded that the device is missing. So, each read of a missing device triggers rescan again and again. This behavior causes a lot of unneeded rescans leading to huge slowdowns. This patch fixes above mentioned issue. Information about missing devices is stored in the data->devices_attached[] array as NULL value in dev member. Rescan is triggered only if no information is found for a given device. This means that only first time read triggers rescan. The patch drops premature return. This way data->devices_attached[] is filled even when a given device is missing. Signed-off-by: Goffredo Baroncelli Signed-off-by: Daniel Kiper Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 9818385e1..ca0277bee 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -588,7 +588,7 @@ find_device_iter (const char *name, void *data) } static grub_device_t -find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan) +find_device (struct grub_btrfs_data *data, grub_uint64_t id) { struct find_device_ctx ctx = { .data = data, @@ -600,10 +600,9 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan) for (i = 0; i < data->n_devices_attached; i++) if (id == data->devices_attached[i].id) return data->devices_attached[i].dev; - if (do_rescan) - grub_device_iterate (find_device_iter, &ctx); - if (!ctx.dev_found) - return NULL; + + grub_device_iterate (find_device_iter, &ctx); + data->n_devices_attached++; if (data->n_devices_attached > data->n_devices_allocated) { @@ -615,7 +614,8 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan) * sizeof (data->devices_attached[0])); if (!data->devices_attached) { - grub_device_close (ctx.dev_found); + if (ctx.dev_found) + grub_device_close (ctx.dev_found); data->devices_attached = tmp; return NULL; } @@ -897,7 +897,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, " for laddr 0x%" PRIxGRUB_UINT64_T "\n", paddr, addr); - dev = find_device (data, stripe->device_id, j); + dev = find_device (data, stripe->device_id); if (!dev) { grub_dprintf ("btrfs", @@ -974,7 +974,8 @@ grub_btrfs_unmount (struct grub_btrfs_data *data) unsigned i; /* The device 0 is closed one layer upper. */ for (i = 1; i < data->n_devices_attached; i++) - grub_device_close (data->devices_attached[i].dev); + if (data->devices_attached[i].dev) + grub_device_close (data->devices_attached[i].dev); grub_free (data->devices_attached); grub_free (data->extent); grub_free (data); From c6f79aca8030689ab2087686654ac431db411fa3 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:35 +0200 Subject: [PATCH 0852/1167] btrfs: Move logging code in grub_btrfs_read_logical() A portion of the logging code is moved outside of internal for(;;). The part that is left inside is the one which depends on the internal for(;;) index. This is a preparatory patch. The next one will refactor the code inside the for(;;) into an another function. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index ca0277bee..4e5292197 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -870,6 +870,18 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, for (j = 0; j < 2; j++) { + grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T + "+0x%" PRIxGRUB_UINT64_T + " (%d stripes (%d substripes) of %" + PRIxGRUB_UINT64_T ")\n", + grub_le_to_cpu64 (key->offset), + grub_le_to_cpu64 (chunk->size), + grub_le_to_cpu16 (chunk->nstripes), + grub_le_to_cpu16 (chunk->nsubstripes), + grub_le_to_cpu64 (chunk->stripe_length)); + grub_dprintf ("btrfs", "reading laddr 0x%" PRIxGRUB_UINT64_T "\n", + addr); + for (i = 0; i < redundancy; i++) { struct grub_btrfs_chunk_stripe *stripe; @@ -882,20 +894,11 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset; - grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T - "+0x%" PRIxGRUB_UINT64_T - " (%d stripes (%d substripes) of %" - PRIxGRUB_UINT64_T ") stripe %" PRIxGRUB_UINT64_T + grub_dprintf ("btrfs", "stripe %" PRIxGRUB_UINT64_T " maps to 0x%" PRIxGRUB_UINT64_T "\n", - grub_le_to_cpu64 (key->offset), - grub_le_to_cpu64 (chunk->size), - grub_le_to_cpu16 (chunk->nstripes), - grub_le_to_cpu16 (chunk->nsubstripes), - grub_le_to_cpu64 (chunk->stripe_length), stripen, stripe->offset); - grub_dprintf ("btrfs", "reading paddr 0x%" PRIxGRUB_UINT64_T - " for laddr 0x%" PRIxGRUB_UINT64_T "\n", paddr, - addr); + grub_dprintf ("btrfs", "reading paddr 0x%" PRIxGRUB_UINT64_T "\n", + paddr); dev = find_device (data, stripe->device_id); if (!dev) From c743736048c3ef2a0fc126a29e4bf654e98fb41a Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:36 +0200 Subject: [PATCH 0853/1167] btrfs: Refactor the code that read from disk Move the code in charge to read the data from disk into a separate function. This helps to separate the error handling logic (which depends on the different raid profiles) from the read from disk logic. Refactoring this code increases the general readability too. This is a preparatory patch, to help the adding of the RAID 5/6 recovery code. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 75 ++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 4e5292197..b2482ba68 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -625,6 +625,46 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id) return ctx.dev_found; } +static grub_err_t +btrfs_read_from_chunk (struct grub_btrfs_data *data, + struct grub_btrfs_chunk_item *chunk, + grub_uint64_t stripen, grub_uint64_t stripe_offset, + int redundancy, grub_uint64_t csize, + void *buf) +{ + struct grub_btrfs_chunk_stripe *stripe; + grub_disk_addr_t paddr; + grub_device_t dev; + grub_err_t err; + + stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1); + /* Right now the redundancy handling is easy. + With RAID5-like it will be more difficult. */ + stripe += stripen + redundancy; + + paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset; + + grub_dprintf ("btrfs", "stripe %" PRIxGRUB_UINT64_T + " maps to 0x%" PRIxGRUB_UINT64_T "\n" + "reading paddr 0x%" PRIxGRUB_UINT64_T "\n", + stripen, stripe->offset, paddr); + + dev = find_device (data, stripe->device_id); + if (!dev) + { + grub_dprintf ("btrfs", + "couldn't find a necessary member device " + "of multi-device filesystem\n"); + grub_errno = GRUB_ERR_NONE; + return GRUB_ERR_READ_ERROR; + } + + err = grub_disk_read (dev->disk, paddr >> GRUB_DISK_SECTOR_BITS, + paddr & (GRUB_DISK_SECTOR_SIZE - 1), + csize, buf); + return err; +} + static grub_err_t grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, void *buf, grub_size_t size, int recursion_depth) @@ -638,7 +678,6 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_err_t err = 0; struct grub_btrfs_key key_out; int challoc = 0; - grub_device_t dev; struct grub_btrfs_key key_in; grub_size_t chsize; grub_disk_addr_t chaddr; @@ -884,36 +923,10 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, for (i = 0; i < redundancy; i++) { - struct grub_btrfs_chunk_stripe *stripe; - grub_disk_addr_t paddr; - - stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1); - /* Right now the redundancy handling is easy. - With RAID5-like it will be more difficult. */ - stripe += stripen + i; - - paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset; - - grub_dprintf ("btrfs", "stripe %" PRIxGRUB_UINT64_T - " maps to 0x%" PRIxGRUB_UINT64_T "\n", - stripen, stripe->offset); - grub_dprintf ("btrfs", "reading paddr 0x%" PRIxGRUB_UINT64_T "\n", - paddr); - - dev = find_device (data, stripe->device_id); - if (!dev) - { - grub_dprintf ("btrfs", - "couldn't find a necessary member device " - "of multi-device filesystem\n"); - err = grub_errno; - grub_errno = GRUB_ERR_NONE; - continue; - } - - err = grub_disk_read (dev->disk, paddr >> GRUB_DISK_SECTOR_BITS, - paddr & (GRUB_DISK_SECTOR_SIZE - 1), - csize, buf); + err = btrfs_read_from_chunk (data, chunk, stripen, + stripe_offset, + i, /* redundancy */ + csize, buf); if (!err) break; grub_errno = GRUB_ERR_NONE; From 94854d9c3d6f02820fb621692463e08cbe284ab0 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:37 +0200 Subject: [PATCH 0854/1167] btrfs: Add support for recovery for a RAID 5 btrfs profiles Add support for recovery for a RAID 5 btrfs profile. In addition it is added some code as preparatory work for RAID 6 recovery code. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 159 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 154 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index b2482ba68..a6f5d4e1e 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -665,6 +666,138 @@ btrfs_read_from_chunk (struct grub_btrfs_data *data, return err; } +struct raid56_buffer { + void *buf; + int data_is_valid; +}; + +static void +rebuild_raid5 (char *dest, struct raid56_buffer *buffers, + grub_uint64_t nstripes, grub_uint64_t csize) +{ + grub_uint64_t i; + int first; + + for(i = 0; buffers[i].data_is_valid && i < nstripes; i++); + + if (i == nstripes) + { + grub_dprintf ("btrfs", "called rebuild_raid5(), but all disks are OK\n"); + return; + } + + grub_dprintf ("btrfs", "rebuilding RAID 5 stripe #%" PRIuGRUB_UINT64_T "\n", i); + + for (i = 0, first = 1; i < nstripes; i++) + { + if (!buffers[i].data_is_valid) + continue; + + if (first) { + grub_memcpy(dest, buffers[i].buf, csize); + first = 0; + } else + grub_crypto_xor (dest, dest, buffers[i].buf, csize); + } +} + +static grub_err_t +raid56_read_retry (struct grub_btrfs_data *data, + struct grub_btrfs_chunk_item *chunk, + grub_uint64_t stripe_offset, + grub_uint64_t csize, void *buf) +{ + struct raid56_buffer *buffers; + grub_uint64_t nstripes = grub_le_to_cpu16 (chunk->nstripes); + grub_uint64_t chunk_type = grub_le_to_cpu64 (chunk->type); + grub_err_t ret = GRUB_ERR_OUT_OF_MEMORY; + grub_uint64_t i, failed_devices; + + buffers = grub_zalloc (sizeof(*buffers) * nstripes); + if (!buffers) + goto cleanup; + + for (i = 0; i < nstripes; i++) + { + buffers[i].buf = grub_zalloc (csize); + if (!buffers[i].buf) + goto cleanup; + } + + for (failed_devices = 0, i = 0; i < nstripes; i++) + { + struct grub_btrfs_chunk_stripe *stripe; + grub_disk_addr_t paddr; + grub_device_t dev; + grub_err_t err; + + /* + * The struct grub_btrfs_chunk_stripe array lives + * behind struct grub_btrfs_chunk_item. + */ + stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1) + i; + + paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset; + grub_dprintf ("btrfs", "reading paddr %" PRIxGRUB_UINT64_T + " from stripe ID %" PRIxGRUB_UINT64_T "\n", + paddr, stripe->device_id); + + dev = find_device (data, stripe->device_id); + if (!dev) + { + grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T " FAILED (dev ID %" + PRIxGRUB_UINT64_T ")\n", i, stripe->device_id); + failed_devices++; + continue; + } + + err = grub_disk_read (dev->disk, paddr >> GRUB_DISK_SECTOR_BITS, + paddr & (GRUB_DISK_SECTOR_SIZE - 1), + csize, buffers[i].buf); + if (err == GRUB_ERR_NONE) + { + buffers[i].data_is_valid = 1; + grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T " OK (dev ID %" + PRIxGRUB_UINT64_T ")\n", i, stripe->device_id); + } + else + { + grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T + " READ FAILED (dev ID %" PRIxGRUB_UINT64_T ")\n", + i, stripe->device_id); + failed_devices++; + } + } + + if (failed_devices > 1 && (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID5)) + { + grub_dprintf ("btrfs", "not enough disks for RAID 5: total %" PRIuGRUB_UINT64_T + ", missing %" PRIuGRUB_UINT64_T "\n", + nstripes, failed_devices); + ret = GRUB_ERR_READ_ERROR; + goto cleanup; + } + else + grub_dprintf ("btrfs", "enough disks for RAID 5: total %" + PRIuGRUB_UINT64_T ", missing %" PRIuGRUB_UINT64_T "\n", + nstripes, failed_devices); + + /* We have enough disks. So, rebuild the data. */ + if (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID5) + rebuild_raid5 (buf, buffers, nstripes, csize); + else + grub_dprintf ("btrfs", "called rebuild_raid6(), NOT IMPLEMENTED\n"); + + ret = GRUB_ERR_NONE; + cleanup: + if (buffers) + for (i = 0; i < nstripes; i++) + grub_free (buffers[i].buf); + grub_free (buffers); + + return ret; +} + static grub_err_t grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, void *buf, grub_size_t size, int recursion_depth) @@ -742,6 +875,10 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_uint16_t nstripes; unsigned redundancy = 1; unsigned i, j; + int is_raid56; + + is_raid56 = !!(grub_le_to_cpu64 (chunk->type) & + GRUB_BTRFS_CHUNK_TYPE_RAID5); if (grub_le_to_cpu64 (chunk->size) <= off) { @@ -921,17 +1058,29 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_dprintf ("btrfs", "reading laddr 0x%" PRIxGRUB_UINT64_T "\n", addr); - for (i = 0; i < redundancy; i++) + if (is_raid56) { err = btrfs_read_from_chunk (data, chunk, stripen, stripe_offset, - i, /* redundancy */ + 0, /* no mirror */ csize, buf); - if (!err) - break; grub_errno = GRUB_ERR_NONE; + if (err) + err = raid56_read_retry (data, chunk, stripe_offset, + csize, buf); } - if (i != redundancy) + else + for (i = 0; i < redundancy; i++) + { + err = btrfs_read_from_chunk (data, chunk, stripen, + stripe_offset, + i, /* redundancy */ + csize, buf); + if (!err) + break; + grub_errno = GRUB_ERR_NONE; + } + if (!err) break; } if (err) From fa926cb4b4de062233827d8d24ff61e8e39f5ffc Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:38 +0200 Subject: [PATCH 0855/1167] btrfs: Make more generic the code for RAID 6 rebuilding The original code which handles the recovery of a RAID 6 disks array assumes that all reads are multiple of 1 << GRUB_DISK_SECTOR_BITS and it assumes that all the I/O is done via the struct grub_diskfilter_segment. This is not true for the btrfs code. In order to reuse the native grub_raid6_recover() code, it is modified to not call grub_diskfilter_read_node() directly, but to call an handler passed as an argument. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/disk/raid6_recover.c | 52 ++++++++++++++++++++++------------ include/grub/diskfilter.h | 9 ++++++ 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index aa674f6ca..75fe464a4 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -74,14 +74,26 @@ mod_255 (unsigned x) } static grub_err_t -grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, - char *buf, grub_disk_addr_t sector, grub_size_t size) +raid6_recover_read_node (void *data, int disknr, + grub_uint64_t sector, + void *buf, grub_size_t size) +{ + struct grub_diskfilter_segment *array = data; + + return grub_diskfilter_read_node (&array->nodes[disknr], + (grub_disk_addr_t)sector, + size >> GRUB_DISK_SECTOR_BITS, buf); +} + +grub_err_t +grub_raid6_recover_gen (void *data, grub_uint64_t nstripes, int disknr, int p, + char *buf, grub_uint64_t sector, grub_size_t size, + int layout, raid_recover_read_t read_func) { int i, q, pos; int bad1 = -1, bad2 = -1; char *pbuf = 0, *qbuf = 0; - size <<= GRUB_DISK_SECTOR_BITS; pbuf = grub_zalloc (size); if (!pbuf) goto quit; @@ -91,17 +103,17 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, goto quit; q = p + 1; - if (q == (int) array->node_count) + if (q == (int) nstripes) q = 0; pos = q + 1; - if (pos == (int) array->node_count) + if (pos == (int) nstripes) pos = 0; - for (i = 0; i < (int) array->node_count - 2; i++) + for (i = 0; i < (int) nstripes - 2; i++) { int c; - if (array->layout & GRUB_RAID_LAYOUT_MUL_FROM_POS) + if (layout & GRUB_RAID_LAYOUT_MUL_FROM_POS) c = pos; else c = i; @@ -109,8 +121,7 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, bad1 = c; else { - if (! grub_diskfilter_read_node (&array->nodes[pos], sector, - size >> GRUB_DISK_SECTOR_BITS, buf)) + if (!read_func (data, pos, sector, buf, size)) { grub_crypto_xor (pbuf, pbuf, buf, size); grub_raid_block_mulx (c, buf, size); @@ -128,7 +139,7 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, } pos++; - if (pos == (int) array->node_count) + if (pos == (int) nstripes) pos = 0; } @@ -139,16 +150,14 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, if (bad2 < 0) { /* One bad device */ - if ((! grub_diskfilter_read_node (&array->nodes[p], sector, - size >> GRUB_DISK_SECTOR_BITS, buf))) + if (!read_func (data, p, sector, buf, size)) { grub_crypto_xor (buf, buf, pbuf, size); goto quit; } grub_errno = GRUB_ERR_NONE; - if (grub_diskfilter_read_node (&array->nodes[q], sector, - size >> GRUB_DISK_SECTOR_BITS, buf)) + if (read_func (data, q, sector, buf, size)) goto quit; grub_crypto_xor (buf, buf, qbuf, size); @@ -160,14 +169,12 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, /* Two bad devices */ unsigned c; - if (grub_diskfilter_read_node (&array->nodes[p], sector, - size >> GRUB_DISK_SECTOR_BITS, buf)) + if (read_func (data, p, sector, buf, size)) goto quit; grub_crypto_xor (pbuf, pbuf, buf, size); - if (grub_diskfilter_read_node (&array->nodes[q], sector, - size >> GRUB_DISK_SECTOR_BITS, buf)) + if (read_func (data, q, sector, buf, size)) goto quit; grub_crypto_xor (qbuf, qbuf, buf, size); @@ -190,6 +197,15 @@ quit: return grub_errno; } +static grub_err_t +grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, + char *buf, grub_disk_addr_t sector, grub_size_t size) +{ + return grub_raid6_recover_gen (array, array->node_count, disknr, p, buf, + sector, size << GRUB_DISK_SECTOR_BITS, + array->layout, raid6_recover_read_node); +} + GRUB_MOD_INIT(raid6rec) { grub_raid6_init_table (); diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h index d89273c1b..8deb1a8c3 100644 --- a/include/grub/diskfilter.h +++ b/include/grub/diskfilter.h @@ -189,6 +189,15 @@ typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_diskfilter_segment extern grub_raid5_recover_func_t grub_raid5_recover_func; extern grub_raid6_recover_func_t grub_raid6_recover_func; +typedef grub_err_t (* raid_recover_read_t)(void *data, int disk_nr, + grub_uint64_t addr, void *dest, + grub_size_t size); + +extern grub_err_t +grub_raid6_recover_gen (void *data, grub_uint64_t nstripes, int disknr, int p, + char *buf, grub_uint64_t sector, grub_size_t size, + int layout, raid_recover_read_t read_func); + grub_err_t grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg); grub_err_t From 72e80c0255733d7e802ab7c0bad9b6dda16f2c1a Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 22 Oct 2018 19:29:39 +0200 Subject: [PATCH 0856/1167] btrfs: Add RAID 6 recovery for a btrfs filesystem Add the RAID 6 recovery, in order to use a RAID 6 filesystem even if some disks (up to two) are missing. This code use the md RAID 6 code already present in grub. Signed-off-by: Goffredo Baroncelli Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 57 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index a6f5d4e1e..cac9ef588 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -30,6 +30,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -701,11 +702,36 @@ rebuild_raid5 (char *dest, struct raid56_buffer *buffers, } } +static grub_err_t +raid6_recover_read_buffer (void *data, int disk_nr, + grub_uint64_t addr __attribute__ ((unused)), + void *dest, grub_size_t size) +{ + struct raid56_buffer *buffers = data; + + if (!buffers[disk_nr].data_is_valid) + return grub_errno = GRUB_ERR_READ_ERROR; + + grub_memcpy(dest, buffers[disk_nr].buf, size); + + return grub_errno = GRUB_ERR_NONE; +} + +static void +rebuild_raid6 (struct raid56_buffer *buffers, grub_uint64_t nstripes, + grub_uint64_t csize, grub_uint64_t parities_pos, void *dest, + grub_uint64_t stripen) + +{ + grub_raid6_recover_gen (buffers, nstripes, stripen, parities_pos, + dest, 0, csize, 0, raid6_recover_read_buffer); +} + static grub_err_t raid56_read_retry (struct grub_btrfs_data *data, struct grub_btrfs_chunk_item *chunk, - grub_uint64_t stripe_offset, - grub_uint64_t csize, void *buf) + grub_uint64_t stripe_offset, grub_uint64_t stripen, + grub_uint64_t csize, void *buf, grub_uint64_t parities_pos) { struct raid56_buffer *buffers; grub_uint64_t nstripes = grub_le_to_cpu16 (chunk->nstripes); @@ -777,6 +803,14 @@ raid56_read_retry (struct grub_btrfs_data *data, ret = GRUB_ERR_READ_ERROR; goto cleanup; } + else if (failed_devices > 2 && (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID6)) + { + grub_dprintf ("btrfs", "not enough disks for RAID 6: total %" PRIuGRUB_UINT64_T + ", missing %" PRIuGRUB_UINT64_T "\n", + nstripes, failed_devices); + ret = GRUB_ERR_READ_ERROR; + goto cleanup; + } else grub_dprintf ("btrfs", "enough disks for RAID 5: total %" PRIuGRUB_UINT64_T ", missing %" PRIuGRUB_UINT64_T "\n", @@ -786,7 +820,7 @@ raid56_read_retry (struct grub_btrfs_data *data, if (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID5) rebuild_raid5 (buf, buffers, nstripes, csize); else - grub_dprintf ("btrfs", "called rebuild_raid6(), NOT IMPLEMENTED\n"); + rebuild_raid6 (buffers, nstripes, csize, parities_pos, buf, stripen); ret = GRUB_ERR_NONE; cleanup: @@ -876,9 +910,11 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, unsigned redundancy = 1; unsigned i, j; int is_raid56; + grub_uint64_t parities_pos = 0; - is_raid56 = !!(grub_le_to_cpu64 (chunk->type) & - GRUB_BTRFS_CHUNK_TYPE_RAID5); + is_raid56 = !!(grub_le_to_cpu64 (chunk->type) & + (GRUB_BTRFS_CHUNK_TYPE_RAID5 | + GRUB_BTRFS_CHUNK_TYPE_RAID6)); if (grub_le_to_cpu64 (chunk->size) <= off) { @@ -1027,6 +1063,15 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, */ grub_divmod64 (high + stripen, nstripes, &stripen); + /* + * parities_pos is equal to ((high - nparities) % nstripes) + * (see the diagram above). However, (high - nparities) can + * be negative, e.g. when high == 0, leading to an incorrect + * results. (high + nstripes - nparities) is always positive and + * modulo nstripes is equal to ((high - nparities) % nstripes). + */ + grub_divmod64 (high + nstripes - nparities, nstripes, &parities_pos); + stripe_offset = chunk_stripe_length * high + low; csize = chunk_stripe_length - low; @@ -1067,7 +1112,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_errno = GRUB_ERR_NONE; if (err) err = raid56_read_retry (data, chunk, stripe_offset, - csize, buf); + stripen, csize, buf, parities_pos); } else for (i = 0; i < redundancy; i++) From f3f8347569383e7f483f37ca70d41eb1af9f990f Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 29 Oct 2018 13:25:25 +0100 Subject: [PATCH 0857/1167] bufio: Use grub_size_t instead of plain int for size Signed-off-by: Vladimir Serbinenko Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/io/bufio.c | 6 +++--- include/grub/bufio.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index dbed64744..d2f4fb493 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -43,7 +43,7 @@ typedef struct grub_bufio *grub_bufio_t; static struct grub_fs grub_bufio_fs; grub_file_t -grub_bufio_open (grub_file_t io, int size) +grub_bufio_open (grub_file_t io, grub_size_t size) { grub_file_t file; grub_bufio_t bufio = 0; @@ -57,7 +57,7 @@ grub_bufio_open (grub_file_t io, int size) else if (size > GRUB_BUFIO_MAX_SIZE) size = GRUB_BUFIO_MAX_SIZE; - if ((size < 0) || ((unsigned) size > io->size)) + if (size > io->size) size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE : io->size); @@ -88,7 +88,7 @@ grub_bufio_open (grub_file_t io, int size) } grub_file_t -grub_buffile_open (const char *name, int size) +grub_buffile_open (const char *name, grub_size_t size) { grub_file_t io, file; diff --git a/include/grub/bufio.h b/include/grub/bufio.h index acdd0c882..77eb8ee56 100644 --- a/include/grub/bufio.h +++ b/include/grub/bufio.h @@ -22,7 +22,7 @@ #include -grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, int size); -grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, int size); +grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, grub_size_t size); +grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, grub_size_t size); #endif /* ! GRUB_BUFIO_H */ From ca0a4f689a02c2c5a5e385f874aaaa38e151564e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 20 Nov 2013 02:28:29 +0100 Subject: [PATCH 0858/1167] verifiers: File type for fine-grained signature-verification controlling Let's provide file type info to the I/O layer. This way verifiers framework and its users will be able to differentiate files and verify only required ones. This is preparatory patch. Signed-off-by: Vladimir Serbinenko Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/commands/acpi.c | 2 +- grub-core/commands/blocklist.c | 4 +- grub-core/commands/cat.c | 2 +- grub-core/commands/cmp.c | 4 +- grub-core/commands/efi/loadbios.c | 4 +- grub-core/commands/file.c | 5 +- grub-core/commands/hashsum.c | 22 ++- grub-core/commands/hexdump.c | 2 +- grub-core/commands/i386/pc/play.c | 2 +- grub-core/commands/keylayouts.c | 2 +- grub-core/commands/legacycfg.c | 2 +- grub-core/commands/loadenv.c | 24 +-- grub-core/commands/ls.c | 8 +- grub-core/commands/minicmd.c | 2 +- grub-core/commands/nativedisk.c | 3 +- grub-core/commands/parttool.c | 2 +- grub-core/commands/search.c | 4 +- grub-core/commands/test.c | 4 +- grub-core/commands/testload.c | 2 +- grub-core/commands/testspeed.c | 2 +- grub-core/commands/verify.c | 51 ++++--- grub-core/disk/loopback.c | 3 +- grub-core/efiemu/main.c | 2 +- grub-core/font/font.c | 4 +- grub-core/fs/zfs/zfscrypt.c | 2 +- grub-core/gettext/gettext.c | 2 +- grub-core/gfxmenu/theme_loader.c | 2 +- grub-core/io/bufio.c | 4 +- grub-core/io/gzio.c | 5 +- grub-core/io/lzopio.c | 6 +- grub-core/io/offset.c | 7 +- grub-core/io/xzio.c | 6 +- grub-core/kern/dl.c | 2 +- grub-core/kern/elf.c | 4 +- grub-core/kern/file.c | 22 ++- grub-core/lib/syslinux_parse.c | 2 +- grub-core/loader/efi/chainloader.c | 2 +- grub-core/loader/i386/bsd.c | 16 +- grub-core/loader/i386/coreboot/chainloader.c | 2 +- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/chainloader.c | 4 +- grub-core/loader/i386/pc/freedos.c | 2 +- grub-core/loader/i386/pc/linux.c | 2 +- grub-core/loader/i386/pc/ntldr.c | 2 +- grub-core/loader/i386/pc/plan9.c | 2 +- grub-core/loader/i386/pc/pxechainloader.c | 2 +- grub-core/loader/i386/pc/truecrypt.c | 2 +- grub-core/loader/i386/xen.c | 7 +- grub-core/loader/i386/xen_file.c | 2 +- grub-core/loader/i386/xnu.c | 2 +- grub-core/loader/linux.c | 6 +- grub-core/loader/macho.c | 4 +- grub-core/loader/mips/linux.c | 2 +- grub-core/loader/multiboot.c | 8 +- grub-core/loader/xnu.c | 16 +- grub-core/loader/xnu_resume.c | 4 +- grub-core/normal/autofs.c | 11 +- grub-core/normal/crypto.c | 2 +- grub-core/normal/dyncmd.c | 2 +- grub-core/normal/main.c | 2 +- grub-core/normal/term.c | 2 +- grub-core/video/readers/jpeg.c | 2 +- grub-core/video/readers/png.c | 2 +- grub-core/video/readers/tga.c | 2 +- include/grub/bufio.h | 4 +- include/grub/elfload.h | 2 +- include/grub/file.h | 152 ++++++++++++++----- include/grub/machoload.h | 3 +- util/grub-fstest.c | 6 +- util/grub-mount.c | 6 +- 70 files changed, 292 insertions(+), 221 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 9f02f2201..5a1499aa0 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -635,7 +635,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) grub_size_t size; char *buf; - file = grub_file_open (args[i]); + file = grub_file_open (args[i], GRUB_FILE_TYPE_ACPI_TABLE); if (! file) { free_tables (); diff --git a/grub-core/commands/blocklist.c b/grub-core/commands/blocklist.c index d1a47b504..944449b77 100644 --- a/grub-core/commands/blocklist.c +++ b/grub-core/commands/blocklist.c @@ -121,8 +121,8 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)), if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - grub_file_filter_disable_compression (); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_PRINT_BLOCKLIST + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) return grub_errno; diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c index 88d904436..ba5f0061a 100644 --- a/grub-core/commands/cat.c +++ b/grub-core/commands/cat.c @@ -56,7 +56,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args) if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_CAT); if (! file) return grub_errno; diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c index cc23ee67e..e9c3b25d3 100644 --- a/grub-core/commands/cmp.c +++ b/grub-core/commands/cmp.c @@ -45,8 +45,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)), grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0], args[1]); - file1 = grub_file_open (args[0]); - file2 = grub_file_open (args[1]); + file1 = grub_file_open (args[0], GRUB_FILE_TYPE_CMP); + file2 = grub_file_open (args[1], GRUB_FILE_TYPE_CMP); if (! file1 || ! file2) goto cleanup; diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c index 132cadbc7..d41d521a4 100644 --- a/grub-core/commands/efi/loadbios.c +++ b/grub-core/commands/efi/loadbios.c @@ -169,7 +169,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), if (argc > 1) { - file = grub_file_open (argv[1]); + file = grub_file_open (argv[1], GRUB_FILE_TYPE_VBE_DUMP); if (! file) return grub_errno; @@ -183,7 +183,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_VBE_DUMP); if (! file) return grub_errno; diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 3ff6d5522..4f81aa1f9 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -165,7 +165,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) if (type == -1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no type specified"); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL); if (!file) return grub_errno; switch (type) @@ -546,7 +546,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) case IS_XNU64: case IS_XNU32: { - macho = grub_macho_open (args[0], (type == IS_XNU64)); + macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, + (type == IS_XNU64)); if (!macho) break; /* FIXME: more checks? */ diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c index d18687351..456ba908b 100644 --- a/grub-core/commands/hashsum.c +++ b/grub-core/commands/hashsum.c @@ -113,7 +113,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename, if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN) return grub_error (GRUB_ERR_BUG, "mdlen is too long"); - hashlist = grub_file_open (hashfilename); + hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST); if (!hashlist) return grub_errno; @@ -141,17 +141,15 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename, filename = grub_xasprintf ("%s/%s", prefix, p); if (!filename) return grub_errno; - if (!uncompress) - grub_file_filter_disable_compression (); - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH + | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS + : GRUB_FILE_TYPE_NONE)); grub_free (filename); } else - { - if (!uncompress) - grub_file_filter_disable_compression (); - file = grub_file_open (p); - } + file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH + | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS + : GRUB_FILE_TYPE_NONE)); if (!file) { grub_file_close (hashlist); @@ -242,9 +240,9 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt, grub_file_t file; grub_err_t err; unsigned j; - if (!uncompress) - grub_file_filter_disable_compression (); - file = grub_file_open (args[i]); + file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH + | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS + : GRUB_FILE_TYPE_NONE)); if (!file) { if (!keep) diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c index 4c884b3a1..eaa12465b 100644 --- a/grub-core/commands/hexdump.c +++ b/grub-core/commands/hexdump.c @@ -90,7 +90,7 @@ grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args) { grub_file_t file; - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_HEXCAT); if (! file) return 0; diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c index 7712e2a36..c81813105 100644 --- a/grub-core/commands/i386/pc/play.c +++ b/grub-core/commands/i386/pc/play.c @@ -93,7 +93,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)), grub_uint32_t tempo; grub_file_t file; - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_AUDIO); if (! file) return grub_errno; diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index f35d3a369..c05d6128a 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -220,7 +220,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)), else filename = argv[0]; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_KEYBOARD_LAYOUT); if (! file) goto fail; diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index b32f3c74c..db7a8f002 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -55,7 +55,7 @@ legacy_file (const char *filename) if (!suffix) return grub_errno; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_CONFIG); if (! file) { grub_free (suffix); diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c index acd93d123..3fd664aac 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -44,7 +44,8 @@ static const struct grub_arg_option options[] = PUBKEY filter (that insists upon properly signed files) as well. PUBKEY filter is restored before the function returns. */ static grub_file_t -open_envblk_file (char *filename, int untrusted) +open_envblk_file (char *filename, + enum grub_file_type type) { grub_file_t file; char *buf = 0; @@ -72,13 +73,7 @@ open_envblk_file (char *filename, int untrusted) grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG); } - /* The filters that are disabled will be re-enabled by the call to - grub_file_open() after this particular file is opened. */ - grub_file_filter_disable_compression (); - if (untrusted) - grub_file_filter_disable_pubkey (); - - file = grub_file_open (filename); + file = grub_file_open (filename, type); grub_free (buf); return file; @@ -171,7 +166,10 @@ grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args) whitelist.list = args; /* state[0] is the -f flag; state[1] is the --skip-sig flag */ - file = open_envblk_file ((state[0].set) ? state[0].arg : 0, state[1].set); + file = open_envblk_file ((state[0].set) ? state[0].arg : 0, + GRUB_FILE_TYPE_LOADENV + | (state[1].set + ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE)); if (! file) return grub_errno; @@ -206,7 +204,10 @@ grub_cmd_list_env (grub_extcmd_context_t ctxt, grub_file_t file; grub_envblk_t envblk; - file = open_envblk_file ((state[0].set) ? state[0].arg : 0, 0); + file = open_envblk_file ((state[0].set) ? state[0].arg : 0, + GRUB_FILE_TYPE_LOADENV + | (state[1].set + ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE)); if (! file) return grub_errno; @@ -390,7 +391,8 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified"); file = open_envblk_file ((state[0].set) ? state[0].arg : 0, - 1 /* allow untrusted */); + GRUB_FILE_TYPE_SAVEENV + | GRUB_FILE_TYPE_SKIP_SIGNATURE); if (! file) return grub_errno; diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index c25161cc4..2cdb2acc5 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -129,8 +129,8 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info, /* XXX: For ext2fs symlinks are detected as files while they should be reported as directories. */ - grub_file_filter_disable_compression (); - file = grub_file_open (pathname); + file = grub_file_open (pathname, GRUB_FILE_TYPE_GET_SIZE + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) { grub_errno = 0; @@ -234,8 +234,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) struct grub_dirhook_info info; grub_errno = 0; - grub_file_filter_disable_compression (); - file = grub_file_open (dirname); + file = grub_file_open (dirname, GRUB_FILE_TYPE_GET_SIZE + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) goto fail; diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c index a3a118241..fc20c6563 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c @@ -43,7 +43,7 @@ grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)), if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_CAT); if (! file) return grub_errno; diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index 2f56a870e..c278f377b 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -242,7 +242,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), if (! filename) goto fail; - file = grub_file_open (filename); + file = grub_file_open (filename, + GRUB_FILE_TYPE_GRUB_MODULE); grub_free (filename); if (! file) goto fail; diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index 693e2cb42..22b46b187 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -193,7 +193,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST); if (file) { char *buf = 0; diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index 7dd32e445..ddda6e7c5 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -81,8 +81,8 @@ iterate_device (const char *name, void *data) if (! buf) return 1; - grub_file_filter_disable_compression (); - file = grub_file_open (buf); + file = grub_file_open (buf, GRUB_FILE_TYPE_FS_SEARCH + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (file) { found = 1; diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index 5f06642f6..13c6ed953 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -355,8 +355,8 @@ test_parse (char **args, int *argn, int argc) if (grub_strcmp (args[*argn], "-s") == 0) { grub_file_t file; - grub_file_filter_disable_compression (); - file = grub_file_open (args[*argn + 1]); + file = grub_file_open (args[*argn + 1], GRUB_FILE_TYPE_GET_SIZE + | GRUB_FILE_TYPE_NO_DECOMPRESS); update_val (file && (grub_file_size (file) != 0), &ctx); if (file) grub_file_close (file); diff --git a/grub-core/commands/testload.c b/grub-core/commands/testload.c index cfab6763d..ff01a0516 100644 --- a/grub-core/commands/testload.c +++ b/grub-core/commands/testload.c @@ -57,7 +57,7 @@ grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)), if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_TESTLOAD); if (! file) return grub_errno; diff --git a/grub-core/commands/testspeed.c b/grub-core/commands/testspeed.c index 042645f8d..c13a9b8d8 100644 --- a/grub-core/commands/testspeed.c +++ b/grub-core/commands/testspeed.c @@ -61,7 +61,7 @@ grub_cmd_testspeed (grub_extcmd_context_t ctxt, int argc, char **args) if (buffer == NULL) return grub_errno; - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_TESTLOAD); if (file == NULL) goto quit; diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 67cb1c785..f0dfeceeb 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -680,10 +680,12 @@ grub_cmd_trust (grub_extcmd_context_t ctxt, if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); - grub_file_filter_disable_compression (); - if (ctxt->state[OPTION_SKIP_SIG].set) - grub_file_filter_disable_pubkey (); - pkf = grub_file_open (args[0]); + pkf = grub_file_open (args[0], + GRUB_FILE_TYPE_PUBLIC_KEY_TRUST + | GRUB_FILE_TYPE_NO_DECOMPRESS + | (ctxt->state[OPTION_SKIP_SIG].set + ? GRUB_FILE_TYPE_SKIP_SIGNATURE + : GRUB_FILE_TYPE_NONE)); if (!pkf) return grub_errno; pk = grub_load_public_key (pkf); @@ -771,10 +773,12 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt, if (argc > 2) { grub_file_t pkf; - grub_file_filter_disable_compression (); - if (ctxt->state[OPTION_SKIP_SIG].set) - grub_file_filter_disable_pubkey (); - pkf = grub_file_open (args[2]); + pkf = grub_file_open (args[2], + GRUB_FILE_TYPE_PUBLIC_KEY + | GRUB_FILE_TYPE_NO_DECOMPRESS + | (ctxt->state[OPTION_SKIP_SIG].set + ? GRUB_FILE_TYPE_SKIP_SIGNATURE + : GRUB_FILE_TYPE_NONE)); if (!pkf) return grub_errno; pk = grub_load_public_key (pkf); @@ -786,16 +790,16 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt, grub_file_close (pkf); } - grub_file_filter_disable_all (); - f = grub_file_open (args[0]); + f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE); if (!f) { err = grub_errno; goto fail; } - grub_file_filter_disable_all (); - sig = grub_file_open (args[1]); + sig = grub_file_open (args[1], + GRUB_FILE_TYPE_SIGNATURE + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (!sig) { err = grub_errno; @@ -858,33 +862,32 @@ struct grub_fs verified_fs = }; static grub_file_t -grub_pubkey_open (grub_file_t io, const char *filename) +grub_pubkey_open (grub_file_t io, enum grub_file_type type) { grub_file_t sig; char *fsuf, *ptr; grub_err_t err; - grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX]; grub_file_t ret; grub_verified_t verified; + if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE + || (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE + || (type & GRUB_FILE_TYPE_SKIP_SIGNATURE)) + return io; + if (!sec) return io; if (io->device->disk && (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID)) return io; - fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig")); + fsuf = grub_malloc (grub_strlen (io->name) + sizeof (".sig")); if (!fsuf) return NULL; - ptr = grub_stpcpy (fsuf, filename); + ptr = grub_stpcpy (fsuf, io->name); grub_memcpy (ptr, ".sig", sizeof (".sig")); - grub_memcpy (curfilt, grub_file_filters_enabled, - sizeof (curfilt)); - grub_file_filter_disable_all (); - sig = grub_file_open (fsuf); - grub_memcpy (grub_file_filters_enabled, curfilt, - sizeof (curfilt)); + sig = grub_file_open (fsuf, GRUB_FILE_TYPE_SIGNATURE); grub_free (fsuf); if (!sig) return NULL; @@ -918,7 +921,7 @@ grub_pubkey_open (grub_file_t io, const char *filename) if (!verified->buf) { grub_file_close (sig); - grub_free (verified); + verified_free (verified); grub_free (ret); return NULL; } @@ -926,7 +929,7 @@ grub_pubkey_open (grub_file_t io, const char *filename) { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - filename); + io->name); grub_file_close (sig); verified_free (verified); grub_free (ret); diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index 2d8deaeaf..9406d931c 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -92,7 +92,8 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args) if (argc < 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (args[1]); + file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) return grub_errno; diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c index f6813b1ed..a81934725 100644 --- a/grub-core/efiemu/main.c +++ b/grub-core/efiemu/main.c @@ -187,7 +187,7 @@ grub_efiemu_load_file (const char *filename) grub_file_t file; grub_err_t err; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE); if (! file) return grub_errno; diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 53d76a64d..85a292557 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -418,7 +418,7 @@ grub_font_load (const char *filename) #endif if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+') - file = grub_buffile_open (filename, 1024); + file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024); else { const char *prefix = grub_env_get ("prefix"); @@ -438,7 +438,7 @@ grub_font_load (const char *filename) ptr = grub_stpcpy (ptr, filename); ptr = grub_stpcpy (ptr, ".pf2"); *ptr = 0; - file = grub_buffile_open (fullname, 1024); + file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024); grub_free (fullname); } if (!file) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 87eef621d..1402e0bc2 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -425,7 +425,7 @@ grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args) if (argc > 0) { grub_file_t file; - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY); if (!file) return grub_errno; real_size = grub_file_read (file, buf, 1024); diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 4880cefe3..4d02e62c1 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -291,7 +291,7 @@ grub_mofile_open (struct grub_gettext_context *ctx, /* Using fd_mo and not another variable because it's needed for grub_gettext_get_info. */ - fd = grub_file_open (filename); + fd = grub_file_open (filename, GRUB_FILE_TYPE_GETTEXT_CATALOG); if (!fd) return grub_errno; diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c index 02978392c..d6829bb5e 100644 --- a/grub-core/gfxmenu/theme_loader.c +++ b/grub-core/gfxmenu/theme_loader.c @@ -743,7 +743,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path) p.view = view; p.theme_dir = grub_get_dirname (theme_path); - file = grub_file_open (theme_path); + file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME); if (! file) { grub_free (p.theme_dir); diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index d2f4fb493..21c14c31a 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -88,11 +88,11 @@ grub_bufio_open (grub_file_t io, grub_size_t size) } grub_file_t -grub_buffile_open (const char *name, grub_size_t size) +grub_buffile_open (const char *name, enum grub_file_type type, grub_size_t size) { grub_file_t io, file; - io = grub_file_open (name); + io = grub_file_open (name, type); if (! io) return 0; diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 86ea8cfde..7760d8b97 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1156,11 +1156,14 @@ initialize_tables (grub_gzio_t gzio) even if IO does not contain data compressed by gzip, return a valid file object. Note that this function won't close IO, even if an error occurs. */ static grub_file_t -grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) +grub_gzio_open (grub_file_t io, enum grub_file_type type) { grub_file_t file; grub_gzio_t gzio = 0; + if (type & GRUB_FILE_TYPE_NO_DECOMPRESS) + return io; + file = (grub_file_t) grub_zalloc (sizeof (*file)); if (! file) return 0; diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c index 7559c6c9c..84edf6dd2 100644 --- a/grub-core/io/lzopio.c +++ b/grub-core/io/lzopio.c @@ -407,12 +407,14 @@ CORRUPTED: } static grub_file_t -grub_lzopio_open (grub_file_t io, - const char *name __attribute__ ((unused))) +grub_lzopio_open (grub_file_t io, enum grub_file_type type) { grub_file_t file; grub_lzopio_t lzopio; + if (type & GRUB_FILE_TYPE_NO_DECOMPRESS) + return io; + file = (grub_file_t) grub_zalloc (sizeof (*file)); if (!file) return 0; diff --git a/grub-core/io/offset.c b/grub-core/io/offset.c index ebed0ebe6..ec8e23208 100644 --- a/grub-core/io/offset.c +++ b/grub-core/io/offset.c @@ -69,7 +69,8 @@ grub_file_offset_close (grub_file_t file) } grub_file_t -grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size) +grub_file_offset_open (grub_file_t parent, enum grub_file_type type, + grub_off_t start, grub_off_t size) { struct grub_offset_file *off_data; grub_file_t off_file, last_off_file; @@ -95,10 +96,10 @@ grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size) last_off_file = NULL; for (filter = GRUB_FILE_FILTER_COMPRESSION_FIRST; off_file && filter <= GRUB_FILE_FILTER_COMPRESSION_LAST; filter++) - if (grub_file_filters_enabled[filter]) + if (grub_file_filters[filter]) { last_off_file = off_file; - off_file = grub_file_filters_enabled[filter] (off_file, parent->name); + off_file = grub_file_filters[filter] (off_file, type); } if (!off_file) diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index a3536ad73..42afeedcd 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -169,12 +169,14 @@ ERROR: } static grub_file_t -grub_xzio_open (grub_file_t io, - const char *name __attribute__ ((unused))) +grub_xzio_open (grub_file_t io, enum grub_file_type type) { grub_file_t file; grub_xzio_t xzio; + if (type & GRUB_FILE_TYPE_NO_DECOMPRESS) + return io; + file = (grub_file_t) grub_zalloc (sizeof (*file)); if (!file) return 0; diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index e394cd96f..f8d58f029 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -688,7 +688,7 @@ grub_dl_load_file (const char *filename) grub_boot_time ("Loading module %s", filename); - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE); if (! file) return 0; diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 4f282c9cf..9d7149b38 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -136,12 +136,12 @@ fail: } grub_elf_t -grub_elf_open (const char *name) +grub_elf_open (const char *name, enum grub_file_type type) { grub_file_t file; grub_elf_t elf; - file = grub_file_open (name); + file = grub_file_open (name, type); if (! file) return 0; diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 668f8930b..643154237 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -28,8 +28,7 @@ void (*EXPORT_VAR (grub_grubnet_fini)) (void); -grub_file_filter_t grub_file_filters_all[GRUB_FILE_FILTER_MAX]; -grub_file_filter_t grub_file_filters_enabled[GRUB_FILE_FILTER_MAX]; +grub_file_filter_t grub_file_filters[GRUB_FILE_FILTER_MAX]; /* Get the device part of the filename NAME. It is enclosed by parentheses. */ char * @@ -59,7 +58,7 @@ grub_file_get_device_name (const char *name) } grub_file_t -grub_file_open (const char *name) +grub_file_open (const char *name, enum grub_file_type type) { grub_device_t device = 0; grub_file_t file = 0, last_file = 0; @@ -114,18 +113,20 @@ grub_file_open (const char *name) file->name = grub_strdup (name); grub_errno = GRUB_ERR_NONE; - for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled); + for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters); filter++) - if (grub_file_filters_enabled[filter]) + if (grub_file_filters[filter]) { last_file = file; - file = grub_file_filters_enabled[filter] (file, name); + file = grub_file_filters[filter] (file, type); + if (file && file != last_file) + { + file->name = grub_strdup (name); + grub_errno = GRUB_ERR_NONE; + } } if (!file) grub_file_close (last_file); - - grub_memcpy (grub_file_filters_enabled, grub_file_filters_all, - sizeof (grub_file_filters_enabled)); return file; @@ -137,9 +138,6 @@ grub_file_open (const char *name) grub_free (file); - grub_memcpy (grub_file_filters_enabled, grub_file_filters_all, - sizeof (grub_file_filters_enabled)); - return 0; } diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 28ba3aef0..c96d85ee5 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -696,7 +696,7 @@ syslinux_parse_real (struct syslinux_menu *menu) char *buf = NULL; grub_err_t err = GRUB_ERR_NONE; - file = grub_file_open (menu->filename); + file = grub_file_open (menu->filename, GRUB_FILE_TYPE_CONFIG); if (!file) return grub_errno; while ((grub_free (buf), buf = grub_file_getline (file))) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index adc856366..f706b1ac3 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -219,7 +219,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), b = grub_efi_system_table->boot_services; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE); if (! file) goto fail; diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 7f96515da..d34da14d9 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1457,7 +1457,7 @@ grub_bsd_load (int argc, char *argv[]) goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL); if (!file) goto fail; @@ -1534,7 +1534,7 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) if (err) return err; - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL); if (! file) return grub_errno; @@ -1693,7 +1693,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) { grub_file_t file; - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL); if (! file) return grub_errno; @@ -1802,7 +1802,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_ENV); if ((!file) || (!file->size)) goto fail; @@ -1907,7 +1907,7 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), return 0; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE); if ((!file) || (!file->size)) goto fail; @@ -1958,7 +1958,7 @@ grub_netbsd_module_load (char *filename, grub_uint32_t type) void *src; grub_err_t err; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_NETBSD_MODULE); if ((!file) || (!file->size)) goto fail; @@ -2048,7 +2048,7 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), return 0; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE_ELF); if (!file) return grub_errno; if (!file->size) @@ -2088,7 +2088,7 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)), if (!openbsd_ramdisk.max_size) return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD doesn't support ramdisk"); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_OPENBSD_RAMDISK); if (! file) return grub_errno; diff --git a/grub-core/loader/i386/coreboot/chainloader.c b/grub-core/loader/i386/coreboot/chainloader.c index 2cb78eee0..0a19ebb9c 100644 --- a/grub-core/loader/i386/coreboot/chainloader.c +++ b/grub-core/loader/i386/coreboot/chainloader.c @@ -439,7 +439,7 @@ grub_cmd_chain (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset (); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_COREBOOT_CHAINLOADER); if (!file) return grub_errno; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 4eab55a2d..b4e40ac7f 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -652,7 +652,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index ef3a322b7..976fea73a 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -172,8 +172,8 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags) grub_dl_ref (my_mod); - grub_file_filter_disable_compression (); - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_PCCHAINLOADER + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/freedos.c b/grub-core/loader/i386/pc/freedos.c index 478f3c513..aac6c9715 100644 --- a/grub-core/loader/i386/pc/freedos.c +++ b/grub-core/loader/i386/pc/freedos.c @@ -110,7 +110,7 @@ grub_cmd_freedos (grub_command_t cmd __attribute__ ((unused)), if (!rel) goto fail; - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEDOS); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 531b58d37..0a5aa0c71 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -139,7 +139,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/ntldr.c b/grub-core/loader/i386/pc/ntldr.c index 1b88f40d8..f0d74145b 100644 --- a/grub-core/loader/i386/pc/ntldr.c +++ b/grub-core/loader/i386/pc/ntldr.c @@ -90,7 +90,7 @@ grub_cmd_ntldr (grub_command_t cmd __attribute__ ((unused)), if (!rel) goto fail; - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_NTLDR); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c index 814a49d50..0351090da 100644 --- a/grub-core/loader/i386/pc/plan9.c +++ b/grub-core/loader/i386/pc/plan9.c @@ -413,7 +413,7 @@ grub_cmd_plan9 (grub_extcmd_context_t ctxt, int argc, char *argv[]) if (!rel) goto fail; - fill_ctx.file = grub_file_open (argv[0]); + fill_ctx.file = grub_file_open (argv[0], GRUB_FILE_TYPE_PLAN9_KERNEL); if (! fill_ctx.file) goto fail; diff --git a/grub-core/loader/i386/pc/pxechainloader.c b/grub-core/loader/i386/pc/pxechainloader.c index e60c62b1b..acb061169 100644 --- a/grub-core/loader/i386/pc/pxechainloader.c +++ b/grub-core/loader/i386/pc/pxechainloader.c @@ -99,7 +99,7 @@ grub_cmd_pxechain (grub_command_t cmd __attribute__ ((unused)), if (!rel) goto fail; - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_PXECHAINLOADER); if (! file) goto fail; diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c index 9ea4fde42..cbeeec7be 100644 --- a/grub-core/loader/i386/pc/truecrypt.c +++ b/grub-core/loader/i386/pc/truecrypt.c @@ -99,7 +99,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)), grub_dl_ref (my_mod); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_TRUECRYPT); if (! file) goto fail; diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 3073f64d5..8a93a527a 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -648,7 +648,7 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), (char *) xen_state.next_start.cmd_line, sizeof (xen_state.next_start.cmd_line) - 1); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (!file) return grub_errno; @@ -893,9 +893,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE); - if (nounzip) - grub_file_filter_disable_compression (); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_INITRD | + (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE)); if (!file) return grub_errno; size = grub_file_size (file); diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 77a93e7b2..9af5d66df 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -78,7 +78,7 @@ grub_xen_file (grub_file_t file) Trim it. */ if (grub_memcmp (magic, XZ_MAGIC, sizeof (XZ_MAGIC) - 1) == 0) payload_length -= 4; - off_file = grub_file_offset_open (file, payload_offset, + off_file = grub_file_offset_open (file, GRUB_FILE_TYPE_LINUX_KERNEL, payload_offset, payload_length); if (!off_file) goto fail; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 59ef73a73..e64ed08f5 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -487,7 +487,7 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)), if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_XNU_DEVPROP); if (! file) return grub_errno; size = grub_file_size (file); diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index be6fa0f4d..471b214d6 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -173,7 +173,6 @@ grub_initrd_init (int argc, char *argv[], eptr = grub_strchr (ptr, ':'); if (eptr) { - grub_file_filter_disable_compression (); initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr); if (!initrd_ctx->components[i].newc_name) { @@ -198,8 +197,9 @@ grub_initrd_init (int argc, char *argv[], root = 0; newc = 0; } - grub_file_filter_disable_compression (); - initrd_ctx->components[i].file = grub_file_open (fname); + initrd_ctx->components[i].file = grub_file_open (fname, + GRUB_FILE_TYPE_LINUX_INITRD + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (!initrd_ctx->components[i].file) { grub_initrd_close (initrd_ctx); diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c index 59b195e27..085f9c689 100644 --- a/grub-core/loader/macho.c +++ b/grub-core/loader/macho.c @@ -188,12 +188,12 @@ fail: } grub_macho_t -grub_macho_open (const char *name, int is_64bit) +grub_macho_open (const char *name, enum grub_file_type type, int is_64bit) { grub_file_t file; grub_macho_t macho; - file = grub_file_open (name); + file = grub_file_open (name, type); if (! file) return 0; diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 5f383be3d..7b28ba731 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -237,7 +237,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - elf = grub_elf_open (argv[0]); + elf = grub_elf_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (! elf) return grub_errno; diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 40c67e824..4a98d7082 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -321,7 +321,7 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_KERNEL); if (! file) return grub_errno; @@ -387,10 +387,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); - if (nounzip) - grub_file_filter_disable_compression (); - - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_MODULE + | (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE)); if (! file) return grub_errno; diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index c9885b1bc..84c8b939c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -351,7 +351,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), grub_xnu_unload (); - macho = grub_macho_open (args[0], 0); + macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 0); if (! macho) return grub_errno; @@ -456,7 +456,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), grub_xnu_unload (); - macho = grub_macho_open (args[0], 1); + macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 1); if (! macho) return grub_errno; @@ -674,7 +674,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, macho = 0; if (infoplistname) - infoplist = grub_file_open (infoplistname); + infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST); else infoplist = 0; grub_errno = GRUB_ERR_NONE; @@ -771,7 +771,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), if (! grub_xnu_heap_size) return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_MKEXT); if (! file) return grub_errno; @@ -885,7 +885,7 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)), if (! grub_xnu_heap_size) return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); - file = grub_file_open (args[0]); + file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_RAMDISK); if (! file) return grub_errno; @@ -925,7 +925,7 @@ grub_xnu_check_os_bundle_required (char *plistname, if (binname) *binname = 0; - file = grub_file_open (plistname); + file = grub_file_open (plistname, GRUB_FILE_TYPE_XNU_INFO_PLIST); if (! file) return 0; @@ -1210,7 +1210,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired, grub_strcpy (binname + grub_strlen (binname), "/"); grub_strcpy (binname + grub_strlen (binname), binsuffix); grub_dprintf ("xnu", "%s:%s\n", ctx.plistname, binname); - binfile = grub_file_open (binname); + binfile = grub_file_open (binname, GRUB_FILE_TYPE_XNU_KEXT); if (! binfile) grub_errno = GRUB_ERR_NONE; @@ -1253,7 +1253,7 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)), /* User explicitly specified plist and binary. */ if (grub_strcmp (args[1], "-") != 0) { - binfile = grub_file_open (args[1]); + binfile = grub_file_open (args[1], GRUB_FILE_TYPE_XNU_KEXT); if (! binfile) return grub_errno; } diff --git a/grub-core/loader/xnu_resume.c b/grub-core/loader/xnu_resume.c index 534a74438..8089804d4 100644 --- a/grub-core/loader/xnu_resume.c +++ b/grub-core/loader/xnu_resume.c @@ -53,8 +53,8 @@ grub_xnu_resume (char *imagename) grub_addr_t target_image; grub_err_t err; - grub_file_filter_disable_compression (); - file = grub_file_open (imagename); + file = grub_file_open (imagename, GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE + | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) return 0; diff --git a/grub-core/normal/autofs.c b/grub-core/normal/autofs.c index 721b9c325..7a7cf2b0f 100644 --- a/grub-core/normal/autofs.c +++ b/grub-core/normal/autofs.c @@ -33,12 +33,6 @@ autoload_fs_module (void) { grub_named_list_t p; int ret = 0; - grub_file_filter_t grub_file_filters_was[GRUB_FILE_FILTER_MAX]; - - grub_memcpy (grub_file_filters_was, grub_file_filters_enabled, - sizeof (grub_file_filters_enabled)); - grub_memcpy (grub_file_filters_enabled, grub_file_filters_all, - sizeof (grub_file_filters_enabled)); while ((p = fs_module_list) != NULL) { @@ -56,9 +50,6 @@ autoload_fs_module (void) grub_free (p); } - grub_memcpy (grub_file_filters_enabled, grub_file_filters_was, - sizeof (grub_file_filters_enabled)); - return ret; } @@ -82,7 +73,7 @@ read_fs_list (const char *prefix) tmp_autoload_hook = grub_fs_autoload_hook; grub_fs_autoload_hook = NULL; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST); if (file) { /* Override previous fs.lst. */ diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c index e6d345f33..d01e6f271 100644 --- a/grub-core/normal/crypto.c +++ b/grub-core/normal/crypto.c @@ -94,7 +94,7 @@ read_crypto_list (const char *prefix) return; } - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST); grub_free (filename); if (!file) { diff --git a/grub-core/normal/dyncmd.c b/grub-core/normal/dyncmd.c index 169c126f5..719ebf477 100644 --- a/grub-core/normal/dyncmd.c +++ b/grub-core/normal/dyncmd.c @@ -106,7 +106,7 @@ read_command_list (const char *prefix) { grub_file_t file; - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST); if (file) { char *buf = NULL; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 78a70a8bf..1b03dfd57 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -123,7 +123,7 @@ read_config_file (const char *config) } /* Try to open the config file. */ - rawfile = grub_file_open (config); + rawfile = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); if (! rawfile) return 0; diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index ac5d69f0f..a1e5c5a0d 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -331,7 +331,7 @@ read_terminal_list (const char *prefix) return; } - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST); grub_free (filename); if (!file) { diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index 21b0d9ded..31359a4c9 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -772,7 +772,7 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap, grub_file_t file; struct grub_jpeg_data *data; - file = grub_buffile_open (filename, 0); + file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0); if (!file) return grub_errno; diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c index e1a01e99f..777e71334 100644 --- a/grub-core/video/readers/png.c +++ b/grub-core/video/readers/png.c @@ -1086,7 +1086,7 @@ grub_video_reader_png (struct grub_video_bitmap **bitmap, grub_file_t file; struct grub_png_data *data; - file = grub_buffile_open (filename, 0); + file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0); if (!file) return grub_errno; diff --git a/grub-core/video/readers/tga.c b/grub-core/video/readers/tga.c index c7a16fa9c..7cb9d1d2a 100644 --- a/grub-core/video/readers/tga.c +++ b/grub-core/video/readers/tga.c @@ -297,7 +297,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap, grub_memset (&data, 0, sizeof (data)); - data.file = grub_buffile_open (filename, 0); + data.file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0); if (! data.file) return grub_errno; diff --git a/include/grub/bufio.h b/include/grub/bufio.h index 77eb8ee56..0ff72d103 100644 --- a/include/grub/bufio.h +++ b/include/grub/bufio.h @@ -23,6 +23,8 @@ #include grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, grub_size_t size); -grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, grub_size_t size); +grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, + enum grub_file_type type, + grub_size_t size); #endif /* ! GRUB_BUFIO_H */ diff --git a/include/grub/elfload.h b/include/grub/elfload.h index 9a7ae4ebb..dbb609c9b 100644 --- a/include/grub/elfload.h +++ b/include/grub/elfload.h @@ -42,7 +42,7 @@ typedef int (*grub_elf32_phdr_iterate_hook_t) typedef int (*grub_elf64_phdr_iterate_hook_t) (grub_elf_t elf, Elf64_Phdr *phdr, void *arg); -grub_elf_t grub_elf_open (const char *); +grub_elf_t grub_elf_open (const char *, enum grub_file_type type); grub_elf_t grub_elf_file (grub_file_t file, const char *filename); grub_err_t grub_elf_close (grub_elf_t); diff --git a/include/grub/file.h b/include/grub/file.h index 739488cbe..5b47c5f91 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -25,6 +25,109 @@ #include #include +enum grub_file_type + { + GRUB_FILE_TYPE_NONE = 0, + /* GRUB module to be loaded. */ + GRUB_FILE_TYPE_GRUB_MODULE, + /* Loopback file to be represented as disk. */ + GRUB_FILE_TYPE_LOOPBACK, + /* Linux kernel to be loaded. */ + GRUB_FILE_TYPE_LINUX_KERNEL, + /* Linux initrd. */ + GRUB_FILE_TYPE_LINUX_INITRD, + + /* Multiboot kernel. */ + GRUB_FILE_TYPE_MULTIBOOT_KERNEL, + /* Multiboot module. */ + GRUB_FILE_TYPE_MULTIBOOT_MODULE, + + GRUB_FILE_TYPE_BSD_KERNEL, + GRUB_FILE_TYPE_FREEBSD_ENV, + GRUB_FILE_TYPE_FREEBSD_MODULE, + GRUB_FILE_TYPE_FREEBSD_MODULE_ELF, + GRUB_FILE_TYPE_NETBSD_MODULE, + GRUB_FILE_TYPE_OPENBSD_RAMDISK, + + GRUB_FILE_TYPE_XNU_INFO_PLIST, + GRUB_FILE_TYPE_XNU_MKEXT, + GRUB_FILE_TYPE_XNU_KEXT, + GRUB_FILE_TYPE_XNU_KERNEL, + GRUB_FILE_TYPE_XNU_RAMDISK, + GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE, + GRUB_FILE_XNU_DEVPROP, + + GRUB_FILE_TYPE_PLAN9_KERNEL, + + GRUB_FILE_TYPE_NTLDR, + GRUB_FILE_TYPE_TRUECRYPT, + GRUB_FILE_TYPE_FREEDOS, + GRUB_FILE_TYPE_PXECHAINLOADER, + GRUB_FILE_TYPE_PCCHAINLOADER, + + GRUB_FILE_TYPE_COREBOOT_CHAINLOADER, + + GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE, + + /* File holding signature. */ + GRUB_FILE_TYPE_SIGNATURE, + /* File holding public key to verify signature once. */ + GRUB_FILE_TYPE_PUBLIC_KEY, + /* File holding public key to add to trused keys. */ + GRUB_FILE_TYPE_PUBLIC_KEY_TRUST, + /* File of which we intend to print a blocklist to the user. */ + GRUB_FILE_TYPE_PRINT_BLOCKLIST, + /* File we intend to use for test loading or testing speed. */ + GRUB_FILE_TYPE_TESTLOAD, + /* File we open only to get its size. E.g. in ls output. */ + GRUB_FILE_TYPE_GET_SIZE, + /* Font file. */ + GRUB_FILE_TYPE_FONT, + /* File holding encryption key for encrypted ZFS. */ + GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY, + /* File we open n grub-fstest. */ + GRUB_FILE_TYPE_FSTEST, + /* File we open n grub-mount. */ + GRUB_FILE_TYPE_MOUNT, + /* File which we attempt to identify the type of. */ + GRUB_FILE_TYPE_FILE_ID, + /* File holding ACPI table. */ + GRUB_FILE_TYPE_ACPI_TABLE, + /* File we intend show to user. */ + GRUB_FILE_TYPE_CAT, + GRUB_FILE_TYPE_HEXCAT, + /* One of pair of files we intend to compare. */ + GRUB_FILE_TYPE_CMP, + /* List of hashes for hashsum. */ + GRUB_FILE_TYPE_HASHLIST, + /* File hashed by hashsum. */ + GRUB_FILE_TYPE_TO_HASH, + /* Keyboard layout. */ + GRUB_FILE_TYPE_KEYBOARD_LAYOUT, + /* Picture file. */ + GRUB_FILE_TYPE_PIXMAP, + /* *.lst shipped by GRUB. */ + GRUB_FILE_TYPE_GRUB_MODULE_LIST, + /* config file. */ + GRUB_FILE_TYPE_CONFIG, + GRUB_FILE_TYPE_THEME, + GRUB_FILE_TYPE_GETTEXT_CATALOG, + GRUB_FILE_TYPE_FS_SEARCH, + GRUB_FILE_TYPE_AUDIO, + GRUB_FILE_TYPE_VBE_DUMP, + + GRUB_FILE_TYPE_LOADENV, + GRUB_FILE_TYPE_SAVEENV, + + GRUB_FILE_TYPE_VERIFY_SIGNATURE, + + GRUB_FILE_TYPE_MASK = 0xffff, + + /* --skip-sig is specified. */ + GRUB_FILE_TYPE_SKIP_SIGNATURE = 0x10000, + GRUB_FILE_TYPE_NO_DECOMPRESS = 0x20000 + }; + /* File description. */ struct grub_file { @@ -77,61 +180,26 @@ typedef enum grub_file_filter_id GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_LZOPIO, } grub_file_filter_id_t; -typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, const char *filename); +typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, enum grub_file_type type); -extern grub_file_filter_t EXPORT_VAR(grub_file_filters_all)[GRUB_FILE_FILTER_MAX]; -extern grub_file_filter_t EXPORT_VAR(grub_file_filters_enabled)[GRUB_FILE_FILTER_MAX]; +extern grub_file_filter_t EXPORT_VAR(grub_file_filters)[GRUB_FILE_FILTER_MAX]; static inline void grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter) { - grub_file_filters_all[id] = filter; - grub_file_filters_enabled[id] = filter; + grub_file_filters[id] = filter; } static inline void grub_file_filter_unregister (grub_file_filter_id_t id) { - grub_file_filters_all[id] = 0; - grub_file_filters_enabled[id] = 0; -} - -static inline void -grub_file_filter_disable (grub_file_filter_id_t id) -{ - grub_file_filters_enabled[id] = 0; -} - -static inline void -grub_file_filter_disable_compression (void) -{ - grub_file_filter_id_t id; - - for (id = GRUB_FILE_FILTER_COMPRESSION_FIRST; - id <= GRUB_FILE_FILTER_COMPRESSION_LAST; id++) - grub_file_filters_enabled[id] = 0; -} - -static inline void -grub_file_filter_disable_all (void) -{ - grub_file_filter_id_t id; - - for (id = 0; - id < GRUB_FILE_FILTER_MAX; id++) - grub_file_filters_enabled[id] = 0; -} - -static inline void -grub_file_filter_disable_pubkey (void) -{ - grub_file_filters_enabled[GRUB_FILE_FILTER_PUBKEY] = 0; + grub_file_filters[id] = 0; } /* Get a device name from NAME. */ char *EXPORT_FUNC(grub_file_get_device_name) (const char *name); -grub_file_t EXPORT_FUNC(grub_file_open) (const char *name); +grub_file_t EXPORT_FUNC(grub_file_open) (const char *name, enum grub_file_type type); grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf, grub_size_t len); grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset); @@ -159,8 +227,8 @@ grub_file_seekable (const grub_file_t file) } grub_file_t -grub_file_offset_open (grub_file_t parent, grub_off_t start, - grub_off_t size); +grub_file_offset_open (grub_file_t parent, enum grub_file_type type, + grub_off_t start, grub_off_t size); void grub_file_offset_close (grub_file_t file); diff --git a/include/grub/machoload.h b/include/grub/machoload.h index 1eec118f1..f1157f410 100644 --- a/include/grub/machoload.h +++ b/include/grub/machoload.h @@ -49,7 +49,8 @@ struct grub_macho_file }; typedef struct grub_macho_file *grub_macho_t; -grub_macho_t grub_macho_open (const char *, int is_64bit); +grub_macho_t grub_macho_open (const char *, enum grub_file_type type, + int is_64bit); grub_macho_t grub_macho_file (grub_file_t file, const char *filename, int is_64bit); grub_err_t grub_macho_close (grub_macho_t); diff --git a/util/grub-fstest.c b/util/grub-fstest.c index a358ae471..7074e8e41 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -120,9 +120,9 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void return; } - if (uncompress == 0) - grub_file_filter_disable_compression (); - file = grub_file_open (pathname); + file = grub_file_open (pathname, ((uncompress == 0) + ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE) + | GRUB_FILE_TYPE_FSTEST); if (!file) { grub_util_error (_("cannot open `%s': %s"), pathname, diff --git a/util/grub-mount.c b/util/grub-mount.c index a25db8a71..e32b502e7 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -208,7 +208,7 @@ fuse_getattr (const char *path, struct stat *st) if (!ctx.file_info.dir) { grub_file_t file; - file = grub_file_open (path); + file = grub_file_open (path, GRUB_FILE_TYPE_GET_SIZE); if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE) { grub_errno = GRUB_ERR_NONE; @@ -244,7 +244,7 @@ static int fuse_open (const char *path, struct fuse_file_info *fi __attribute__ ((unused))) { grub_file_t file; - file = grub_file_open (path); + file = grub_file_open (path, GRUB_FILE_TYPE_MOUNT); if (! file) return translate_error (); files[first_fd++] = file; @@ -308,7 +308,7 @@ fuse_readdir_call_fill (const char *filename, grub_file_t file; char *tmp; tmp = xasprintf ("%s/%s", ctx->path, filename); - file = grub_file_open (tmp); + file = grub_file_open (tmp, GRUB_FILE_TYPE_GET_SIZE); free (tmp); /* Symlink to directory. */ if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE) From 75a919e334f8514b6adbc024743cfcd9b88fa394 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 5 Feb 2017 14:25:47 +0100 Subject: [PATCH 0859/1167] verifiers: Framework core Verifiers framework provides core file verification functionality which can be used by various security mechanisms, e.g., UEFI secure boot, TPM, PGP signature verification, etc. The patch contains PGP code changes and probably they should be extracted to separate patch for the sake of clarity. Signed-off-by: Vladimir Serbinenko Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/Makefile.core.def | 5 + grub-core/commands/verifiers.c | 197 ++++++++++++ grub-core/commands/verify.c | 540 ++++++++++++++++----------------- include/grub/file.h | 2 +- include/grub/list.h | 1 + include/grub/verify.h | 65 ++++ 6 files changed, 526 insertions(+), 284 deletions(-) create mode 100644 grub-core/commands/verifiers.c create mode 100644 include/grub/verify.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 9590e87d9..9af31c098 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -894,6 +894,11 @@ module = { cppflags = '-I$(srcdir)/lib/posix_wrap'; }; +module = { + name = verifiers; + common = commands/verifiers.c; +}; + module = { name = hdparm; common = commands/hdparm.c; diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c new file mode 100644 index 000000000..fde88318d --- /dev/null +++ b/grub-core/commands/verifiers.c @@ -0,0 +1,197 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2017 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 . + * + * Verifiers helper. + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +struct grub_file_verifier *grub_file_verifiers; + +struct grub_verified +{ + grub_file_t file; + void *buf; +}; +typedef struct grub_verified *grub_verified_t; + +static void +verified_free (grub_verified_t verified) +{ + if (verified) + { + grub_free (verified->buf); + grub_free (verified); + } +} + +static grub_ssize_t +verified_read (struct grub_file *file, char *buf, grub_size_t len) +{ + grub_verified_t verified = file->data; + + grub_memcpy (buf, (char *) verified->buf + file->offset, len); + return len; +} + +static grub_err_t +verified_close (struct grub_file *file) +{ + grub_verified_t verified = file->data; + + grub_file_close (verified->file); + verified_free (verified); + file->data = 0; + + /* Device and name are freed by parent. */ + file->device = 0; + file->name = 0; + + return grub_errno; +} + +struct grub_fs verified_fs = +{ + .name = "verified_read", + .read = verified_read, + .close = verified_close +}; + +static grub_file_t +grub_verifiers_open (grub_file_t io, enum grub_file_type type) +{ + grub_verified_t verified = NULL; + struct grub_file_verifier *ver; + void *context; + grub_file_t ret = 0; + grub_err_t err; + + grub_dprintf ("verify", "file: %s type: %d\n", io->name, type); + + if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE + || (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE + || (type & GRUB_FILE_TYPE_SKIP_SIGNATURE)) + return io; + + if (io->device->disk && + (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID + || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID)) + return io; + + FOR_LIST_ELEMENTS(ver, grub_file_verifiers) + { + enum grub_verify_flags flags = 0; + err = ver->init (io, type, &context, &flags); + if (err) + goto fail_noclose; + if (!(flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION)) + break; + } + + if (!ver) + /* No verifiers wanted to verify. Just return underlying file. */ + return io; + + ret = grub_malloc (sizeof (*ret)); + if (!ret) + { + goto fail; + } + *ret = *io; + + ret->fs = &verified_fs; + ret->not_easily_seekable = 0; + if (ret->size >> (sizeof (grub_size_t) * GRUB_CHAR_BIT - 1)) + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + N_("big file signature isn't implemented yet")); + goto fail; + } + verified = grub_malloc (sizeof (*verified)); + if (!verified) + { + goto fail; + } + verified->buf = grub_malloc (ret->size); + if (!verified->buf) + { + goto fail; + } + if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size) + { + if (!grub_errno) + grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), + io->name); + goto fail; + } + + err = ver->write (context, verified->buf, ret->size); + if (err) + goto fail; + + err = ver->fini ? ver->fini (context) : GRUB_ERR_NONE; + if (err) + goto fail; + + if (ver->close) + ver->close (context); + + FOR_LIST_ELEMENTS_NEXT(ver, grub_file_verifiers) + { + enum grub_verify_flags flags = 0; + err = ver->init (io, type, &context, &flags); + if (err) + goto fail_noclose; + if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION) + continue; + err = ver->write (context, verified->buf, ret->size); + if (err) + goto fail; + + err = ver->fini ? ver->fini (context) : GRUB_ERR_NONE; + if (err) + goto fail; + + if (ver->close) + ver->close (context); + } + + verified->file = io; + ret->data = verified; + return ret; + + fail: + ver->close (context); + fail_noclose: + verified_free (verified); + grub_free (ret); + return NULL; +} + +GRUB_MOD_INIT(verifiers) +{ + grub_file_filter_register (GRUB_FILE_FILTER_VERIFY, grub_verifiers_open); +} + +GRUB_MOD_FINI(verifiers) +{ + grub_file_filter_unregister (GRUB_FILE_FILTER_VERIFY); +} diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index f0dfeceeb..29e74a640 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -30,16 +30,10 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -struct grub_verified -{ - grub_file_t file; - void *buf; -}; -typedef struct grub_verified *grub_verified_t; - enum { OPTION_SKIP_SIG = 0 @@ -445,23 +439,27 @@ rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval, return ret; } +struct grub_pubkey_context +{ + grub_file_t sig; + struct signature_v4_header v4; + grub_uint8_t v; + const gcry_md_spec_t *hash; + void *hash_context; +}; + static grub_err_t -grub_verify_signature_real (char *buf, grub_size_t size, - grub_file_t f, grub_file_t sig, - struct grub_public_key *pkey) +grub_verify_signature_init (struct grub_pubkey_context *ctxt, grub_file_t sig) { grub_size_t len; - grub_uint8_t v; grub_uint8_t h; grub_uint8_t t; grub_uint8_t pk; - const gcry_md_spec_t *hash; - struct signature_v4_header v4; grub_err_t err; - grub_size_t i; - gcry_mpi_t mpis[10]; grub_uint8_t type = 0; + grub_memset (ctxt, 0, sizeof (*ctxt)); + err = read_packet_header (sig, &type, &len); if (err) return err; @@ -469,18 +467,18 @@ grub_verify_signature_real (char *buf, grub_size_t size, if (type != 0x2) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - if (grub_file_read (sig, &v, sizeof (v)) != sizeof (v)) + if (grub_file_read (sig, &ctxt->v, sizeof (ctxt->v)) != sizeof (ctxt->v)) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - if (v != 4) + if (ctxt->v != 4) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - if (grub_file_read (sig, &v4, sizeof (v4)) != sizeof (v4)) + if (grub_file_read (sig, &ctxt->v4, sizeof (ctxt->v4)) != sizeof (ctxt->v4)) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - h = v4.hash; - t = v4.type; - pk = v4.pkeyalgo; + h = ctxt->v4.hash; + t = ctxt->v4.type; + pk = ctxt->v4.pkeyalgo; if (t != 0) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); @@ -491,183 +489,233 @@ grub_verify_signature_real (char *buf, grub_size_t size, if (pk >= ARRAY_SIZE (pkalgos) || pkalgos[pk].name == NULL) return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - hash = grub_crypto_lookup_md_by_name (hashes[h]); - if (!hash) + ctxt->hash = grub_crypto_lookup_md_by_name (hashes[h]); + if (!ctxt->hash) return grub_error (GRUB_ERR_BAD_SIGNATURE, "hash `%s' not loaded", hashes[h]); grub_dprintf ("crypt", "alive\n"); - { - void *context = NULL; - unsigned char *hval; - grub_ssize_t rem = grub_be_to_cpu16 (v4.hashed_sub); - grub_uint32_t headlen = grub_cpu_to_be32 (rem + 6); - grub_uint8_t s; - grub_uint16_t unhashed_sub; - grub_ssize_t r; - grub_uint8_t hash_start[2]; - gcry_mpi_t hmpi; - grub_uint64_t keyid = 0; - struct grub_public_subkey *sk; - grub_uint8_t *readbuf = NULL; + ctxt->sig = sig; - context = grub_zalloc (hash->contextsize); - readbuf = grub_zalloc (READBUF_SIZE); - if (!context || !readbuf) - goto fail; + ctxt->hash_context = grub_zalloc (ctxt->hash->contextsize); + if (!ctxt->hash_context) + return grub_errno; - hash->init (context); - if (buf) - hash->write (context, buf, size); - else - while (1) - { - r = grub_file_read (f, readbuf, READBUF_SIZE); - if (r < 0) - goto fail; - if (r == 0) - break; - hash->write (context, readbuf, r); - } + ctxt->hash->init (ctxt->hash_context); - hash->write (context, &v, sizeof (v)); - hash->write (context, &v4, sizeof (v4)); - while (rem) - { - r = grub_file_read (sig, readbuf, - rem < READBUF_SIZE ? rem : READBUF_SIZE); - if (r < 0) - goto fail; - if (r == 0) - break; - hash->write (context, readbuf, r); - rem -= r; - } - hash->write (context, &v, sizeof (v)); - s = 0xff; - hash->write (context, &s, sizeof (s)); - hash->write (context, &headlen, sizeof (headlen)); - r = grub_file_read (sig, &unhashed_sub, sizeof (unhashed_sub)); - if (r != sizeof (unhashed_sub)) - goto fail; + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_pubkey_write (void *ctxt_, void *buf, grub_size_t size) +{ + struct grub_pubkey_context *ctxt = ctxt_; + ctxt->hash->write (ctxt->hash_context, buf, size); + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_verify_signature_real (struct grub_pubkey_context *ctxt, + struct grub_public_key *pkey) +{ + gcry_mpi_t mpis[10]; + grub_uint8_t pk = ctxt->v4.pkeyalgo; + grub_size_t i; + grub_uint8_t *readbuf = NULL; + unsigned char *hval; + grub_ssize_t rem = grub_be_to_cpu16 (ctxt->v4.hashed_sub); + grub_uint32_t headlen = grub_cpu_to_be32 (rem + 6); + grub_uint8_t s; + grub_uint16_t unhashed_sub; + grub_ssize_t r; + grub_uint8_t hash_start[2]; + gcry_mpi_t hmpi; + grub_uint64_t keyid = 0; + struct grub_public_subkey *sk; + + readbuf = grub_malloc (READBUF_SIZE); + if (!readbuf) + goto fail; + + ctxt->hash->write (ctxt->hash_context, &ctxt->v, sizeof (ctxt->v)); + ctxt->hash->write (ctxt->hash_context, &ctxt->v4, sizeof (ctxt->v4)); + while (rem) { - grub_uint8_t *ptr; - grub_uint32_t l; - rem = grub_be_to_cpu16 (unhashed_sub); - if (rem > READBUF_SIZE) + r = grub_file_read (ctxt->sig, readbuf, + rem < READBUF_SIZE ? rem : READBUF_SIZE); + if (r < 0) goto fail; - r = grub_file_read (sig, readbuf, rem); - if (r != rem) + if (r == 0) + break; + ctxt->hash->write (ctxt->hash_context, readbuf, r); + rem -= r; + } + ctxt->hash->write (ctxt->hash_context, &ctxt->v, sizeof (ctxt->v)); + s = 0xff; + ctxt->hash->write (ctxt->hash_context, &s, sizeof (s)); + ctxt->hash->write (ctxt->hash_context, &headlen, sizeof (headlen)); + r = grub_file_read (ctxt->sig, &unhashed_sub, sizeof (unhashed_sub)); + if (r != sizeof (unhashed_sub)) + goto fail; + { + grub_uint8_t *ptr; + grub_uint32_t l; + rem = grub_be_to_cpu16 (unhashed_sub); + if (rem > READBUF_SIZE) + goto fail; + r = grub_file_read (ctxt->sig, readbuf, rem); + if (r != rem) + goto fail; + for (ptr = readbuf; ptr < readbuf + rem; ptr += l) + { + if (*ptr < 192) + l = *ptr++; + else if (*ptr < 255) + { + if (ptr + 1 >= readbuf + rem) + break; + l = (((ptr[0] & ~192) << GRUB_CHAR_BIT) | ptr[1]) + 192; + ptr += 2; + } + else + { + if (ptr + 5 >= readbuf + rem) + break; + l = grub_be_to_cpu32 (grub_get_unaligned32 (ptr + 1)); + ptr += 5; + } + if (*ptr == 0x10 && l >= 8) + keyid = grub_get_unaligned64 (ptr + 1); + } + } + + ctxt->hash->final (ctxt->hash_context); + + grub_dprintf ("crypt", "alive\n"); + + hval = ctxt->hash->read (ctxt->hash_context); + + if (grub_file_read (ctxt->sig, hash_start, sizeof (hash_start)) != sizeof (hash_start)) + goto fail; + if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0) + goto fail; + + grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (ctxt->sig)); + + for (i = 0; i < pkalgos[pk].nmpisig; i++) + { + grub_uint16_t l; + grub_size_t lb; + grub_dprintf ("crypt", "alive\n"); + if (grub_file_read (ctxt->sig, &l, sizeof (l)) != sizeof (l)) goto fail; - for (ptr = readbuf; ptr < readbuf + rem; ptr += l) - { - if (*ptr < 192) - l = *ptr++; - else if (*ptr < 255) - { - if (ptr + 1 >= readbuf + rem) - break; - l = (((ptr[0] & ~192) << GRUB_CHAR_BIT) | ptr[1]) + 192; - ptr += 2; - } - else - { - if (ptr + 5 >= readbuf + rem) - break; - l = grub_be_to_cpu32 (grub_get_unaligned32 (ptr + 1)); - ptr += 5; - } - if (*ptr == 0x10 && l >= 8) - keyid = grub_get_unaligned64 (ptr + 1); - } + grub_dprintf ("crypt", "alive\n"); + lb = (grub_be_to_cpu16 (l) + 7) / 8; + grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l)); + if (lb > READBUF_SIZE - sizeof (grub_uint16_t)) + goto fail; + grub_dprintf ("crypt", "alive\n"); + if (grub_file_read (ctxt->sig, readbuf + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb) + goto fail; + grub_dprintf ("crypt", "alive\n"); + grub_memcpy (readbuf, &l, sizeof (l)); + grub_dprintf ("crypt", "alive\n"); + + if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP, + readbuf, lb + sizeof (grub_uint16_t), 0)) + goto fail; + grub_dprintf ("crypt", "alive\n"); } - hash->final (context); - - grub_dprintf ("crypt", "alive\n"); - - hval = hash->read (context); - - if (grub_file_read (sig, hash_start, sizeof (hash_start)) != sizeof (hash_start)) + if (pkey) + sk = grub_crypto_pk_locate_subkey (keyid, pkey); + else + sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid); + if (!sk) + { + /* TRANSLATORS: %08x is 32-bit key id. */ + grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), + keyid); goto fail; - if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0) + } + + if (pkalgos[pk].pad (&hmpi, hval, ctxt->hash, sk)) + goto fail; + if (!*pkalgos[pk].algo) + { + grub_dl_load (pkalgos[pk].module); + grub_errno = GRUB_ERR_NONE; + } + + if (!*pkalgos[pk].algo) + { + grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), + pkalgos[pk].module); goto fail; + } + if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0)) + goto fail; - grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (sig)); + grub_free (readbuf); - for (i = 0; i < pkalgos[pk].nmpisig; i++) - { - grub_uint16_t l; - grub_size_t lb; - grub_dprintf ("crypt", "alive\n"); - if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l)) - goto fail; - grub_dprintf ("crypt", "alive\n"); - lb = (grub_be_to_cpu16 (l) + 7) / 8; - grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l)); - if (lb > READBUF_SIZE - sizeof (grub_uint16_t)) - goto fail; - grub_dprintf ("crypt", "alive\n"); - if (grub_file_read (sig, readbuf + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb) - goto fail; - grub_dprintf ("crypt", "alive\n"); - grub_memcpy (readbuf, &l, sizeof (l)); - grub_dprintf ("crypt", "alive\n"); + return GRUB_ERR_NONE; - if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP, - readbuf, lb + sizeof (grub_uint16_t), 0)) - goto fail; - grub_dprintf ("crypt", "alive\n"); - } + fail: + grub_free (readbuf); + if (!grub_errno) + return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); + return grub_errno; +} - if (pkey) - sk = grub_crypto_pk_locate_subkey (keyid, pkey); - else - sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid); - if (!sk) - { - /* TRANSLATORS: %08x is 32-bit key id. */ - grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), - keyid); - goto fail; - } +static void +grub_pubkey_close_real (struct grub_pubkey_context *ctxt) +{ + if (ctxt->sig) + grub_file_close (ctxt->sig); + if (ctxt->hash_context) + grub_free (ctxt->hash_context); +} - if (pkalgos[pk].pad (&hmpi, hval, hash, sk)) - goto fail; - if (!*pkalgos[pk].algo) - { - grub_dl_load (pkalgos[pk].module); - grub_errno = GRUB_ERR_NONE; - } - - if (!*pkalgos[pk].algo) - { - grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), - pkalgos[pk].module); - goto fail; - } - if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0)) - goto fail; - - grub_free (context); - grub_free (readbuf); - - return GRUB_ERR_NONE; - - fail: - grub_free (context); - grub_free (readbuf); - if (!grub_errno) - return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - return grub_errno; - } +static void +grub_pubkey_close (void *ctxt) +{ + grub_pubkey_close_real (ctxt); + grub_free (ctxt); } grub_err_t grub_verify_signature (grub_file_t f, grub_file_t sig, struct grub_public_key *pkey) { - return grub_verify_signature_real (0, 0, f, sig, pkey); + grub_err_t err; + struct grub_pubkey_context ctxt; + grub_uint8_t *readbuf = NULL; + + err = grub_verify_signature_init (&ctxt, sig); + if (err) + return err; + + readbuf = grub_zalloc (READBUF_SIZE); + if (!readbuf) + goto fail; + + while (1) + { + grub_ssize_t r; + r = grub_file_read (f, readbuf, READBUF_SIZE); + if (r < 0) + goto fail; + if (r == 0) + break; + err = grub_pubkey_write (&ctxt, readbuf, r); + if (err) + return err; + } + + grub_verify_signature_real (&ctxt, pkey); + fail: + grub_pubkey_close_real (&ctxt); + return grub_errno; } static grub_err_t @@ -819,134 +867,52 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt, static int sec = 0; -static void -verified_free (grub_verified_t verified) -{ - if (verified) - { - grub_free (verified->buf); - grub_free (verified); - } -} - -static grub_ssize_t -verified_read (struct grub_file *file, char *buf, grub_size_t len) -{ - grub_verified_t verified = file->data; - - grub_memcpy (buf, (char *) verified->buf + file->offset, len); - return len; -} - static grub_err_t -verified_close (struct grub_file *file) -{ - grub_verified_t verified = file->data; - - grub_file_close (verified->file); - verified_free (verified); - file->data = 0; - - /* device and name are freed by parent */ - file->device = 0; - file->name = 0; - - return grub_errno; -} - -struct grub_fs verified_fs = -{ - .name = "verified_read", - .read = verified_read, - .close = verified_close -}; - -static grub_file_t -grub_pubkey_open (grub_file_t io, enum grub_file_type type) +grub_pubkey_init (grub_file_t io, enum grub_file_type type __attribute__ ((unused)), + void **context, enum grub_verify_flags *flags) { grub_file_t sig; char *fsuf, *ptr; grub_err_t err; - grub_file_t ret; - grub_verified_t verified; - - if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE - || (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE - || (type & GRUB_FILE_TYPE_SKIP_SIGNATURE)) - return io; + struct grub_pubkey_context *ctxt; if (!sec) - return io; - if (io->device->disk && - (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID - || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID)) - return io; + { + *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; + return GRUB_ERR_NONE; + } + fsuf = grub_malloc (grub_strlen (io->name) + sizeof (".sig")); if (!fsuf) - return NULL; + return grub_errno; ptr = grub_stpcpy (fsuf, io->name); grub_memcpy (ptr, ".sig", sizeof (".sig")); sig = grub_file_open (fsuf, GRUB_FILE_TYPE_SIGNATURE); grub_free (fsuf); if (!sig) - return NULL; + return grub_errno; - ret = grub_malloc (sizeof (*ret)); - if (!ret) + ctxt = grub_malloc (sizeof (*ctxt)); + if (!ctxt) { grub_file_close (sig); - return NULL; + return grub_errno; } - *ret = *io; - - ret->fs = &verified_fs; - ret->not_easily_seekable = 0; - if (ret->size >> (sizeof (grub_size_t) * GRUB_CHAR_BIT - 1)) - { - grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "big file signature isn't implemented yet"); - grub_file_close (sig); - grub_free (ret); - return NULL; - } - verified = grub_malloc (sizeof (*verified)); - if (!verified) - { - grub_file_close (sig); - grub_free (ret); - return NULL; - } - verified->buf = grub_malloc (ret->size); - if (!verified->buf) - { - grub_file_close (sig); - verified_free (verified); - grub_free (ret); - return NULL; - } - if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size) - { - if (!grub_errno) - grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - io->name); - grub_file_close (sig); - verified_free (verified); - grub_free (ret); - return NULL; - } - - err = grub_verify_signature_real (verified->buf, ret->size, 0, sig, NULL); - grub_file_close (sig); + err = grub_verify_signature_init (ctxt, sig); if (err) { - verified_free (verified); - grub_free (ret); - return NULL; + grub_pubkey_close (ctxt); + return err; } - verified->file = io; - ret->data = verified; - return ret; + *context = ctxt; + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_pubkey_fini (void *ctxt) +{ + return grub_verify_signature_real (ctxt, NULL); } static char * @@ -970,8 +936,16 @@ struct grub_fs pseudo_fs = { .name = "pseudo", .read = pseudo_read -}; + }; +struct grub_file_verifier grub_pubkey_verifier = + { + .name = "pgp", + .init = grub_pubkey_init, + .fini = grub_pubkey_fini, + .write = grub_pubkey_write, + .close = grub_pubkey_close, + }; static grub_extcmd_t cmd, cmd_trust; static grub_command_t cmd_distrust, cmd_list; @@ -986,8 +960,6 @@ GRUB_MOD_INIT(verify) sec = 1; else sec = 0; - - grub_file_filter_register (GRUB_FILE_FILTER_PUBKEY, grub_pubkey_open); grub_register_variable_hook ("check_signatures", 0, grub_env_write_sec); grub_env_export ("check_signatures"); @@ -1033,11 +1005,13 @@ GRUB_MOD_INIT(verify) cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust, N_("PUBKEY_ID"), N_("Remove PUBKEY_ID from trusted keys.")); + + grub_verifier_register (&grub_pubkey_verifier); } GRUB_MOD_FINI(verify) { - grub_file_filter_unregister (GRUB_FILE_FILTER_PUBKEY); + grub_verifier_unregister (&grub_pubkey_verifier); grub_unregister_extcmd (cmd); grub_unregister_extcmd (cmd_trust); grub_unregister_command (cmd_list); diff --git a/include/grub/file.h b/include/grub/file.h index 5b47c5f91..19dda67f6 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -171,7 +171,7 @@ extern grub_disk_read_hook_t EXPORT_VAR(grub_file_progress_hook); /* Filters with lower ID are executed first. */ typedef enum grub_file_filter_id { - GRUB_FILE_FILTER_PUBKEY, + GRUB_FILE_FILTER_VERIFY, GRUB_FILE_FILTER_GZIO, GRUB_FILE_FILTER_XZIO, GRUB_FILE_FILTER_LZOPIO, diff --git a/include/grub/list.h b/include/grub/list.h index d170ff6da..b13acb962 100644 --- a/include/grub/list.h +++ b/include/grub/list.h @@ -35,6 +35,7 @@ void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item); void EXPORT_FUNC(grub_list_remove) (grub_list_t item); #define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next) +#define FOR_LIST_ELEMENTS_NEXT(var, list) for ((var) = (var)->next; (var); (var) = (var)->next) #define FOR_LIST_ELEMENTS_SAFE(var, nxt, list) for ((var) = (list), (nxt) = ((var) ? (var)->next : 0); (var); (var) = (nxt), ((nxt) = (var) ? (var)->next : 0)) static inline void * diff --git a/include/grub/verify.h b/include/grub/verify.h new file mode 100644 index 000000000..298120f57 --- /dev/null +++ b/include/grub/verify.h @@ -0,0 +1,65 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2017 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 . + */ + +#include +#include + +enum grub_verify_flags + { + GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1, + GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2 + }; + +struct grub_file_verifier +{ + struct grub_file_verifier *next; + struct grub_file_verifier **prev; + + const char *name; + + /* + * Check if file needs to be verified and set up context. + * init/read/fini is structured in the same way as hash interface. + */ + grub_err_t (*init) (grub_file_t io, enum grub_file_type type, + void **context, enum grub_verify_flags *flags); + + /* + * Right now we pass the whole file in one call but it may + * change in the future. If you insist on single buffer you + * need to set GRUB_VERIFY_FLAGS_SINGLE_CHUNK in verify_flags. + */ + grub_err_t (*write) (void *context, void *buf, grub_size_t size); + + grub_err_t (*fini) (void *context); + void (*close) (void *context); +}; + +extern struct grub_file_verifier *grub_file_verifiers; + +static inline void +grub_verifier_register (struct grub_file_verifier *ver) +{ + grub_list_push (GRUB_AS_LIST_P (&grub_file_verifiers), GRUB_AS_LIST (ver)); +} + +static inline void +grub_verifier_unregister (struct grub_file_verifier *ver) +{ + grub_list_remove (GRUB_AS_LIST (ver)); +} From 4d4a8c96e3593d76fe7b025665ccdecc70a53c1f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 7 Feb 2017 02:10:14 +0100 Subject: [PATCH 0860/1167] verifiers: Add possibility to verify kernel and modules command lines Signed-off-by: Vladimir Serbinenko Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/commands/verifiers.c | 14 ++++++++++++++ grub-core/lib/cmdline.c | 9 +++++---- grub-core/loader/arm/linux.c | 8 ++++++-- grub-core/loader/arm64/linux.c | 10 +++++++--- grub-core/loader/i386/bsd.c | 6 ++++++ grub-core/loader/i386/linux.c | 16 +++++++++++----- grub-core/loader/i386/multiboot_mbi.c | 16 ++++++++++------ grub-core/loader/i386/pc/linux.c | 13 ++++++++----- grub-core/loader/i386/pc/plan9.c | 11 +++++++++++ grub-core/loader/i386/xen.c | 7 +++++++ grub-core/loader/ia64/efi/linux.c | 7 +++++++ grub-core/loader/mips/linux.c | 8 ++++++++ grub-core/loader/multiboot_mbi2.c | 13 +++++++------ grub-core/loader/powerpc/ieee1275/linux.c | 5 +++-- grub-core/loader/sparc64/ieee1275/linux.c | 5 +++-- grub-core/loader/xnu.c | 9 +++++++++ include/grub/lib/cmdline.h | 5 +++-- include/grub/verify.h | 11 +++++++++++ 18 files changed, 136 insertions(+), 37 deletions(-) diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c index fde88318d..59ea418a2 100644 --- a/grub-core/commands/verifiers.c +++ b/grub-core/commands/verifiers.c @@ -186,6 +186,20 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) return NULL; } +grub_err_t +grub_verify_string (char *str, enum grub_verify_string_type type) +{ + struct grub_file_verifier *ver; + FOR_LIST_ELEMENTS(ver, grub_file_verifiers) + { + grub_err_t err; + err = ver->verify_string ? ver->verify_string (str, type) : GRUB_ERR_NONE; + if (err) + return err; + } + return GRUB_ERR_NONE; +} + GRUB_MOD_INIT(verifiers) { grub_file_filter_register (GRUB_FILE_FILTER_VERIFY, grub_verifiers_open); diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c index d5e10ee87..ed0b149dc 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c @@ -62,12 +62,13 @@ unsigned int grub_loader_cmdline_size (int argc, char *argv[]) return size; } -int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - grub_size_t size) +grub_err_t +grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size, enum grub_verify_string_type type) { int i, space; unsigned int arg_size; - char *c; + char *c, *orig_buf = buf; for (i = 0; i < argc; i++) { @@ -104,5 +105,5 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, *buf = 0; - return i; + return grub_verify_string (orig_buf, type); } diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index b4f609d2d..80293fb1f 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -28,6 +28,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -383,8 +384,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* Create kernel command line. */ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - linux_args + sizeof (LINUX_IMAGE) - 1, size); + err = grub_create_loader_cmdline (argc, argv, + linux_args + sizeof (LINUX_IMAGE) - 1, size, + GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; return GRUB_ERR_NONE; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 1f86229f8..b8315b53f 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -32,6 +32,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -339,9 +340,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - linux_args + sizeof (LINUX_IMAGE) - 1, - cmdline_size); + err = grub_create_loader_cmdline (argc, argv, + linux_args + sizeof (LINUX_IMAGE) - 1, + cmdline_size, + GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; if (grub_errno == GRUB_ERR_NONE) { diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index d34da14d9..c26edb4a9 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef GRUB_MACHINE_PCBIOS #include #endif @@ -416,6 +417,8 @@ grub_freebsd_add_meta_module (const char *filename, const char *type, grub_addr_t addr, grub_uint32_t size) { const char *name; + grub_err_t err; + name = grub_strrchr (filename, '/'); if (name) name++; @@ -469,6 +472,9 @@ grub_freebsd_add_meta_module (const char *filename, const char *type, *(p++) = ' '; } *p = 0; + err = grub_verify_string (cmdline, GRUB_VERIFY_MODULE_CMDLINE); + if (err) + return err; } } diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index b4e40ac7f..c408b10d8 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -969,11 +969,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (!linux_cmdline) goto fail; grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - linux_cmdline - + sizeof (LINUX_IMAGE) - 1, - maximal_cmdline_size - - (sizeof (LINUX_IMAGE) - 1)); + { + grub_err_t err; + err = grub_create_loader_cmdline (argc, argv, + linux_cmdline + + sizeof (LINUX_IMAGE) - 1, + maximal_cmdline_size + - (sizeof (LINUX_IMAGE) - 1), + GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; + } len = prot_file_size; if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index dc98dbcae..ad3cc292f 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -673,10 +673,8 @@ grub_multiboot_init_mbi (int argc, char *argv[]) return grub_errno; cmdline_size = len; - grub_create_loader_cmdline (argc, argv, cmdline, - cmdline_size); - - return GRUB_ERR_NONE; + return grub_create_loader_cmdline (argc, argv, cmdline, + cmdline_size, GRUB_VERIFY_KERNEL_CMDLINE); } grub_err_t @@ -685,6 +683,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, { struct module *newmod; grub_size_t len = 0; + grub_err_t err; newmod = grub_malloc (sizeof (*newmod)); if (!newmod) @@ -704,8 +703,13 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, newmod->cmdline_size = len; total_modcmd += ALIGN_UP (len, 4); - grub_create_loader_cmdline (argc, argv, newmod->cmdline, - newmod->cmdline_size); + err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, + newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE); + if (err) + { + grub_free (newmod); + return grub_errno; + } if (modules_last) modules_last->next = newmod; diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 0a5aa0c71..47ea2945e 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -334,11 +334,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* Create kernel command line. */ grub_memcpy ((char *)grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - (char *)grub_linux_real_chunk - + GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1, - maximal_cmdline_size - - (sizeof (LINUX_IMAGE) - 1)); + err = grub_create_loader_cmdline (argc, argv, + (char *)grub_linux_real_chunk + + GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1, + maximal_cmdline_size + - (sizeof (LINUX_IMAGE) - 1), + GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; if (grub_linux_is_bzimage) grub_linux_prot_target = GRUB_LINUX_BZIMAGE_ADDR; diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c index 0351090da..37550155d 100644 --- a/grub-core/loader/i386/pc/plan9.c +++ b/grub-core/loader/i386/pc/plan9.c @@ -33,6 +33,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -505,6 +506,7 @@ grub_cmd_plan9 (grub_extcmd_context_t ctxt, int argc, char *argv[]) configptr = grub_stpcpy (configptr, "bootfile="); configptr = grub_stpcpy (configptr, bootpath); *configptr++ = '\n'; + char *cmdline = configptr; { int i; for (i = 1; i < argc; i++) @@ -513,6 +515,15 @@ grub_cmd_plan9 (grub_extcmd_context_t ctxt, int argc, char *argv[]) *configptr++ = '\n'; } } + + { + grub_err_t err; + *configptr = '\0'; + err = grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; + } + configptr = grub_stpcpy (configptr, fill_ctx.pmap); { diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 8a93a527a..1a99ca72c 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -40,6 +40,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -647,6 +648,9 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), grub_create_loader_cmdline (argc - 1, argv + 1, (char *) xen_state.next_start.cmd_line, sizeof (xen_state.next_start.cmd_line) - 1); + err = grub_verify_string (xen_state.next_start.cmd_line, GRUB_VERIFY_MODULE_CMDLINE); + if (err) + return err; file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (!file) @@ -908,6 +912,9 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), grub_create_loader_cmdline (argc - 1, argv + 1, get_virtual_current_address (ch), cmdline_len); + err = grub_verify_string (get_virtual_current_address (ch), GRUB_VERIFY_MODULE_CMDLINE); + if (err) + goto fail; xen_state.module_info_page[xen_state.n_modules].cmdline = xen_state.max_addr - xen_state.modules_target_start; diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 96fce713a..6477d70f0 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -33,6 +33,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -501,6 +502,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), p = grub_stpcpy (p, argv[i]); } cmdline[10] = '='; + + *p = '\0'; + + err = grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + goto fail; boot_param->command_line = (grub_uint64_t) cmdline; boot_param->efi_systab = (grub_uint64_t) grub_efi_system_table; diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 7b28ba731..e256c440f 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -327,6 +327,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), linux_argv++; linux_args += ALIGN_UP (sizeof ("a0"), 4); + char *params = linux_args; + #ifdef GRUB_MACHINE_MIPS_LOONGSON { unsigned mtype = grub_arch_machine; @@ -352,6 +354,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), linux_args += ALIGN_UP (grub_strlen (argv[i]) + 1, 4); } + *linux_args = '\0'; + + err = grub_verify_string (params, GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + return err; + /* Reserve space for rd arguments. */ rd_addr_arg_off = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground; linux_args += ALIGN_UP (sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), 4); diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 747e10850..53da78615 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -1038,10 +1038,8 @@ grub_multiboot2_init_mbi (int argc, char *argv[]) return grub_errno; cmdline_size = len; - grub_create_loader_cmdline (argc, argv, cmdline, - cmdline_size); - - return GRUB_ERR_NONE; + return grub_create_loader_cmdline (argc, argv, cmdline, cmdline_size, + GRUB_VERIFY_KERNEL_CMDLINE); } grub_err_t @@ -1050,6 +1048,7 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, { struct module *newmod; grub_size_t len = 0; + grub_err_t err; newmod = grub_malloc (sizeof (*newmod)); if (!newmod) @@ -1068,8 +1067,10 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, newmod->cmdline_size = len; total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN); - grub_create_loader_cmdline (argc, argv, newmod->cmdline, - newmod->cmdline_size); + err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, + newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE); + if (err) + return err; if (modules_last) modules_last->next = newmod; diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 6e814649f..c114e7df4 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -302,8 +302,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* Create kernel command line. */ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, - size); + if (grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size)) + goto out; out: diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 67ef04883..abe46faa0 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -340,8 +340,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* Create kernel command line. */ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, - size); + if (grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size, GRUB_VERIFY_KERNEL_CMDLINE)) + goto out; out: if (elf) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 84c8b939c..ff66be4bf 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -33,6 +33,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -425,6 +426,10 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), if (ptr != grub_xnu_cmdline) *(ptr - 1) = 0; + err = grub_verify_string (grub_xnu_cmdline, GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + return err; + #if defined (__i386) && !defined (GRUB_MACHINE_EFI) err = grub_efiemu_autocore (); if (err) @@ -534,6 +539,10 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), if (ptr != grub_xnu_cmdline) *(ptr - 1) = 0; + err = grub_verify_string (grub_xnu_cmdline, GRUB_VERIFY_KERNEL_CMDLINE); + if (err) + return err; + #if defined (__i386) && !defined (GRUB_MACHINE_EFI) err = grub_efiemu_autocore (); if (err) diff --git a/include/grub/lib/cmdline.h b/include/grub/lib/cmdline.h index 1fe8d0179..cdca09b7a 100644 --- a/include/grub/lib/cmdline.h +++ b/include/grub/lib/cmdline.h @@ -21,11 +21,12 @@ #define GRUB_CMDLINE_HEADER 1 #include +#include #define LINUX_IMAGE "BOOT_IMAGE=" unsigned int grub_loader_cmdline_size (int argc, char *argv[]); -int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - grub_size_t size); +grub_err_t grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size, enum grub_verify_string_type type); #endif /* ! GRUB_CMDLINE_HEADER */ diff --git a/include/grub/verify.h b/include/grub/verify.h index 298120f57..9f892d8fe 100644 --- a/include/grub/verify.h +++ b/include/grub/verify.h @@ -25,6 +25,12 @@ enum grub_verify_flags GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2 }; +enum grub_verify_string_type + { + GRUB_VERIFY_KERNEL_CMDLINE, + GRUB_VERIFY_MODULE_CMDLINE, + }; + struct grub_file_verifier { struct grub_file_verifier *next; @@ -48,6 +54,8 @@ struct grub_file_verifier grub_err_t (*fini) (void *context); void (*close) (void *context); + + grub_err_t (*verify_string) (char *str, enum grub_verify_string_type type); }; extern struct grub_file_verifier *grub_file_verifiers; @@ -63,3 +71,6 @@ grub_verifier_unregister (struct grub_file_verifier *ver) { grub_list_remove (GRUB_AS_LIST (ver)); } + +grub_err_t +grub_verify_string (char *str, enum grub_verify_string_type type); From 5b8d5353950765ae08a22a96deb25354702d313b Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Wed, 26 Sep 2018 13:17:52 +0200 Subject: [PATCH 0861/1167] verifiers: Add possibility to defer verification to other verifiers This way if a verifier requires verification of a given file it can defer task to another verifier (another authority) if it is not able to do it itself. E.g. shim_lock verifier, posted as a subsequent patch, is able to verify only PE files. This means that it is not able to verify any of GRUB2 modules which have to be trusted on UEFI systems with secure boot enabled. So, it can defer verification to other verifier, e.g. PGP one. I silently assume that other verifiers are trusted and will do good job for us. Or at least they will not do any harm. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/commands/verifiers.c | 23 ++++++++++++++++++++--- include/grub/verify.h | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c index 59ea418a2..c638d5f43 100644 --- a/grub-core/commands/verifiers.c +++ b/grub-core/commands/verifiers.c @@ -83,6 +83,7 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) void *context; grub_file_t ret = 0; grub_err_t err; + int defer = 0; grub_dprintf ("verify", "file: %s type: %d\n", io->name, type); @@ -102,13 +103,27 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) err = ver->init (io, type, &context, &flags); if (err) goto fail_noclose; + if (flags & GRUB_VERIFY_FLAGS_DEFER_AUTH) + { + defer = 1; + continue; + } if (!(flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION)) break; } if (!ver) - /* No verifiers wanted to verify. Just return underlying file. */ - return io; + { + if (defer) + { + grub_error (GRUB_ERR_ACCESS_DENIED, + N_("verification requested but nobody cares: %s"), io->name); + goto fail_noclose; + } + + /* No verifiers wanted to verify. Just return underlying file. */ + return io; + } ret = grub_malloc (sizeof (*ret)); if (!ret) @@ -160,7 +175,9 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) err = ver->init (io, type, &context, &flags); if (err) goto fail_noclose; - if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION) + if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION || + /* Verification done earlier. So, we are happy here. */ + flags & GRUB_VERIFY_FLAGS_DEFER_AUTH) continue; err = ver->write (context, verified->buf, ret->size); if (err) diff --git a/include/grub/verify.h b/include/grub/verify.h index 9f892d8fe..79022b422 100644 --- a/include/grub/verify.h +++ b/include/grub/verify.h @@ -22,7 +22,9 @@ enum grub_verify_flags { GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1, - GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2 + GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2, + /* Defer verification to another authority. */ + GRUB_VERIFY_FLAGS_DEFER_AUTH = 4 }; enum grub_verify_string_type From b07feb8746c3bb845e3f0d33d37c0bded704d14d Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 2 Oct 2018 22:36:43 +0200 Subject: [PATCH 0862/1167] verifiers: Rename verify module to pgp module Just for clarity. No functional change. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/Makefile.core.def | 4 ++-- grub-core/commands/{verify.c => pgp.c} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename grub-core/commands/{verify.c => pgp.c} (100%) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 9af31c098..7904f8542 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -888,8 +888,8 @@ module = { }; module = { - name = verify; - common = commands/verify.c; + name = pgp; + common = commands/pgp.c; cflags = '$(CFLAGS_POSIX)'; cppflags = '-I$(srcdir)/lib/posix_wrap'; }; diff --git a/grub-core/commands/verify.c b/grub-core/commands/pgp.c similarity index 100% rename from grub-core/commands/verify.c rename to grub-core/commands/pgp.c From 3d612924c36f349eb68665ec5fbc1ea98b2accf5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 May 2017 16:39:38 +0200 Subject: [PATCH 0863/1167] verifiers: Add the documentation Signed-off-by: Vladimir Serbinenko Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- docs/grub-dev.texi | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index a9f4de631..ca40874e5 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -84,6 +84,7 @@ This edition documents version @value{VERSION}. * Video Subsystem:: * PFF2 Font File Format:: * Graphical Menu Software Design:: +* Verifiers framework:: * Copying This Manual:: Copying This Manual * Index:: @end menu @@ -1949,6 +1950,63 @@ the graphics mode that was in use before @code{grub_video_setup()} was called might fix some of the problems. +@node Verifiers framework +@chapter Verifiers framework + +To register your own verifier call @samp{grub_verifier_register} with a structure +pointing to your functions. + +The interface is inspired by the hash interface with @samp{init}/@samp{write}/@samp{fini}. + +There are essentially 2 ways of using it, hashing and whole-file verification. + +With the hashing approach: +During @samp{init} you decide whether you want to check the given file and init context. +In @samp{write} you update your hashing state. +In @samp{fini} you check that the hash matches the expected value/passes some check/... + +With whole-file verification: +During @samp{init} you decide whether you want to check the given file and init context. +In @samp{write} you verify the file and return an error if it fails. +You don't have @samp{fini}. + +Additional @samp{verify_string} receives various strings like kernel parameters +to verify. Returning no error means successful verification and an error stops +the current action. + +Detailed description of the API: + +Every time a file is opened your @samp{init} function is called with file descriptor +and file type. Your function can have the following outcomes: + +@itemize + +@item returning no error and setting @samp{*flags} to @samp{GRUB_VERIFY_FLAGS_DEFER_AUTH}. +In this case verification is deferred to other active verifiers. Verification +fails if nobody cares or selected verifier fails. + +@item returning no error and setting @samp{*flags} to @samp{GRUB_VERIFY_FLAGS_SKIP_VERIFICATION}. +In this case your verifier will not be called anymore and it is assumed to have +skipped verification. + +@item returning no error and not setting @samp{*flags} to @samp{GRUB_VERIFY_FLAGS_SKIP_VERIFICATION} +In this case verification is done as described in the following section. + +@item returning an error. Then opening of the file will fail due to failed verification. + +@end itemize + +In the third case your @samp{write} will be called with chunks of the file. If +you need the whole file in a single chunk then during @samp{init} set the bit +@samp{GRUB_VERIFY_FLAGS_SINGLE_CHUNK} in @samp{*flags}. During @samp{init} you +may set @samp{*context} if you need additional context. At every iteration you +may return an error and the file will be considered as having failed the +verification. If you return no error then verification continues. + +Optionally at the end of the file @samp{fini}, if it exists, is called with just +the context. If you return no error during any of @samp{init}, @samp{write} and +@samp{fini} then the file is considered as having succeded verification. + @node Copying This Manual @appendix Copying This Manual From ee7808e2197cbf5e8515d90ecbd81c9d0dd6fc15 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 2 Oct 2018 18:49:26 +0200 Subject: [PATCH 0864/1167] dl: Add support for persistent modules This type of modules cannot be unloaded. This is useful if a given functionality, e.g. UEFI secure boot shim signature verification, should not be disabled if it was enabled at some point in time. Somebody may say that we can use standalone GRUB2 here. That is true. However, the code is not so big nor complicated hence it make sense to support modularized configs too. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/commands/minicmd.c | 3 +++ include/grub/dl.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c index fc20c6563..6bbce3128 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c @@ -137,6 +137,9 @@ grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)), if (! mod) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module"); + if (grub_dl_is_persistent (mod)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload persistent module"); + if (grub_dl_unref (mod) <= 0) grub_dl_unload (mod); diff --git a/include/grub/dl.h b/include/grub/dl.h index 2bca56ce0..fee27a14c 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -175,6 +175,7 @@ struct grub_dl { char *name; int ref_count; + int persistent; grub_dl_dep_t dep; grub_dl_segment_t segment; Elf_Sym *symtab; @@ -240,6 +241,18 @@ grub_dl_get (const char *name) return 0; } +static inline void +grub_dl_set_persistent (grub_dl_t mod) +{ + mod->persistent = 1; +} + +static inline int +grub_dl_is_persistent (grub_dl_t mod) +{ + return mod->persistent; +} + #endif grub_err_t grub_dl_register_symbol (const char *name, void *addr, From 878398c1a39079a54c2836e27e9d1b0eb67a66cd Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 3 Aug 2018 13:25:44 +0200 Subject: [PATCH 0865/1167] efi: Add EFI shim lock verifier This module provides shim lock verification for various kernels if UEFI secure boot is enabled on a machine. It is recommended to put this module into GRUB2 standalone image (avoid putting iorw and memrw modules into it; they are disallowed if UEFI secure boot is enabled). However, it is also possible to use it as a normal module. Though such configurations are more fragile and less secure due to various limitations. If the module is loaded and UEFI secure boot is enabled then: - module itself cannot be unloaded (persistent module), - the iorw and memrw modules cannot be loaded, - if the iorw and memrw modules are loaded then machine boot is disabled, - GRUB2 defers modules and ACPI tables verification to other verifiers. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- docs/grub.texi | 15 +++ grub-core/Makefile.core.def | 6 ++ grub-core/commands/efi/shim_lock.c | 141 +++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 grub-core/commands/efi/shim_lock.c diff --git a/docs/grub.texi b/docs/grub.texi index 2adfa97be..471d97c95 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5544,6 +5544,7 @@ environment variables and commands are listed in the same order. @menu * Authentication and authorisation:: Users and access control * Using digital signatures:: Booting digitally signed code +* UEFI secure boot and shim:: Booting digitally signed PE files @end menu @node Authentication and authorisation @@ -5706,6 +5707,20 @@ or BIOS) configuration to cause the machine to boot from a different (attacker-controlled) device. GRUB is at best only one link in a secure boot chain. +@node UEFI secure boot and shim +@section UEFI secure boot and shim support + +The GRUB, except the @command{chainloader} command, works with the UEFI secure +boot and the shim. This functionality is provided by the shim_lock module. It +is recommend to build in this and other required modules into the @file{core.img}. +All modules not stored in the @file{core.img} and the ACPI tables for the +@command{acpi} command have to be signed, e.g. using PGP. Additionally, the +@command{iorw} and the @command{memrw} commands are prohibited if the UEFI +secure boot is enabled. This is done due to security reasons. All above +mentioned requirements are enforced by the shim_lock module. And itself it +is a persistent module which means that it cannot be unloaded if it was +loaded into the memory. + @node Platform limitations @chapter Platform limitations diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 7904f8542..6e2cc8444 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -899,6 +899,12 @@ module = { common = commands/verifiers.c; }; +module = { + name = shim_lock; + common = commands/efi/shim_lock.c; + enable = x86_64_efi; +}; + module = { name = hdparm; common = commands/hdparm.c; diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c new file mode 100644 index 000000000..01246b0fc --- /dev/null +++ b/grub-core/commands/efi/shim_lock.c @@ -0,0 +1,141 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2017 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 . + * + * EFI shim lock verifier. + */ + +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +#define GRUB_EFI_SHIM_LOCK_GUID \ + { 0x605dab50, 0xe046, 0x4300, \ + { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \ + } + +struct grub_efi_shim_lock_protocol +{ + grub_efi_status_t + (*verify) (void *buffer, grub_uint32_t size); +}; +typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t; + +static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID; +static grub_efi_shim_lock_protocol_t *sl; + +/* List of modules which cannot be loaded if UEFI secure boot mode is enabled. */ +static const char * const disabled_mods[] = {"iorw", "memrw", NULL}; + +static grub_err_t +shim_lock_init (grub_file_t io, enum grub_file_type type, + void **context __attribute__ ((unused)), + enum grub_verify_flags *flags) +{ + const char *b, *e; + int i; + + *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; + + if (!sl) + return GRUB_ERR_NONE; + + switch (type & GRUB_FILE_TYPE_MASK) + { + case GRUB_FILE_TYPE_GRUB_MODULE: + /* Establish GRUB module name. */ + b = grub_strrchr (io->name, '/'); + e = grub_strrchr (io->name, '.'); + + b = b ? (b + 1) : io->name; + e = e ? e : io->name + grub_strlen (io->name); + e = (e > b) ? e : io->name + grub_strlen (io->name); + + for (i = 0; disabled_mods[i]; i++) + if (!grub_strncmp (b, disabled_mods[i], grub_strlen (b) - grub_strlen (e))) + { + grub_error (GRUB_ERR_ACCESS_DENIED, + N_("module cannot be loaded in UEFI secure boot mode: %s"), + io->name); + return GRUB_ERR_ACCESS_DENIED; + } + + /* Fall through. */ + + case GRUB_FILE_TYPE_ACPI_TABLE: + *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH; + + return GRUB_ERR_NONE; + + case GRUB_FILE_TYPE_LINUX_KERNEL: + case GRUB_FILE_TYPE_MULTIBOOT_KERNEL: + case GRUB_FILE_TYPE_BSD_KERNEL: + case GRUB_FILE_TYPE_XNU_KERNEL: + case GRUB_FILE_TYPE_PLAN9_KERNEL: + for (i = 0; disabled_mods[i]; i++) + if (grub_dl_get (disabled_mods[i])) + { + grub_error (GRUB_ERR_ACCESS_DENIED, + N_("cannot boot due to dangerous module in memory: %s"), + disabled_mods[i]); + return GRUB_ERR_ACCESS_DENIED; + } + + *flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK; + + /* Fall through. */ + + default: + return GRUB_ERR_NONE; + } +} + +static grub_err_t +shim_lock_write (void *context __attribute__ ((unused)), void *buf, grub_size_t size) +{ + if (sl->verify (buf, size) != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad shim signature")); + + return GRUB_ERR_NONE; +} + +struct grub_file_verifier shim_lock = + { + .name = "shim_lock", + .init = shim_lock_init, + .write = shim_lock_write + }; + +GRUB_MOD_INIT(shim_lock) +{ + sl = grub_efi_locate_protocol (&shim_lock_guid, 0); + grub_verifier_register (&shim_lock); + + if (!sl) + return; + + grub_dl_set_persistent (mod); +} + +GRUB_MOD_FINI(shim_lock) +{ + grub_verifier_unregister (&shim_lock); +} From b71ac53751877dac18cfc091db2e22b805462278 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Tue, 23 Oct 2018 15:00:13 +0200 Subject: [PATCH 0866/1167] unix/platform: Initialize variable to fix grub-install on UEFI system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a UEFI system, were no boot entry *grub* is present, currently, `grub-install` fails with an error. $ efibootmgr BootCurrent: 0000 Timeout: 0 seconds BootOrder: 0001,0006,0003,0004,0005 Boot0001 Diskette Drive Boot0003* USB Storage Device Boot0004* CD/DVD/CD-RW Drive Boot0005 Onboard NIC Boot0006* WDC WD2500AAKX-75U6AA0 $ sudo grub-install /dev/sda Installing for x86_64-efi platform. grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020. The error code is always different, and the error message (incorrectly) points to efibootmgr. But, the error is in GRUB’s function `grub_install_remove_efi_entries_by_distributor()`, where the variable `rc` for the return value, is uninitialized and never set, when no boot entry for the distributor is found. The content of that uninitialized variable is then returned as the error code of efibootmgr. Set the variable to 0, so that success is returned, when no entry needs to be deleted. Tested on Dell OptiPlex 7010 with firmware A28. $ sudo ./grub-install /dev/sda Installing for x86_64-efi platform. Installation finished. No error reported. [1]: https://github.com/rhboot/efibootmgr/issues/100 Signed-off-by: Paul Menzel Reviewed-by: Daniel Kiper --- grub-core/osdep/unix/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c index ca448bc11..55b8f4016 100644 --- a/grub-core/osdep/unix/platform.c +++ b/grub-core/osdep/unix/platform.c @@ -85,7 +85,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd); char *line = NULL; size_t len = 0; - int rc; + int rc = 0; if (!pid) { From e720eef6a69bc4acc767d9a4cf8bc939b8b98e11 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 29 Oct 2018 12:33:37 +0000 Subject: [PATCH 0867/1167] Cope with / being on a ZFS root dataset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If / is on the root dataset in a ZFS pool, then ${bootfs} will be set to "/" (whereas if it is on a non-root dataset, there will be no trailing slash). Passing "root=ZFS=${rpool}/" will fail to boot, but "root=ZFS=${rpool}" works fine, so strip the trailing slash. Fixes: https://savannah.gnu.org/bugs/?52746 Signed-off-by: Colin Watson Tested-by: Fejes József Reviewed-by: Daniel Kiper --- util/grub.d/10_linux.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 61ebd7dc7..4532266be 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -73,7 +73,7 @@ case x"$GRUB_FS" in xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" - LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" + LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" ;; esac diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index e8143b079..d22626e30 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -81,7 +81,7 @@ case x"$GRUB_FS" in xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" - LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" + LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" ;; esac From c0a9f534782776a290074bdf4ddd434e55dd7232 Mon Sep 17 00:00:00 2001 From: Matthew Daley Date: Wed, 7 Nov 2018 11:44:08 +1300 Subject: [PATCH 0868/1167] mkimage: Pad DTBs to target-specific pointer size Device tree (DTB) lengths are being padded to a multiple of 4 bytes rather than the target-specific pointer size. This causes objects following OBJ_TYPE_DTB objects to be incorrectly parsed during GRUB execution on arm64. Fix by using ALIGN_ADDR(), not ALIGN_UP(). Signed-by-off: Matthew Daley Reviewed-by: Daniel Kiper --- util/mkimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/mkimage.c b/util/mkimage.c index e22d82afa..b2f43fea6 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -829,7 +829,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (dtb_path) { - dtb_size = ALIGN_UP(grub_util_get_image_size (dtb_path), 4); + dtb_size = ALIGN_ADDR(grub_util_get_image_size (dtb_path)); total_module_size += dtb_size + sizeof (struct grub_module_header); } From a5d865a039ce1fcf35e33551df540c01e3612443 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 14 Nov 2018 19:29:15 +0000 Subject: [PATCH 0869/1167] include/grub/verify.h: Add include guard verify.h was added without include guards. This means compiling anything including both include/grub/verify.h and include/grub/lib/cmdline.h fails (at least grub-core/loader/arm64/linux.c. Add the necessary include guard. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- include/grub/verify.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/grub/verify.h b/include/grub/verify.h index 79022b422..3d8f3e1a4 100644 --- a/include/grub/verify.h +++ b/include/grub/verify.h @@ -16,6 +16,9 @@ * along with GRUB. If not, see . */ +#ifndef GRUB_VERIFY_HEADER +#define GRUB_VERIFY_HEADER 1 + #include #include @@ -76,3 +79,5 @@ grub_verifier_unregister (struct grub_file_verifier *ver) grub_err_t grub_verify_string (char *str, enum grub_verify_string_type type); + +#endif /* ! GRUB_VERIFY_HEADER */ From 7453c2cc32525a5eebe3b268433d0dfc73622917 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 14 Nov 2018 19:29:16 +0000 Subject: [PATCH 0870/1167] include/grub/file.h: Add device tree file type The API change of grub_file_open() for adding verifiers did not include a type for device tree blobs. Add GRUB_FILE_TYPE_DEVICE_TREE_IMAGE to the grub_file_type enum. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- include/grub/file.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/grub/file.h b/include/grub/file.h index 19dda67f6..9aae46355 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -69,6 +69,8 @@ enum grub_file_type GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE, + GRUB_FILE_TYPE_DEVICE_TREE_IMAGE, + /* File holding signature. */ GRUB_FILE_TYPE_SIGNATURE, /* File holding public key to verify signature once. */ From dfb1742aab1fcf40cde2e3a5e44437d21b6c81cf Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 14 Nov 2018 19:29:17 +0000 Subject: [PATCH 0871/1167] grub-core/loader/efi/fdt.c: Fixup grub_file_open() call The verifiers framework changed the API of grub_file_open(), but did not fix up all users. Add the file type GRUB_FILE_TYPE_DEVICE_TREE_IMAGE to the "devicetree" command handler call. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/efi/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index a4c6e8036..a18ca8ccb 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -123,7 +123,7 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), return GRUB_ERR_NONE; } - dtb = grub_file_open (argv[0]); + dtb = grub_file_open (argv[0], GRUB_FILE_TYPE_DEVICE_TREE_IMAGE); if (!dtb) goto out; From 9d0559c647bc30cef9b9eeb70dc1317ba5dcfd15 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 14 Nov 2018 19:29:18 +0000 Subject: [PATCH 0872/1167] arm64/efi: Fix breakage caused by verifiers - add variable "err" (used but not defined), - add GRUB_FILE_TYPE_LINUX_KERNEL to grub_file_open() call. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index b8315b53f..c37295c0b 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -288,6 +288,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; struct linux_armxx_kernel_header lh; + grub_err_t err; grub_dl_ref (my_mod); @@ -297,7 +298,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (!file) goto fail; From 58bfe4358194812b0430f0a82f99982b1eaae768 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 14 Nov 2018 19:29:19 +0000 Subject: [PATCH 0873/1167] arm-uboot, ia64, sparc64: Fix up grub_file_open() calls The verifiers framework changed the grub_file_open() interface, breaking all non-x86 linux loaders. Add file types to the grub_file_open() calls to make them build again. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm/linux.c | 6 +++--- grub-core/loader/ia64/efi/linux.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 80293fb1f..67ed79359 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -363,7 +363,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (!file) goto fail; @@ -408,7 +408,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_INITRD); if (!file) return grub_errno; @@ -471,7 +471,7 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - dtb = grub_file_open (argv[0]); + dtb = grub_file_open (argv[0], GRUB_FILE_TYPE_DEVICE_TREE_IMAGE); if (!dtb) return grub_errno; diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 6477d70f0..639a1f379 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -460,7 +460,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (! file) goto fail; diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index abe46faa0..bb47ee0cc 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -306,7 +306,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (!file) goto out; From 25e35377a84779ceeb350aa530e5adde287f6eb6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Tue, 20 Nov 2018 10:45:04 +0000 Subject: [PATCH 0874/1167] arm64/xen: Fix too few arguments to function grub_create_loader_cmdline() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, building xen_boot.c omits: loader/arm64/xen_boot.c: In function ‘xen_boot_binary_load’: loader/arm64/xen_boot.c:370:7: error: too few arguments to function ‘grub_create_loader_cmdline’ grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from loader/arm64/xen_boot.c:36:0: ../include/grub/lib/cmdline.h:29:12: note: declared here grub_err_t grub_create_loader_cmdline (int argc, char *argv[], char *buf, Signed-off-by: Lee Jones Reviewed-by: Julien Grall Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/xen_boot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 1003a0b99..33a855df4 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -368,7 +368,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, return; } grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, - binary->cmdline_size); + binary->cmdline_size, + GRUB_VERIFY_KERNEL_CMDLINE); grub_dprintf ("xen_loader", "Xen_boot cmdline @ %p %s, size: %d\n", binary->cmdline, binary->cmdline, binary->cmdline_size); From 5c6f9bc1567d6e3364a623a963088f9a3f1e1348 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Tue, 20 Nov 2018 12:37:01 +0000 Subject: [PATCH 0875/1167] generic/blocklist: Fix implicit declaration of function grub_file_filter_disable_compression() grub_file_filter_disable_compression() no longer exists. Signed-off-by: Lee Jones Reviewed-by: Daniel Kiper --- grub-core/osdep/generic/blocklist.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/grub-core/osdep/generic/blocklist.c b/grub-core/osdep/generic/blocklist.c index 74024fd06..ea2a511b6 100644 --- a/grub-core/osdep/generic/blocklist.c +++ b/grub-core/osdep/generic/blocklist.c @@ -59,8 +59,7 @@ grub_install_get_blocklist (grub_device_t root_dev, grub_disk_cache_invalidate_all (); - grub_file_filter_disable_compression (); - file = grub_file_open (core_path_dev); + file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | FILE_TYPE_NO_DECOMPRESS); if (file) { if (grub_file_size (file) != core_size) @@ -117,8 +116,7 @@ grub_install_get_blocklist (grub_device_t root_dev, grub_file_t file; /* Now read the core image to determine where the sectors are. */ - grub_file_filter_disable_compression (); - file = grub_file_open (core_path_dev); + file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | FILE_TYPE_NO_DECOMPRESS); if (! file) grub_util_error ("%s", grub_errmsg); From e8b37e2c8de7570ca9a6c7ba874762d8c4ba9373 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 20 Nov 2018 19:15:37 +0800 Subject: [PATCH 0876/1167] verifiers: fix double close on pgp's sig file descriptor An error emerged as when I was testing the verifiers branch, so instead of putting it in pgp prefix, the verifiers is used to reflect what the patch is based on. While running verify_detached, grub aborts with error. verify_detached /@/.snapshots/1/snapshot/boot/grub/grub.cfg /@/.snapshots/1/snapshot/boot/grub/grub.cfg.sig alloc magic is broken at 0x7beea660: 0 Aborted. Press any key to exit. The error is caused by sig file descriptor been closed twice, first time in grub_verify_signature() to which it is passed as parameter. Second in grub_cmd_verify_signature() or in whichever opens the sig file descriptor. The second close is not consider as bug to me either, as in common rule of what opens a file has to close it to avoid file descriptor leakage. After all the design of grub_verify_signature() makes it difficult to keep a good trace on opened file descriptor from it's caller. Let's refine the application interface to accept file path rather than descriptor, in this way the caller doesn't have to care about closing the descriptor by delegating it to grub_verify_signature() with full tracing to opened file descriptor by itself. Also making it clear that sig descriptor is not referenced in error returning path of grub_verify_signature_init(), so it can be closed directly by it's caller. This also makes delegating it to grub_pubkey_close() infeasible to help in relieving file descriptor leakage as it has to depend on uncertainty of ctxt fields in error returning path. Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/commands/pgp.c | 35 +++++++++++++++++------------------ include/grub/pubkey.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c index 29e74a640..0487479af 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -495,13 +495,12 @@ grub_verify_signature_init (struct grub_pubkey_context *ctxt, grub_file_t sig) grub_dprintf ("crypt", "alive\n"); - ctxt->sig = sig; - ctxt->hash_context = grub_zalloc (ctxt->hash->contextsize); if (!ctxt->hash_context) return grub_errno; ctxt->hash->init (ctxt->hash_context); + ctxt->sig = sig; return GRUB_ERR_NONE; } @@ -684,16 +683,26 @@ grub_pubkey_close (void *ctxt) } grub_err_t -grub_verify_signature (grub_file_t f, grub_file_t sig, +grub_verify_signature (grub_file_t f, const char *fsig, struct grub_public_key *pkey) { + grub_file_t sig; grub_err_t err; struct grub_pubkey_context ctxt; grub_uint8_t *readbuf = NULL; + sig = grub_file_open (fsig, + GRUB_FILE_TYPE_SIGNATURE + | GRUB_FILE_TYPE_NO_DECOMPRESS); + if (!sig) + return grub_errno; + err = grub_verify_signature_init (&ctxt, sig); if (err) - return err; + { + grub_file_close (sig); + return err; + } readbuf = grub_zalloc (READBUF_SIZE); if (!readbuf) @@ -807,7 +816,7 @@ static grub_err_t grub_cmd_verify_signature (grub_extcmd_context_t ctxt, int argc, char **args) { - grub_file_t f = NULL, sig = NULL; + grub_file_t f = NULL; grub_err_t err = GRUB_ERR_NONE; struct grub_public_key *pk = NULL; @@ -845,19 +854,8 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt, goto fail; } - sig = grub_file_open (args[1], - GRUB_FILE_TYPE_SIGNATURE - | GRUB_FILE_TYPE_NO_DECOMPRESS); - if (!sig) - { - err = grub_errno; - goto fail; - } - - err = grub_verify_signature (f, sig, pk); + err = grub_verify_signature (f, args[1], pk); fail: - if (sig) - grub_file_close (sig); if (f) grub_file_close (f); if (pk) @@ -902,7 +900,8 @@ grub_pubkey_init (grub_file_t io, enum grub_file_type type __attribute__ ((unuse err = grub_verify_signature_init (ctxt, sig); if (err) { - grub_pubkey_close (ctxt); + grub_free (ctxt); + grub_file_close (sig); return err; } *context = ctxt; diff --git a/include/grub/pubkey.h b/include/grub/pubkey.h index 4a9d04b43..fb8be9cbb 100644 --- a/include/grub/pubkey.h +++ b/include/grub/pubkey.h @@ -25,7 +25,7 @@ struct grub_public_key * grub_load_public_key (grub_file_t f); grub_err_t -grub_verify_signature (grub_file_t f, grub_file_t sig, +grub_verify_signature (grub_file_t f, const char *fsig, struct grub_public_key *pk); From 461f1d8af1820623dfc1e1e62c6f9f24c33793ba Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Mon, 19 Nov 2018 11:20:07 -0800 Subject: [PATCH 0877/1167] zstd: Import upstream zstd-1.3.6 - Import zstd-1.3.6 from upstream - Add zstd's module.c file - Add the zstd module to Makefile.core.def Import zstd-1.3.6 from upstream [1]. Only the files need for decompression are imported. I used the latest zstd release, which includes patches [2] to build cleanly in GRUB. I included the script used to import zstd-1.3.6 below at the bottom of the commit message. Upstream zstd commit hash: 4fa456d7f12f8b27bd3b2f5dfd4f46898cb31c24 Upstream zstd commit name: Merge pull request #1354 from facebook/dev Zstd requires some posix headers, which it gets from posix_wrap. This can be checked by inspecting the .Po files generated by automake, which contain the header dependencies. After building run the command `cat grub-core/lib/zstd/.deps-core/*.Po` to see the dependencies [3]. The only OS dependencies are: - stddef.h, which is already a dependency in posix_wrap, and used for size_t by lzo and xz. - stdarg.h, which comes from the grub/misc.h header, and we don't use in zstd. All the types like uint64_t are typedefed to grub_uint64_t under the hood. The only exception is size_t, which comes from stddef.h. This is already the case for lzo and xz. I don't think there are any cross-compilation concerns, because cross-compilers provide their own system headers (and it would already be broken). [1] https://github.com/facebook/zstd/releases/tag/v1.3.6 [2] https://github.com/facebook/zstd/pull/1344 [3] https://gist.github.com/terrelln/7a16b92f5a1b3aecf980f944b4a966c4 ``` curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz.sha256 sha256sum --check zstd-1.3.6.tar.gz.sha256 tar xzf zstd-1.3.6.tar.gz SRC_LIB="zstd-1.3.6/lib" DST_LIB="grub-core/lib/zstd" rm -rf $DST_LIB mkdir -p $DST_LIB cp $SRC_LIB/zstd.h $DST_LIB/ cp $SRC_LIB/common/*.[hc] $DST_LIB/ cp $SRC_LIB/decompress/*.[hc] $DST_LIB/ rm $DST_LIB/{pool.[hc],threading.[hc]} rm -rf zstd-1.3.6* echo SUCCESS! ``` Signed-off-by: Nick Terrell Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 15 + grub-core/lib/zstd/bitstream.h | 458 ++++ grub-core/lib/zstd/compiler.h | 133 ++ grub-core/lib/zstd/cpu.h | 215 ++ grub-core/lib/zstd/debug.c | 44 + grub-core/lib/zstd/debug.h | 123 + grub-core/lib/zstd/entropy_common.c | 236 ++ grub-core/lib/zstd/error_private.c | 48 + grub-core/lib/zstd/error_private.h | 76 + grub-core/lib/zstd/fse.h | 708 ++++++ grub-core/lib/zstd/fse_decompress.c | 309 +++ grub-core/lib/zstd/huf.h | 334 +++ grub-core/lib/zstd/huf_decompress.c | 1096 +++++++++ grub-core/lib/zstd/mem.h | 374 ++++ grub-core/lib/zstd/module.c | 21 + grub-core/lib/zstd/xxhash.c | 876 ++++++++ grub-core/lib/zstd/xxhash.h | 305 +++ grub-core/lib/zstd/zstd.h | 1516 +++++++++++++ grub-core/lib/zstd/zstd_common.c | 81 + grub-core/lib/zstd/zstd_decompress.c | 3108 ++++++++++++++++++++++++++ grub-core/lib/zstd/zstd_errors.h | 92 + grub-core/lib/zstd/zstd_internal.h | 257 +++ 22 files changed, 10425 insertions(+) create mode 100644 grub-core/lib/zstd/bitstream.h create mode 100644 grub-core/lib/zstd/compiler.h create mode 100644 grub-core/lib/zstd/cpu.h create mode 100644 grub-core/lib/zstd/debug.c create mode 100644 grub-core/lib/zstd/debug.h create mode 100644 grub-core/lib/zstd/entropy_common.c create mode 100644 grub-core/lib/zstd/error_private.c create mode 100644 grub-core/lib/zstd/error_private.h create mode 100644 grub-core/lib/zstd/fse.h create mode 100644 grub-core/lib/zstd/fse_decompress.c create mode 100644 grub-core/lib/zstd/huf.h create mode 100644 grub-core/lib/zstd/huf_decompress.c create mode 100644 grub-core/lib/zstd/mem.h create mode 100644 grub-core/lib/zstd/module.c create mode 100644 grub-core/lib/zstd/xxhash.c create mode 100644 grub-core/lib/zstd/xxhash.h create mode 100644 grub-core/lib/zstd/zstd.h create mode 100644 grub-core/lib/zstd/zstd_common.c create mode 100644 grub-core/lib/zstd/zstd_decompress.c create mode 100644 grub-core/lib/zstd/zstd_errors.h create mode 100644 grub-core/lib/zstd/zstd_internal.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 6e2cc8444..829e7bb57 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1271,6 +1271,21 @@ module = { common = fs/bfs.c; }; +module = { + name = zstd; + common = lib/zstd/debug.c; + common = lib/zstd/entropy_common.c; + common = lib/zstd/error_private.c; + common = lib/zstd/fse_decompress.c; + common = lib/zstd/huf_decompress.c; + common = lib/zstd/module.c; + common = lib/zstd/xxhash.c; + common = lib/zstd/zstd_common.c; + common = lib/zstd/zstd_decompress.c; + cflags = '$(CFLAGS_POSIX) -Wno-undef'; + cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd'; +}; + module = { name = btrfs; common = fs/btrfs.c; diff --git a/grub-core/lib/zstd/bitstream.h b/grub-core/lib/zstd/bitstream.h new file mode 100644 index 000000000..2f91460c5 --- /dev/null +++ b/grub-core/lib/zstd/bitstream.h @@ -0,0 +1,458 @@ +/* ****************************************************************** + bitstream + Part of FSE library + Copyright (C) 2013-present, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - Source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ +#ifndef BITSTREAM_H_MODULE +#define BITSTREAM_H_MODULE + +#if defined (__cplusplus) +extern "C" { +#endif + +/* +* This API consists of small unitary functions, which must be inlined for best performance. +* Since link-time-optimization is not available for all compilers, +* these functions are defined into a .h to be included. +*/ + +/*-**************************************** +* Dependencies +******************************************/ +#include "mem.h" /* unaligned access routines */ +#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */ +#include "error_private.h" /* error codes and messages */ + + +/*========================================= +* Target specific +=========================================*/ +#if defined(__BMI__) && defined(__GNUC__) +# include /* support for bextr (experimental) */ +#endif + +#define STREAM_ACCUMULATOR_MIN_32 25 +#define STREAM_ACCUMULATOR_MIN_64 57 +#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) + + +/*-****************************************** +* bitStream encoding API (write forward) +********************************************/ +/* bitStream can mix input from multiple sources. + * A critical property of these streams is that they encode and decode in **reverse** direction. + * So the first bit sequence you add will be the last to be read, like a LIFO stack. + */ +typedef struct { + size_t bitContainer; + unsigned bitPos; + char* startPtr; + char* ptr; + char* endPtr; +} BIT_CStream_t; + +MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity); +MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits); +MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC); +MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC); + +/* Start with initCStream, providing the size of buffer to write into. +* bitStream will never write outside of this buffer. +* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code. +* +* bits are first added to a local register. +* Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems. +* Writing data into memory is an explicit operation, performed by the flushBits function. +* Hence keep track how many bits are potentially stored into local register to avoid register overflow. +* After a flushBits, a maximum of 7 bits might still be stored into local register. +* +* Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers. +* +* Last operation is to close the bitStream. +* The function returns the final size of CStream in bytes. +* If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable) +*/ + + +/*-******************************************** +* bitStream decoding API (read backward) +**********************************************/ +typedef struct { + size_t bitContainer; + unsigned bitsConsumed; + const char* ptr; + const char* start; + const char* limitPtr; +} BIT_DStream_t; + +typedef enum { BIT_DStream_unfinished = 0, + BIT_DStream_endOfBuffer = 1, + BIT_DStream_completed = 2, + BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */ + /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */ + +MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize); +MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits); +MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); +MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); + + +/* Start by invoking BIT_initDStream(). +* A chunk of the bitStream is then stored into a local register. +* Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). +* You can then retrieve bitFields stored into the local register, **in reverse order**. +* Local register is explicitly reloaded from memory by the BIT_reloadDStream() method. +* A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished. +* Otherwise, it can be less than that, so proceed accordingly. +* Checking if DStream has reached its end can be performed with BIT_endOfDStream(). +*/ + + +/*-**************************************** +* unsafe API +******************************************/ +MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits); +/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */ + +MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC); +/* unsafe version; does not check buffer overflow */ + +MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); +/* faster, but works only if nbBits >= 1 */ + + + +/*-************************************************************** +* Internal functions +****************************************************************/ +MEM_STATIC unsigned BIT_highbit32 (U32 val) +{ + assert(val != 0); + { +# if defined(_MSC_VER) /* Visual */ + unsigned long r=0; + _BitScanReverse ( &r, val ); + return (unsigned) r; +# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */ + return 31 - __builtin_clz (val); +# else /* Software version */ + static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, + 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, + 19, 27, 23, 6, 26, 5, 4, 31 }; + U32 v = val; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27]; +# endif + } +} + +/*===== Local Constants =====*/ +static const unsigned BIT_mask[] = { + 0, 1, 3, 7, 0xF, 0x1F, + 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, + 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF, + 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, + 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, + 0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */ +#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0])) + +/*-************************************************************** +* bitStream encoding +****************************************************************/ +/*! BIT_initCStream() : + * `dstCapacity` must be > sizeof(size_t) + * @return : 0 if success, + * otherwise an error code (can be tested using ERR_isError()) */ +MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, + void* startPtr, size_t dstCapacity) +{ + bitC->bitContainer = 0; + bitC->bitPos = 0; + bitC->startPtr = (char*)startPtr; + bitC->ptr = bitC->startPtr; + bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer); + if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall); + return 0; +} + +/*! BIT_addBits() : + * can add up to 31 bits into `bitC`. + * Note : does not check for register overflow ! */ +MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, + size_t value, unsigned nbBits) +{ + MEM_STATIC_ASSERT(BIT_MASK_SIZE == 32); + assert(nbBits < BIT_MASK_SIZE); + assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); + bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos; + bitC->bitPos += nbBits; +} + +/*! BIT_addBitsFast() : + * works only if `value` is _clean_, + * meaning all high bits above nbBits are 0 */ +MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, + size_t value, unsigned nbBits) +{ + assert((value>>nbBits) == 0); + assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); + bitC->bitContainer |= value << bitC->bitPos; + bitC->bitPos += nbBits; +} + +/*! BIT_flushBitsFast() : + * assumption : bitContainer has not overflowed + * unsafe version; does not check buffer overflow */ +MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC) +{ + size_t const nbBytes = bitC->bitPos >> 3; + assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); + MEM_writeLEST(bitC->ptr, bitC->bitContainer); + bitC->ptr += nbBytes; + assert(bitC->ptr <= bitC->endPtr); + bitC->bitPos &= 7; + bitC->bitContainer >>= nbBytes*8; +} + +/*! BIT_flushBits() : + * assumption : bitContainer has not overflowed + * safe version; check for buffer overflow, and prevents it. + * note : does not signal buffer overflow. + * overflow will be revealed later on using BIT_closeCStream() */ +MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC) +{ + size_t const nbBytes = bitC->bitPos >> 3; + assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); + MEM_writeLEST(bitC->ptr, bitC->bitContainer); + bitC->ptr += nbBytes; + if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr; + bitC->bitPos &= 7; + bitC->bitContainer >>= nbBytes*8; +} + +/*! BIT_closeCStream() : + * @return : size of CStream, in bytes, + * or 0 if it could not fit into dstBuffer */ +MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC) +{ + BIT_addBitsFast(bitC, 1, 1); /* endMark */ + BIT_flushBits(bitC); + if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */ + return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0); +} + + +/*-******************************************************** +* bitStream decoding +**********************************************************/ +/*! BIT_initDStream() : + * Initialize a BIT_DStream_t. + * `bitD` : a pointer to an already allocated BIT_DStream_t structure. + * `srcSize` must be the *exact* size of the bitStream, in bytes. + * @return : size of stream (== srcSize), or an errorCode if a problem is detected + */ +MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize) +{ + if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); } + + bitD->start = (const char*)srcBuffer; + bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer); + + if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */ + bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer); + bitD->bitContainer = MEM_readLEST(bitD->ptr); + { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; + bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */ + if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ } + } else { + bitD->ptr = bitD->start; + bitD->bitContainer = *(const BYTE*)(bitD->start); + switch(srcSize) + { + case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16); + /* fall-through */ + + case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24); + /* fall-through */ + + case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32); + /* fall-through */ + + case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24; + /* fall-through */ + + case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16; + /* fall-through */ + + case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8; + /* fall-through */ + + default: break; + } + { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; + bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; + if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */ + } + bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8; + } + + return srcSize; +} + +MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start) +{ + return bitContainer >> start; +} + +MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits) +{ +#if defined(__BMI__) && defined(__GNUC__) && __GNUC__*1000+__GNUC_MINOR__ >= 4008 /* experimental */ +# if defined(__x86_64__) + if (sizeof(bitContainer)==8) + return _bextr_u64(bitContainer, start, nbBits); + else +# endif + return _bextr_u32(bitContainer, start, nbBits); +#else + assert(nbBits < BIT_MASK_SIZE); + return (bitContainer >> start) & BIT_mask[nbBits]; +#endif +} + +MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) +{ + assert(nbBits < BIT_MASK_SIZE); + return bitContainer & BIT_mask[nbBits]; +} + +/*! BIT_lookBits() : + * Provides next n bits from local register. + * local register is not modified. + * On 32-bits, maxNbBits==24. + * On 64-bits, maxNbBits==56. + * @return : value extracted */ +MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits) +{ +#if defined(__BMI__) && defined(__GNUC__) /* experimental; fails if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8 */ + return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits); +#else + U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; + return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask); +#endif +} + +/*! BIT_lookBitsFast() : + * unsafe version; only works if nbBits >= 1 */ +MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits) +{ + U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; + assert(nbBits >= 1); + return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask); +} + +MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) +{ + bitD->bitsConsumed += nbBits; +} + +/*! BIT_readBits() : + * Read (consume) next n bits from local register and update. + * Pay attention to not read more than nbBits contained into local register. + * @return : extracted value. */ +MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) +{ + size_t const value = BIT_lookBits(bitD, nbBits); + BIT_skipBits(bitD, nbBits); + return value; +} + +/*! BIT_readBitsFast() : + * unsafe version; only works only if nbBits >= 1 */ +MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits) +{ + size_t const value = BIT_lookBitsFast(bitD, nbBits); + assert(nbBits >= 1); + BIT_skipBits(bitD, nbBits); + return value; +} + +/*! BIT_reloadDStream() : + * Refill `bitD` from buffer previously set in BIT_initDStream() . + * This function is safe, it guarantees it will not read beyond src buffer. + * @return : status of `BIT_DStream_t` internal register. + * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */ +MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) +{ + if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */ + return BIT_DStream_overflow; + + if (bitD->ptr >= bitD->limitPtr) { + bitD->ptr -= bitD->bitsConsumed >> 3; + bitD->bitsConsumed &= 7; + bitD->bitContainer = MEM_readLEST(bitD->ptr); + return BIT_DStream_unfinished; + } + if (bitD->ptr == bitD->start) { + if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer; + return BIT_DStream_completed; + } + /* start < ptr < limitPtr */ + { U32 nbBytes = bitD->bitsConsumed >> 3; + BIT_DStream_status result = BIT_DStream_unfinished; + if (bitD->ptr - nbBytes < bitD->start) { + nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ + result = BIT_DStream_endOfBuffer; + } + bitD->ptr -= nbBytes; + bitD->bitsConsumed -= nbBytes*8; + bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */ + return result; + } +} + +/*! BIT_endOfDStream() : + * @return : 1 if DStream has _exactly_ reached its end (all bits consumed). + */ +MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream) +{ + return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8)); +} + +#if defined (__cplusplus) +} +#endif + +#endif /* BITSTREAM_H_MODULE */ diff --git a/grub-core/lib/zstd/compiler.h b/grub-core/lib/zstd/compiler.h new file mode 100644 index 000000000..07f875e4d --- /dev/null +++ b/grub-core/lib/zstd/compiler.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_COMPILER_H +#define ZSTD_COMPILER_H + +/*-******************************************************* +* Compiler specifics +*********************************************************/ +/* force inlining */ +#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define INLINE_KEYWORD inline +#else +# define INLINE_KEYWORD +#endif + +#if defined(__GNUC__) +# define FORCE_INLINE_ATTR __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define FORCE_INLINE_ATTR __forceinline +#else +# define FORCE_INLINE_ATTR +#endif + +/** + * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant + * parameters. They must be inlined for the compiler to elimininate the constant + * branches. + */ +#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR +/** + * HINT_INLINE is used to help the compiler generate better code. It is *not* + * used for "templates", so it can be tweaked based on the compilers + * performance. + * + * gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the + * always_inline attribute. + * + * clang up to 5.0.0 (trunk) benefit tremendously from the always_inline + * attribute. + */ +#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5 +# define HINT_INLINE static INLINE_KEYWORD +#else +# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR +#endif + +/* force no inlining */ +#ifdef _MSC_VER +# define FORCE_NOINLINE static __declspec(noinline) +#else +# ifdef __GNUC__ +# define FORCE_NOINLINE static __attribute__((__noinline__)) +# else +# define FORCE_NOINLINE static +# endif +#endif + +/* target attribute */ +#ifndef __has_attribute + #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif +#if defined(__GNUC__) +# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target))) +#else +# define TARGET_ATTRIBUTE(target) +#endif + +/* Enable runtime BMI2 dispatch based on the CPU. + * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default. + */ +#ifndef DYNAMIC_BMI2 + #if ((defined(__clang__) && __has_attribute(__target__)) \ + || (defined(__GNUC__) \ + && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \ + && (defined(__x86_64__) || defined(_M_X86)) \ + && !defined(__BMI2__) + # define DYNAMIC_BMI2 1 + #else + # define DYNAMIC_BMI2 0 + #endif +#endif + +/* prefetch + * can be disabled, by declaring NO_PREFETCH macro + * All prefetch invocations use a single default locality 2, + * generating instruction prefetcht1, + * which, according to Intel, means "load data into L2 cache". + * This is a good enough "middle ground" for the time being, + * though in theory, it would be better to specialize locality depending on data being prefetched. + * Tests could not determine any sensible difference based on locality value. */ +#if defined(NO_PREFETCH) +# define PREFETCH(ptr) (void)(ptr) /* disabled */ +#else +# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ +# include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ +# define PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) +# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) +# define PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */) +# else +# define PREFETCH(ptr) (void)(ptr) /* disabled */ +# endif +#endif /* NO_PREFETCH */ + +#define CACHELINE_SIZE 64 + +#define PREFETCH_AREA(p, s) { \ + const char* const _ptr = (const char*)(p); \ + size_t const _size = (size_t)(s); \ + size_t _pos; \ + for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \ + PREFETCH(_ptr + _pos); \ + } \ +} + +/* disable warnings */ +#ifdef _MSC_VER /* Visual Studio */ +# include /* For Visual 2005 */ +# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */ +# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ +# pragma warning(disable : 4324) /* disable: C4324: padded structure */ +#endif + +#endif /* ZSTD_COMPILER_H */ diff --git a/grub-core/lib/zstd/cpu.h b/grub-core/lib/zstd/cpu.h new file mode 100644 index 000000000..eeb428ad5 --- /dev/null +++ b/grub-core/lib/zstd/cpu.h @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_COMMON_CPU_H +#define ZSTD_COMMON_CPU_H + +/** + * Implementation taken from folly/CpuId.h + * https://github.com/facebook/folly/blob/master/folly/CpuId.h + */ + +#include + +#include "mem.h" + +#ifdef _MSC_VER +#include +#endif + +typedef struct { + U32 f1c; + U32 f1d; + U32 f7b; + U32 f7c; +} ZSTD_cpuid_t; + +MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) { + U32 f1c = 0; + U32 f1d = 0; + U32 f7b = 0; + U32 f7c = 0; +#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) + int reg[4]; + __cpuid((int*)reg, 0); + { + int const n = reg[0]; + if (n >= 1) { + __cpuid((int*)reg, 1); + f1c = (U32)reg[2]; + f1d = (U32)reg[3]; + } + if (n >= 7) { + __cpuidex((int*)reg, 7, 0); + f7b = (U32)reg[1]; + f7c = (U32)reg[2]; + } + } +#elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__) + /* The following block like the normal cpuid branch below, but gcc + * reserves ebx for use of its pic register so we must specially + * handle the save and restore to avoid clobbering the register + */ + U32 n; + __asm__( + "pushl %%ebx\n\t" + "cpuid\n\t" + "popl %%ebx\n\t" + : "=a"(n) + : "a"(0) + : "ecx", "edx"); + if (n >= 1) { + U32 f1a; + __asm__( + "pushl %%ebx\n\t" + "cpuid\n\t" + "popl %%ebx\n\t" + : "=a"(f1a), "=c"(f1c), "=d"(f1d) + : "a"(1)); + } + if (n >= 7) { + __asm__( + "pushl %%ebx\n\t" + "cpuid\n\t" + "movl %%ebx, %%eax\n\r" + "popl %%ebx" + : "=a"(f7b), "=c"(f7c) + : "a"(7), "c"(0) + : "edx"); + } +#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__) + U32 n; + __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx"); + if (n >= 1) { + U32 f1a; + __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx"); + } + if (n >= 7) { + U32 f7a; + __asm__("cpuid" + : "=a"(f7a), "=b"(f7b), "=c"(f7c) + : "a"(7), "c"(0) + : "edx"); + } +#endif + { + ZSTD_cpuid_t cpuid; + cpuid.f1c = f1c; + cpuid.f1d = f1d; + cpuid.f7b = f7b; + cpuid.f7c = f7c; + return cpuid; + } +} + +#define X(name, r, bit) \ + MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \ + return ((cpuid.r) & (1U << bit)) != 0; \ + } + +/* cpuid(1): Processor Info and Feature Bits. */ +#define C(name, bit) X(name, f1c, bit) + C(sse3, 0) + C(pclmuldq, 1) + C(dtes64, 2) + C(monitor, 3) + C(dscpl, 4) + C(vmx, 5) + C(smx, 6) + C(eist, 7) + C(tm2, 8) + C(ssse3, 9) + C(cnxtid, 10) + C(fma, 12) + C(cx16, 13) + C(xtpr, 14) + C(pdcm, 15) + C(pcid, 17) + C(dca, 18) + C(sse41, 19) + C(sse42, 20) + C(x2apic, 21) + C(movbe, 22) + C(popcnt, 23) + C(tscdeadline, 24) + C(aes, 25) + C(xsave, 26) + C(osxsave, 27) + C(avx, 28) + C(f16c, 29) + C(rdrand, 30) +#undef C +#define D(name, bit) X(name, f1d, bit) + D(fpu, 0) + D(vme, 1) + D(de, 2) + D(pse, 3) + D(tsc, 4) + D(msr, 5) + D(pae, 6) + D(mce, 7) + D(cx8, 8) + D(apic, 9) + D(sep, 11) + D(mtrr, 12) + D(pge, 13) + D(mca, 14) + D(cmov, 15) + D(pat, 16) + D(pse36, 17) + D(psn, 18) + D(clfsh, 19) + D(ds, 21) + D(acpi, 22) + D(mmx, 23) + D(fxsr, 24) + D(sse, 25) + D(sse2, 26) + D(ss, 27) + D(htt, 28) + D(tm, 29) + D(pbe, 31) +#undef D + +/* cpuid(7): Extended Features. */ +#define B(name, bit) X(name, f7b, bit) + B(bmi1, 3) + B(hle, 4) + B(avx2, 5) + B(smep, 7) + B(bmi2, 8) + B(erms, 9) + B(invpcid, 10) + B(rtm, 11) + B(mpx, 14) + B(avx512f, 16) + B(avx512dq, 17) + B(rdseed, 18) + B(adx, 19) + B(smap, 20) + B(avx512ifma, 21) + B(pcommit, 22) + B(clflushopt, 23) + B(clwb, 24) + B(avx512pf, 26) + B(avx512er, 27) + B(avx512cd, 28) + B(sha, 29) + B(avx512bw, 30) + B(avx512vl, 31) +#undef B +#define C(name, bit) X(name, f7c, bit) + C(prefetchwt1, 0) + C(avx512vbmi, 1) +#undef C + +#undef X + +#endif /* ZSTD_COMMON_CPU_H */ diff --git a/grub-core/lib/zstd/debug.c b/grub-core/lib/zstd/debug.c new file mode 100644 index 000000000..3ebdd1cb1 --- /dev/null +++ b/grub-core/lib/zstd/debug.c @@ -0,0 +1,44 @@ +/* ****************************************************************** + debug + Part of FSE library + Copyright (C) 2013-present, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - Source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ + + +/* + * This module only hosts one global variable + * which can be used to dynamically influence the verbosity of traces, + * such as DEBUGLOG and RAWLOG + */ + +#include "debug.h" + +int g_debuglevel = DEBUGLEVEL; diff --git a/grub-core/lib/zstd/debug.h b/grub-core/lib/zstd/debug.h new file mode 100644 index 000000000..0c04ad2cc --- /dev/null +++ b/grub-core/lib/zstd/debug.h @@ -0,0 +1,123 @@ +/* ****************************************************************** + debug + Part of FSE library + Copyright (C) 2013-present, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - Source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ + + +/* + * The purpose of this header is to enable debug functions. + * They regroup assert(), DEBUGLOG() and RAWLOG() for run-time, + * and DEBUG_STATIC_ASSERT() for compile-time. + * + * By default, DEBUGLEVEL==0, which means run-time debug is disabled. + * + * Level 1 enables assert() only. + * Starting level 2, traces can be generated and pushed to stderr. + * The higher the level, the more verbose the traces. + * + * It's possible to dynamically adjust level using variable g_debug_level, + * which is only declared if DEBUGLEVEL>=2, + * and is a global variable, not multi-thread protected (use with care) + */ + +#ifndef DEBUG_H_12987983217 +#define DEBUG_H_12987983217 + +#if defined (__cplusplus) +extern "C" { +#endif + + +/* static assert is triggered at compile time, leaving no runtime artefact, + * but can only work with compile-time constants. + * This variant can only be used inside a function. */ +#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1]) + + +/* DEBUGLEVEL is expected to be defined externally, + * typically through compiler command line. + * Value must be a number. */ +#ifndef DEBUGLEVEL +# define DEBUGLEVEL 0 +#endif + +/* recommended values for DEBUGLEVEL : + * 0 : no debug, all run-time functions disabled + * 1 : no display, enables assert() only + * 2 : reserved, for currently active debug path + * 3 : events once per object lifetime (CCtx, CDict, etc.) + * 4 : events once per frame + * 5 : events once per block + * 6 : events once per sequence (verbose) + * 7+: events at every position (*very* verbose) + * + * It's generally inconvenient to output traces > 5. + * In which case, it's possible to selectively enable higher verbosity levels + * by modifying g_debug_level. + */ + +#if (DEBUGLEVEL>=1) +# include +#else +# ifndef assert /* assert may be already defined, due to prior #include */ +# define assert(condition) ((void)0) /* disable assert (default) */ +# endif +#endif + +#if (DEBUGLEVEL>=2) +# include +extern int g_debuglevel; /* here, this variable is only declared, + it actually lives in debug.c, + and is shared by the whole process. + It's typically used to enable very verbose levels + on selective conditions (such as position in src) */ + +# define RAWLOG(l, ...) { \ + if (l<=g_debuglevel) { \ + fprintf(stderr, __VA_ARGS__); \ + } } +# define DEBUGLOG(l, ...) { \ + if (l<=g_debuglevel) { \ + fprintf(stderr, __FILE__ ": " __VA_ARGS__); \ + fprintf(stderr, " \n"); \ + } } +#else +# define RAWLOG(l, ...) {} /* disabled */ +# define DEBUGLOG(l, ...) {} /* disabled */ +#endif + + +#if defined (__cplusplus) +} +#endif + +#endif /* DEBUG_H_12987983217 */ diff --git a/grub-core/lib/zstd/entropy_common.c b/grub-core/lib/zstd/entropy_common.c new file mode 100644 index 000000000..b12944e1d --- /dev/null +++ b/grub-core/lib/zstd/entropy_common.c @@ -0,0 +1,236 @@ +/* + Common functions of New Generation Entropy library + Copyright (C) 2016, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy + - Public forum : https://groups.google.com/forum/#!forum/lz4c +*************************************************************************** */ + +/* ************************************* +* Dependencies +***************************************/ +#include "mem.h" +#include "error_private.h" /* ERR_*, ERROR */ +#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */ +#include "fse.h" +#define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */ +#include "huf.h" + + +/*=== Version ===*/ +unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; } + + +/*=== Error Management ===*/ +unsigned FSE_isError(size_t code) { return ERR_isError(code); } +const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); } + +unsigned HUF_isError(size_t code) { return ERR_isError(code); } +const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); } + + +/*-************************************************************** +* FSE NCount encoding-decoding +****************************************************************/ +size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr, + const void* headerBuffer, size_t hbSize) +{ + const BYTE* const istart = (const BYTE*) headerBuffer; + const BYTE* const iend = istart + hbSize; + const BYTE* ip = istart; + int nbBits; + int remaining; + int threshold; + U32 bitStream; + int bitCount; + unsigned charnum = 0; + int previous0 = 0; + + if (hbSize < 4) { + /* This function only works when hbSize >= 4 */ + char buffer[4]; + memset(buffer, 0, sizeof(buffer)); + memcpy(buffer, headerBuffer, hbSize); + { size_t const countSize = FSE_readNCount(normalizedCounter, maxSVPtr, tableLogPtr, + buffer, sizeof(buffer)); + if (FSE_isError(countSize)) return countSize; + if (countSize > hbSize) return ERROR(corruption_detected); + return countSize; + } } + assert(hbSize >= 4); + + /* init */ + memset(normalizedCounter, 0, (*maxSVPtr+1) * sizeof(normalizedCounter[0])); /* all symbols not present in NCount have a frequency of 0 */ + bitStream = MEM_readLE32(ip); + nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */ + if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge); + bitStream >>= 4; + bitCount = 4; + *tableLogPtr = nbBits; + remaining = (1<1) & (charnum<=*maxSVPtr)) { + if (previous0) { + unsigned n0 = charnum; + while ((bitStream & 0xFFFF) == 0xFFFF) { + n0 += 24; + if (ip < iend-5) { + ip += 2; + bitStream = MEM_readLE32(ip) >> bitCount; + } else { + bitStream >>= 16; + bitCount += 16; + } } + while ((bitStream & 3) == 3) { + n0 += 3; + bitStream >>= 2; + bitCount += 2; + } + n0 += bitStream & 3; + bitCount += 2; + if (n0 > *maxSVPtr) return ERROR(maxSymbolValue_tooSmall); + while (charnum < n0) normalizedCounter[charnum++] = 0; + if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) { + assert((bitCount >> 3) <= 3); /* For first condition to work */ + ip += bitCount>>3; + bitCount &= 7; + bitStream = MEM_readLE32(ip) >> bitCount; + } else { + bitStream >>= 2; + } } + { int const max = (2*threshold-1) - remaining; + int count; + + if ((bitStream & (threshold-1)) < (U32)max) { + count = bitStream & (threshold-1); + bitCount += nbBits-1; + } else { + count = bitStream & (2*threshold-1); + if (count >= threshold) count -= max; + bitCount += nbBits; + } + + count--; /* extra accuracy */ + remaining -= count < 0 ? -count : count; /* -1 means +1 */ + normalizedCounter[charnum++] = (short)count; + previous0 = !count; + while (remaining < threshold) { + nbBits--; + threshold >>= 1; + } + + if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) { + ip += bitCount>>3; + bitCount &= 7; + } else { + bitCount -= (int)(8 * (iend - 4 - ip)); + ip = iend - 4; + } + bitStream = MEM_readLE32(ip) >> (bitCount & 31); + } } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */ + if (remaining != 1) return ERROR(corruption_detected); + if (bitCount > 32) return ERROR(corruption_detected); + *maxSVPtr = charnum-1; + + ip += (bitCount+7)>>3; + return ip-istart; +} + + +/*! HUF_readStats() : + Read compact Huffman tree, saved by HUF_writeCTable(). + `huffWeight` is destination buffer. + `rankStats` is assumed to be a table of at least HUF_TABLELOG_MAX U32. + @return : size read from `src` , or an error Code . + Note : Needed by HUF_readCTable() and HUF_readDTableX?() . +*/ +size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats, + U32* nbSymbolsPtr, U32* tableLogPtr, + const void* src, size_t srcSize) +{ + U32 weightTotal; + const BYTE* ip = (const BYTE*) src; + size_t iSize; + size_t oSize; + + if (!srcSize) return ERROR(srcSize_wrong); + iSize = ip[0]; + /* memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */ + + if (iSize >= 128) { /* special header */ + oSize = iSize - 127; + iSize = ((oSize+1)/2); + if (iSize+1 > srcSize) return ERROR(srcSize_wrong); + if (oSize >= hwSize) return ERROR(corruption_detected); + ip += 1; + { U32 n; + for (n=0; n> 4; + huffWeight[n+1] = ip[n/2] & 15; + } } } + else { /* header compressed with FSE (normal case) */ + FSE_DTable fseWorkspace[FSE_DTABLE_SIZE_U32(6)]; /* 6 is max possible tableLog for HUF header (maybe even 5, to be tested) */ + if (iSize+1 > srcSize) return ERROR(srcSize_wrong); + oSize = FSE_decompress_wksp(huffWeight, hwSize-1, ip+1, iSize, fseWorkspace, 6); /* max (hwSize-1) values decoded, as last one is implied */ + if (FSE_isError(oSize)) return oSize; + } + + /* collect weight stats */ + memset(rankStats, 0, (HUF_TABLELOG_MAX + 1) * sizeof(U32)); + weightTotal = 0; + { U32 n; for (n=0; n= HUF_TABLELOG_MAX) return ERROR(corruption_detected); + rankStats[huffWeight[n]]++; + weightTotal += (1 << huffWeight[n]) >> 1; + } } + if (weightTotal == 0) return ERROR(corruption_detected); + + /* get last non-null symbol weight (implied, total must be 2^n) */ + { U32 const tableLog = BIT_highbit32(weightTotal) + 1; + if (tableLog > HUF_TABLELOG_MAX) return ERROR(corruption_detected); + *tableLogPtr = tableLog; + /* determine last weight */ + { U32 const total = 1 << tableLog; + U32 const rest = total - weightTotal; + U32 const verif = 1 << BIT_highbit32(rest); + U32 const lastWeight = BIT_highbit32(rest) + 1; + if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */ + huffWeight[oSize] = (BYTE)lastWeight; + rankStats[lastWeight]++; + } } + + /* check tree construction validity */ + if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */ + + /* results */ + *nbSymbolsPtr = (U32)(oSize+1); + return iSize+1; +} diff --git a/grub-core/lib/zstd/error_private.c b/grub-core/lib/zstd/error_private.c new file mode 100644 index 000000000..d004ee636 --- /dev/null +++ b/grub-core/lib/zstd/error_private.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +/* The purpose of this file is to have a single list of error strings embedded in binary */ + +#include "error_private.h" + +const char* ERR_getErrorString(ERR_enum code) +{ + static const char* const notErrorCode = "Unspecified error code"; + switch( code ) + { + case PREFIX(no_error): return "No error detected"; + case PREFIX(GENERIC): return "Error (generic)"; + case PREFIX(prefix_unknown): return "Unknown frame descriptor"; + case PREFIX(version_unsupported): return "Version not supported"; + case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter"; + case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding"; + case PREFIX(corruption_detected): return "Corrupted block detected"; + case PREFIX(checksum_wrong): return "Restored data doesn't match checksum"; + case PREFIX(parameter_unsupported): return "Unsupported parameter"; + case PREFIX(parameter_outOfBound): return "Parameter is out of bound"; + case PREFIX(init_missing): return "Context should be init first"; + case PREFIX(memory_allocation): return "Allocation error : not enough memory"; + case PREFIX(workSpace_tooSmall): return "workSpace buffer is not large enough"; + case PREFIX(stage_wrong): return "Operation not authorized at current processing stage"; + case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported"; + case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large"; + case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small"; + case PREFIX(dictionary_corrupted): return "Dictionary is corrupted"; + case PREFIX(dictionary_wrong): return "Dictionary mismatch"; + case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples"; + case PREFIX(dstSize_tooSmall): return "Destination buffer is too small"; + case PREFIX(srcSize_wrong): return "Src size is incorrect"; + /* following error codes are not stable and may be removed or changed in a future version */ + case PREFIX(frameIndex_tooLarge): return "Frame index is too large"; + case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking"; + case PREFIX(maxCode): + default: return notErrorCode; + } +} diff --git a/grub-core/lib/zstd/error_private.h b/grub-core/lib/zstd/error_private.h new file mode 100644 index 000000000..0d2fa7e34 --- /dev/null +++ b/grub-core/lib/zstd/error_private.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +/* Note : this module is expected to remain private, do not expose it */ + +#ifndef ERROR_H_MODULE +#define ERROR_H_MODULE + +#if defined (__cplusplus) +extern "C" { +#endif + + +/* **************************************** +* Dependencies +******************************************/ +#include /* size_t */ +#include "zstd_errors.h" /* enum list */ + + +/* **************************************** +* Compiler-specific +******************************************/ +#if defined(__GNUC__) +# define ERR_STATIC static __attribute__((unused)) +#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) +# define ERR_STATIC static inline +#elif defined(_MSC_VER) +# define ERR_STATIC static __inline +#else +# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ +#endif + + +/*-**************************************** +* Customization (error_public.h) +******************************************/ +typedef ZSTD_ErrorCode ERR_enum; +#define PREFIX(name) ZSTD_error_##name + + +/*-**************************************** +* Error codes handling +******************************************/ +#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */ +#define ERROR(name) ZSTD_ERROR(name) +#define ZSTD_ERROR(name) ((size_t)-PREFIX(name)) + +ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); } + +ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); } + + +/*-**************************************** +* Error Strings +******************************************/ + +const char* ERR_getErrorString(ERR_enum code); /* error_private.c */ + +ERR_STATIC const char* ERR_getErrorName(size_t code) +{ + return ERR_getErrorString(ERR_getErrorCode(code)); +} + +#if defined (__cplusplus) +} +#endif + +#endif /* ERROR_H_MODULE */ diff --git a/grub-core/lib/zstd/fse.h b/grub-core/lib/zstd/fse.h new file mode 100644 index 000000000..a5a6b6d4d --- /dev/null +++ b/grub-core/lib/zstd/fse.h @@ -0,0 +1,708 @@ +/* ****************************************************************** + FSE : Finite State Entropy codec + Public Prototypes declaration + Copyright (C) 2013-2016, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - Source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ + +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef FSE_H +#define FSE_H + + +/*-***************************************** +* Dependencies +******************************************/ +#include /* size_t, ptrdiff_t */ + + +/*-***************************************** +* FSE_PUBLIC_API : control library symbols visibility +******************************************/ +#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4) +# define FSE_PUBLIC_API __attribute__ ((visibility ("default"))) +#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */ +# define FSE_PUBLIC_API __declspec(dllexport) +#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1) +# define FSE_PUBLIC_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define FSE_PUBLIC_API +#endif + +/*------ Version ------*/ +#define FSE_VERSION_MAJOR 0 +#define FSE_VERSION_MINOR 9 +#define FSE_VERSION_RELEASE 0 + +#define FSE_LIB_VERSION FSE_VERSION_MAJOR.FSE_VERSION_MINOR.FSE_VERSION_RELEASE +#define FSE_QUOTE(str) #str +#define FSE_EXPAND_AND_QUOTE(str) FSE_QUOTE(str) +#define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE(FSE_LIB_VERSION) + +#define FSE_VERSION_NUMBER (FSE_VERSION_MAJOR *100*100 + FSE_VERSION_MINOR *100 + FSE_VERSION_RELEASE) +FSE_PUBLIC_API unsigned FSE_versionNumber(void); /**< library version number; to be used when checking dll version */ + + +/*-**************************************** +* FSE simple functions +******************************************/ +/*! FSE_compress() : + Compress content of buffer 'src', of size 'srcSize', into destination buffer 'dst'. + 'dst' buffer must be already allocated. Compression runs faster is dstCapacity >= FSE_compressBound(srcSize). + @return : size of compressed data (<= dstCapacity). + Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!! + if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead. + if FSE_isError(return), compression failed (more details using FSE_getErrorName()) +*/ +FSE_PUBLIC_API size_t FSE_compress(void* dst, size_t dstCapacity, + const void* src, size_t srcSize); + +/*! FSE_decompress(): + Decompress FSE data from buffer 'cSrc', of size 'cSrcSize', + into already allocated destination buffer 'dst', of size 'dstCapacity'. + @return : size of regenerated data (<= maxDstSize), + or an error code, which can be tested using FSE_isError() . + + ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!! + Why ? : making this distinction requires a header. + Header management is intentionally delegated to the user layer, which can better manage special cases. +*/ +FSE_PUBLIC_API size_t FSE_decompress(void* dst, size_t dstCapacity, + const void* cSrc, size_t cSrcSize); + + +/*-***************************************** +* Tool functions +******************************************/ +FSE_PUBLIC_API size_t FSE_compressBound(size_t size); /* maximum compressed size */ + +/* Error Management */ +FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return value is an error code */ +FSE_PUBLIC_API const char* FSE_getErrorName(size_t code); /* provides error code string (useful for debugging) */ + + +/*-***************************************** +* FSE advanced functions +******************************************/ +/*! FSE_compress2() : + Same as FSE_compress(), but allows the selection of 'maxSymbolValue' and 'tableLog' + Both parameters can be defined as '0' to mean : use default value + @return : size of compressed data + Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!! + if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression. + if FSE_isError(return), it's an error code. +*/ +FSE_PUBLIC_API size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog); + + +/*-***************************************** +* FSE detailed API +******************************************/ +/*! +FSE_compress() does the following: +1. count symbol occurrence from source[] into table count[] (see hist.h) +2. normalize counters so that sum(count[]) == Power_of_2 (2^tableLog) +3. save normalized counters to memory buffer using writeNCount() +4. build encoding table 'CTable' from normalized counters +5. encode the data stream using encoding table 'CTable' + +FSE_decompress() does the following: +1. read normalized counters with readNCount() +2. build decoding table 'DTable' from normalized counters +3. decode the data stream using decoding table 'DTable' + +The following API allows targeting specific sub-functions for advanced tasks. +For example, it's possible to compress several blocks using the same 'CTable', +or to save and provide normalized distribution using external method. +*/ + +/* *** COMPRESSION *** */ + +/*! FSE_optimalTableLog(): + dynamically downsize 'tableLog' when conditions are met. + It saves CPU time, by using smaller tables, while preserving or even improving compression ratio. + @return : recommended tableLog (necessarily <= 'maxTableLog') */ +FSE_PUBLIC_API unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue); + +/*! FSE_normalizeCount(): + normalize counts so that sum(count[]) == Power_of_2 (2^tableLog) + 'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1). + @return : tableLog, + or an errorCode, which can be tested using FSE_isError() */ +FSE_PUBLIC_API size_t FSE_normalizeCount(short* normalizedCounter, unsigned tableLog, + const unsigned* count, size_t srcSize, unsigned maxSymbolValue); + +/*! FSE_NCountWriteBound(): + Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'. + Typically useful for allocation purpose. */ +FSE_PUBLIC_API size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog); + +/*! FSE_writeNCount(): + Compactly save 'normalizedCounter' into 'buffer'. + @return : size of the compressed table, + or an errorCode, which can be tested using FSE_isError(). */ +FSE_PUBLIC_API size_t FSE_writeNCount (void* buffer, size_t bufferSize, + const short* normalizedCounter, + unsigned maxSymbolValue, unsigned tableLog); + +/*! Constructor and Destructor of FSE_CTable. + Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */ +typedef unsigned FSE_CTable; /* don't allocate that. It's only meant to be more restrictive than void* */ +FSE_PUBLIC_API FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog); +FSE_PUBLIC_API void FSE_freeCTable (FSE_CTable* ct); + +/*! FSE_buildCTable(): + Builds `ct`, which must be already allocated, using FSE_createCTable(). + @return : 0, or an errorCode, which can be tested using FSE_isError() */ +FSE_PUBLIC_API size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog); + +/*! FSE_compress_usingCTable(): + Compress `src` using `ct` into `dst` which must be already allocated. + @return : size of compressed data (<= `dstCapacity`), + or 0 if compressed data could not fit into `dst`, + or an errorCode, which can be tested using FSE_isError() */ +FSE_PUBLIC_API size_t FSE_compress_usingCTable (void* dst, size_t dstCapacity, const void* src, size_t srcSize, const FSE_CTable* ct); + +/*! +Tutorial : +---------- +The first step is to count all symbols. FSE_count() does this job very fast. +Result will be saved into 'count', a table of unsigned int, which must be already allocated, and have 'maxSymbolValuePtr[0]+1' cells. +'src' is a table of bytes of size 'srcSize'. All values within 'src' MUST be <= maxSymbolValuePtr[0] +maxSymbolValuePtr[0] will be updated, with its real value (necessarily <= original value) +FSE_count() will return the number of occurrence of the most frequent symbol. +This can be used to know if there is a single symbol within 'src', and to quickly evaluate its compressibility. +If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()). + +The next step is to normalize the frequencies. +FSE_normalizeCount() will ensure that sum of frequencies is == 2 ^'tableLog'. +It also guarantees a minimum of 1 to any Symbol with frequency >= 1. +You can use 'tableLog'==0 to mean "use default tableLog value". +If you are unsure of which tableLog value to use, you can ask FSE_optimalTableLog(), +which will provide the optimal valid tableLog given sourceSize, maxSymbolValue, and a user-defined maximum (0 means "default"). + +The result of FSE_normalizeCount() will be saved into a table, +called 'normalizedCounter', which is a table of signed short. +'normalizedCounter' must be already allocated, and have at least 'maxSymbolValue+1' cells. +The return value is tableLog if everything proceeded as expected. +It is 0 if there is a single symbol within distribution. +If there is an error (ex: invalid tableLog value), the function will return an ErrorCode (which can be tested using FSE_isError()). + +'normalizedCounter' can be saved in a compact manner to a memory area using FSE_writeNCount(). +'buffer' must be already allocated. +For guaranteed success, buffer size must be at least FSE_headerBound(). +The result of the function is the number of bytes written into 'buffer'. +If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError(); ex : buffer size too small). + +'normalizedCounter' can then be used to create the compression table 'CTable'. +The space required by 'CTable' must be already allocated, using FSE_createCTable(). +You can then use FSE_buildCTable() to fill 'CTable'. +If there is an error, both functions will return an ErrorCode (which can be tested using FSE_isError()). + +'CTable' can then be used to compress 'src', with FSE_compress_usingCTable(). +Similar to FSE_count(), the convention is that 'src' is assumed to be a table of char of size 'srcSize' +The function returns the size of compressed data (without header), necessarily <= `dstCapacity`. +If it returns '0', compressed data could not fit into 'dst'. +If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()). +*/ + + +/* *** DECOMPRESSION *** */ + +/*! FSE_readNCount(): + Read compactly saved 'normalizedCounter' from 'rBuffer'. + @return : size read from 'rBuffer', + or an errorCode, which can be tested using FSE_isError(). + maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */ +FSE_PUBLIC_API size_t FSE_readNCount (short* normalizedCounter, + unsigned* maxSymbolValuePtr, unsigned* tableLogPtr, + const void* rBuffer, size_t rBuffSize); + +/*! Constructor and Destructor of FSE_DTable. + Note that its size depends on 'tableLog' */ +typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */ +FSE_PUBLIC_API FSE_DTable* FSE_createDTable(unsigned tableLog); +FSE_PUBLIC_API void FSE_freeDTable(FSE_DTable* dt); + +/*! FSE_buildDTable(): + Builds 'dt', which must be already allocated, using FSE_createDTable(). + return : 0, or an errorCode, which can be tested using FSE_isError() */ +FSE_PUBLIC_API size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog); + +/*! FSE_decompress_usingDTable(): + Decompress compressed source `cSrc` of size `cSrcSize` using `dt` + into `dst` which must be already allocated. + @return : size of regenerated data (necessarily <= `dstCapacity`), + or an errorCode, which can be tested using FSE_isError() */ +FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt); + +/*! +Tutorial : +---------- +(Note : these functions only decompress FSE-compressed blocks. + If block is uncompressed, use memcpy() instead + If block is a single repeated byte, use memset() instead ) + +The first step is to obtain the normalized frequencies of symbols. +This can be performed by FSE_readNCount() if it was saved using FSE_writeNCount(). +'normalizedCounter' must be already allocated, and have at least 'maxSymbolValuePtr[0]+1' cells of signed short. +In practice, that means it's necessary to know 'maxSymbolValue' beforehand, +or size the table to handle worst case situations (typically 256). +FSE_readNCount() will provide 'tableLog' and 'maxSymbolValue'. +The result of FSE_readNCount() is the number of bytes read from 'rBuffer'. +Note that 'rBufferSize' must be at least 4 bytes, even if useful information is less than that. +If there is an error, the function will return an error code, which can be tested using FSE_isError(). + +The next step is to build the decompression tables 'FSE_DTable' from 'normalizedCounter'. +This is performed by the function FSE_buildDTable(). +The space required by 'FSE_DTable' must be already allocated using FSE_createDTable(). +If there is an error, the function will return an error code, which can be tested using FSE_isError(). + +`FSE_DTable` can then be used to decompress `cSrc`, with FSE_decompress_usingDTable(). +`cSrcSize` must be strictly correct, otherwise decompression will fail. +FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`). +If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small) +*/ + +#endif /* FSE_H */ + +#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) +#define FSE_H_FSE_STATIC_LINKING_ONLY + +/* *** Dependency *** */ +#include "bitstream.h" + + +/* ***************************************** +* Static allocation +*******************************************/ +/* FSE buffer bounds */ +#define FSE_NCOUNTBOUND 512 +#define FSE_BLOCKBOUND(size) (size + (size>>7)) +#define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */ + +/* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */ +#define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2)) +#define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1< 12) ? (1 << (maxTableLog - 2)) : 1024) ) +size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize); + +size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits); +/**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */ + +size_t FSE_buildCTable_rle (FSE_CTable* ct, unsigned char symbolValue); +/**< build a fake FSE_CTable, designed to compress always the same symbolValue */ + +/* FSE_buildCTable_wksp() : + * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`). + * `wkspSize` must be >= `(1<= BIT_DStream_completed + +When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. +Checking if DStream has reached its end is performed by : + BIT_endOfDStream(&DStream); +Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. + FSE_endOfDState(&DState); +*/ + + +/* ***************************************** +* FSE unsafe API +*******************************************/ +static unsigned char FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD); +/* faster, but works only if nbBits is always >= 1 (otherwise, result will be corrupted) */ + + +/* ***************************************** +* Implementation of inlined functions +*******************************************/ +typedef struct { + int deltaFindState; + U32 deltaNbBits; +} FSE_symbolCompressionTransform; /* total 8 bytes */ + +MEM_STATIC void FSE_initCState(FSE_CState_t* statePtr, const FSE_CTable* ct) +{ + const void* ptr = ct; + const U16* u16ptr = (const U16*) ptr; + const U32 tableLog = MEM_read16(ptr); + statePtr->value = (ptrdiff_t)1<stateTable = u16ptr+2; + statePtr->symbolTT = ((const U32*)ct + 1 + (tableLog ? (1<<(tableLog-1)) : 1)); + statePtr->stateLog = tableLog; +} + + +/*! FSE_initCState2() : +* Same as FSE_initCState(), but the first symbol to include (which will be the last to be read) +* uses the smallest state value possible, saving the cost of this symbol */ +MEM_STATIC void FSE_initCState2(FSE_CState_t* statePtr, const FSE_CTable* ct, U32 symbol) +{ + FSE_initCState(statePtr, ct); + { const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol]; + const U16* stateTable = (const U16*)(statePtr->stateTable); + U32 nbBitsOut = (U32)((symbolTT.deltaNbBits + (1<<15)) >> 16); + statePtr->value = (nbBitsOut << 16) - symbolTT.deltaNbBits; + statePtr->value = stateTable[(statePtr->value >> nbBitsOut) + symbolTT.deltaFindState]; + } +} + +MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, U32 symbol) +{ + FSE_symbolCompressionTransform const symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol]; + const U16* const stateTable = (const U16*)(statePtr->stateTable); + U32 const nbBitsOut = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16); + BIT_addBits(bitC, statePtr->value, nbBitsOut); + statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState]; +} + +MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr) +{ + BIT_addBits(bitC, statePtr->value, statePtr->stateLog); + BIT_flushBits(bitC); +} + + +/* FSE_getMaxNbBits() : + * Approximate maximum cost of a symbol, in bits. + * Fractional get rounded up (i.e : a symbol with a normalized frequency of 3 gives the same result as a frequency of 2) + * note 1 : assume symbolValue is valid (<= maxSymbolValue) + * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */ +MEM_STATIC U32 FSE_getMaxNbBits(const void* symbolTTPtr, U32 symbolValue) +{ + const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr; + return (symbolTT[symbolValue].deltaNbBits + ((1<<16)-1)) >> 16; +} + +/* FSE_bitCost() : + * Approximate symbol cost, as fractional value, using fixed-point format (accuracyLog fractional bits) + * note 1 : assume symbolValue is valid (<= maxSymbolValue) + * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */ +MEM_STATIC U32 FSE_bitCost(const void* symbolTTPtr, U32 tableLog, U32 symbolValue, U32 accuracyLog) +{ + const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr; + U32 const minNbBits = symbolTT[symbolValue].deltaNbBits >> 16; + U32 const threshold = (minNbBits+1) << 16; + assert(tableLog < 16); + assert(accuracyLog < 31-tableLog); /* ensure enough room for renormalization double shift */ + { U32 const tableSize = 1 << tableLog; + U32 const deltaFromThreshold = threshold - (symbolTT[symbolValue].deltaNbBits + tableSize); + U32 const normalizedDeltaFromThreshold = (deltaFromThreshold << accuracyLog) >> tableLog; /* linear interpolation (very approximate) */ + U32 const bitMultiplier = 1 << accuracyLog; + assert(symbolTT[symbolValue].deltaNbBits + tableSize <= threshold); + assert(normalizedDeltaFromThreshold <= bitMultiplier); + return (minNbBits+1)*bitMultiplier - normalizedDeltaFromThreshold; + } +} + + +/* ====== Decompression ====== */ + +typedef struct { + U16 tableLog; + U16 fastMode; +} FSE_DTableHeader; /* sizeof U32 */ + +typedef struct +{ + unsigned short newState; + unsigned char symbol; + unsigned char nbBits; +} FSE_decode_t; /* size == U32 */ + +MEM_STATIC void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt) +{ + const void* ptr = dt; + const FSE_DTableHeader* const DTableH = (const FSE_DTableHeader*)ptr; + DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog); + BIT_reloadDStream(bitD); + DStatePtr->table = dt + 1; +} + +MEM_STATIC BYTE FSE_peekSymbol(const FSE_DState_t* DStatePtr) +{ + FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; + return DInfo.symbol; +} + +MEM_STATIC void FSE_updateState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD) +{ + FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; + U32 const nbBits = DInfo.nbBits; + size_t const lowBits = BIT_readBits(bitD, nbBits); + DStatePtr->state = DInfo.newState + lowBits; +} + +MEM_STATIC BYTE FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD) +{ + FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; + U32 const nbBits = DInfo.nbBits; + BYTE const symbol = DInfo.symbol; + size_t const lowBits = BIT_readBits(bitD, nbBits); + + DStatePtr->state = DInfo.newState + lowBits; + return symbol; +} + +/*! FSE_decodeSymbolFast() : + unsafe, only works if no symbol has a probability > 50% */ +MEM_STATIC BYTE FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD) +{ + FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; + U32 const nbBits = DInfo.nbBits; + BYTE const symbol = DInfo.symbol; + size_t const lowBits = BIT_readBitsFast(bitD, nbBits); + + DStatePtr->state = DInfo.newState + lowBits; + return symbol; +} + +MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) +{ + return DStatePtr->state == 0; +} + + + +#ifndef FSE_COMMONDEFS_ONLY + +/* ************************************************************** +* Tuning parameters +****************************************************************/ +/*!MEMORY_USAGE : +* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) +* Increasing memory usage improves compression ratio +* Reduced memory usage can improve speed, due to cache effect +* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */ +#ifndef FSE_MAX_MEMORY_USAGE +# define FSE_MAX_MEMORY_USAGE 14 +#endif +#ifndef FSE_DEFAULT_MEMORY_USAGE +# define FSE_DEFAULT_MEMORY_USAGE 13 +#endif + +/*!FSE_MAX_SYMBOL_VALUE : +* Maximum symbol value authorized. +* Required for proper stack allocation */ +#ifndef FSE_MAX_SYMBOL_VALUE +# define FSE_MAX_SYMBOL_VALUE 255 +#endif + +/* ************************************************************** +* template functions type & suffix +****************************************************************/ +#define FSE_FUNCTION_TYPE BYTE +#define FSE_FUNCTION_EXTENSION +#define FSE_DECODE_TYPE FSE_decode_t + + +#endif /* !FSE_COMMONDEFS_ONLY */ + + +/* *************************************************************** +* Constants +*****************************************************************/ +#define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE-2) +#define FSE_MAX_TABLESIZE (1U< FSE_TABLELOG_ABSOLUTE_MAX +# error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported" +#endif + +#define FSE_TABLESTEP(tableSize) ((tableSize>>1) + (tableSize>>3) + 3) + + +#endif /* FSE_STATIC_LINKING_ONLY */ + + +#if defined (__cplusplus) +} +#endif diff --git a/grub-core/lib/zstd/fse_decompress.c b/grub-core/lib/zstd/fse_decompress.c new file mode 100644 index 000000000..72bbead5b --- /dev/null +++ b/grub-core/lib/zstd/fse_decompress.c @@ -0,0 +1,309 @@ +/* ****************************************************************** + FSE : Finite State Entropy decoder + Copyright (C) 2013-2015, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy + - Public forum : https://groups.google.com/forum/#!forum/lz4c +****************************************************************** */ + + +/* ************************************************************** +* Includes +****************************************************************/ +#include /* malloc, free, qsort */ +#include /* memcpy, memset */ +#include "bitstream.h" +#include "compiler.h" +#define FSE_STATIC_LINKING_ONLY +#include "fse.h" +#include "error_private.h" + + +/* ************************************************************** +* Error Management +****************************************************************/ +#define FSE_isError ERR_isError +#define FSE_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) /* use only *after* variable declarations */ + +/* check and forward error code */ +#define CHECK_F(f) { size_t const e = f; if (FSE_isError(e)) return e; } + + +/* ************************************************************** +* Templates +****************************************************************/ +/* + designed to be included + for type-specific functions (template emulation in C) + Objective is to write these functions only once, for improved maintenance +*/ + +/* safety checks */ +#ifndef FSE_FUNCTION_EXTENSION +# error "FSE_FUNCTION_EXTENSION must be defined" +#endif +#ifndef FSE_FUNCTION_TYPE +# error "FSE_FUNCTION_TYPE must be defined" +#endif + +/* Function names */ +#define FSE_CAT(X,Y) X##Y +#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y) +#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y) + + +/* Function templates */ +FSE_DTable* FSE_createDTable (unsigned tableLog) +{ + if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX; + return (FSE_DTable*)malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) ); +} + +void FSE_freeDTable (FSE_DTable* dt) +{ + free(dt); +} + +size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) +{ + void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */ + FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr); + U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1]; + + U32 const maxSV1 = maxSymbolValue + 1; + U32 const tableSize = 1 << tableLog; + U32 highThreshold = tableSize-1; + + /* Sanity Checks */ + if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge); + if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge); + + /* Init, lay down lowprob symbols */ + { FSE_DTableHeader DTableH; + DTableH.tableLog = (U16)tableLog; + DTableH.fastMode = 1; + { S16 const largeLimit= (S16)(1 << (tableLog-1)); + U32 s; + for (s=0; s= largeLimit) DTableH.fastMode=0; + symbolNext[s] = normalizedCounter[s]; + } } } + memcpy(dt, &DTableH, sizeof(DTableH)); + } + + /* Spread symbols */ + { U32 const tableMask = tableSize-1; + U32 const step = FSE_TABLESTEP(tableSize); + U32 s, position = 0; + for (s=0; s highThreshold) position = (position + step) & tableMask; /* lowprob area */ + } } + if (position!=0) return ERROR(GENERIC); /* position must reach all cells once, otherwise normalizedCounter is incorrect */ + } + + /* Build Decoding table */ + { U32 u; + for (u=0; utableLog = 0; + DTableH->fastMode = 0; + + cell->newState = 0; + cell->symbol = symbolValue; + cell->nbBits = 0; + + return 0; +} + + +size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits) +{ + void* ptr = dt; + FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; + void* dPtr = dt + 1; + FSE_decode_t* const dinfo = (FSE_decode_t*)dPtr; + const unsigned tableSize = 1 << nbBits; + const unsigned tableMask = tableSize - 1; + const unsigned maxSV1 = tableMask+1; + unsigned s; + + /* Sanity checks */ + if (nbBits < 1) return ERROR(GENERIC); /* min size */ + + /* Build Decoding Table */ + DTableH->tableLog = (U16)nbBits; + DTableH->fastMode = 1; + for (s=0; s sizeof(bitD.bitContainer)*8) /* This test must be static */ + BIT_reloadDStream(&bitD); + + op[1] = FSE_GETSYMBOL(&state2); + + if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ + { if (BIT_reloadDStream(&bitD) > BIT_DStream_unfinished) { op+=2; break; } } + + op[2] = FSE_GETSYMBOL(&state1); + + if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ + BIT_reloadDStream(&bitD); + + op[3] = FSE_GETSYMBOL(&state2); + } + + /* tail */ + /* note : BIT_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */ + while (1) { + if (op>(omax-2)) return ERROR(dstSize_tooSmall); + *op++ = FSE_GETSYMBOL(&state1); + if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) { + *op++ = FSE_GETSYMBOL(&state2); + break; + } + + if (op>(omax-2)) return ERROR(dstSize_tooSmall); + *op++ = FSE_GETSYMBOL(&state2); + if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) { + *op++ = FSE_GETSYMBOL(&state1); + break; + } } + + return op-ostart; +} + + +size_t FSE_decompress_usingDTable(void* dst, size_t originalSize, + const void* cSrc, size_t cSrcSize, + const FSE_DTable* dt) +{ + const void* ptr = dt; + const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr; + const U32 fastMode = DTableH->fastMode; + + /* select fast mode (static) */ + if (fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1); + return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0); +} + + +size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog) +{ + const BYTE* const istart = (const BYTE*)cSrc; + const BYTE* ip = istart; + short counting[FSE_MAX_SYMBOL_VALUE+1]; + unsigned tableLog; + unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE; + + /* normal FSE decoding mode */ + size_t const NCountLength = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize); + if (FSE_isError(NCountLength)) return NCountLength; + //if (NCountLength >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size; supposed to be already checked in NCountLength, only remaining case : NCountLength==cSrcSize */ + if (tableLog > maxLog) return ERROR(tableLog_tooLarge); + ip += NCountLength; + cSrcSize -= NCountLength; + + CHECK_F( FSE_buildDTable (workSpace, counting, maxSymbolValue, tableLog) ); + + return FSE_decompress_usingDTable (dst, dstCapacity, ip, cSrcSize, workSpace); /* always return, even if it is an error code */ +} + + +typedef FSE_DTable DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)]; + +size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize) +{ + DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */ + return FSE_decompress_wksp(dst, dstCapacity, cSrc, cSrcSize, dt, FSE_MAX_TABLELOG); +} + + + +#endif /* FSE_COMMONDEFS_ONLY */ diff --git a/grub-core/lib/zstd/huf.h b/grub-core/lib/zstd/huf.h new file mode 100644 index 000000000..de9464111 --- /dev/null +++ b/grub-core/lib/zstd/huf.h @@ -0,0 +1,334 @@ +/* ****************************************************************** + huff0 huffman codec, + part of Finite State Entropy library + Copyright (C) 2013-present, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - Source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ + +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef HUF_H_298734234 +#define HUF_H_298734234 + +/* *** Dependencies *** */ +#include /* size_t */ + + +/* *** library symbols visibility *** */ +/* Note : when linking with -fvisibility=hidden on gcc, or by default on Visual, + * HUF symbols remain "private" (internal symbols for library only). + * Set macro FSE_DLL_EXPORT to 1 if you want HUF symbols visible on DLL interface */ +#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4) +# define HUF_PUBLIC_API __attribute__ ((visibility ("default"))) +#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */ +# define HUF_PUBLIC_API __declspec(dllexport) +#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1) +# define HUF_PUBLIC_API __declspec(dllimport) /* not required, just to generate faster code (saves a function pointer load from IAT and an indirect jump) */ +#else +# define HUF_PUBLIC_API +#endif + + +/* ========================== */ +/* *** simple functions *** */ +/* ========================== */ + +/** HUF_compress() : + * Compress content from buffer 'src', of size 'srcSize', into buffer 'dst'. + * 'dst' buffer must be already allocated. + * Compression runs faster if `dstCapacity` >= HUF_compressBound(srcSize). + * `srcSize` must be <= `HUF_BLOCKSIZE_MAX` == 128 KB. + * @return : size of compressed data (<= `dstCapacity`). + * Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!! + * if HUF_isError(return), compression failed (more details using HUF_getErrorName()) + */ +HUF_PUBLIC_API size_t HUF_compress(void* dst, size_t dstCapacity, + const void* src, size_t srcSize); + +/** HUF_decompress() : + * Decompress HUF data from buffer 'cSrc', of size 'cSrcSize', + * into already allocated buffer 'dst', of minimum size 'dstSize'. + * `originalSize` : **must** be the ***exact*** size of original (uncompressed) data. + * Note : in contrast with FSE, HUF_decompress can regenerate + * RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data, + * because it knows size to regenerate (originalSize). + * @return : size of regenerated data (== originalSize), + * or an error code, which can be tested using HUF_isError() + */ +HUF_PUBLIC_API size_t HUF_decompress(void* dst, size_t originalSize, + const void* cSrc, size_t cSrcSize); + + +/* *** Tool functions *** */ +#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */ +HUF_PUBLIC_API size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */ + +/* Error Management */ +HUF_PUBLIC_API unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */ +HUF_PUBLIC_API const char* HUF_getErrorName(size_t code); /**< provides error code string (useful for debugging) */ + + +/* *** Advanced function *** */ + +/** HUF_compress2() : + * Same as HUF_compress(), but offers control over `maxSymbolValue` and `tableLog`. + * `maxSymbolValue` must be <= HUF_SYMBOLVALUE_MAX . + * `tableLog` must be `<= HUF_TABLELOG_MAX` . */ +HUF_PUBLIC_API size_t HUF_compress2 (void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + unsigned maxSymbolValue, unsigned tableLog); + +/** HUF_compress4X_wksp() : + * Same as HUF_compress2(), but uses externally allocated `workSpace`. + * `workspace` must have minimum alignment of 4, and be at least as large as HUF_WORKSPACE_SIZE */ +#define HUF_WORKSPACE_SIZE (6 << 10) +#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32)) +HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + unsigned maxSymbolValue, unsigned tableLog, + void* workSpace, size_t wkspSize); + +#endif /* HUF_H_298734234 */ + +/* ****************************************************************** + * WARNING !! + * The following section contains advanced and experimental definitions + * which shall never be used in the context of a dynamic library, + * because they are not guaranteed to remain stable in the future. + * Only consider them in association with static linking. + * *****************************************************************/ +#if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY) +#define HUF_H_HUF_STATIC_LINKING_ONLY + +/* *** Dependencies *** */ +#include "mem.h" /* U32 */ + + +/* *** Constants *** */ +#define HUF_TABLELOG_MAX 12 /* max runtime value of tableLog (due to static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */ +#define HUF_TABLELOG_DEFAULT 11 /* default tableLog value when none specified */ +#define HUF_SYMBOLVALUE_MAX 255 + +#define HUF_TABLELOG_ABSOLUTEMAX 15 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */ +#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX) +# error "HUF_TABLELOG_MAX is too large !" +#endif + + +/* **************************************** +* Static allocation +******************************************/ +/* HUF buffer bounds */ +#define HUF_CTABLEBOUND 129 +#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8) /* only true when incompressible is pre-filtered with fast heuristic */ +#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size)) /* Macro version, useful for static allocation */ + +/* static allocation of HUF's Compression Table */ +#define HUF_CTABLE_SIZE_U32(maxSymbolValue) ((maxSymbolValue)+1) /* Use tables of U32, for proper alignment */ +#define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_U32(maxSymbolValue) * sizeof(U32)) +#define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \ + U32 name##hb[HUF_CTABLE_SIZE_U32(maxSymbolValue)]; \ + void* name##hv = &(name##hb); \ + HUF_CElt* name = (HUF_CElt*)(name##hv) /* no final ; */ + +/* static allocation of HUF's DTable */ +typedef U32 HUF_DTable; +#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog))) +#define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \ + HUF_DTable DTable[HUF_DTABLE_SIZE((maxTableLog)-1)] = { ((U32)((maxTableLog)-1) * 0x01000001) } +#define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \ + HUF_DTable DTable[HUF_DTABLE_SIZE(maxTableLog)] = { ((U32)(maxTableLog) * 0x01000001) } + + +/* **************************************** +* Advanced decompression functions +******************************************/ +size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */ +size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */ + +size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< decodes RLE and uncompressed */ +size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */ +size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */ +size_t HUF_decompress4X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */ +size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */ +size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */ +size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */ + + +/* **************************************** + * HUF detailed API + * ****************************************/ + +/*! HUF_compress() does the following: + * 1. count symbol occurrence from source[] into table count[] using FSE_count() (exposed within "fse.h") + * 2. (optional) refine tableLog using HUF_optimalTableLog() + * 3. build Huffman table from count using HUF_buildCTable() + * 4. save Huffman table to memory buffer using HUF_writeCTable() + * 5. encode the data stream using HUF_compress4X_usingCTable() + * + * The following API allows targeting specific sub-functions for advanced tasks. + * For example, it's possible to compress several blocks using the same 'CTable', + * or to save and regenerate 'CTable' using external methods. + */ +unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue); +typedef struct HUF_CElt_s HUF_CElt; /* incomplete type */ +size_t HUF_buildCTable (HUF_CElt* CTable, const unsigned* count, unsigned maxSymbolValue, unsigned maxNbBits); /* @return : maxNbBits; CTable and count can overlap. In which case, CTable will overwrite count content */ +size_t HUF_writeCTable (void* dst, size_t maxDstSize, const HUF_CElt* CTable, unsigned maxSymbolValue, unsigned huffLog); +size_t HUF_compress4X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable); + +typedef enum { + HUF_repeat_none, /**< Cannot use the previous table */ + HUF_repeat_check, /**< Can use the previous table but it must be checked. Note : The previous table must have been constructed by HUF_compress{1, 4}X_repeat */ + HUF_repeat_valid /**< Can use the previous table and it is assumed to be valid */ + } HUF_repeat; +/** HUF_compress4X_repeat() : + * Same as HUF_compress4X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none. + * If it uses hufTable it does not modify hufTable or repeat. + * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used. + * If preferRepeat then the old table will always be used if valid. */ +size_t HUF_compress4X_repeat(void* dst, size_t dstSize, + const void* src, size_t srcSize, + unsigned maxSymbolValue, unsigned tableLog, + void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */ + HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2); + +/** HUF_buildCTable_wksp() : + * Same as HUF_buildCTable(), but using externally allocated scratch buffer. + * `workSpace` must be aligned on 4-bytes boundaries, and its size must be >= HUF_CTABLE_WORKSPACE_SIZE. + */ +#define HUF_CTABLE_WORKSPACE_SIZE_U32 (2*HUF_SYMBOLVALUE_MAX +1 +1) +#define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned)) +size_t HUF_buildCTable_wksp (HUF_CElt* tree, + const U32* count, U32 maxSymbolValue, U32 maxNbBits, + void* workSpace, size_t wkspSize); + +/*! HUF_readStats() : + * Read compact Huffman tree, saved by HUF_writeCTable(). + * `huffWeight` is destination buffer. + * @return : size read from `src` , or an error Code . + * Note : Needed by HUF_readCTable() and HUF_readDTableXn() . */ +size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, + U32* rankStats, U32* nbSymbolsPtr, U32* tableLogPtr, + const void* src, size_t srcSize); + +/** HUF_readCTable() : + * Loading a CTable saved with HUF_writeCTable() */ +size_t HUF_readCTable (HUF_CElt* CTable, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize); + +/** HUF_getNbBits() : + * Read nbBits from CTable symbolTable, for symbol `symbolValue` presumed <= HUF_SYMBOLVALUE_MAX + * Note 1 : is not inlined, as HUF_CElt definition is private + * Note 2 : const void* used, so that it can provide a statically allocated table as argument (which uses type U32) */ +U32 HUF_getNbBits(const void* symbolTable, U32 symbolValue); + +/* + * HUF_decompress() does the following: + * 1. select the decompression algorithm (X1, X2) based on pre-computed heuristics + * 2. build Huffman table from save, using HUF_readDTableX?() + * 3. decode 1 or 4 segments in parallel using HUF_decompress?X?_usingDTable() + */ + +/** HUF_selectDecoder() : + * Tells which decoder is likely to decode faster, + * based on a set of pre-computed metrics. + * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 . + * Assumption : 0 < dstSize <= 128 KB */ +U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize); + +/** + * The minimum workspace size for the `workSpace` used in + * HUF_readDTableX1_wksp() and HUF_readDTableX2_wksp(). + * + * The space used depends on HUF_TABLELOG_MAX, ranging from ~1500 bytes when + * HUF_TABLE_LOG_MAX=12 to ~1850 bytes when HUF_TABLE_LOG_MAX=15. + * Buffer overflow errors may potentially occur if code modifications result in + * a required workspace size greater than that specified in the following + * macro. + */ +#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10) +#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32)) + +size_t HUF_readDTableX1 (HUF_DTable* DTable, const void* src, size_t srcSize); +size_t HUF_readDTableX1_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize); +size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize); +size_t HUF_readDTableX2_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize); + +size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); +size_t HUF_decompress4X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); +size_t HUF_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); + + +/* ====================== */ +/* single stream variants */ +/* ====================== */ + +size_t HUF_compress1X (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog); +size_t HUF_compress1X_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize); /**< `workSpace` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned */ +size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable); +/** HUF_compress1X_repeat() : + * Same as HUF_compress1X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none. + * If it uses hufTable it does not modify hufTable or repeat. + * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used. + * If preferRepeat then the old table will always be used if valid. */ +size_t HUF_compress1X_repeat(void* dst, size_t dstSize, + const void* src, size_t srcSize, + unsigned maxSymbolValue, unsigned tableLog, + void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */ + HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2); + +size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* single-symbol decoder */ +size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */ + +size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); +size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); +size_t HUF_decompress1X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */ +size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */ +size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */ +size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */ + +size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */ +size_t HUF_decompress1X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); +size_t HUF_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); + +/* BMI2 variants. + * If the CPU has BMI2 support, pass bmi2=1, otherwise pass bmi2=0. + */ +size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2); +size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2); +size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2); +size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2); + +#endif /* HUF_STATIC_LINKING_ONLY */ + +#if defined (__cplusplus) +} +#endif diff --git a/grub-core/lib/zstd/huf_decompress.c b/grub-core/lib/zstd/huf_decompress.c new file mode 100644 index 000000000..83ecaff01 --- /dev/null +++ b/grub-core/lib/zstd/huf_decompress.c @@ -0,0 +1,1096 @@ +/* ****************************************************************** + huff0 huffman decoder, + part of Finite State Entropy library + Copyright (C) 2013-present, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy +****************************************************************** */ + +/* ************************************************************** +* Dependencies +****************************************************************/ +#include /* memcpy, memset */ +#include "compiler.h" +#include "bitstream.h" /* BIT_* */ +#include "fse.h" /* to compress headers */ +#define HUF_STATIC_LINKING_ONLY +#include "huf.h" +#include "error_private.h" + + +/* ************************************************************** +* Error Management +****************************************************************/ +#define HUF_isError ERR_isError +#define CHECK_F(f) { size_t const err_ = (f); if (HUF_isError(err_)) return err_; } + + +/* ************************************************************** +* Byte alignment for workSpace management +****************************************************************/ +#define HUF_ALIGN(x, a) HUF_ALIGN_MASK((x), (a) - 1) +#define HUF_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) + + +/*-***************************/ +/* generic DTableDesc */ +/*-***************************/ +typedef struct { BYTE maxTableLog; BYTE tableType; BYTE tableLog; BYTE reserved; } DTableDesc; + +static DTableDesc HUF_getDTableDesc(const HUF_DTable* table) +{ + DTableDesc dtd; + memcpy(&dtd, table, sizeof(dtd)); + return dtd; +} + + +/*-***************************/ +/* single-symbol decoding */ +/*-***************************/ +typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX1; /* single-symbol decoding */ + +size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize) +{ + U32 tableLog = 0; + U32 nbSymbols = 0; + size_t iSize; + void* const dtPtr = DTable + 1; + HUF_DEltX1* const dt = (HUF_DEltX1*)dtPtr; + + U32* rankVal; + BYTE* huffWeight; + size_t spaceUsed32 = 0; + + rankVal = (U32 *)workSpace + spaceUsed32; + spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1; + huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32); + spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2; + + if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge); + + DEBUG_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable)); + /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */ + + iSize = HUF_readStats(huffWeight, HUF_SYMBOLVALUE_MAX + 1, rankVal, &nbSymbols, &tableLog, src, srcSize); + if (HUF_isError(iSize)) return iSize; + + /* Table header */ + { DTableDesc dtd = HUF_getDTableDesc(DTable); + if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small, Huffman tree cannot fit in */ + dtd.tableType = 0; + dtd.tableLog = (BYTE)tableLog; + memcpy(DTable, &dtd, sizeof(dtd)); + } + + /* Calculate starting value for each rank */ + { U32 n, nextRankStart = 0; + for (n=1; n> 1; + U32 u; + HUF_DEltX1 D; + D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w); + for (u = rankVal[w]; u < rankVal[w] + length; u++) + dt[u] = D; + rankVal[w] += length; + } } + + return iSize; +} + +size_t HUF_readDTableX1(HUF_DTable* DTable, const void* src, size_t srcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_readDTableX1_wksp(DTable, src, srcSize, + workSpace, sizeof(workSpace)); +} + +FORCE_INLINE_TEMPLATE BYTE +HUF_decodeSymbolX1(BIT_DStream_t* Dstream, const HUF_DEltX1* dt, const U32 dtLog) +{ + size_t const val = BIT_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */ + BYTE const c = dt[val].byte; + BIT_skipBits(Dstream, dt[val].nbBits); + return c; +} + +#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) \ + *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog) + +#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr) \ + if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \ + HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) + +#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr) \ + if (MEM_64bits()) \ + HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) + +HINT_INLINE size_t +HUF_decodeStreamX1(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX1* const dt, const U32 dtLog) +{ + BYTE* const pStart = p; + + /* up to 4 symbols at a time */ + while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-3)) { + HUF_DECODE_SYMBOLX1_2(p, bitDPtr); + HUF_DECODE_SYMBOLX1_1(p, bitDPtr); + HUF_DECODE_SYMBOLX1_2(p, bitDPtr); + HUF_DECODE_SYMBOLX1_0(p, bitDPtr); + } + + /* [0-3] symbols remaining */ + if (MEM_32bits()) + while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd)) + HUF_DECODE_SYMBOLX1_0(p, bitDPtr); + + /* no more data to retrieve from bitstream, no need to reload */ + while (p < pEnd) + HUF_DECODE_SYMBOLX1_0(p, bitDPtr); + + return pEnd-pStart; +} + +FORCE_INLINE_TEMPLATE size_t +HUF_decompress1X1_usingDTable_internal_body( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + BYTE* op = (BYTE*)dst; + BYTE* const oend = op + dstSize; + const void* dtPtr = DTable + 1; + const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr; + BIT_DStream_t bitD; + DTableDesc const dtd = HUF_getDTableDesc(DTable); + U32 const dtLog = dtd.tableLog; + + CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) ); + + HUF_decodeStreamX1(op, &bitD, oend, dt, dtLog); + + if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected); + + return dstSize; +} + +FORCE_INLINE_TEMPLATE size_t +HUF_decompress4X1_usingDTable_internal_body( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + /* Check */ + if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */ + + { const BYTE* const istart = (const BYTE*) cSrc; + BYTE* const ostart = (BYTE*) dst; + BYTE* const oend = ostart + dstSize; + const void* const dtPtr = DTable + 1; + const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr; + + /* Init */ + BIT_DStream_t bitD1; + BIT_DStream_t bitD2; + BIT_DStream_t bitD3; + BIT_DStream_t bitD4; + size_t const length1 = MEM_readLE16(istart); + size_t const length2 = MEM_readLE16(istart+2); + size_t const length3 = MEM_readLE16(istart+4); + size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6); + const BYTE* const istart1 = istart + 6; /* jumpTable */ + const BYTE* const istart2 = istart1 + length1; + const BYTE* const istart3 = istart2 + length2; + const BYTE* const istart4 = istart3 + length3; + const size_t segmentSize = (dstSize+3) / 4; + BYTE* const opStart2 = ostart + segmentSize; + BYTE* const opStart3 = opStart2 + segmentSize; + BYTE* const opStart4 = opStart3 + segmentSize; + BYTE* op1 = ostart; + BYTE* op2 = opStart2; + BYTE* op3 = opStart3; + BYTE* op4 = opStart4; + U32 endSignal = BIT_DStream_unfinished; + DTableDesc const dtd = HUF_getDTableDesc(DTable); + U32 const dtLog = dtd.tableLog; + + if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */ + CHECK_F( BIT_initDStream(&bitD1, istart1, length1) ); + CHECK_F( BIT_initDStream(&bitD2, istart2, length2) ); + CHECK_F( BIT_initDStream(&bitD3, istart3, length3) ); + CHECK_F( BIT_initDStream(&bitD4, istart4, length4) ); + + /* up to 16 symbols per loop (4 symbols per stream) in 64-bit mode */ + endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); + while ( (endSignal==BIT_DStream_unfinished) && (op4<(oend-3)) ) { + HUF_DECODE_SYMBOLX1_2(op1, &bitD1); + HUF_DECODE_SYMBOLX1_2(op2, &bitD2); + HUF_DECODE_SYMBOLX1_2(op3, &bitD3); + HUF_DECODE_SYMBOLX1_2(op4, &bitD4); + HUF_DECODE_SYMBOLX1_1(op1, &bitD1); + HUF_DECODE_SYMBOLX1_1(op2, &bitD2); + HUF_DECODE_SYMBOLX1_1(op3, &bitD3); + HUF_DECODE_SYMBOLX1_1(op4, &bitD4); + HUF_DECODE_SYMBOLX1_2(op1, &bitD1); + HUF_DECODE_SYMBOLX1_2(op2, &bitD2); + HUF_DECODE_SYMBOLX1_2(op3, &bitD3); + HUF_DECODE_SYMBOLX1_2(op4, &bitD4); + HUF_DECODE_SYMBOLX1_0(op1, &bitD1); + HUF_DECODE_SYMBOLX1_0(op2, &bitD2); + HUF_DECODE_SYMBOLX1_0(op3, &bitD3); + HUF_DECODE_SYMBOLX1_0(op4, &bitD4); + BIT_reloadDStream(&bitD1); + BIT_reloadDStream(&bitD2); + BIT_reloadDStream(&bitD3); + BIT_reloadDStream(&bitD4); + } + + /* check corruption */ + /* note : should not be necessary : op# advance in lock step, and we control op4. + * but curiously, binary generated by gcc 7.2 & 7.3 with -mbmi2 runs faster when >=1 test is present */ + if (op1 > opStart2) return ERROR(corruption_detected); + if (op2 > opStart3) return ERROR(corruption_detected); + if (op3 > opStart4) return ERROR(corruption_detected); + /* note : op4 supposed already verified within main loop */ + + /* finish bitStreams one by one */ + HUF_decodeStreamX1(op1, &bitD1, opStart2, dt, dtLog); + HUF_decodeStreamX1(op2, &bitD2, opStart3, dt, dtLog); + HUF_decodeStreamX1(op3, &bitD3, opStart4, dt, dtLog); + HUF_decodeStreamX1(op4, &bitD4, oend, dt, dtLog); + + /* check */ + { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4); + if (!endCheck) return ERROR(corruption_detected); } + + /* decoded size */ + return dstSize; + } +} + + +typedef size_t (*HUF_decompress_usingDTable_t)(void *dst, size_t dstSize, + const void *cSrc, + size_t cSrcSize, + const HUF_DTable *DTable); +#if DYNAMIC_BMI2 + +#define HUF_DGEN(fn) \ + \ + static size_t fn##_default( \ + void* dst, size_t dstSize, \ + const void* cSrc, size_t cSrcSize, \ + const HUF_DTable* DTable) \ + { \ + return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \ + } \ + \ + static TARGET_ATTRIBUTE("bmi2") size_t fn##_bmi2( \ + void* dst, size_t dstSize, \ + const void* cSrc, size_t cSrcSize, \ + const HUF_DTable* DTable) \ + { \ + return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \ + } \ + \ + static size_t fn(void* dst, size_t dstSize, void const* cSrc, \ + size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \ + { \ + if (bmi2) { \ + return fn##_bmi2(dst, dstSize, cSrc, cSrcSize, DTable); \ + } \ + return fn##_default(dst, dstSize, cSrc, cSrcSize, DTable); \ + } + +#else + +#define HUF_DGEN(fn) \ + static size_t fn(void* dst, size_t dstSize, void const* cSrc, \ + size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \ + { \ + (void)bmi2; \ + return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \ + } + +#endif + +HUF_DGEN(HUF_decompress1X1_usingDTable_internal) +HUF_DGEN(HUF_decompress4X1_usingDTable_internal) + + + +size_t HUF_decompress1X1_usingDTable( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc dtd = HUF_getDTableDesc(DTable); + if (dtd.tableType != 0) return ERROR(GENERIC); + return HUF_decompress1X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + +size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize) +{ + const BYTE* ip = (const BYTE*) cSrc; + + size_t const hSize = HUF_readDTableX1_wksp(DCtx, cSrc, cSrcSize, workSpace, wkspSize); + if (HUF_isError(hSize)) return hSize; + if (hSize >= cSrcSize) return ERROR(srcSize_wrong); + ip += hSize; cSrcSize -= hSize; + + return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0); +} + + +size_t HUF_decompress1X1_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress1X1_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} + +size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX); + return HUF_decompress1X1_DCtx (DTable, dst, dstSize, cSrc, cSrcSize); +} + +size_t HUF_decompress4X1_usingDTable( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc dtd = HUF_getDTableDesc(DTable); + if (dtd.tableType != 0) return ERROR(GENERIC); + return HUF_decompress4X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + +static size_t HUF_decompress4X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize, int bmi2) +{ + const BYTE* ip = (const BYTE*) cSrc; + + size_t const hSize = HUF_readDTableX1_wksp (dctx, cSrc, cSrcSize, + workSpace, wkspSize); + if (HUF_isError(hSize)) return hSize; + if (hSize >= cSrcSize) return ERROR(srcSize_wrong); + ip += hSize; cSrcSize -= hSize; + + return HUF_decompress4X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2); +} + +size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize) +{ + return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, 0); +} + + +size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} +size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX); + return HUF_decompress4X1_DCtx(DTable, dst, dstSize, cSrc, cSrcSize); +} + + +/* *************************/ +/* double-symbols decoding */ +/* *************************/ + +typedef struct { U16 sequence; BYTE nbBits; BYTE length; } HUF_DEltX2; /* double-symbols decoding */ +typedef struct { BYTE symbol; BYTE weight; } sortedSymbol_t; +typedef U32 rankValCol_t[HUF_TABLELOG_MAX + 1]; +typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX]; + + +/* HUF_fillDTableX2Level2() : + * `rankValOrigin` must be a table of at least (HUF_TABLELOG_MAX + 1) U32 */ +static void HUF_fillDTableX2Level2(HUF_DEltX2* DTable, U32 sizeLog, const U32 consumed, + const U32* rankValOrigin, const int minWeight, + const sortedSymbol_t* sortedSymbols, const U32 sortedListSize, + U32 nbBitsBaseline, U16 baseSeq) +{ + HUF_DEltX2 DElt; + U32 rankVal[HUF_TABLELOG_MAX + 1]; + + /* get pre-calculated rankVal */ + memcpy(rankVal, rankValOrigin, sizeof(rankVal)); + + /* fill skipped values */ + if (minWeight>1) { + U32 i, skipSize = rankVal[minWeight]; + MEM_writeLE16(&(DElt.sequence), baseSeq); + DElt.nbBits = (BYTE)(consumed); + DElt.length = 1; + for (i = 0; i < skipSize; i++) + DTable[i] = DElt; + } + + /* fill DTable */ + { U32 s; for (s=0; s= 1 */ + + rankVal[weight] += length; + } } +} + + +static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog, + const sortedSymbol_t* sortedList, const U32 sortedListSize, + const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight, + const U32 nbBitsBaseline) +{ + U32 rankVal[HUF_TABLELOG_MAX + 1]; + const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */ + const U32 minBits = nbBitsBaseline - maxWeight; + U32 s; + + memcpy(rankVal, rankValOrigin, sizeof(rankVal)); + + /* fill DTable */ + for (s=0; s= minBits) { /* enough room for a second symbol */ + U32 sortedRank; + int minWeight = nbBits + scaleLog; + if (minWeight < 1) minWeight = 1; + sortedRank = rankStart[minWeight]; + HUF_fillDTableX2Level2(DTable+start, targetLog-nbBits, nbBits, + rankValOrigin[nbBits], minWeight, + sortedList+sortedRank, sortedListSize-sortedRank, + nbBitsBaseline, symbol); + } else { + HUF_DEltX2 DElt; + MEM_writeLE16(&(DElt.sequence), symbol); + DElt.nbBits = (BYTE)(nbBits); + DElt.length = 1; + { U32 const end = start + length; + U32 u; + for (u = start; u < end; u++) DTable[u] = DElt; + } } + rankVal[weight] += length; + } +} + +size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, + const void* src, size_t srcSize, + void* workSpace, size_t wkspSize) +{ + U32 tableLog, maxW, sizeOfSort, nbSymbols; + DTableDesc dtd = HUF_getDTableDesc(DTable); + U32 const maxTableLog = dtd.maxTableLog; + size_t iSize; + void* dtPtr = DTable+1; /* force compiler to avoid strict-aliasing */ + HUF_DEltX2* const dt = (HUF_DEltX2*)dtPtr; + U32 *rankStart; + + rankValCol_t* rankVal; + U32* rankStats; + U32* rankStart0; + sortedSymbol_t* sortedSymbol; + BYTE* weightList; + size_t spaceUsed32 = 0; + + rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32); + spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2; + rankStats = (U32 *)workSpace + spaceUsed32; + spaceUsed32 += HUF_TABLELOG_MAX + 1; + rankStart0 = (U32 *)workSpace + spaceUsed32; + spaceUsed32 += HUF_TABLELOG_MAX + 2; + sortedSymbol = (sortedSymbol_t *)workSpace + (spaceUsed32 * sizeof(U32)) / sizeof(sortedSymbol_t); + spaceUsed32 += HUF_ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2; + weightList = (BYTE *)((U32 *)workSpace + spaceUsed32); + spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2; + + if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge); + + rankStart = rankStart0 + 1; + memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1)); + + DEBUG_STATIC_ASSERT(sizeof(HUF_DEltX2) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */ + if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge); + /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */ + + iSize = HUF_readStats(weightList, HUF_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize); + if (HUF_isError(iSize)) return iSize; + + /* check result */ + if (tableLog > maxTableLog) return ERROR(tableLog_tooLarge); /* DTable can't fit code depth */ + + /* find maxWeight */ + for (maxW = tableLog; rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */ + + /* Get start index of each weight */ + { U32 w, nextRankStart = 0; + for (w=1; w> consumed; + } } } } + + HUF_fillDTableX2(dt, maxTableLog, + sortedSymbol, sizeOfSort, + rankStart0, rankVal, maxW, + tableLog+1); + + dtd.tableLog = (BYTE)maxTableLog; + dtd.tableType = 1; + memcpy(DTable, &dtd, sizeof(dtd)); + return iSize; +} + +size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_readDTableX2_wksp(DTable, src, srcSize, + workSpace, sizeof(workSpace)); +} + + +FORCE_INLINE_TEMPLATE U32 +HUF_decodeSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog) +{ + size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ + memcpy(op, dt+val, 2); + BIT_skipBits(DStream, dt[val].nbBits); + return dt[val].length; +} + +FORCE_INLINE_TEMPLATE U32 +HUF_decodeLastSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog) +{ + size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ + memcpy(op, dt+val, 1); + if (dt[val].length==1) BIT_skipBits(DStream, dt[val].nbBits); + else { + if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) { + BIT_skipBits(DStream, dt[val].nbBits); + if (DStream->bitsConsumed > (sizeof(DStream->bitContainer)*8)) + /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */ + DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8); + } } + return 1; +} + +#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \ + ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog) + +#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \ + if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \ + ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog) + +#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \ + if (MEM_64bits()) \ + ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog) + +HINT_INLINE size_t +HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd, + const HUF_DEltX2* const dt, const U32 dtLog) +{ + BYTE* const pStart = p; + + /* up to 8 symbols at a time */ + while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-(sizeof(bitDPtr->bitContainer)-1))) { + HUF_DECODE_SYMBOLX2_2(p, bitDPtr); + HUF_DECODE_SYMBOLX2_1(p, bitDPtr); + HUF_DECODE_SYMBOLX2_2(p, bitDPtr); + HUF_DECODE_SYMBOLX2_0(p, bitDPtr); + } + + /* closer to end : up to 2 symbols at a time */ + while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p <= pEnd-2)) + HUF_DECODE_SYMBOLX2_0(p, bitDPtr); + + while (p <= pEnd-2) + HUF_DECODE_SYMBOLX2_0(p, bitDPtr); /* no need to reload : reached the end of DStream */ + + if (p < pEnd) + p += HUF_decodeLastSymbolX2(p, bitDPtr, dt, dtLog); + + return p-pStart; +} + +FORCE_INLINE_TEMPLATE size_t +HUF_decompress1X2_usingDTable_internal_body( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + BIT_DStream_t bitD; + + /* Init */ + CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) ); + + /* decode */ + { BYTE* const ostart = (BYTE*) dst; + BYTE* const oend = ostart + dstSize; + const void* const dtPtr = DTable+1; /* force compiler to not use strict-aliasing */ + const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr; + DTableDesc const dtd = HUF_getDTableDesc(DTable); + HUF_decodeStreamX2(ostart, &bitD, oend, dt, dtd.tableLog); + } + + /* check */ + if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected); + + /* decoded size */ + return dstSize; +} + + +FORCE_INLINE_TEMPLATE size_t +HUF_decompress4X2_usingDTable_internal_body( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */ + + { const BYTE* const istart = (const BYTE*) cSrc; + BYTE* const ostart = (BYTE*) dst; + BYTE* const oend = ostart + dstSize; + const void* const dtPtr = DTable+1; + const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr; + + /* Init */ + BIT_DStream_t bitD1; + BIT_DStream_t bitD2; + BIT_DStream_t bitD3; + BIT_DStream_t bitD4; + size_t const length1 = MEM_readLE16(istart); + size_t const length2 = MEM_readLE16(istart+2); + size_t const length3 = MEM_readLE16(istart+4); + size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6); + const BYTE* const istart1 = istart + 6; /* jumpTable */ + const BYTE* const istart2 = istart1 + length1; + const BYTE* const istart3 = istart2 + length2; + const BYTE* const istart4 = istart3 + length3; + size_t const segmentSize = (dstSize+3) / 4; + BYTE* const opStart2 = ostart + segmentSize; + BYTE* const opStart3 = opStart2 + segmentSize; + BYTE* const opStart4 = opStart3 + segmentSize; + BYTE* op1 = ostart; + BYTE* op2 = opStart2; + BYTE* op3 = opStart3; + BYTE* op4 = opStart4; + U32 endSignal; + DTableDesc const dtd = HUF_getDTableDesc(DTable); + U32 const dtLog = dtd.tableLog; + + if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */ + CHECK_F( BIT_initDStream(&bitD1, istart1, length1) ); + CHECK_F( BIT_initDStream(&bitD2, istart2, length2) ); + CHECK_F( BIT_initDStream(&bitD3, istart3, length3) ); + CHECK_F( BIT_initDStream(&bitD4, istart4, length4) ); + + /* 16-32 symbols per loop (4-8 symbols per stream) */ + endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); + for ( ; (endSignal==BIT_DStream_unfinished) & (op4<(oend-(sizeof(bitD4.bitContainer)-1))) ; ) { + HUF_DECODE_SYMBOLX2_2(op1, &bitD1); + HUF_DECODE_SYMBOLX2_2(op2, &bitD2); + HUF_DECODE_SYMBOLX2_2(op3, &bitD3); + HUF_DECODE_SYMBOLX2_2(op4, &bitD4); + HUF_DECODE_SYMBOLX2_1(op1, &bitD1); + HUF_DECODE_SYMBOLX2_1(op2, &bitD2); + HUF_DECODE_SYMBOLX2_1(op3, &bitD3); + HUF_DECODE_SYMBOLX2_1(op4, &bitD4); + HUF_DECODE_SYMBOLX2_2(op1, &bitD1); + HUF_DECODE_SYMBOLX2_2(op2, &bitD2); + HUF_DECODE_SYMBOLX2_2(op3, &bitD3); + HUF_DECODE_SYMBOLX2_2(op4, &bitD4); + HUF_DECODE_SYMBOLX2_0(op1, &bitD1); + HUF_DECODE_SYMBOLX2_0(op2, &bitD2); + HUF_DECODE_SYMBOLX2_0(op3, &bitD3); + HUF_DECODE_SYMBOLX2_0(op4, &bitD4); + + endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); + } + + /* check corruption */ + if (op1 > opStart2) return ERROR(corruption_detected); + if (op2 > opStart3) return ERROR(corruption_detected); + if (op3 > opStart4) return ERROR(corruption_detected); + /* note : op4 already verified within main loop */ + + /* finish bitStreams one by one */ + HUF_decodeStreamX2(op1, &bitD1, opStart2, dt, dtLog); + HUF_decodeStreamX2(op2, &bitD2, opStart3, dt, dtLog); + HUF_decodeStreamX2(op3, &bitD3, opStart4, dt, dtLog); + HUF_decodeStreamX2(op4, &bitD4, oend, dt, dtLog); + + /* check */ + { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4); + if (!endCheck) return ERROR(corruption_detected); } + + /* decoded size */ + return dstSize; + } +} + +HUF_DGEN(HUF_decompress1X2_usingDTable_internal) +HUF_DGEN(HUF_decompress4X2_usingDTable_internal) + +size_t HUF_decompress1X2_usingDTable( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc dtd = HUF_getDTableDesc(DTable); + if (dtd.tableType != 1) return ERROR(GENERIC); + return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + +size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize) +{ + const BYTE* ip = (const BYTE*) cSrc; + + size_t const hSize = HUF_readDTableX2_wksp(DCtx, cSrc, cSrcSize, + workSpace, wkspSize); + if (HUF_isError(hSize)) return hSize; + if (hSize >= cSrcSize) return ERROR(srcSize_wrong); + ip += hSize; cSrcSize -= hSize; + + return HUF_decompress1X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0); +} + + +size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} + +size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX); + return HUF_decompress1X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize); +} + +size_t HUF_decompress4X2_usingDTable( + void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc dtd = HUF_getDTableDesc(DTable); + if (dtd.tableType != 1) return ERROR(GENERIC); + return HUF_decompress4X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + +static size_t HUF_decompress4X2_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize, int bmi2) +{ + const BYTE* ip = (const BYTE*) cSrc; + + size_t hSize = HUF_readDTableX2_wksp(dctx, cSrc, cSrcSize, + workSpace, wkspSize); + if (HUF_isError(hSize)) return hSize; + if (hSize >= cSrcSize) return ERROR(srcSize_wrong); + ip += hSize; cSrcSize -= hSize; + + return HUF_decompress4X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2); +} + +size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize) +{ + return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, /* bmi2 */ 0); +} + + +size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} + +size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX); + return HUF_decompress4X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize); +} + + +/* ***********************************/ +/* Universal decompression selectors */ +/* ***********************************/ + +size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc const dtd = HUF_getDTableDesc(DTable); + return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) : + HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + +size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, + const void* cSrc, size_t cSrcSize, + const HUF_DTable* DTable) +{ + DTableDesc const dtd = HUF_getDTableDesc(DTable); + return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) : + HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0); +} + + +typedef struct { U32 tableTime; U32 decode256Time; } algo_time_t; +static const algo_time_t algoTime[16 /* Quantization */][3 /* single, double, quad */] = +{ + /* single, double, quad */ + {{0,0}, {1,1}, {2,2}}, /* Q==0 : impossible */ + {{0,0}, {1,1}, {2,2}}, /* Q==1 : impossible */ + {{ 38,130}, {1313, 74}, {2151, 38}}, /* Q == 2 : 12-18% */ + {{ 448,128}, {1353, 74}, {2238, 41}}, /* Q == 3 : 18-25% */ + {{ 556,128}, {1353, 74}, {2238, 47}}, /* Q == 4 : 25-32% */ + {{ 714,128}, {1418, 74}, {2436, 53}}, /* Q == 5 : 32-38% */ + {{ 883,128}, {1437, 74}, {2464, 61}}, /* Q == 6 : 38-44% */ + {{ 897,128}, {1515, 75}, {2622, 68}}, /* Q == 7 : 44-50% */ + {{ 926,128}, {1613, 75}, {2730, 75}}, /* Q == 8 : 50-56% */ + {{ 947,128}, {1729, 77}, {3359, 77}}, /* Q == 9 : 56-62% */ + {{1107,128}, {2083, 81}, {4006, 84}}, /* Q ==10 : 62-69% */ + {{1177,128}, {2379, 87}, {4785, 88}}, /* Q ==11 : 69-75% */ + {{1242,128}, {2415, 93}, {5155, 84}}, /* Q ==12 : 75-81% */ + {{1349,128}, {2644,106}, {5260,106}}, /* Q ==13 : 81-87% */ + {{1455,128}, {2422,124}, {4174,124}}, /* Q ==14 : 87-93% */ + {{ 722,128}, {1891,145}, {1936,146}}, /* Q ==15 : 93-99% */ +}; + +/** HUF_selectDecoder() : + * Tells which decoder is likely to decode faster, + * based on a set of pre-computed metrics. + * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 . + * Assumption : 0 < dstSize <= 128 KB */ +U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize) +{ + assert(dstSize > 0); + assert(dstSize <= 128*1024); + /* decoder timing evaluation */ + { U32 const Q = (cSrcSize >= dstSize) ? 15 : (U32)(cSrcSize * 16 / dstSize); /* Q < 16 */ + U32 const D256 = (U32)(dstSize >> 8); + U32 const DTime0 = algoTime[Q][0].tableTime + (algoTime[Q][0].decode256Time * D256); + U32 DTime1 = algoTime[Q][1].tableTime + (algoTime[Q][1].decode256Time * D256); + DTime1 += DTime1 >> 3; /* advantage to algorithm using less memory, to reduce cache eviction */ + return DTime1 < DTime0; +} } + + +typedef size_t (*decompressionAlgo)(void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); + +size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 }; + + /* validation checks */ + if (dstSize == 0) return ERROR(dstSize_tooSmall); + if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */ + if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */ + if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */ + + { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); + return decompress[algoNb](dst, dstSize, cSrc, cSrcSize); + } +} + +size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + /* validation checks */ + if (dstSize == 0) return ERROR(dstSize_tooSmall); + if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */ + if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */ + if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */ + + { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); + return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) : + HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ; + } +} + +size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} + + +size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, + size_t dstSize, const void* cSrc, + size_t cSrcSize, void* workSpace, + size_t wkspSize) +{ + /* validation checks */ + if (dstSize == 0) return ERROR(dstSize_tooSmall); + if (cSrcSize == 0) return ERROR(corruption_detected); + + { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); + return algoNb ? HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize): + HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize); + } +} + +size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize, + void* workSpace, size_t wkspSize) +{ + /* validation checks */ + if (dstSize == 0) return ERROR(dstSize_tooSmall); + if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */ + if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */ + if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */ + + { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); + return algoNb ? HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc, + cSrcSize, workSpace, wkspSize): + HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc, + cSrcSize, workSpace, wkspSize); + } +} + +size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, + const void* cSrc, size_t cSrcSize) +{ + U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; + return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, + workSpace, sizeof(workSpace)); +} + + +size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2) +{ + DTableDesc const dtd = HUF_getDTableDesc(DTable); + return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) : + HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2); +} + +size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2) +{ + const BYTE* ip = (const BYTE*) cSrc; + + size_t const hSize = HUF_readDTableX1_wksp(dctx, cSrc, cSrcSize, workSpace, wkspSize); + if (HUF_isError(hSize)) return hSize; + if (hSize >= cSrcSize) return ERROR(srcSize_wrong); + ip += hSize; cSrcSize -= hSize; + + return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2); +} + +size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2) +{ + DTableDesc const dtd = HUF_getDTableDesc(DTable); + return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) : + HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2); +} + +size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2) +{ + /* validation checks */ + if (dstSize == 0) return ERROR(dstSize_tooSmall); + if (cSrcSize == 0) return ERROR(corruption_detected); + + { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); + return algoNb ? HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2) : + HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2); + } +} diff --git a/grub-core/lib/zstd/mem.h b/grub-core/lib/zstd/mem.h new file mode 100644 index 000000000..2051bcad1 --- /dev/null +++ b/grub-core/lib/zstd/mem.h @@ -0,0 +1,374 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef MEM_H_MODULE +#define MEM_H_MODULE + +#if defined (__cplusplus) +extern "C" { +#endif + +/*-**************************************** +* Dependencies +******************************************/ +#include /* size_t, ptrdiff_t */ +#include /* memcpy */ + + +/*-**************************************** +* Compiler specifics +******************************************/ +#if defined(_MSC_VER) /* Visual Studio */ +# include /* _byteswap_ulong */ +# include /* _byteswap_* */ +#endif +#if defined(__GNUC__) +# define MEM_STATIC static __inline __attribute__((unused)) +#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) +# define MEM_STATIC static inline +#elif defined(_MSC_VER) +# define MEM_STATIC static __inline +#else +# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ +#endif + +/* code only tested on 32 and 64 bits systems */ +#define MEM_STATIC_ASSERT(c) { enum { MEM_static_assert = 1/(int)(!!(c)) }; } +MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); } + + +/*-************************************************************** +* Basic Types +*****************************************************************/ +#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef int16_t S16; + typedef uint32_t U32; + typedef int32_t S32; + typedef uint64_t U64; + typedef int64_t S64; +#else +# include +#if CHAR_BIT != 8 +# error "this implementation requires char to be exactly 8-bit type" +#endif + typedef unsigned char BYTE; +#if USHRT_MAX != 65535 +# error "this implementation requires short to be exactly 16-bit type" +#endif + typedef unsigned short U16; + typedef signed short S16; +#if UINT_MAX != 4294967295 +# error "this implementation requires int to be exactly 32-bit type" +#endif + typedef unsigned int U32; + typedef signed int S32; +/* note : there are no limits defined for long long type in C90. + * limits exist in C99, however, in such case, is preferred */ + typedef unsigned long long U64; + typedef signed long long S64; +#endif + + +/*-************************************************************** +* Memory I/O +*****************************************************************/ +/* MEM_FORCE_MEMORY_ACCESS : + * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable. + * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal. + * The below switch allow to select different access method for improved performance. + * Method 0 (default) : use `memcpy()`. Safe and portable. + * Method 1 : `__packed` statement. It depends on compiler extension (i.e., not portable). + * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`. + * Method 2 : direct access. This method is portable but violate C standard. + * It can generate buggy code on targets depending on alignment. + * In some circumstances, it's the only known way to get the most performance (i.e. GCC + ARMv6) + * See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details. + * Prefer these methods in priority order (0 > 1 > 2) + */ +#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ +# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ) +# define MEM_FORCE_MEMORY_ACCESS 2 +# elif defined(__INTEL_COMPILER) || defined(__GNUC__) +# define MEM_FORCE_MEMORY_ACCESS 1 +# endif +#endif + +MEM_STATIC unsigned MEM_32bits(void) { return sizeof(size_t)==4; } +MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; } + +MEM_STATIC unsigned MEM_isLittleEndian(void) +{ + const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ + return one.c[0]; +} + +#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2) + +/* violates C standard, by lying on structure alignment. +Only use if no other choice to achieve best performance on target platform */ +MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; } +MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; } +MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; } +MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; } + +MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; } +MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; } +MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; } + +#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1) + +/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ +/* currently only defined for gcc and icc */ +#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32)) + __pragma( pack(push, 1) ) + typedef struct { U16 v; } unalign16; + typedef struct { U32 v; } unalign32; + typedef struct { U64 v; } unalign64; + typedef struct { size_t v; } unalignArch; + __pragma( pack(pop) ) +#else + typedef struct { U16 v; } __attribute__((packed)) unalign16; + typedef struct { U32 v; } __attribute__((packed)) unalign32; + typedef struct { U64 v; } __attribute__((packed)) unalign64; + typedef struct { size_t v; } __attribute__((packed)) unalignArch; +#endif + +MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; } +MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; } +MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; } +MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; } + +MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; } +MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; } +MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; } + +#else + +/* default method, safe and standard. + can sometimes prove slower */ + +MEM_STATIC U16 MEM_read16(const void* memPtr) +{ + U16 val; memcpy(&val, memPtr, sizeof(val)); return val; +} + +MEM_STATIC U32 MEM_read32(const void* memPtr) +{ + U32 val; memcpy(&val, memPtr, sizeof(val)); return val; +} + +MEM_STATIC U64 MEM_read64(const void* memPtr) +{ + U64 val; memcpy(&val, memPtr, sizeof(val)); return val; +} + +MEM_STATIC size_t MEM_readST(const void* memPtr) +{ + size_t val; memcpy(&val, memPtr, sizeof(val)); return val; +} + +MEM_STATIC void MEM_write16(void* memPtr, U16 value) +{ + memcpy(memPtr, &value, sizeof(value)); +} + +MEM_STATIC void MEM_write32(void* memPtr, U32 value) +{ + memcpy(memPtr, &value, sizeof(value)); +} + +MEM_STATIC void MEM_write64(void* memPtr, U64 value) +{ + memcpy(memPtr, &value, sizeof(value)); +} + +#endif /* MEM_FORCE_MEMORY_ACCESS */ + +MEM_STATIC U32 MEM_swap32(U32 in) +{ +#if defined(_MSC_VER) /* Visual Studio */ + return _byteswap_ulong(in); +#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403) + return __builtin_bswap32(in); +#else + return ((in << 24) & 0xff000000 ) | + ((in << 8) & 0x00ff0000 ) | + ((in >> 8) & 0x0000ff00 ) | + ((in >> 24) & 0x000000ff ); +#endif +} + +MEM_STATIC U64 MEM_swap64(U64 in) +{ +#if defined(_MSC_VER) /* Visual Studio */ + return _byteswap_uint64(in); +#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403) + return __builtin_bswap64(in); +#else + return ((in << 56) & 0xff00000000000000ULL) | + ((in << 40) & 0x00ff000000000000ULL) | + ((in << 24) & 0x0000ff0000000000ULL) | + ((in << 8) & 0x000000ff00000000ULL) | + ((in >> 8) & 0x00000000ff000000ULL) | + ((in >> 24) & 0x0000000000ff0000ULL) | + ((in >> 40) & 0x000000000000ff00ULL) | + ((in >> 56) & 0x00000000000000ffULL); +#endif +} + +MEM_STATIC size_t MEM_swapST(size_t in) +{ + if (MEM_32bits()) + return (size_t)MEM_swap32((U32)in); + else + return (size_t)MEM_swap64((U64)in); +} + +/*=== Little endian r/w ===*/ + +MEM_STATIC U16 MEM_readLE16(const void* memPtr) +{ + if (MEM_isLittleEndian()) + return MEM_read16(memPtr); + else { + const BYTE* p = (const BYTE*)memPtr; + return (U16)(p[0] + (p[1]<<8)); + } +} + +MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val) +{ + if (MEM_isLittleEndian()) { + MEM_write16(memPtr, val); + } else { + BYTE* p = (BYTE*)memPtr; + p[0] = (BYTE)val; + p[1] = (BYTE)(val>>8); + } +} + +MEM_STATIC U32 MEM_readLE24(const void* memPtr) +{ + return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16); +} + +MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val) +{ + MEM_writeLE16(memPtr, (U16)val); + ((BYTE*)memPtr)[2] = (BYTE)(val>>16); +} + +MEM_STATIC U32 MEM_readLE32(const void* memPtr) +{ + if (MEM_isLittleEndian()) + return MEM_read32(memPtr); + else + return MEM_swap32(MEM_read32(memPtr)); +} + +MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32) +{ + if (MEM_isLittleEndian()) + MEM_write32(memPtr, val32); + else + MEM_write32(memPtr, MEM_swap32(val32)); +} + +MEM_STATIC U64 MEM_readLE64(const void* memPtr) +{ + if (MEM_isLittleEndian()) + return MEM_read64(memPtr); + else + return MEM_swap64(MEM_read64(memPtr)); +} + +MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64) +{ + if (MEM_isLittleEndian()) + MEM_write64(memPtr, val64); + else + MEM_write64(memPtr, MEM_swap64(val64)); +} + +MEM_STATIC size_t MEM_readLEST(const void* memPtr) +{ + if (MEM_32bits()) + return (size_t)MEM_readLE32(memPtr); + else + return (size_t)MEM_readLE64(memPtr); +} + +MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val) +{ + if (MEM_32bits()) + MEM_writeLE32(memPtr, (U32)val); + else + MEM_writeLE64(memPtr, (U64)val); +} + +/*=== Big endian r/w ===*/ + +MEM_STATIC U32 MEM_readBE32(const void* memPtr) +{ + if (MEM_isLittleEndian()) + return MEM_swap32(MEM_read32(memPtr)); + else + return MEM_read32(memPtr); +} + +MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32) +{ + if (MEM_isLittleEndian()) + MEM_write32(memPtr, MEM_swap32(val32)); + else + MEM_write32(memPtr, val32); +} + +MEM_STATIC U64 MEM_readBE64(const void* memPtr) +{ + if (MEM_isLittleEndian()) + return MEM_swap64(MEM_read64(memPtr)); + else + return MEM_read64(memPtr); +} + +MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64) +{ + if (MEM_isLittleEndian()) + MEM_write64(memPtr, MEM_swap64(val64)); + else + MEM_write64(memPtr, val64); +} + +MEM_STATIC size_t MEM_readBEST(const void* memPtr) +{ + if (MEM_32bits()) + return (size_t)MEM_readBE32(memPtr); + else + return (size_t)MEM_readBE64(memPtr); +} + +MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val) +{ + if (MEM_32bits()) + MEM_writeBE32(memPtr, (U32)val); + else + MEM_writeBE64(memPtr, (U64)val); +} + + +#if defined (__cplusplus) +} +#endif + +#endif /* MEM_H_MODULE */ diff --git a/grub-core/lib/zstd/module.c b/grub-core/lib/zstd/module.c new file mode 100644 index 000000000..e64d068f4 --- /dev/null +++ b/grub-core/lib/zstd/module.c @@ -0,0 +1,21 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include + +GRUB_MOD_LICENSE ("GPLv3"); diff --git a/grub-core/lib/zstd/xxhash.c b/grub-core/lib/zstd/xxhash.c new file mode 100644 index 000000000..532b81619 --- /dev/null +++ b/grub-core/lib/zstd/xxhash.c @@ -0,0 +1,876 @@ +/* +* xxHash - Fast Hash algorithm +* Copyright (C) 2012-2016, Yann Collet +* +* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* You can contact the author at : +* - xxHash homepage: http://www.xxhash.com +* - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + + +/* ************************************* +* Tuning parameters +***************************************/ +/*!XXH_FORCE_MEMORY_ACCESS : + * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable. + * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal. + * The below switch allow to select different access method for improved performance. + * Method 0 (default) : use `memcpy()`. Safe and portable. + * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable). + * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`. + * Method 2 : direct access. This method doesn't depend on compiler but violate C standard. + * It can generate buggy code on targets which do not support unaligned memory accesses. + * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6) + * See http://stackoverflow.com/a/32095106/646947 for details. + * Prefer these methods in priority order (0 > 1 > 2) + */ +#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ +# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ) +# define XXH_FORCE_MEMORY_ACCESS 2 +# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \ + (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) )) +# define XXH_FORCE_MEMORY_ACCESS 1 +# endif +#endif + +/*!XXH_ACCEPT_NULL_INPUT_POINTER : + * If the input pointer is a null pointer, xxHash default behavior is to trigger a memory access error, since it is a bad pointer. + * When this option is enabled, xxHash output for null input pointers will be the same as a null-length input. + * By default, this option is disabled. To enable it, uncomment below define : + */ +/* #define XXH_ACCEPT_NULL_INPUT_POINTER 1 */ + +/*!XXH_FORCE_NATIVE_FORMAT : + * By default, xxHash library provides endian-independant Hash values, based on little-endian convention. + * Results are therefore identical for little-endian and big-endian CPU. + * This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format. + * Should endian-independance be of no importance for your application, you may set the #define below to 1, + * to improve speed for Big-endian CPU. + * This option has no impact on Little_Endian CPU. + */ +#ifndef XXH_FORCE_NATIVE_FORMAT /* can be defined externally */ +# define XXH_FORCE_NATIVE_FORMAT 0 +#endif + +/*!XXH_FORCE_ALIGN_CHECK : + * This is a minor performance trick, only useful with lots of very small keys. + * It means : check for aligned/unaligned input. + * The check costs one initial branch per hash; set to 0 when the input data + * is guaranteed to be aligned. + */ +#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */ +# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) +# define XXH_FORCE_ALIGN_CHECK 0 +# else +# define XXH_FORCE_ALIGN_CHECK 1 +# endif +#endif + + +/* ************************************* +* Includes & Memory related functions +***************************************/ +/* Modify the local functions below should you wish to use some other memory routines */ +/* for malloc(), free() */ +#include +#include /* size_t */ +static void* XXH_malloc(size_t s) { return malloc(s); } +static void XXH_free (void* p) { free(p); } +/* for memcpy() */ +#include +static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); } + +#ifndef XXH_STATIC_LINKING_ONLY +# define XXH_STATIC_LINKING_ONLY +#endif +#include "xxhash.h" + + +/* ************************************* +* Compiler Specific Options +***************************************/ +#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define INLINE_KEYWORD inline +#else +# define INLINE_KEYWORD +#endif + +#if defined(__GNUC__) +# define FORCE_INLINE_ATTR __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define FORCE_INLINE_ATTR __forceinline +#else +# define FORCE_INLINE_ATTR +#endif + +#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR + + +#ifdef _MSC_VER +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +#endif + + +/* ************************************* +* Basic Types +***************************************/ +#ifndef MEM_MODULE +# define MEM_MODULE +# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef uint32_t U32; + typedef int32_t S32; + typedef uint64_t U64; +# else + typedef unsigned char BYTE; + typedef unsigned short U16; + typedef unsigned int U32; + typedef signed int S32; + typedef unsigned long long U64; /* if your compiler doesn't support unsigned long long, replace by another 64-bit type here. Note that xxhash.h will also need to be updated. */ +# endif +#endif + + +#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2)) + +/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */ +static U32 XXH_read32(const void* memPtr) { return *(const U32*) memPtr; } +static U64 XXH_read64(const void* memPtr) { return *(const U64*) memPtr; } + +#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) + +/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ +/* currently only defined for gcc and icc */ +typedef union { U32 u32; U64 u64; } __attribute__((packed)) unalign; + +static U32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; } +static U64 XXH_read64(const void* ptr) { return ((const unalign*)ptr)->u64; } + +#else + +/* portable and safe solution. Generally efficient. + * see : http://stackoverflow.com/a/32095106/646947 + */ + +static U32 XXH_read32(const void* memPtr) +{ + U32 val; + memcpy(&val, memPtr, sizeof(val)); + return val; +} + +static U64 XXH_read64(const void* memPtr) +{ + U64 val; + memcpy(&val, memPtr, sizeof(val)); + return val; +} + +#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */ + + +/* **************************************** +* Compiler-specific Functions and Macros +******************************************/ +#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) + +/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */ +#if defined(_MSC_VER) +# define XXH_rotl32(x,r) _rotl(x,r) +# define XXH_rotl64(x,r) _rotl64(x,r) +#else +# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r))) +# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r))) +#endif + +#if defined(_MSC_VER) /* Visual Studio */ +# define XXH_swap32 _byteswap_ulong +# define XXH_swap64 _byteswap_uint64 +#elif GCC_VERSION >= 403 +# define XXH_swap32 __builtin_bswap32 +# define XXH_swap64 __builtin_bswap64 +#else +static U32 XXH_swap32 (U32 x) +{ + return ((x << 24) & 0xff000000 ) | + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff ); +} +static U64 XXH_swap64 (U64 x) +{ + return ((x << 56) & 0xff00000000000000ULL) | + ((x << 40) & 0x00ff000000000000ULL) | + ((x << 24) & 0x0000ff0000000000ULL) | + ((x << 8) & 0x000000ff00000000ULL) | + ((x >> 8) & 0x00000000ff000000ULL) | + ((x >> 24) & 0x0000000000ff0000ULL) | + ((x >> 40) & 0x000000000000ff00ULL) | + ((x >> 56) & 0x00000000000000ffULL); +} +#endif + + +/* ************************************* +* Architecture Macros +***************************************/ +typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; + +/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */ +#ifndef XXH_CPU_LITTLE_ENDIAN + static const int g_one = 1; +# define XXH_CPU_LITTLE_ENDIAN (*(const char*)(&g_one)) +#endif + + +/* *************************** +* Memory reads +*****************************/ +typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; + +FORCE_INLINE_TEMPLATE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr)); + else + return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr); +} + +FORCE_INLINE_TEMPLATE U32 XXH_readLE32(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE32_align(ptr, endian, XXH_unaligned); +} + +static U32 XXH_readBE32(const void* ptr) +{ + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr); +} + +FORCE_INLINE_TEMPLATE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr)); + else + return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr); +} + +FORCE_INLINE_TEMPLATE U64 XXH_readLE64(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE64_align(ptr, endian, XXH_unaligned); +} + +static U64 XXH_readBE64(const void* ptr) +{ + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr); +} + + +/* ************************************* +* Macros +***************************************/ +#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ + + +/* ************************************* +* Constants +***************************************/ +static const U32 PRIME32_1 = 2654435761U; +static const U32 PRIME32_2 = 2246822519U; +static const U32 PRIME32_3 = 3266489917U; +static const U32 PRIME32_4 = 668265263U; +static const U32 PRIME32_5 = 374761393U; + +static const U64 PRIME64_1 = 11400714785074694791ULL; +static const U64 PRIME64_2 = 14029467366897019727ULL; +static const U64 PRIME64_3 = 1609587929392839161ULL; +static const U64 PRIME64_4 = 9650029242287828579ULL; +static const U64 PRIME64_5 = 2870177450012600261ULL; + +XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; } + + +/* ************************** +* Utils +****************************/ +XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dstState, const XXH32_state_t* restrict srcState) +{ + memcpy(dstState, srcState, sizeof(*dstState)); +} + +XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dstState, const XXH64_state_t* restrict srcState) +{ + memcpy(dstState, srcState, sizeof(*dstState)); +} + + +/* *************************** +* Simple Hash Functions +*****************************/ + +static U32 XXH32_round(U32 seed, U32 input) +{ + seed += input * PRIME32_2; + seed = XXH_rotl32(seed, 13); + seed *= PRIME32_1; + return seed; +} + +FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* bEnd = p + len; + U32 h32; +#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align) + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (p==NULL) { + len=0; + bEnd=p=(const BYTE*)(size_t)16; + } +#endif + + if (len>=16) { + const BYTE* const limit = bEnd - 16; + U32 v1 = seed + PRIME32_1 + PRIME32_2; + U32 v2 = seed + PRIME32_2; + U32 v3 = seed + 0; + U32 v4 = seed - PRIME32_1; + + do { + v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4; + v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4; + v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4; + v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4; + } while (p<=limit); + + h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18); + } else { + h32 = seed + PRIME32_5; + } + + h32 += (U32) len; + + while (p+4<=bEnd) { + h32 += XXH_get32bits(p) * PRIME32_3; + h32 = XXH_rotl32(h32, 17) * PRIME32_4 ; + p+=4; + } + + while (p> 15; + h32 *= PRIME32_2; + h32 ^= h32 >> 13; + h32 *= PRIME32_3; + h32 ^= h32 >> 16; + + return h32; +} + + +XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed) +{ +#if 0 + /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ + XXH32_CREATESTATE_STATIC(state); + XXH32_reset(state, seed); + XXH32_update(state, input, len); + return XXH32_digest(state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if (XXH_FORCE_ALIGN_CHECK) { + if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */ + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } } + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + + +static U64 XXH64_round(U64 acc, U64 input) +{ + acc += input * PRIME64_2; + acc = XXH_rotl64(acc, 31); + acc *= PRIME64_1; + return acc; +} + +static U64 XXH64_mergeRound(U64 acc, U64 val) +{ + val = XXH64_round(0, val); + acc ^= val; + acc = acc * PRIME64_1 + PRIME64_4; + return acc; +} + +FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + U64 h64; +#define XXH_get64bits(p) XXH_readLE64_align(p, endian, align) + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (p==NULL) { + len=0; + bEnd=p=(const BYTE*)(size_t)32; + } +#endif + + if (len>=32) { + const BYTE* const limit = bEnd - 32; + U64 v1 = seed + PRIME64_1 + PRIME64_2; + U64 v2 = seed + PRIME64_2; + U64 v3 = seed + 0; + U64 v4 = seed - PRIME64_1; + + do { + v1 = XXH64_round(v1, XXH_get64bits(p)); p+=8; + v2 = XXH64_round(v2, XXH_get64bits(p)); p+=8; + v3 = XXH64_round(v3, XXH_get64bits(p)); p+=8; + v4 = XXH64_round(v4, XXH_get64bits(p)); p+=8; + } while (p<=limit); + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + h64 = XXH64_mergeRound(h64, v1); + h64 = XXH64_mergeRound(h64, v2); + h64 = XXH64_mergeRound(h64, v3); + h64 = XXH64_mergeRound(h64, v4); + + } else { + h64 = seed + PRIME64_5; + } + + h64 += (U64) len; + + while (p+8<=bEnd) { + U64 const k1 = XXH64_round(0, XXH_get64bits(p)); + h64 ^= k1; + h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; + p+=8; + } + + if (p+4<=bEnd) { + h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1; + h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; + p+=4; + } + + while (p> 33; + h64 *= PRIME64_2; + h64 ^= h64 >> 29; + h64 *= PRIME64_3; + h64 ^= h64 >> 32; + + return h64; +} + + +XXH_PUBLIC_API unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed) +{ +#if 0 + /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ + XXH64_CREATESTATE_STATIC(state); + XXH64_reset(state, seed); + XXH64_update(state, input, len); + return XXH64_digest(state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if (XXH_FORCE_ALIGN_CHECK) { + if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */ + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } } + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + + +/* ************************************************** +* Advanced Hash Functions +****************************************************/ + +XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void) +{ + return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t)); +} +XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; +} + +XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void) +{ + return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t)); +} +XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; +} + + +/*** Hash feed ***/ + +XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed) +{ + XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ + memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */ + state.v1 = seed + PRIME32_1 + PRIME32_2; + state.v2 = seed + PRIME32_2; + state.v3 = seed + 0; + state.v4 = seed - PRIME32_1; + memcpy(statePtr, &state, sizeof(state)); + return XXH_OK; +} + + +XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed) +{ + XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ + memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */ + state.v1 = seed + PRIME64_1 + PRIME64_2; + state.v2 = seed + PRIME64_2; + state.v3 = seed + 0; + state.v4 = seed - PRIME64_1; + memcpy(statePtr, &state, sizeof(state)); + return XXH_OK; +} + + +FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (input==NULL) return XXH_ERROR; +#endif + + state->total_len_32 += (unsigned)len; + state->large_len |= (len>=16) | (state->total_len_32>=16); + + if (state->memsize + len < 16) { /* fill in tmp buffer */ + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len); + state->memsize += (unsigned)len; + return XXH_OK; + } + + if (state->memsize) { /* some data left from previous update */ + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize); + { const U32* p32 = state->mem32; + state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++; + state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++; + state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++; + state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian)); p32++; + } + p += 16-state->memsize; + state->memsize = 0; + } + + if (p <= bEnd-16) { + const BYTE* const limit = bEnd - 16; + U32 v1 = state->v1; + U32 v2 = state->v2; + U32 v3 = state->v3; + U32 v4 = state->v4; + + do { + v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4; + v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4; + v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4; + v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4; + } while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) { + XXH_memcpy(state->mem32, p, (size_t)(bEnd-p)); + state->memsize = (unsigned)(bEnd-p); + } + + return XXH_OK; +} + +XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH32_update_endian(state_in, input, len, XXH_bigEndian); +} + + + +FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian) +{ + const BYTE * p = (const BYTE*)state->mem32; + const BYTE* const bEnd = (const BYTE*)(state->mem32) + state->memsize; + U32 h32; + + if (state->large_len) { + h32 = XXH_rotl32(state->v1, 1) + XXH_rotl32(state->v2, 7) + XXH_rotl32(state->v3, 12) + XXH_rotl32(state->v4, 18); + } else { + h32 = state->v3 /* == seed */ + PRIME32_5; + } + + h32 += state->total_len_32; + + while (p+4<=bEnd) { + h32 += XXH_readLE32(p, endian) * PRIME32_3; + h32 = XXH_rotl32(h32, 17) * PRIME32_4; + p+=4; + } + + while (p> 15; + h32 *= PRIME32_2; + h32 ^= h32 >> 13; + h32 *= PRIME32_3; + h32 ^= h32 >> 16; + + return h32; +} + + +XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_digest_endian(state_in, XXH_littleEndian); + else + return XXH32_digest_endian(state_in, XXH_bigEndian); +} + + + +/* **** XXH64 **** */ + +FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (input==NULL) return XXH_ERROR; +#endif + + state->total_len += len; + + if (state->memsize + len < 32) { /* fill in tmp buffer */ + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len); + state->memsize += (U32)len; + return XXH_OK; + } + + if (state->memsize) { /* tmp buffer is full */ + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize); + state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0, endian)); + state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1, endian)); + state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2, endian)); + state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3, endian)); + p += 32-state->memsize; + state->memsize = 0; + } + + if (p+32 <= bEnd) { + const BYTE* const limit = bEnd - 32; + U64 v1 = state->v1; + U64 v2 = state->v2; + U64 v3 = state->v3; + U64 v4 = state->v4; + + do { + v1 = XXH64_round(v1, XXH_readLE64(p, endian)); p+=8; + v2 = XXH64_round(v2, XXH_readLE64(p, endian)); p+=8; + v3 = XXH64_round(v3, XXH_readLE64(p, endian)); p+=8; + v4 = XXH64_round(v4, XXH_readLE64(p, endian)); p+=8; + } while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) { + XXH_memcpy(state->mem64, p, (size_t)(bEnd-p)); + state->memsize = (unsigned)(bEnd-p); + } + + return XXH_OK; +} + +XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH64_update_endian(state_in, input, len, XXH_bigEndian); +} + + + +FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian) +{ + const BYTE * p = (const BYTE*)state->mem64; + const BYTE* const bEnd = (const BYTE*)state->mem64 + state->memsize; + U64 h64; + + if (state->total_len >= 32) { + U64 const v1 = state->v1; + U64 const v2 = state->v2; + U64 const v3 = state->v3; + U64 const v4 = state->v4; + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + h64 = XXH64_mergeRound(h64, v1); + h64 = XXH64_mergeRound(h64, v2); + h64 = XXH64_mergeRound(h64, v3); + h64 = XXH64_mergeRound(h64, v4); + } else { + h64 = state->v3 + PRIME64_5; + } + + h64 += (U64) state->total_len; + + while (p+8<=bEnd) { + U64 const k1 = XXH64_round(0, XXH_readLE64(p, endian)); + h64 ^= k1; + h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; + p+=8; + } + + if (p+4<=bEnd) { + h64 ^= (U64)(XXH_readLE32(p, endian)) * PRIME64_1; + h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; + p+=4; + } + + while (p> 33; + h64 *= PRIME64_2; + h64 ^= h64 >> 29; + h64 *= PRIME64_3; + h64 ^= h64 >> 32; + + return h64; +} + + +XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_digest_endian(state_in, XXH_littleEndian); + else + return XXH64_digest_endian(state_in, XXH_bigEndian); +} + + +/* ************************** +* Canonical representation +****************************/ + +/*! Default XXH result types are basic unsigned 32 and 64 bits. +* The canonical representation follows human-readable write convention, aka big-endian (large digits first). +* These functions allow transformation of hash result into and from its canonical format. +* This way, hash values can be written into a file or buffer, and remain comparable across different systems and programs. +*/ + +XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash) +{ + XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t)); + if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash); + memcpy(dst, &hash, sizeof(*dst)); +} + +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash) +{ + XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t)); + if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash); + memcpy(dst, &hash, sizeof(*dst)); +} + +XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) +{ + return XXH_readBE32(src); +} + +XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) +{ + return XXH_readBE64(src); +} diff --git a/grub-core/lib/zstd/xxhash.h b/grub-core/lib/zstd/xxhash.h new file mode 100644 index 000000000..9bad1f59f --- /dev/null +++ b/grub-core/lib/zstd/xxhash.h @@ -0,0 +1,305 @@ +/* + xxHash - Extremely Fast Hash algorithm + Header File + Copyright (C) 2012-2016, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + +/* Notice extracted from xxHash homepage : + +xxHash is an extremely fast Hash algorithm, running at RAM speed limits. +It also successfully passes all tests from the SMHasher suite. + +Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) + +Name Speed Q.Score Author +xxHash 5.4 GB/s 10 +CrapWow 3.2 GB/s 2 Andrew +MumurHash 3a 2.7 GB/s 10 Austin Appleby +SpookyHash 2.0 GB/s 10 Bob Jenkins +SBox 1.4 GB/s 9 Bret Mulvey +Lookup3 1.2 GB/s 9 Bob Jenkins +SuperFastHash 1.2 GB/s 1 Paul Hsieh +CityHash64 1.05 GB/s 10 Pike & Alakuijala +FNV 0.55 GB/s 5 Fowler, Noll, Vo +CRC32 0.43 GB/s 9 +MD5-32 0.33 GB/s 10 Ronald L. Rivest +SHA1-32 0.28 GB/s 10 + +Q.Score is a measure of quality of the hash function. +It depends on successfully passing SMHasher test set. +10 is a perfect score. + +A 64-bits version, named XXH64, is available since r35. +It offers much better speed, but for 64-bits applications only. +Name Speed on 64 bits Speed on 32 bits +XXH64 13.8 GB/s 1.9 GB/s +XXH32 6.8 GB/s 6.0 GB/s +*/ + +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef XXHASH_H_5627135585666179 +#define XXHASH_H_5627135585666179 1 + + +/* **************************** +* Definitions +******************************/ +#include /* size_t */ +typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; + + +/* **************************** +* API modifier +******************************/ +/** XXH_PRIVATE_API +* This is useful if you want to include xxhash functions in `static` mode +* in order to inline them, and remove their symbol from the public list. +* Methodology : +* #define XXH_PRIVATE_API +* #include "xxhash.h" +* `xxhash.c` is automatically included. +* It's not useful to compile and link it as a separate module anymore. +*/ +#ifdef XXH_PRIVATE_API +# ifndef XXH_STATIC_LINKING_ONLY +# define XXH_STATIC_LINKING_ONLY +# endif +# if defined(__GNUC__) +# define XXH_PUBLIC_API static __inline __attribute__((unused)) +# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) +# define XXH_PUBLIC_API static inline +# elif defined(_MSC_VER) +# define XXH_PUBLIC_API static __inline +# else +# define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */ +# endif +#else +# define XXH_PUBLIC_API /* do nothing */ +#endif /* XXH_PRIVATE_API */ + +/*!XXH_NAMESPACE, aka Namespace Emulation : + +If you want to include _and expose_ xxHash functions from within your own library, +but also want to avoid symbol collisions with another library which also includes xxHash, + +you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library +with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid numeric values). + +Note that no change is required within the calling program as long as it includes `xxhash.h` : +regular symbol name will be automatically translated by this header. +*/ +#ifdef XXH_NAMESPACE +# define XXH_CAT(A,B) A##B +# define XXH_NAME2(A,B) XXH_CAT(A,B) +# define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32) +# define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64) +# define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber) +# define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState) +# define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState) +# define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState) +# define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState) +# define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset) +# define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset) +# define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update) +# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update) +# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest) +# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest) +# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState) +# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState) +# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash) +# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash) +# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical) +# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical) +#endif + + +/* ************************************* +* Version +***************************************/ +#define XXH_VERSION_MAJOR 0 +#define XXH_VERSION_MINOR 6 +#define XXH_VERSION_RELEASE 2 +#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) +XXH_PUBLIC_API unsigned XXH_versionNumber (void); + + +/* **************************** +* Simple Hash Functions +******************************/ +typedef unsigned int XXH32_hash_t; +typedef unsigned long long XXH64_hash_t; + +XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed); +XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed); + +/*! +XXH32() : + Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input". + The memory between input & input+length must be valid (allocated and read-accessible). + "seed" can be used to alter the result predictably. + Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s +XXH64() : + Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". + "seed" can be used to alter the result predictably. + This function runs 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark). +*/ + + +/* **************************** +* Streaming Hash Functions +******************************/ +typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */ +typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */ + +/*! State allocation, compatible with dynamic libraries */ + +XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void); +XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); + +XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void); +XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); + + +/* hash streaming */ + +XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed); +XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); +XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); + +XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed); +XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); +XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr); + +/* +These functions generate the xxHash of an input provided in multiple segments. +Note that, for small input, they are slower than single-call functions, due to state management. +For small input, prefer `XXH32()` and `XXH64()` . + +XXH state must first be allocated, using XXH*_createState() . + +Start a new hash by initializing state with a seed, using XXH*_reset(). + +Then, feed the hash state by calling XXH*_update() as many times as necessary. +Obviously, input must be allocated and read accessible. +The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. + +Finally, a hash value can be produced anytime, by using XXH*_digest(). +This function returns the nn-bits hash as an int or long long. + +It's still possible to continue inserting input into the hash state after a digest, +and generate some new hashes later on, by calling again XXH*_digest(). + +When done, free XXH state space if it was allocated dynamically. +*/ + + +/* ************************** +* Utils +****************************/ +#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* ! C99 */ +# define restrict /* disable restrict */ +#endif + +XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dst_state, const XXH32_state_t* restrict src_state); +XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH64_state_t* restrict src_state); + + +/* ************************** +* Canonical representation +****************************/ +/* Default result type for XXH functions are primitive unsigned 32 and 64 bits. +* The canonical representation uses human-readable write convention, aka big-endian (large digits first). +* These functions allow transformation of hash result into and from its canonical format. +* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs. +*/ +typedef struct { unsigned char digest[4]; } XXH32_canonical_t; +typedef struct { unsigned char digest[8]; } XXH64_canonical_t; + +XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash); +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash); + +XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); +XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src); + +#endif /* XXHASH_H_5627135585666179 */ + + + +/* ================================================================================================ + This section contains definitions which are not guaranteed to remain stable. + They may change in future versions, becoming incompatible with a different version of the library. + They shall only be used with static linking. + Never use these definitions in association with dynamic linking ! +=================================================================================================== */ +#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345) +#define XXH_STATIC_H_3543687687345 + +/* These definitions are only meant to allow allocation of XXH state + statically, on stack, or in a struct for example. + Do not use members directly. */ + + struct XXH32_state_s { + unsigned total_len_32; + unsigned large_len; + unsigned v1; + unsigned v2; + unsigned v3; + unsigned v4; + unsigned mem32[4]; /* buffer defined as U32 for alignment */ + unsigned memsize; + unsigned reserved; /* never read nor write, will be removed in a future version */ + }; /* typedef'd to XXH32_state_t */ + + struct XXH64_state_s { + unsigned long long total_len; + unsigned long long v1; + unsigned long long v2; + unsigned long long v3; + unsigned long long v4; + unsigned long long mem64[4]; /* buffer defined as U64 for alignment */ + unsigned memsize; + unsigned reserved[2]; /* never read nor write, will be removed in a future version */ + }; /* typedef'd to XXH64_state_t */ + + +# ifdef XXH_PRIVATE_API +# include "xxhash.c" /* include xxhash functions as `static`, for inlining */ +# endif + +#endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */ + + +#if defined (__cplusplus) +} +#endif diff --git a/grub-core/lib/zstd/zstd.h b/grub-core/lib/zstd/zstd.h new file mode 100644 index 000000000..7b6964be3 --- /dev/null +++ b/grub-core/lib/zstd/zstd.h @@ -0,0 +1,1516 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ +#if defined (__cplusplus) +extern "C" { +#endif + +#ifndef ZSTD_H_235446 +#define ZSTD_H_235446 + +/* ====== Dependency ======*/ +#include /* size_t */ + + +/* ===== ZSTDLIB_API : control library symbols visibility ===== */ +#ifndef ZSTDLIB_VISIBILITY +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default"))) +# else +# define ZSTDLIB_VISIBILITY +# endif +#endif +#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY +#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define ZSTDLIB_API ZSTDLIB_VISIBILITY +#endif + + +/******************************************************************************* + Introduction + + zstd, short for Zstandard, is a fast lossless compression algorithm, targeting + real-time compression scenarios at zlib-level and better compression ratios. + The zstd compression library provides in-memory compression and decompression + functions. + + The library supports regular compression levels from 1 up to ZSTD_maxCLevel(), + which is currently 22. Levels >= 20, labeled `--ultra`, should be used with + caution, as they require more memory. The library also offers negative + compression levels, which extend the range of speed vs. ratio preferences. + The lower the level, the faster the speed (at the cost of compression). + + Compression can be done in: + - a single step (described as Simple API) + - a single step, reusing a context (described as Explicit context) + - unbounded multiple steps (described as Streaming compression) + + The compression ratio achievable on small data can be highly improved using + a dictionary. Dictionary compression can be performed in: + - a single step (described as Simple dictionary API) + - a single step, reusing a dictionary (described as Bulk-processing + dictionary API) + + Advanced experimental functions can be accessed using + `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h. + + Advanced experimental APIs should never be used with a dynamically-linked + library. They are not "stable"; their definitions or signatures may change in + the future. Only static linking is allowed. +*******************************************************************************/ + +/*------ Version ------*/ +#define ZSTD_VERSION_MAJOR 1 +#define ZSTD_VERSION_MINOR 3 +#define ZSTD_VERSION_RELEASE 6 + +#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) +ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */ + +#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE +#define ZSTD_QUOTE(str) #str +#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str) +#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION) +ZSTDLIB_API const char* ZSTD_versionString(void); /* v1.3.0+ */ + +/*************************************** +* Default constant +***************************************/ +#ifndef ZSTD_CLEVEL_DEFAULT +# define ZSTD_CLEVEL_DEFAULT 3 +#endif + +/*************************************** +* Simple API +***************************************/ +/*! ZSTD_compress() : + * Compresses `src` content as a single zstd compressed frame into already allocated `dst`. + * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`. + * @return : compressed size written into `dst` (<= `dstCapacity), + * or an error code if it fails (which can be tested using ZSTD_isError()). */ +ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + int compressionLevel); + +/*! ZSTD_decompress() : + * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. + * `dstCapacity` is an upper bound of originalSize to regenerate. + * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. + * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), + * or an errorCode if it fails (which can be tested using ZSTD_isError()). */ +ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity, + const void* src, size_t compressedSize); + +/*! ZSTD_getFrameContentSize() : added in v1.3.0 + * `src` should point to the start of a ZSTD encoded frame. + * `srcSize` must be at least as large as the frame header. + * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough. + * @return : - decompressed size of `src` frame content, if known + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined + * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) + * note 1 : a 0 return value means the frame is valid but "empty". + * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode. + * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. + * In which case, it's necessary to use streaming mode to decompress data. + * Optionally, application can rely on some implicit limit, + * as ZSTD_decompress() only needs an upper bound of decompressed size. + * (For example, data could be necessarily cut into blocks <= 16 KB). + * note 3 : decompressed size is always present when compression is completed using single-pass functions, + * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict(). + * note 4 : decompressed size can be very large (64-bits value), + * potentially larger than what local system can handle as a single memory segment. + * In which case, it's necessary to use streaming mode to decompress data. + * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified. + * Always ensure return value fits within application's authorized limits. + * Each application can set its own limits. + * note 6 : This function replaces ZSTD_getDecompressedSize() */ +#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1) +#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2) +ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize); + +/*! ZSTD_getDecompressedSize() : + * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize(). + * Both functions work the same way, but ZSTD_getDecompressedSize() blends + * "empty", "unknown" and "error" results to the same return value (0), + * while ZSTD_getFrameContentSize() gives them separate return values. + * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */ +ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize); + + +/*====== Helper functions ======*/ +#define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */ +ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */ +ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */ +ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */ +ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */ + + +/*************************************** +* Explicit context +***************************************/ +/*= Compression context + * When compressing many times, + * it is recommended to allocate a context just once, and re-use it for each successive compression operation. + * This will make workload friendlier for system's memory. + * Use one context per thread for parallel execution in multi-threaded environments. */ +typedef struct ZSTD_CCtx_s ZSTD_CCtx; +ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void); +ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); + +/*! ZSTD_compressCCtx() : + * Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */ +ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + int compressionLevel); + +/*= Decompression context + * When decompressing many times, + * it is recommended to allocate a context only once, + * and re-use it for each successive compression operation. + * This will make workload friendlier for system's memory. + * Use one context per thread for parallel execution. */ +typedef struct ZSTD_DCtx_s ZSTD_DCtx; +ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void); +ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); + +/*! ZSTD_decompressDCtx() : + * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */ +ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize); + + +/************************** +* Simple dictionary API +***************************/ +/*! ZSTD_compress_usingDict() : + * Compression using a predefined Dictionary (see dictBuilder/zdict.h). + * Note : This function loads the dictionary, resulting in significant startup delay. + * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */ +ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize, + int compressionLevel); + +/*! ZSTD_decompress_usingDict() : + * Decompression using a predefined Dictionary (see dictBuilder/zdict.h). + * Dictionary must be identical to the one used during compression. + * Note : This function loads the dictionary, resulting in significant startup delay. + * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */ +ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize); + + +/********************************** + * Bulk processing dictionary API + *********************************/ +typedef struct ZSTD_CDict_s ZSTD_CDict; + +/*! ZSTD_createCDict() : + * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. + * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. + * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. + * `dictBuffer` can be released after ZSTD_CDict creation, since its content is copied within CDict + * Note : A ZSTD_CDict can be created with an empty dictionary, but it is inefficient for small data. */ +ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, + int compressionLevel); + +/*! ZSTD_freeCDict() : + * Function frees memory allocated by ZSTD_createCDict(). */ +ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); + +/*! ZSTD_compress_usingCDict() : + * Compression using a digested Dictionary. + * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times. + * Note that compression level is decided during dictionary creation. + * Frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) + * Note : ZSTD_compress_usingCDict() can be used with a ZSTD_CDict created from an empty dictionary. + * But it is inefficient for small data, and it is recommended to use ZSTD_compressCCtx(). */ +ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_CDict* cdict); + + +typedef struct ZSTD_DDict_s ZSTD_DDict; + +/*! ZSTD_createDDict() : + * Create a digested dictionary, ready to start decompression operation without startup delay. + * dictBuffer can be released after DDict creation, as its content is copied inside DDict */ +ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize); + +/*! ZSTD_freeDDict() : + * Function frees memory allocated with ZSTD_createDDict() */ +ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); + +/*! ZSTD_decompress_usingDDict() : + * Decompression using a digested Dictionary. + * Faster startup than ZSTD_decompress_usingDict(), recommended when same dictionary is used multiple times. */ +ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_DDict* ddict); + + +/**************************** +* Streaming +****************************/ + +typedef struct ZSTD_inBuffer_s { + const void* src; /**< start of input buffer */ + size_t size; /**< size of input buffer */ + size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */ +} ZSTD_inBuffer; + +typedef struct ZSTD_outBuffer_s { + void* dst; /**< start of output buffer */ + size_t size; /**< size of output buffer */ + size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */ +} ZSTD_outBuffer; + + + +/*-*********************************************************************** +* Streaming compression - HowTo +* +* A ZSTD_CStream object is required to track streaming operation. +* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources. +* ZSTD_CStream objects can be reused multiple times on consecutive compression operations. +* It is recommended to re-use ZSTD_CStream in situations where many streaming operations will be achieved consecutively, +* since it will play nicer with system's memory, by re-using already allocated memory. +* Use one separate ZSTD_CStream per thread for parallel execution. +* +* Start a new compression by initializing ZSTD_CStream context. +* Use ZSTD_initCStream() to start a new compression operation. +* Use variants ZSTD_initCStream_usingDict() or ZSTD_initCStream_usingCDict() for streaming with dictionary (experimental section) +* +* Use ZSTD_compressStream() as many times as necessary to consume input stream. +* The function will automatically update both `pos` fields within `input` and `output`. +* Note that the function may not consume the entire input, +* for example, because the output buffer is already full, +* in which case `input.pos < input.size`. +* The caller must check if input has been entirely consumed. +* If not, the caller must make some room to receive more compressed data, +* typically by emptying output buffer, or allocating a new output buffer, +* and then present again remaining input data. +* @return : a size hint, preferred nb of bytes to use as input for next function call +* or an error code, which can be tested using ZSTD_isError(). +* Note 1 : it's just a hint, to help latency a little, any other value will work fine. +* Note 2 : size hint is guaranteed to be <= ZSTD_CStreamInSize() +* +* At any moment, it's possible to flush whatever data might remain stuck within internal buffer, +* using ZSTD_flushStream(). `output->pos` will be updated. +* Note that, if `output->size` is too small, a single invocation of ZSTD_flushStream() might not be enough (return code > 0). +* In which case, make some room to receive more compressed data, and call again ZSTD_flushStream(). +* @return : 0 if internal buffers are entirely flushed, +* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), +* or an error code, which can be tested using ZSTD_isError(). +* +* ZSTD_endStream() instructs to finish a frame. +* It will perform a flush and write frame epilogue. +* The epilogue is required for decoders to consider a frame completed. +* flush() operation is the same, and follows same rules as ZSTD_flushStream(). +* @return : 0 if frame fully completed and fully flushed, +* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), +* or an error code, which can be tested using ZSTD_isError(). +* +* *******************************************************************/ + +typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */ + /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */ +/*===== ZSTD_CStream management functions =====*/ +ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void); +ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); + +/*===== Streaming compression functions =====*/ +ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel); +ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input); +ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); +ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); + +ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */ +ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block in all circumstances. */ + + + +/*-*************************************************************************** +* Streaming decompression - HowTo +* +* A ZSTD_DStream object is required to track streaming operations. +* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources. +* ZSTD_DStream objects can be re-used multiple times. +* +* Use ZSTD_initDStream() to start a new decompression operation, +* or ZSTD_initDStream_usingDict() if decompression requires a dictionary. +* @return : recommended first input size +* +* Use ZSTD_decompressStream() repetitively to consume your input. +* The function will update both `pos` fields. +* If `input.pos < input.size`, some input has not been consumed. +* It's up to the caller to present again remaining data. +* If `output.pos < output.size`, decoder has flushed everything it could. +* @return : 0 when a frame is completely decoded and fully flushed, +* an error code, which can be tested using ZSTD_isError(), +* any other value > 0, which means there is still some decoding to do to complete current frame. +* The return value is a suggested next input size (a hint to improve latency) that will never load more than the current frame. +* *******************************************************************************/ + +typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */ + /* For compatibility with versions <= v1.2.0, continue to consider them separated. */ +/*===== ZSTD_DStream management functions =====*/ +ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void); +ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); + +/*===== Streaming decompression functions =====*/ +ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds); +ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input); + +ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ +ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */ + +#endif /* ZSTD_H_235446 */ + + + + +#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) +#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY + +/**************************************************************************************** + * ADVANCED AND EXPERIMENTAL FUNCTIONS + **************************************************************************************** + * The definitions in this section are considered experimental. + * They should never be used with a dynamic library, as prototypes may change in the future. + * They are provided for advanced scenarios. + * Use them only in association with static linking. + * ***************************************************************************************/ + +ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */ + +/* --- Constants ---*/ +#define ZSTD_MAGICNUMBER 0xFD2FB528 /* v0.8+ */ +#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* v0.7+ */ +#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U + +#define ZSTD_BLOCKSIZELOG_MAX 17 +#define ZSTD_BLOCKSIZE_MAX (1<= first frame size + * @return : the compressed size of the first frame starting at `src`, + * suitable to pass to `ZSTD_decompress` or similar, + * or an error code if input is invalid */ +ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize); + +/*! ZSTD_findDecompressedSize() : + * `src` should point the start of a series of ZSTD encoded and/or skippable frames + * `srcSize` must be the _exact_ size of this series + * (i.e. there should be a frame boundary exactly at `srcSize` bytes after `src`) + * @return : - decompressed size of all data in all successive frames + * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN + * - if an error occurred: ZSTD_CONTENTSIZE_ERROR + * + * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. + * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. + * In which case, it's necessary to use streaming mode to decompress data. + * note 2 : decompressed size is always present when compression is done with ZSTD_compress() + * note 3 : decompressed size can be very large (64-bits value), + * potentially larger than what local system can handle as a single memory segment. + * In which case, it's necessary to use streaming mode to decompress data. + * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. + * Always ensure result fits within application's authorized limits. + * Each application can set its own limits. + * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to + * read each contained frame header. This is fast as most of the data is skipped, + * however it does mean that all frame data must be present and valid. */ +ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize); + +/*! ZSTD_frameHeaderSize() : + * srcSize must be >= ZSTD_frameHeaderSize_prefix. + * @return : size of the Frame Header, + * or an error code (if srcSize is too small) */ +ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize); + + +/*************************************** +* Memory management +***************************************/ + +/*! ZSTD_sizeof_*() : + * These functions give the current memory usage of selected object. + * Object memory usage can evolve when re-used. */ +ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); +ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); +ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); +ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); +ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); +ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); + +/*! ZSTD_estimate*() : + * These functions make it possible to estimate memory usage + * of a future {D,C}Ctx, before its creation. + * ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one. + * It will also consider src size to be arbitrarily "large", which is worst case. + * If srcSize is known to always be small, ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation. + * ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. + * ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbWorkers is >= 1. + * Note : CCtx size estimation is only correct for single-threaded compression. */ +ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel); +ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams); +ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params); +ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void); + +/*! ZSTD_estimateCStreamSize() : + * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one. + * It will also consider src size to be arbitrarily "large", which is worst case. + * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation. + * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. + * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbWorkers is >= 1. + * Note : CStream size estimation is only correct for single-threaded compression. + * ZSTD_DStream memory budget depends on window Size. + * This information can be passed manually, using ZSTD_estimateDStreamSize, + * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame(); + * Note : if streaming is init with function ZSTD_init?Stream_usingDict(), + * an internal ?Dict will be created, which additional size is not estimated here. + * In this case, get total size by adding ZSTD_estimate?DictSize */ +ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel); +ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams); +ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params); +ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize); +ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize); + +/*! ZSTD_estimate?DictSize() : + * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). + * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced(). + * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller. + */ +ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel); +ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod); +ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod); + +/*! ZSTD_initStatic*() : + * Initialize an object using a pre-allocated fixed-size buffer. + * workspace: The memory area to emplace the object into. + * Provided pointer *must be 8-bytes aligned*. + * Buffer must outlive object. + * workspaceSize: Use ZSTD_estimate*Size() to determine + * how large workspace must be to support target scenario. + * @return : pointer to object (same address as workspace, just different type), + * or NULL if error (size too small, incorrect alignment, etc.) + * Note : zstd will never resize nor malloc() when using a static buffer. + * If the object requires more memory than available, + * zstd will just error out (typically ZSTD_error_memory_allocation). + * Note 2 : there is no corresponding "free" function. + * Since workspace is allocated externally, it must be freed externally too. + * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level + * into its associated cParams. + * Limitation 1 : currently not compatible with internal dictionary creation, triggered by + * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict(). + * Limitation 2 : static cctx currently not compatible with multi-threading. + * Limitation 3 : static dctx is incompatible with legacy support. + */ +ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize); +ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */ + +ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize); +ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */ + +ZSTDLIB_API const ZSTD_CDict* ZSTD_initStaticCDict( + void* workspace, size_t workspaceSize, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_compressionParameters cParams); + +ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict( + void* workspace, size_t workspaceSize, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType); + +/*! Custom memory allocation : + * These prototypes make it possible to pass your own allocation/free functions. + * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below. + * All allocation/free operations will be completed using these custom variants instead of regular ones. + */ +typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); +typedef void (*ZSTD_freeFunction) (void* opaque, void* address); +typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem; +static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */ + +ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem); +ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem); +ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem); +ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem); + +ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_compressionParameters cParams, + ZSTD_customMem customMem); + +ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_customMem customMem); + + + +/*************************************** +* Advanced compression functions +***************************************/ + +/*! ZSTD_createCDict_byReference() : + * Create a digested dictionary for compression + * Dictionary content is simply referenced, and therefore stays in dictBuffer. + * It is important that dictBuffer outlives CDict, it must remain read accessible throughout the lifetime of CDict */ +ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel); + +/*! ZSTD_getCParams() : +* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. +* `estimatedSrcSize` value is optional, select 0 if not known */ +ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); + +/*! ZSTD_getParams() : +* same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. +* All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */ +ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); + +/*! ZSTD_checkCParams() : +* Ensure param values remain within authorized range */ +ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params); + +/*! ZSTD_adjustCParams() : + * optimize params for a given `srcSize` and `dictSize`. + * both values are optional, select `0` if unknown. */ +ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize); + +/*! ZSTD_compress_advanced() : +* Same as ZSTD_compress_usingDict(), with fine-tune control over each compression parameter */ +ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict,size_t dictSize, + ZSTD_parameters params); + +/*! ZSTD_compress_usingCDict_advanced() : +* Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters */ +ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_CDict* cdict, ZSTD_frameParameters fParams); + + +/*--- Advanced decompression functions ---*/ + +/*! ZSTD_isFrame() : + * Tells if the content of `buffer` starts with a valid Frame Identifier. + * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. + * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. + * Note 3 : Skippable Frame Identifiers are considered valid. */ +ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size); + +/*! ZSTD_createDDict_byReference() : + * Create a digested dictionary, ready to start decompression operation without startup delay. + * Dictionary content is referenced, and therefore stays in dictBuffer. + * It is important that dictBuffer outlives DDict, + * it must remain read accessible throughout the lifetime of DDict */ +ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize); + + +/*! ZSTD_getDictID_fromDict() : + * Provides the dictID stored within dictionary. + * if @return == 0, the dictionary is not conformant with Zstandard specification. + * It can still be loaded, but as a content-only dictionary. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); + +/*! ZSTD_getDictID_fromDDict() : + * Provides the dictID of the dictionary loaded into `ddict`. + * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. + * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); + +/*! ZSTD_getDictID_fromFrame() : + * Provides the dictID required to decompressed the frame stored within `src`. + * If @return == 0, the dictID could not be decoded. + * This could for one of the following reasons : + * - The frame does not require a dictionary to be decoded (most common case). + * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information. + * Note : this use case also happens when using a non-conformant dictionary. + * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). + * - This is not a Zstandard frame. + * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */ +ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); + + +/******************************************************************** +* Advanced streaming functions +********************************************************************/ + +/*===== Advanced Streaming compression functions =====*/ +ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If it is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, "0" also disables frame content size field. It may be enabled in the future. */ +ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< creates of an internal CDict (incompatible with static CCtx), except if dict == NULL or dictSize < 8, in which case no dict is used. Note: dict is loaded with ZSTD_dm_auto (treated as a full zstd dictionary if it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.*/ +ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize, + ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. dict is loaded with ZSTD_dm_auto and ZSTD_dlm_byCopy. */ +ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */ +ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. */ + +/*! ZSTD_resetCStream() : + * start a new compression job, using same parameters from previous job. + * This is typically useful to skip dictionary loading stage, since it will re-use it in-place. + * Note that zcs must be init at least once before using ZSTD_resetCStream(). + * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN. + * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end. + * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, + * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. + * @return : 0, or an error code (which can be tested using ZSTD_isError()) + */ +ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); + + +typedef struct { + unsigned long long ingested; /* nb input bytes read and buffered */ + unsigned long long consumed; /* nb input bytes actually compressed */ + unsigned long long produced; /* nb of compressed bytes generated and buffered */ + unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */ + unsigned currentJobID; /* MT only : latest started job nb */ + unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */ +} ZSTD_frameProgression; + +/* ZSTD_getFrameProgression() : + * tells how much data has been ingested (read from input) + * consumed (input actually compressed) and produced (output) for current frame. + * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed. + * Aggregates progression inside active worker threads. + */ +ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx); + +/*! ZSTD_toFlushNow() : + * Tell how many bytes are ready to be flushed immediately. + * Useful for multithreading scenarios (nbWorkers >= 1). + * Probe the oldest active job, defined as oldest job not yet entirely flushed, + * and check its output buffer. + * @return : amount of data stored in oldest job and ready to be flushed immediately. + * if @return == 0, it means either : + * + there is no active job (could be checked with ZSTD_frameProgression()), or + * + oldest job is still actively compressing data, + * but everything it has produced has also been flushed so far, + * therefore flushing speed is currently limited by production speed of oldest job + * irrespective of the speed of concurrent newer jobs. + */ +ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx); + + + +/*===== Advanced Streaming decompression functions =====*/ +typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e; +ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue); /* obsolete : this API will be removed in a future version */ +ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: no dictionary will be used if dict == NULL or dictSize < 8 */ +ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict is referenced, it must outlive decompression session */ +ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */ + + +/********************************************************************* +* Buffer-less and synchronous inner streaming functions +* +* This is an advanced API, giving full control over buffer management, for users which need direct control over memory. +* But it's also a complex one, with several restrictions, documented below. +* Prefer normal streaming API for an easier experience. +********************************************************************* */ + +/** + Buffer-less streaming compression (synchronous mode) + + A ZSTD_CCtx object is required to track streaming operations. + Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource. + ZSTD_CCtx object can be re-used multiple times within successive compression operations. + + Start by initializing a context. + Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression, + or ZSTD_compressBegin_advanced(), for finer parameter control. + It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx() + + Then, consume your input using ZSTD_compressContinue(). + There are some important considerations to keep in mind when using this advanced function : + - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only. + - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks. + - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario. + Worst case evaluation is provided by ZSTD_compressBound(). + ZSTD_compressContinue() doesn't guarantee recover after a failed compression. + - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog). + It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) + - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. + In which case, it will "discard" the relevant memory section from its history. + + Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. + It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame. + Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders. + + `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again. +*/ + +/*===== Buffer-less streaming compression functions =====*/ +ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); +ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); +ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ +ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */ +ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */ +ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */ + +ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); + + +/*- + Buffer-less streaming decompression (synchronous mode) + + A ZSTD_DCtx object is required to track streaming operations. + Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it. + A ZSTD_DCtx object can be re-used multiple times. + + First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader(). + Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough. + Data fragment must be large enough to ensure successful decoding. + `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough. + @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled. + >0 : `srcSize` is too small, please provide at least @result bytes on next attempt. + errorCode, which can be tested using ZSTD_isError(). + + It fills a ZSTD_frameHeader structure with important information to correctly decode the frame, + such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`). + Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information. + As a consequence, check that values remain within valid application range. + For example, do not allocate memory blindly, check that `windowSize` is within expectation. + Each application can set its own limits, depending on local restrictions. + For extended interoperability, it is recommended to support `windowSize` of at least 8 MB. + + ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes. + ZSTD_decompressContinue() is very sensitive to contiguity, + if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place, + or that previous contiguous segment is large enough to properly handle maximum back-reference distance. + There are multiple ways to guarantee this condition. + + The most memory efficient way is to use a round buffer of sufficient size. + Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(), + which can @return an error code if required value is too large for current system (in 32-bits mode). + In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one, + up to the moment there is not enough room left in the buffer to guarantee decoding another full block, + which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`. + At which point, decoding can resume from the beginning of the buffer. + Note that already decoded data stored in the buffer should be flushed before being overwritten. + + There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory. + + Finally, if you control the compression process, you can also ignore all buffer size rules, + as long as the encoder and decoder progress in "lock-step", + aka use exactly the same buffer sizes, break contiguity at the same place, etc. + + Once buffers are setup, start decompression, with ZSTD_decompressBegin(). + If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict(). + + Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively. + ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue(). + ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail. + + @result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity). + It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item. + It can also be an error code, which can be tested with ZSTD_isError(). + + A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero. + Context can then be reset to start a new decompression. + + Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType(). + This information is not required to properly decode a frame. + + == Special case : skippable frames == + + Skippable frames allow integration of user-defined data into a flow of concatenated frames. + Skippable frames will be ignored (skipped) by decompressor. + The format of skippable frames is as follows : + a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F + b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits + c) Frame Content - any content (User Data) of length equal to Frame Size + For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame. + For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content. +*/ + +/*===== Buffer-less streaming decompression functions =====*/ +typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e; +typedef struct { + unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */ + unsigned long long windowSize; /* can be very large, up to <= frameContentSize */ + unsigned blockSizeMax; + ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */ + unsigned headerSize; + unsigned dictID; + unsigned checksumFlag; +} ZSTD_frameHeader; +/** ZSTD_getFrameHeader() : + * decode Frame Header, or requires larger `srcSize`. + * @return : 0, `zfhPtr` is correctly filled, + * >0, `srcSize` is too small, value is wanted `srcSize` amount, + * or an error code, which can be tested using ZSTD_isError() */ +ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */ +ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */ + +ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx); +ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); +ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); + +ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx); +ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); + +/* misc */ +ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx); +typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e; +ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx); + + + +/* ============================================ */ +/** New advanced API (experimental) */ +/* ============================================ */ + +/* API design : + * In this advanced API, parameters are pushed one by one into an existing context, + * using ZSTD_CCtx_set*() functions. + * Pushed parameters are sticky : they are applied to next job, and any subsequent job. + * It's possible to reset parameters to "default" using ZSTD_CCtx_reset(). + * Important : "sticky" parameters only work with `ZSTD_compress_generic()` ! + * For any other entry point, "sticky" parameters are ignored ! + * + * This API is intended to replace all others advanced / experimental API entry points. + */ + +/* note on enum design : + * All enum will be pinned to explicit values before reaching "stable API" status */ + +typedef enum { + /* Opened question : should we have a format ZSTD_f_auto ? + * Today, it would mean exactly the same as ZSTD_f_zstd1. + * But, in the future, should several formats become supported, + * on the compression side, it would mean "default format". + * On the decompression side, it would mean "automatic format detection", + * so that ZSTD_f_zstd1 would mean "accept *only* zstd frames". + * Since meaning is a little different, another option could be to define different enums for compression and decompression. + * This question could be kept for later, when there are actually multiple formats to support, + * but there is also the question of pinning enum values, and pinning value `0` is especially important */ + ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */ + ZSTD_f_zstd1_magicless, /* Variant of zstd frame format, without initial 4-bytes magic number. + * Useful to save 4 bytes per generated frame. + * Decoder cannot recognise automatically this format, requiring instructions. */ +} ZSTD_format_e; + +typedef enum { + /* compression format */ + ZSTD_p_format = 10, /* See ZSTD_format_e enum definition. + * Cast selected format as unsigned for ZSTD_CCtx_setParameter() compatibility. */ + + /* compression parameters */ + ZSTD_p_compressionLevel=100, /* Update all compression parameters according to pre-defined cLevel table + * Default level is ZSTD_CLEVEL_DEFAULT==3. + * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT. + * Note 1 : it's possible to pass a negative compression level by casting it to unsigned type. + * Note 2 : setting a level sets all default values of other compression parameters. + * Note 3 : setting compressionLevel automatically updates ZSTD_p_compressLiterals. */ + ZSTD_p_windowLog, /* Maximum allowed back-reference distance, expressed as power of 2. + * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX. + * Special: value 0 means "use default windowLog". + * Note: Using a window size greater than ZSTD_MAXWINDOWSIZE_DEFAULT (default: 2^27) + * requires explicitly allowing such window size during decompression stage. */ + ZSTD_p_hashLog, /* Size of the initial probe table, as a power of 2. + * Resulting table size is (1 << (hashLog+2)). + * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX. + * Larger tables improve compression ratio of strategies <= dFast, + * and improve speed of strategies > dFast. + * Special: value 0 means "use default hashLog". */ + ZSTD_p_chainLog, /* Size of the multi-probe search table, as a power of 2. + * Resulting table size is (1 << (chainLog+2)). + * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX. + * Larger tables result in better and slower compression. + * This parameter is useless when using "fast" strategy. + * Note it's still useful when using "dfast" strategy, + * in which case it defines a secondary probe table. + * Special: value 0 means "use default chainLog". */ + ZSTD_p_searchLog, /* Number of search attempts, as a power of 2. + * More attempts result in better and slower compression. + * This parameter is useless when using "fast" and "dFast" strategies. + * Special: value 0 means "use default searchLog". */ + ZSTD_p_minMatch, /* Minimum size of searched matches (note : repCode matches can be smaller). + * Larger values make faster compression and decompression, but decrease ratio. + * Must be clamped between ZSTD_SEARCHLENGTH_MIN and ZSTD_SEARCHLENGTH_MAX. + * Note that currently, for all strategies < btopt, effective minimum is 4. + * , for all strategies > fast, effective maximum is 6. + * Special: value 0 means "use default minMatchLength". */ + ZSTD_p_targetLength, /* Impact of this field depends on strategy. + * For strategies btopt & btultra: + * Length of Match considered "good enough" to stop search. + * Larger values make compression stronger, and slower. + * For strategy fast: + * Distance between match sampling. + * Larger values make compression faster, and weaker. + * Special: value 0 means "use default targetLength". */ + ZSTD_p_compressionStrategy, /* See ZSTD_strategy enum definition. + * Cast selected strategy as unsigned for ZSTD_CCtx_setParameter() compatibility. + * The higher the value of selected strategy, the more complex it is, + * resulting in stronger and slower compression. + * Special: value 0 means "use default strategy". */ + + ZSTD_p_enableLongDistanceMatching=160, /* Enable long distance matching. + * This parameter is designed to improve compression ratio + * for large inputs, by finding large matches at long distance. + * It increases memory usage and window size. + * Note: enabling this parameter increases ZSTD_p_windowLog to 128 MB + * except when expressly set to a different value. */ + ZSTD_p_ldmHashLog, /* Size of the table for long distance matching, as a power of 2. + * Larger values increase memory usage and compression ratio, + * but decrease compression speed. + * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX + * default: windowlog - 7. + * Special: value 0 means "automatically determine hashlog". */ + ZSTD_p_ldmMinMatch, /* Minimum match size for long distance matcher. + * Larger/too small values usually decrease compression ratio. + * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX. + * Special: value 0 means "use default value" (default: 64). */ + ZSTD_p_ldmBucketSizeLog, /* Log size of each bucket in the LDM hash table for collision resolution. + * Larger values improve collision resolution but decrease compression speed. + * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX . + * Special: value 0 means "use default value" (default: 3). */ + ZSTD_p_ldmHashEveryLog, /* Frequency of inserting/looking up entries in the LDM hash table. + * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN). + * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage. + * Larger values improve compression speed. + * Deviating far from default value will likely result in a compression ratio decrease. + * Special: value 0 means "automatically determine hashEveryLog". */ + + /* frame parameters */ + ZSTD_p_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1) + * Content size must be known at the beginning of compression, + * it is provided using ZSTD_CCtx_setPledgedSrcSize() */ + ZSTD_p_checksumFlag, /* A 32-bits checksum of content is written at end of frame (default:0) */ + ZSTD_p_dictIDFlag, /* When applicable, dictionary's ID is written into frame header (default:1) */ + + /* multi-threading parameters */ + /* These parameters are only useful if multi-threading is enabled (ZSTD_MULTITHREAD). + * They return an error otherwise. */ + ZSTD_p_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel. + * When nbWorkers >= 1, triggers asynchronous mode : + * ZSTD_compress_generic() consumes some input, flush some output if possible, and immediately gives back control to caller, + * while compression work is performed in parallel, within worker threads. + * (note : a strong exception to this rule is when first invocation sets ZSTD_e_end : it becomes a blocking call). + * More workers improve speed, but also increase memory usage. + * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */ + ZSTD_p_jobSize, /* Size of a compression job. This value is enforced only in non-blocking mode. + * Each compression job is completed in parallel, so this value indirectly controls the nb of active threads. + * 0 means default, which is dynamically determined based on compression parameters. + * Job size must be a minimum of overlapSize, or 1 MB, whichever is largest. + * The minimum size is automatically and transparently enforced */ + ZSTD_p_overlapSizeLog, /* Size of previous input reloaded at the beginning of each job. + * 0 => no overlap, 6(default) => use 1/8th of windowSize, >=9 => use full windowSize */ + + /* =================================================================== */ + /* experimental parameters - no stability guaranteed */ + /* =================================================================== */ + + ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize, + * even when referencing into Dictionary content (default:0) */ + ZSTD_p_forceAttachDict, /* ZSTD supports usage of a CDict in-place + * (avoiding having to copy the compression tables + * from the CDict into the working context). Using + * a CDict in this way saves an initial setup step, + * but comes at the cost of more work per byte of + * input. ZSTD has a simple internal heuristic that + * guesses which strategy will be faster. You can + * use this flag to override that guess. + * + * Note that the by-reference, in-place strategy is + * only used when reusing a compression context + * with compatible compression parameters. (If + * incompatible / uninitialized, the working + * context needs to be cleared anyways, which is + * about as expensive as overwriting it with the + * dictionary context, so there's no savings in + * using the CDict by-ref.) + * + * Values greater than 0 force attaching the dict. + * Values less than 0 force copying the dict. + * 0 selects the default heuristic-guided behavior. + */ + +} ZSTD_cParameter; + + +/*! ZSTD_CCtx_setParameter() : + * Set one compression parameter, selected by enum ZSTD_cParameter. + * Setting a parameter is generally only possible during frame initialization (before starting compression). + * Exception : when using multi-threading mode (nbThreads >= 1), + * following parameters can be updated _during_ compression (within same frame): + * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. + * new parameters will be active on next job, or after a flush(). + * Note : when `value` type is not unsigned (int, or enum), cast it to unsigned for proper type checking. + * @result : informational value (typically, value being set, correctly clamped), + * or an error code (which can be tested with ZSTD_isError()). */ +ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value); + +/*! ZSTD_CCtx_getParameter() : + * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned* value); + +/*! ZSTD_CCtx_setPledgedSrcSize() : + * Total input data size to be compressed as a single frame. + * This value will be controlled at the end, and result in error if not respected. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Note 1 : 0 means zero, empty. + * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN. + * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new compression job. + * Note 2 : If all data is provided and consumed in a single round, + * this value is overriden by srcSize instead. */ +ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize); + +/*! ZSTD_CCtx_loadDictionary() : + * Create an internal CDict from `dict` buffer. + * Decompression will have to use same dictionary. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special: Adding a NULL (or 0-size) dictionary invalidates previous dictionary, + * meaning "return to no-dictionary mode". + * Note 1 : Dictionary will be used for all future compression jobs. + * To return to "no-dictionary" situation, load a NULL dictionary + * Note 2 : Loading a dictionary involves building tables, which are dependent on compression parameters. + * For this reason, compression parameters cannot be changed anymore after loading a dictionary. + * It's also a CPU consuming operation, with non-negligible impact on latency. + * Note 3 :`dict` content will be copied internally. + * Use ZSTD_CCtx_loadDictionary_byReference() to reference dictionary content instead. + * In such a case, dictionary buffer must outlive its users. + * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() + * to precisely select how dictionary content must be interpreted. */ +ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); +ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); +ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); + + +/*! ZSTD_CCtx_refCDict() : + * Reference a prepared dictionary, to be used for all next compression jobs. + * Note that compression parameters are enforced from within CDict, + * and supercede any compression parameter previously set within CCtx. + * The dictionary will remain valid for future compression jobs using same CCtx. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special : adding a NULL CDict means "return to no-dictionary mode". + * Note 1 : Currently, only one dictionary can be managed. + * Adding a new dictionary effectively "discards" any previous one. + * Note 2 : CDict is just referenced, its lifetime must outlive CCtx. */ +ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); + +/*! ZSTD_CCtx_refPrefix() : + * Reference a prefix (single-usage dictionary) for next compression job. + * Decompression will need same prefix to properly regenerate data. + * Compressing with a prefix is similar in outcome as performing a diff and compressing it, + * but performs much faster, especially during decompression (compression speed is tunable with compression level). + * Note that prefix is **only used once**. Tables are discarded at end of compression job (ZSTD_e_end). + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary + * Note 1 : Prefix buffer is referenced. It **must** outlive compression job. + * Its contain must remain unmodified up to end of compression (ZSTD_e_end). + * Note 2 : If the intention is to diff some large src data blob with some prior version of itself, + * ensure that the window size is large enough to contain the entire source. + * See ZSTD_p_windowLog. + * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. + * It's a CPU consuming operation, with non-negligible impact on latency. + * If there is a need to use same prefix multiple times, consider loadDictionary instead. + * Note 4 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent). + * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode. */ +ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, + const void* prefix, size_t prefixSize); +ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, + const void* prefix, size_t prefixSize, + ZSTD_dictContentType_e dictContentType); + +/*! ZSTD_CCtx_reset() : + * Return a CCtx to clean state. + * Useful after an error, or to interrupt an ongoing compression job and start a new one. + * Any internal data not yet flushed is cancelled. + * The parameters and dictionary are kept unchanged, to reset them use ZSTD_CCtx_resetParameters(). + */ +ZSTDLIB_API void ZSTD_CCtx_reset(ZSTD_CCtx* cctx); + +/*! ZSTD_CCtx_resetParameters() : + * All parameters are back to default values (compression level is ZSTD_CLEVEL_DEFAULT). + * Dictionary (if any) is dropped. + * Resetting parameters is only possible during frame initialization (before starting compression). + * To reset the context use ZSTD_CCtx_reset(). + * @return 0 or an error code (which can be checked with ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_CCtx_resetParameters(ZSTD_CCtx* cctx); + + + +typedef enum { + ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal conditions */ + ZSTD_e_flush, /* flush any data provided so far - frame will continue, future data can still reference previous data for better compression */ + ZSTD_e_end /* flush any remaining data and close current frame. Any additional data starts a new frame. */ +} ZSTD_EndDirective; + +/*! ZSTD_compress_generic() : + * Behave about the same as ZSTD_compressStream. To note : + * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_setParameter() + * - Compression parameters cannot be changed once compression is started. + * - outpot->pos must be <= dstCapacity, input->pos must be <= srcSize + * - outpot->pos and input->pos will be updated. They are guaranteed to remain below their respective limit. + * - In single-thread mode (default), function is blocking : it completed its job before returning to caller. + * - In multi-thread mode, function is non-blocking : it just acquires a copy of input, and distribute job to internal worker threads, + * and then immediately returns, just indicating that there is some data remaining to be flushed. + * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. + * - Exception : in multi-threading mode, if the first call requests a ZSTD_e_end directive, it is blocking : it will complete compression before giving back control to caller. + * - @return provides a minimum amount of data remaining to be flushed from internal buffers + * or an error code, which can be tested using ZSTD_isError(). + * if @return != 0, flush is not fully completed, there is still some data left within internal buffers. + * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. + * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. + * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), + * only ZSTD_e_end or ZSTD_e_flush operations are allowed. + * Before starting a new compression job, or changing compression parameters, + * it is required to fully flush internal buffers. + */ +ZSTDLIB_API size_t ZSTD_compress_generic (ZSTD_CCtx* cctx, + ZSTD_outBuffer* output, + ZSTD_inBuffer* input, + ZSTD_EndDirective endOp); + + +/*! ZSTD_compress_generic_simpleArgs() : + * Same as ZSTD_compress_generic(), + * but using only integral types as arguments. + * Argument list is larger than ZSTD_{in,out}Buffer, + * but can be helpful for binders from dynamic languages + * which have troubles handling structures containing memory pointers. + */ +ZSTDLIB_API size_t ZSTD_compress_generic_simpleArgs ( + ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, size_t* dstPos, + const void* src, size_t srcSize, size_t* srcPos, + ZSTD_EndDirective endOp); + + +/*! ZSTD_CCtx_params : + * Quick howto : + * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure + * - ZSTD_CCtxParam_setParameter() : Push parameters one by one into + * an existing ZSTD_CCtx_params structure. + * This is similar to + * ZSTD_CCtx_setParameter(). + * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to + * an existing CCtx. + * These parameters will be applied to + * all subsequent compression jobs. + * - ZSTD_compress_generic() : Do compression using the CCtx. + * - ZSTD_freeCCtxParams() : Free the memory. + * + * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() + * for static allocation for single-threaded compression. + */ +ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void); +ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); + + +/*! ZSTD_CCtxParams_reset() : + * Reset params to default values. + */ +ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params); + +/*! ZSTD_CCtxParams_init() : + * Initializes the compression parameters of cctxParams according to + * compression level. All other parameters are reset to their default values. + */ +ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel); + +/*! ZSTD_CCtxParams_init_advanced() : + * Initializes the compression and frame parameters of cctxParams according to + * params. All other parameters are reset to their default values. + */ +ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); + + +/*! ZSTD_CCtxParam_setParameter() : + * Similar to ZSTD_CCtx_setParameter. + * Set one compression parameter, selected by enum ZSTD_cParameter. + * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams(). + * Note : when `value` is an enum, cast it to unsigned for proper type checking. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value); + +/*! ZSTD_CCtxParam_getParameter() : + * Similar to ZSTD_CCtx_getParameter. + * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_CCtxParam_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned* value); + +/*! ZSTD_CCtx_setParametersUsingCCtxParams() : + * Apply a set of ZSTD_CCtx_params to the compression context. + * This can be done even after compression is started, + * if nbWorkers==0, this will have no impact until a new compression is started. + * if nbWorkers>=1, new parameters will be picked up at next job, + * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated). + */ +ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams( + ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params); + + +/* ==================================== */ +/*=== Advanced decompression API ===*/ +/* ==================================== */ + +/* The following API works the same way as the advanced compression API : + * a context is created, parameters are pushed into it one by one, + * then the context can be used to decompress data using an interface similar to the straming API. + */ + +/*! ZSTD_DCtx_loadDictionary() : + * Create an internal DDict from dict buffer, + * to be used to decompress next frames. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, + * meaning "return to no-dictionary mode". + * Note 1 : `dict` content will be copied internally. + * Use ZSTD_DCtx_loadDictionary_byReference() + * to reference dictionary content instead. + * In which case, the dictionary buffer must outlive its users. + * Note 2 : Loading a dictionary involves building tables, + * which has a non-negligible impact on CPU usage and latency. + * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to select + * how dictionary content will be interpreted and loaded. + */ +ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); +ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); +ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); + + +/*! ZSTD_DCtx_refDDict() : + * Reference a prepared dictionary, to be used to decompress next frames. + * The dictionary remains active for decompression of future frames using same DCtx. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Note 1 : Currently, only one dictionary can be managed. + * Referencing a new dictionary effectively "discards" any previous one. + * Special : adding a NULL DDict means "return to no-dictionary mode". + * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx. + */ +ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); + + +/*! ZSTD_DCtx_refPrefix() : + * Reference a prefix (single-usage dictionary) for next compression job. + * This is the reverse operation of ZSTD_CCtx_refPrefix(), + * and must use the same prefix as the one used during compression. + * Prefix is **only used once**. Reference is discarded at end of frame. + * End of frame is reached when ZSTD_DCtx_decompress_generic() returns 0. + * @result : 0, or an error code (which can be tested with ZSTD_isError()). + * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary + * Note 2 : Prefix buffer is referenced. It **must** outlive decompression job. + * Prefix buffer must remain unmodified up to the end of frame, + * reached when ZSTD_DCtx_decompress_generic() returns 0. + * Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent). + * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode. + * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. + * A fulldict prefix is more costly though. + */ +ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, + const void* prefix, size_t prefixSize); +ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, + const void* prefix, size_t prefixSize, + ZSTD_dictContentType_e dictContentType); + + +/*! ZSTD_DCtx_setMaxWindowSize() : + * Refuses allocating internal buffers for frames requiring a window size larger than provided limit. + * This is useful to prevent a decoder context from reserving too much memory for itself (potential attack scenario). + * This parameter is only useful in streaming mode, since no internal buffer is allocated in direct mode. + * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_MAX) + * @return : 0, or an error code (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize); + + +/*! ZSTD_DCtx_setFormat() : + * Instruct the decoder context about what kind of data to decode next. + * This instruction is mandatory to decode data without a fully-formed header, + * such ZSTD_f_zstd1_magicless for example. + * @return : 0, or an error code (which can be tested using ZSTD_isError()). + */ +ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format); + + +/*! ZSTD_getFrameHeader_advanced() : + * same as ZSTD_getFrameHeader(), + * with added capability to select a format (like ZSTD_f_zstd1_magicless) */ +ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, + const void* src, size_t srcSize, ZSTD_format_e format); + + +/*! ZSTD_decompress_generic() : + * Behave the same as ZSTD_decompressStream. + * Decompression parameters cannot be changed once decompression is started. + * @return : an error code, which can be tested using ZSTD_isError() + * if >0, a hint, nb of expected input bytes for next invocation. + * `0` means : a frame has just been fully decoded and flushed. + */ +ZSTDLIB_API size_t ZSTD_decompress_generic(ZSTD_DCtx* dctx, + ZSTD_outBuffer* output, + ZSTD_inBuffer* input); + + +/*! ZSTD_decompress_generic_simpleArgs() : + * Same as ZSTD_decompress_generic(), + * but using only integral types as arguments. + * Argument list is larger than ZSTD_{in,out}Buffer, + * but can be helpful for binders from dynamic languages + * which have troubles handling structures containing memory pointers. + */ +ZSTDLIB_API size_t ZSTD_decompress_generic_simpleArgs ( + ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, size_t* dstPos, + const void* src, size_t srcSize, size_t* srcPos); + + +/*! ZSTD_DCtx_reset() : + * Return a DCtx to clean state. + * If a decompression was ongoing, any internal data not yet flushed is cancelled. + * All parameters are back to default values, including sticky ones. + * Dictionary (if any) is dropped. + * Parameters can be modified again after a reset. + */ +ZSTDLIB_API void ZSTD_DCtx_reset(ZSTD_DCtx* dctx); + + + +/* ============================ */ +/** Block level API */ +/* ============================ */ + +/*! + Block functions produce and decode raw zstd blocks, without frame metadata. + Frame metadata cost is typically ~18 bytes, which can be non-negligible for very small blocks (< 100 bytes). + User will have to take in charge required information to regenerate data, such as compressed and content sizes. + + A few rules to respect : + - Compressing and decompressing require a context structure + + Use ZSTD_createCCtx() and ZSTD_createDCtx() + - It is necessary to init context before starting + + compression : any ZSTD_compressBegin*() variant, including with dictionary + + decompression : any ZSTD_decompressBegin*() variant, including with dictionary + + copyCCtx() and copyDCtx() can be used too + - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB + + If input is larger than a block size, it's necessary to split input data into multiple blocks + + For inputs larger than a single block size, consider using the regular ZSTD_compress() instead. + Frame metadata is not that costly, and quickly becomes negligible as source size grows larger. + - When a block is considered not compressible enough, ZSTD_compressBlock() result will be zero. + In which case, nothing is produced into `dst`. + + User must test for such outcome and deal directly with uncompressed data + + ZSTD_decompressBlock() doesn't accept uncompressed data as input !!! + + In case of multiple successive blocks, should some of them be uncompressed, + decoder must be informed of their existence in order to follow proper history. + Use ZSTD_insertBlock() for such a case. +*/ + +/*===== Raw zstd block functions =====*/ +ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx); +ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); +ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */ + + +#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ + +#if defined (__cplusplus) +} +#endif diff --git a/grub-core/lib/zstd/zstd_common.c b/grub-core/lib/zstd/zstd_common.c new file mode 100644 index 000000000..6f05d240e --- /dev/null +++ b/grub-core/lib/zstd/zstd_common.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + + + +/*-************************************* +* Dependencies +***************************************/ +#include /* malloc, calloc, free */ +#include /* memset */ +#include "error_private.h" +#include "zstd_internal.h" + + +/*-**************************************** +* Version +******************************************/ +unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; } + +const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; } + + +/*-**************************************** +* ZSTD Error Management +******************************************/ +/*! ZSTD_isError() : + * tells if a return value is an error code */ +unsigned ZSTD_isError(size_t code) { return ERR_isError(code); } + +/*! ZSTD_getErrorName() : + * provides error code string from function result (useful for debugging) */ +const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); } + +/*! ZSTD_getError() : + * convert a `size_t` function result into a proper ZSTD_errorCode enum */ +ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); } + +/*! ZSTD_getErrorString() : + * provides error code string from enum */ +const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); } + + + +/*=************************************************************** +* Custom allocator +****************************************************************/ +void* ZSTD_malloc(size_t size, ZSTD_customMem customMem) +{ + if (customMem.customAlloc) + return customMem.customAlloc(customMem.opaque, size); + return malloc(size); +} + +void* ZSTD_calloc(size_t size, ZSTD_customMem customMem) +{ + if (customMem.customAlloc) { + /* calloc implemented as malloc+memset; + * not as efficient as calloc, but next best guess for custom malloc */ + void* const ptr = customMem.customAlloc(customMem.opaque, size); + memset(ptr, 0, size); + return ptr; + } + return calloc(1, size); +} + +void ZSTD_free(void* ptr, ZSTD_customMem customMem) +{ + if (ptr!=NULL) { + if (customMem.customFree) + customMem.customFree(customMem.opaque, ptr); + else + free(ptr); + } +} diff --git a/grub-core/lib/zstd/zstd_decompress.c b/grub-core/lib/zstd/zstd_decompress.c new file mode 100644 index 000000000..711b5b6d7 --- /dev/null +++ b/grub-core/lib/zstd/zstd_decompress.c @@ -0,0 +1,3108 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + + +/* *************************************************************** +* Tuning parameters +*****************************************************************/ +/*! + * HEAPMODE : + * Select how default decompression function ZSTD_decompress() allocates its context, + * on stack (0), or into heap (1, default; requires malloc()). + * Note that functions with explicit context such as ZSTD_decompressDCtx() are unaffected. + */ +#ifndef ZSTD_HEAPMODE +# define ZSTD_HEAPMODE 1 +#endif + +/*! +* LEGACY_SUPPORT : +* if set to 1+, ZSTD_decompress() can decode older formats (v0.1+) +*/ +#ifndef ZSTD_LEGACY_SUPPORT +# define ZSTD_LEGACY_SUPPORT 0 +#endif + +/*! + * MAXWINDOWSIZE_DEFAULT : + * maximum window size accepted by DStream __by default__. + * Frames requiring more memory will be rejected. + * It's possible to set a different limit using ZSTD_DCtx_setMaxWindowSize(). + */ +#ifndef ZSTD_MAXWINDOWSIZE_DEFAULT +# define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_DEFAULTMAX) + 1) +#endif + +/*! + * NO_FORWARD_PROGRESS_MAX : + * maximum allowed nb of calls to ZSTD_decompressStream() and ZSTD_decompress_generic() + * without any forward progress + * (defined as: no byte read from input, and no byte flushed to output) + * before triggering an error. + */ +#ifndef ZSTD_NO_FORWARD_PROGRESS_MAX +# define ZSTD_NO_FORWARD_PROGRESS_MAX 16 +#endif + + +/*-******************************************************* +* Dependencies +*********************************************************/ +#include /* memcpy, memmove, memset */ +#include "compiler.h" /* prefetch */ +#include "cpu.h" /* bmi2 */ +#include "mem.h" /* low level memory routines */ +#define FSE_STATIC_LINKING_ONLY +#include "fse.h" +#define HUF_STATIC_LINKING_ONLY +#include "huf.h" +#include "zstd_internal.h" + +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1) +# include "zstd_legacy.h" +#endif + +static const void* ZSTD_DDictDictContent(const ZSTD_DDict* ddict); +static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict); + + +/*-************************************* +* Errors +***************************************/ +#define ZSTD_isError ERR_isError /* for inlining */ +#define FSE_isError ERR_isError +#define HUF_isError ERR_isError + + +/*_******************************************************* +* Memory operations +**********************************************************/ +static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); } + + +/*-************************************************************* +* Context management +***************************************************************/ +typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader, + ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock, + ZSTDds_decompressLastBlock, ZSTDds_checkChecksum, + ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage; + +typedef enum { zdss_init=0, zdss_loadHeader, + zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage; + + +typedef struct { + U32 fastMode; + U32 tableLog; +} ZSTD_seqSymbol_header; + +typedef struct { + U16 nextState; + BYTE nbAdditionalBits; + BYTE nbBits; + U32 baseValue; +} ZSTD_seqSymbol; + +#define SEQSYMBOL_TABLE_SIZE(log) (1 + (1 << (log))) + +typedef struct { + ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */ + ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */ + ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */ + HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */ + U32 rep[ZSTD_REP_NUM]; +} ZSTD_entropyDTables_t; + +struct ZSTD_DCtx_s +{ + const ZSTD_seqSymbol* LLTptr; + const ZSTD_seqSymbol* MLTptr; + const ZSTD_seqSymbol* OFTptr; + const HUF_DTable* HUFptr; + ZSTD_entropyDTables_t entropy; + U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */ + const void* previousDstEnd; /* detect continuity */ + const void* prefixStart; /* start of current segment */ + const void* virtualStart; /* virtual start of previous segment if it was just before current one */ + const void* dictEnd; /* end of previous segment */ + size_t expected; + ZSTD_frameHeader fParams; + U64 decodedSize; + blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */ + ZSTD_dStage stage; + U32 litEntropy; + U32 fseEntropy; + XXH64_state_t xxhState; + size_t headerSize; + ZSTD_format_e format; + const BYTE* litPtr; + ZSTD_customMem customMem; + size_t litSize; + size_t rleSize; + size_t staticSize; + int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */ + + /* dictionary */ + ZSTD_DDict* ddictLocal; + const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */ + U32 dictID; + int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */ + + /* streaming */ + ZSTD_dStreamStage streamStage; + char* inBuff; + size_t inBuffSize; + size_t inPos; + size_t maxWindowSize; + char* outBuff; + size_t outBuffSize; + size_t outStart; + size_t outEnd; + size_t lhSize; + void* legacyContext; + U32 previousLegacyVersion; + U32 legacyVersion; + U32 hostageByte; + int noForwardProgress; + + /* workspace */ + BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH]; + BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]; +}; /* typedef'd to ZSTD_DCtx within "zstd.h" */ + +size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx) +{ + if (dctx==NULL) return 0; /* support sizeof NULL */ + return sizeof(*dctx) + + ZSTD_sizeof_DDict(dctx->ddictLocal) + + dctx->inBuffSize + dctx->outBuffSize; +} + +size_t ZSTD_estimateDCtxSize(void) { return sizeof(ZSTD_DCtx); } + + +static size_t ZSTD_startingInputLength(ZSTD_format_e format) +{ + size_t const startingInputLength = (format==ZSTD_f_zstd1_magicless) ? + ZSTD_frameHeaderSize_prefix - ZSTD_FRAMEIDSIZE : + ZSTD_frameHeaderSize_prefix; + ZSTD_STATIC_ASSERT(ZSTD_FRAMEHEADERSIZE_PREFIX >= ZSTD_FRAMEIDSIZE); + /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */ + assert( (format == ZSTD_f_zstd1) || (format == ZSTD_f_zstd1_magicless) ); + return startingInputLength; +} + +static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx) +{ + dctx->format = ZSTD_f_zstd1; /* ZSTD_decompressBegin() invokes ZSTD_startingInputLength() with argument dctx->format */ + dctx->staticSize = 0; + dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT; + dctx->ddict = NULL; + dctx->ddictLocal = NULL; + dctx->dictEnd = NULL; + dctx->ddictIsCold = 0; + dctx->inBuff = NULL; + dctx->inBuffSize = 0; + dctx->outBuffSize = 0; + dctx->streamStage = zdss_init; + dctx->legacyContext = NULL; + dctx->previousLegacyVersion = 0; + dctx->noForwardProgress = 0; + dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid()); +} + +ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize) +{ + ZSTD_DCtx* const dctx = (ZSTD_DCtx*) workspace; + + if ((size_t)workspace & 7) return NULL; /* 8-aligned */ + if (workspaceSize < sizeof(ZSTD_DCtx)) return NULL; /* minimum size */ + + ZSTD_initDCtx_internal(dctx); + dctx->staticSize = workspaceSize; + dctx->inBuff = (char*)(dctx+1); + return dctx; +} + +ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem) +{ + if (!customMem.customAlloc ^ !customMem.customFree) return NULL; + + { ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(*dctx), customMem); + if (!dctx) return NULL; + dctx->customMem = customMem; + ZSTD_initDCtx_internal(dctx); + return dctx; + } +} + +ZSTD_DCtx* ZSTD_createDCtx(void) +{ + DEBUGLOG(3, "ZSTD_createDCtx"); + return ZSTD_createDCtx_advanced(ZSTD_defaultCMem); +} + +size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx) +{ + if (dctx==NULL) return 0; /* support free on NULL */ + if (dctx->staticSize) return ERROR(memory_allocation); /* not compatible with static DCtx */ + { ZSTD_customMem const cMem = dctx->customMem; + ZSTD_freeDDict(dctx->ddictLocal); + dctx->ddictLocal = NULL; + ZSTD_free(dctx->inBuff, cMem); + dctx->inBuff = NULL; +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) + if (dctx->legacyContext) + ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion); +#endif + ZSTD_free(dctx, cMem); + return 0; + } +} + +/* no longer useful */ +void ZSTD_copyDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx) +{ + size_t const toCopy = (size_t)((char*)(&dstDCtx->inBuff) - (char*)dstDCtx); + memcpy(dstDCtx, srcDCtx, toCopy); /* no need to copy workspace */ +} + + +/*-************************************************************* + * Frame header decoding + ***************************************************************/ + +/*! ZSTD_isFrame() : + * Tells if the content of `buffer` starts with a valid Frame Identifier. + * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. + * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. + * Note 3 : Skippable Frame Identifiers are considered valid. */ +unsigned ZSTD_isFrame(const void* buffer, size_t size) +{ + if (size < ZSTD_FRAMEIDSIZE) return 0; + { U32 const magic = MEM_readLE32(buffer); + if (magic == ZSTD_MAGICNUMBER) return 1; + if ((magic & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) return 1; + } +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) + if (ZSTD_isLegacy(buffer, size)) return 1; +#endif + return 0; +} + +/** ZSTD_frameHeaderSize_internal() : + * srcSize must be large enough to reach header size fields. + * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless. + * @return : size of the Frame Header + * or an error code, which can be tested with ZSTD_isError() */ +static size_t ZSTD_frameHeaderSize_internal(const void* src, size_t srcSize, ZSTD_format_e format) +{ + size_t const minInputSize = ZSTD_startingInputLength(format); + if (srcSize < minInputSize) return ERROR(srcSize_wrong); + + { BYTE const fhd = ((const BYTE*)src)[minInputSize-1]; + U32 const dictID= fhd & 3; + U32 const singleSegment = (fhd >> 5) & 1; + U32 const fcsId = fhd >> 6; + return minInputSize + !singleSegment + + ZSTD_did_fieldSize[dictID] + ZSTD_fcs_fieldSize[fcsId] + + (singleSegment && !fcsId); + } +} + +/** ZSTD_frameHeaderSize() : + * srcSize must be >= ZSTD_frameHeaderSize_prefix. + * @return : size of the Frame Header, + * or an error code (if srcSize is too small) */ +size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize) +{ + return ZSTD_frameHeaderSize_internal(src, srcSize, ZSTD_f_zstd1); +} + + +/** ZSTD_getFrameHeader_advanced() : + * decode Frame Header, or require larger `srcSize`. + * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless + * @return : 0, `zfhPtr` is correctly filled, + * >0, `srcSize` is too small, value is wanted `srcSize` amount, + * or an error code, which can be tested using ZSTD_isError() */ +size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format) +{ + const BYTE* ip = (const BYTE*)src; + size_t const minInputSize = ZSTD_startingInputLength(format); + + memset(zfhPtr, 0, sizeof(*zfhPtr)); /* not strictly necessary, but static analyzer do not understand that zfhPtr is only going to be read only if return value is zero, since they are 2 different signals */ + if (srcSize < minInputSize) return minInputSize; + if (src==NULL) return ERROR(GENERIC); /* invalid parameter */ + + if ( (format != ZSTD_f_zstd1_magicless) + && (MEM_readLE32(src) != ZSTD_MAGICNUMBER) ) { + if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { + /* skippable frame */ + if (srcSize < ZSTD_skippableHeaderSize) + return ZSTD_skippableHeaderSize; /* magic number + frame length */ + memset(zfhPtr, 0, sizeof(*zfhPtr)); + zfhPtr->frameContentSize = MEM_readLE32((const char *)src + ZSTD_FRAMEIDSIZE); + zfhPtr->frameType = ZSTD_skippableFrame; + return 0; + } + return ERROR(prefix_unknown); + } + + /* ensure there is enough `srcSize` to fully read/decode frame header */ + { size_t const fhsize = ZSTD_frameHeaderSize_internal(src, srcSize, format); + if (srcSize < fhsize) return fhsize; + zfhPtr->headerSize = (U32)fhsize; + } + + { BYTE const fhdByte = ip[minInputSize-1]; + size_t pos = minInputSize; + U32 const dictIDSizeCode = fhdByte&3; + U32 const checksumFlag = (fhdByte>>2)&1; + U32 const singleSegment = (fhdByte>>5)&1; + U32 const fcsID = fhdByte>>6; + U64 windowSize = 0; + U32 dictID = 0; + U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN; + if ((fhdByte & 0x08) != 0) + return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */ + + if (!singleSegment) { + BYTE const wlByte = ip[pos++]; + U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN; + if (windowLog > ZSTD_WINDOWLOG_MAX) + return ERROR(frameParameter_windowTooLarge); + windowSize = (1ULL << windowLog); + windowSize += (windowSize >> 3) * (wlByte&7); + } + switch(dictIDSizeCode) + { + default: assert(0); /* impossible */ + case 0 : break; + case 1 : dictID = ip[pos]; pos++; break; + case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break; + case 3 : dictID = MEM_readLE32(ip+pos); pos+=4; break; + } + switch(fcsID) + { + default: assert(0); /* impossible */ + case 0 : if (singleSegment) frameContentSize = ip[pos]; break; + case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break; + case 2 : frameContentSize = MEM_readLE32(ip+pos); break; + case 3 : frameContentSize = MEM_readLE64(ip+pos); break; + } + if (singleSegment) windowSize = frameContentSize; + + zfhPtr->frameType = ZSTD_frame; + zfhPtr->frameContentSize = frameContentSize; + zfhPtr->windowSize = windowSize; + zfhPtr->blockSizeMax = (unsigned) MIN(windowSize, ZSTD_BLOCKSIZE_MAX); + zfhPtr->dictID = dictID; + zfhPtr->checksumFlag = checksumFlag; + } + return 0; +} + +/** ZSTD_getFrameHeader() : + * decode Frame Header, or require larger `srcSize`. + * note : this function does not consume input, it only reads it. + * @return : 0, `zfhPtr` is correctly filled, + * >0, `srcSize` is too small, value is wanted `srcSize` amount, + * or an error code, which can be tested using ZSTD_isError() */ +size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize) +{ + return ZSTD_getFrameHeader_advanced(zfhPtr, src, srcSize, ZSTD_f_zstd1); +} + + +/** ZSTD_getFrameContentSize() : + * compatible with legacy mode + * @return : decompressed size of the single frame pointed to be `src` if known, otherwise + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined + * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */ +unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize) +{ +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) + if (ZSTD_isLegacy(src, srcSize)) { + unsigned long long const ret = ZSTD_getDecompressedSize_legacy(src, srcSize); + return ret == 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret; + } +#endif + { ZSTD_frameHeader zfh; + if (ZSTD_getFrameHeader(&zfh, src, srcSize) != 0) + return ZSTD_CONTENTSIZE_ERROR; + if (zfh.frameType == ZSTD_skippableFrame) { + return 0; + } else { + return zfh.frameContentSize; + } } +} + +/** ZSTD_findDecompressedSize() : + * compatible with legacy mode + * `srcSize` must be the exact length of some number of ZSTD compressed and/or + * skippable frames + * @return : decompressed size of the frames contained */ +unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize) +{ + unsigned long long totalDstSize = 0; + + while (srcSize >= ZSTD_frameHeaderSize_prefix) { + U32 const magicNumber = MEM_readLE32(src); + + if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { + size_t skippableSize; + if (srcSize < ZSTD_skippableHeaderSize) + return ERROR(srcSize_wrong); + skippableSize = MEM_readLE32((const BYTE *)src + ZSTD_FRAMEIDSIZE) + + ZSTD_skippableHeaderSize; + if (srcSize < skippableSize) { + return ZSTD_CONTENTSIZE_ERROR; + } + + src = (const BYTE *)src + skippableSize; + srcSize -= skippableSize; + continue; + } + + { unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize); + if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret; + + /* check for overflow */ + if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR; + totalDstSize += ret; + } + { size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize); + if (ZSTD_isError(frameSrcSize)) { + return ZSTD_CONTENTSIZE_ERROR; + } + + src = (const BYTE *)src + frameSrcSize; + srcSize -= frameSrcSize; + } + } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */ + + if (srcSize) return ZSTD_CONTENTSIZE_ERROR; + + return totalDstSize; +} + +/** ZSTD_getDecompressedSize() : +* compatible with legacy mode +* @return : decompressed size if known, 0 otherwise + note : 0 can mean any of the following : + - frame content is empty + - decompressed size field is not present in frame header + - frame header unknown / not supported + - frame header not complete (`srcSize` too small) */ +unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize) +{ + unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize); + ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_ERROR < ZSTD_CONTENTSIZE_UNKNOWN); + return (ret >= ZSTD_CONTENTSIZE_ERROR) ? 0 : ret; +} + + +/** ZSTD_decodeFrameHeader() : +* `headerSize` must be the size provided by ZSTD_frameHeaderSize(). +* @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */ +static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t headerSize) +{ + size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format); + if (ZSTD_isError(result)) return result; /* invalid header */ + if (result>0) return ERROR(srcSize_wrong); /* headerSize too small */ + if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID)) + return ERROR(dictionary_wrong); + if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0); + return 0; +} + + +/*-************************************************************* + * Block decoding + ***************************************************************/ + +/*! ZSTD_getcBlockSize() : +* Provides the size of compressed block from block header `src` */ +size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, + blockProperties_t* bpPtr) +{ + if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); + { U32 const cBlockHeader = MEM_readLE24(src); + U32 const cSize = cBlockHeader >> 3; + bpPtr->lastBlock = cBlockHeader & 1; + bpPtr->blockType = (blockType_e)((cBlockHeader >> 1) & 3); + bpPtr->origSize = cSize; /* only useful for RLE */ + if (bpPtr->blockType == bt_rle) return 1; + if (bpPtr->blockType == bt_reserved) return ERROR(corruption_detected); + return cSize; + } +} + + +static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity, + const void* src, size_t srcSize) +{ + if (dst==NULL) return ERROR(dstSize_tooSmall); + if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall); + memcpy(dst, src, srcSize); + return srcSize; +} + + +static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + size_t regenSize) +{ + if (srcSize != 1) return ERROR(srcSize_wrong); + if (regenSize > dstCapacity) return ERROR(dstSize_tooSmall); + memset(dst, *(const BYTE*)src, regenSize); + return regenSize; +} + +/* Hidden declaration for fullbench */ +size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx, + const void* src, size_t srcSize); +/*! ZSTD_decodeLiteralsBlock() : + * @return : nb of bytes read from src (< srcSize ) + * note : symbol not declared but exposed for fullbench */ +size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx, + const void* src, size_t srcSize) /* note : srcSize < BLOCKSIZE */ +{ + if (srcSize < MIN_CBLOCK_SIZE) return ERROR(corruption_detected); + + { const BYTE* const istart = (const BYTE*) src; + symbolEncodingType_e const litEncType = (symbolEncodingType_e)(istart[0] & 3); + + switch(litEncType) + { + case set_repeat: + if (dctx->litEntropy==0) return ERROR(dictionary_corrupted); + /* fall-through */ + + case set_compressed: + if (srcSize < 5) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */ + { size_t lhSize, litSize, litCSize; + U32 singleStream=0; + U32 const lhlCode = (istart[0] >> 2) & 3; + U32 const lhc = MEM_readLE32(istart); + switch(lhlCode) + { + case 0: case 1: default: /* note : default is impossible, since lhlCode into [0..3] */ + /* 2 - 2 - 10 - 10 */ + singleStream = !lhlCode; + lhSize = 3; + litSize = (lhc >> 4) & 0x3FF; + litCSize = (lhc >> 14) & 0x3FF; + break; + case 2: + /* 2 - 2 - 14 - 14 */ + lhSize = 4; + litSize = (lhc >> 4) & 0x3FFF; + litCSize = lhc >> 18; + break; + case 3: + /* 2 - 2 - 18 - 18 */ + lhSize = 5; + litSize = (lhc >> 4) & 0x3FFFF; + litCSize = (lhc >> 22) + (istart[4] << 10); + break; + } + if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected); + if (litCSize + lhSize > srcSize) return ERROR(corruption_detected); + + /* prefetch huffman table if cold */ + if (dctx->ddictIsCold && (litSize > 768 /* heuristic */)) { + PREFETCH_AREA(dctx->HUFptr, sizeof(dctx->entropy.hufTable)); + } + + if (HUF_isError((litEncType==set_repeat) ? + ( singleStream ? + HUF_decompress1X_usingDTable_bmi2(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr, dctx->bmi2) : + HUF_decompress4X_usingDTable_bmi2(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr, dctx->bmi2) ) : + ( singleStream ? + HUF_decompress1X1_DCtx_wksp_bmi2(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize, + dctx->workspace, sizeof(dctx->workspace), dctx->bmi2) : + HUF_decompress4X_hufOnly_wksp_bmi2(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize, + dctx->workspace, sizeof(dctx->workspace), dctx->bmi2)))) + return ERROR(corruption_detected); + + dctx->litPtr = dctx->litBuffer; + dctx->litSize = litSize; + dctx->litEntropy = 1; + if (litEncType==set_compressed) dctx->HUFptr = dctx->entropy.hufTable; + memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH); + return litCSize + lhSize; + } + + case set_basic: + { size_t litSize, lhSize; + U32 const lhlCode = ((istart[0]) >> 2) & 3; + switch(lhlCode) + { + case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */ + lhSize = 1; + litSize = istart[0] >> 3; + break; + case 1: + lhSize = 2; + litSize = MEM_readLE16(istart) >> 4; + break; + case 3: + lhSize = 3; + litSize = MEM_readLE24(istart) >> 4; + break; + } + + if (lhSize+litSize+WILDCOPY_OVERLENGTH > srcSize) { /* risk reading beyond src buffer with wildcopy */ + if (litSize+lhSize > srcSize) return ERROR(corruption_detected); + memcpy(dctx->litBuffer, istart+lhSize, litSize); + dctx->litPtr = dctx->litBuffer; + dctx->litSize = litSize; + memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH); + return lhSize+litSize; + } + /* direct reference into compressed stream */ + dctx->litPtr = istart+lhSize; + dctx->litSize = litSize; + return lhSize+litSize; + } + + case set_rle: + { U32 const lhlCode = ((istart[0]) >> 2) & 3; + size_t litSize, lhSize; + switch(lhlCode) + { + case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */ + lhSize = 1; + litSize = istart[0] >> 3; + break; + case 1: + lhSize = 2; + litSize = MEM_readLE16(istart) >> 4; + break; + case 3: + lhSize = 3; + litSize = MEM_readLE24(istart) >> 4; + if (srcSize<4) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need lhSize+1 = 4 */ + break; + } + if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected); + memset(dctx->litBuffer, istart[lhSize], litSize + WILDCOPY_OVERLENGTH); + dctx->litPtr = dctx->litBuffer; + dctx->litSize = litSize; + return lhSize+1; + } + default: + return ERROR(corruption_detected); /* impossible */ + } + } +} + +/* Default FSE distribution tables. + * These are pre-calculated FSE decoding tables using default distributions as defined in specification : + * https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#default-distributions + * They were generated programmatically with following method : + * - start from default distributions, present in /lib/common/zstd_internal.h + * - generate tables normally, using ZSTD_buildFSETable() + * - printout the content of tables + * - pretify output, report below, test with fuzzer to ensure it's correct */ + +/* Default FSE distribution table for Literal Lengths */ +static const ZSTD_seqSymbol LL_defaultDTable[(1<tableLog = 0; + DTableH->fastMode = 0; + + cell->nbBits = 0; + cell->nextState = 0; + assert(nbAddBits < 255); + cell->nbAdditionalBits = (BYTE)nbAddBits; + cell->baseValue = baseValue; +} + + +/* ZSTD_buildFSETable() : + * generate FSE decoding table for one symbol (ll, ml or off) */ +static void +ZSTD_buildFSETable(ZSTD_seqSymbol* dt, + const short* normalizedCounter, unsigned maxSymbolValue, + const U32* baseValue, const U32* nbAdditionalBits, + unsigned tableLog) +{ + ZSTD_seqSymbol* const tableDecode = dt+1; + U16 symbolNext[MaxSeq+1]; + + U32 const maxSV1 = maxSymbolValue + 1; + U32 const tableSize = 1 << tableLog; + U32 highThreshold = tableSize-1; + + /* Sanity Checks */ + assert(maxSymbolValue <= MaxSeq); + assert(tableLog <= MaxFSELog); + + /* Init, lay down lowprob symbols */ + { ZSTD_seqSymbol_header DTableH; + DTableH.tableLog = tableLog; + DTableH.fastMode = 1; + { S16 const largeLimit= (S16)(1 << (tableLog-1)); + U32 s; + for (s=0; s= largeLimit) DTableH.fastMode=0; + symbolNext[s] = normalizedCounter[s]; + } } } + memcpy(dt, &DTableH, sizeof(DTableH)); + } + + /* Spread symbols */ + { U32 const tableMask = tableSize-1; + U32 const step = FSE_TABLESTEP(tableSize); + U32 s, position = 0; + for (s=0; s highThreshold) position = (position + step) & tableMask; /* lowprob area */ + } } + assert(position == 0); /* position must reach all cells once, otherwise normalizedCounter is incorrect */ + } + + /* Build Decoding table */ + { U32 u; + for (u=0; u max) return ERROR(corruption_detected); + { U32 const symbol = *(const BYTE*)src; + U32 const baseline = baseValue[symbol]; + U32 const nbBits = nbAdditionalBits[symbol]; + ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits); + } + *DTablePtr = DTableSpace; + return 1; + case set_basic : + *DTablePtr = defaultTable; + return 0; + case set_repeat: + if (!flagRepeatTable) return ERROR(corruption_detected); + /* prefetch FSE table if used */ + if (ddictIsCold && (nbSeq > 24 /* heuristic */)) { + const void* const pStart = *DTablePtr; + size_t const pSize = sizeof(ZSTD_seqSymbol) * (SEQSYMBOL_TABLE_SIZE(maxLog)); + PREFETCH_AREA(pStart, pSize); + } + return 0; + case set_compressed : + { U32 tableLog; + S16 norm[MaxSeq+1]; + size_t const headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize); + if (FSE_isError(headerSize)) return ERROR(corruption_detected); + if (tableLog > maxLog) return ERROR(corruption_detected); + ZSTD_buildFSETable(DTableSpace, norm, max, baseValue, nbAdditionalBits, tableLog); + *DTablePtr = DTableSpace; + return headerSize; + } + default : /* impossible */ + assert(0); + return ERROR(GENERIC); + } +} + +static const U32 LL_base[MaxLL+1] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 18, 20, 22, 24, 28, 32, 40, + 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, + 0x2000, 0x4000, 0x8000, 0x10000 }; + +static const U32 OF_base[MaxOff+1] = { + 0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D, + 0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD, + 0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD, + 0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD }; + +static const U32 OF_bits[MaxOff+1] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 }; + +static const U32 ML_base[MaxML+1] = { + 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, + 35, 37, 39, 41, 43, 47, 51, 59, + 67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803, + 0x1003, 0x2003, 0x4003, 0x8003, 0x10003 }; + +/* Hidden delcaration for fullbench */ +size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr, + const void* src, size_t srcSize); + +size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr, + const void* src, size_t srcSize) +{ + const BYTE* const istart = (const BYTE* const)src; + const BYTE* const iend = istart + srcSize; + const BYTE* ip = istart; + int nbSeq; + DEBUGLOG(5, "ZSTD_decodeSeqHeaders"); + + /* check */ + if (srcSize < MIN_SEQUENCES_SIZE) return ERROR(srcSize_wrong); + + /* SeqHead */ + nbSeq = *ip++; + if (!nbSeq) { *nbSeqPtr=0; return 1; } + if (nbSeq > 0x7F) { + if (nbSeq == 0xFF) { + if (ip+2 > iend) return ERROR(srcSize_wrong); + nbSeq = MEM_readLE16(ip) + LONGNBSEQ, ip+=2; + } else { + if (ip >= iend) return ERROR(srcSize_wrong); + nbSeq = ((nbSeq-0x80)<<8) + *ip++; + } + } + *nbSeqPtr = nbSeq; + + /* FSE table descriptors */ + if (ip+4 > iend) return ERROR(srcSize_wrong); /* minimum possible size */ + { symbolEncodingType_e const LLtype = (symbolEncodingType_e)(*ip >> 6); + symbolEncodingType_e const OFtype = (symbolEncodingType_e)((*ip >> 4) & 3); + symbolEncodingType_e const MLtype = (symbolEncodingType_e)((*ip >> 2) & 3); + ip++; + + /* Build DTables */ + { size_t const llhSize = ZSTD_buildSeqTable(dctx->entropy.LLTable, &dctx->LLTptr, + LLtype, MaxLL, LLFSELog, + ip, iend-ip, + LL_base, LL_bits, + LL_defaultDTable, dctx->fseEntropy, + dctx->ddictIsCold, nbSeq); + if (ZSTD_isError(llhSize)) return ERROR(corruption_detected); + ip += llhSize; + } + + { size_t const ofhSize = ZSTD_buildSeqTable(dctx->entropy.OFTable, &dctx->OFTptr, + OFtype, MaxOff, OffFSELog, + ip, iend-ip, + OF_base, OF_bits, + OF_defaultDTable, dctx->fseEntropy, + dctx->ddictIsCold, nbSeq); + if (ZSTD_isError(ofhSize)) return ERROR(corruption_detected); + ip += ofhSize; + } + + { size_t const mlhSize = ZSTD_buildSeqTable(dctx->entropy.MLTable, &dctx->MLTptr, + MLtype, MaxML, MLFSELog, + ip, iend-ip, + ML_base, ML_bits, + ML_defaultDTable, dctx->fseEntropy, + dctx->ddictIsCold, nbSeq); + if (ZSTD_isError(mlhSize)) return ERROR(corruption_detected); + ip += mlhSize; + } + } + + /* prefetch dictionary content */ + if (dctx->ddictIsCold) { + size_t const dictSize = (const char*)dctx->prefixStart - (const char*)dctx->virtualStart; + size_t const psmin = MIN(dictSize, (size_t)(64*nbSeq) /* heuristic */ ); + size_t const pSize = MIN(psmin, 128 KB /* protection */ ); + const void* const pStart = (const char*)dctx->dictEnd - pSize; + PREFETCH_AREA(pStart, pSize); + dctx->ddictIsCold = 0; + } + + return ip-istart; +} + + +typedef struct { + size_t litLength; + size_t matchLength; + size_t offset; + const BYTE* match; +} seq_t; + +typedef struct { + size_t state; + const ZSTD_seqSymbol* table; +} ZSTD_fseState; + +typedef struct { + BIT_DStream_t DStream; + ZSTD_fseState stateLL; + ZSTD_fseState stateOffb; + ZSTD_fseState stateML; + size_t prevOffset[ZSTD_REP_NUM]; + const BYTE* prefixStart; + const BYTE* dictEnd; + size_t pos; +} seqState_t; + + +FORCE_NOINLINE +size_t ZSTD_execSequenceLast7(BYTE* op, + BYTE* const oend, seq_t sequence, + const BYTE** litPtr, const BYTE* const litLimit, + const BYTE* const base, const BYTE* const vBase, const BYTE* const dictEnd) +{ + BYTE* const oLitEnd = op + sequence.litLength; + size_t const sequenceLength = sequence.litLength + sequence.matchLength; + BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */ + BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH; + const BYTE* const iLitEnd = *litPtr + sequence.litLength; + const BYTE* match = oLitEnd - sequence.offset; + + /* check */ + if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */ + if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */ + if (oLitEnd <= oend_w) return ERROR(GENERIC); /* Precondition */ + + /* copy literals */ + if (op < oend_w) { + ZSTD_wildcopy(op, *litPtr, oend_w - op); + *litPtr += oend_w - op; + op = oend_w; + } + while (op < oLitEnd) *op++ = *(*litPtr)++; + + /* copy Match */ + if (sequence.offset > (size_t)(oLitEnd - base)) { + /* offset beyond prefix */ + if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected); + match = dictEnd - (base-match); + if (match + sequence.matchLength <= dictEnd) { + memmove(oLitEnd, match, sequence.matchLength); + return sequenceLength; + } + /* span extDict & currentPrefixSegment */ + { size_t const length1 = dictEnd - match; + memmove(oLitEnd, match, length1); + op = oLitEnd + length1; + sequence.matchLength -= length1; + match = base; + } } + while (op < oMatchEnd) *op++ = *match++; + return sequenceLength; +} + + +HINT_INLINE +size_t ZSTD_execSequence(BYTE* op, + BYTE* const oend, seq_t sequence, + const BYTE** litPtr, const BYTE* const litLimit, + const BYTE* const prefixStart, const BYTE* const virtualStart, const BYTE* const dictEnd) +{ + BYTE* const oLitEnd = op + sequence.litLength; + size_t const sequenceLength = sequence.litLength + sequence.matchLength; + BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */ + BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH; + const BYTE* const iLitEnd = *litPtr + sequence.litLength; + const BYTE* match = oLitEnd - sequence.offset; + + /* check */ + if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */ + if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */ + if (oLitEnd>oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, virtualStart, dictEnd); + + /* copy Literals */ + ZSTD_copy8(op, *litPtr); + if (sequence.litLength > 8) + ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */ + op = oLitEnd; + *litPtr = iLitEnd; /* update for next sequence */ + + /* copy Match */ + if (sequence.offset > (size_t)(oLitEnd - prefixStart)) { + /* offset beyond prefix -> go into extDict */ + if (sequence.offset > (size_t)(oLitEnd - virtualStart)) + return ERROR(corruption_detected); + match = dictEnd + (match - prefixStart); + if (match + sequence.matchLength <= dictEnd) { + memmove(oLitEnd, match, sequence.matchLength); + return sequenceLength; + } + /* span extDict & currentPrefixSegment */ + { size_t const length1 = dictEnd - match; + memmove(oLitEnd, match, length1); + op = oLitEnd + length1; + sequence.matchLength -= length1; + match = prefixStart; + if (op > oend_w || sequence.matchLength < MINMATCH) { + U32 i; + for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i]; + return sequenceLength; + } + } } + /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */ + + /* match within prefix */ + if (sequence.offset < 8) { + /* close range match, overlap */ + static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */ + static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */ + int const sub2 = dec64table[sequence.offset]; + op[0] = match[0]; + op[1] = match[1]; + op[2] = match[2]; + op[3] = match[3]; + match += dec32table[sequence.offset]; + ZSTD_copy4(op+4, match); + match -= sub2; + } else { + ZSTD_copy8(op, match); + } + op += 8; match += 8; + + if (oMatchEnd > oend-(16-MINMATCH)) { + if (op < oend_w) { + ZSTD_wildcopy(op, match, oend_w - op); + match += oend_w - op; + op = oend_w; + } + while (op < oMatchEnd) *op++ = *match++; + } else { + ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */ + } + return sequenceLength; +} + + +HINT_INLINE +size_t ZSTD_execSequenceLong(BYTE* op, + BYTE* const oend, seq_t sequence, + const BYTE** litPtr, const BYTE* const litLimit, + const BYTE* const prefixStart, const BYTE* const dictStart, const BYTE* const dictEnd) +{ + BYTE* const oLitEnd = op + sequence.litLength; + size_t const sequenceLength = sequence.litLength + sequence.matchLength; + BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */ + BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH; + const BYTE* const iLitEnd = *litPtr + sequence.litLength; + const BYTE* match = sequence.match; + + /* check */ + if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */ + if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */ + if (oLitEnd > oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, dictStart, dictEnd); + + /* copy Literals */ + ZSTD_copy8(op, *litPtr); /* note : op <= oLitEnd <= oend_w == oend - 8 */ + if (sequence.litLength > 8) + ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */ + op = oLitEnd; + *litPtr = iLitEnd; /* update for next sequence */ + + /* copy Match */ + if (sequence.offset > (size_t)(oLitEnd - prefixStart)) { + /* offset beyond prefix */ + if (sequence.offset > (size_t)(oLitEnd - dictStart)) return ERROR(corruption_detected); + if (match + sequence.matchLength <= dictEnd) { + memmove(oLitEnd, match, sequence.matchLength); + return sequenceLength; + } + /* span extDict & currentPrefixSegment */ + { size_t const length1 = dictEnd - match; + memmove(oLitEnd, match, length1); + op = oLitEnd + length1; + sequence.matchLength -= length1; + match = prefixStart; + if (op > oend_w || sequence.matchLength < MINMATCH) { + U32 i; + for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i]; + return sequenceLength; + } + } } + assert(op <= oend_w); + assert(sequence.matchLength >= MINMATCH); + + /* match within prefix */ + if (sequence.offset < 8) { + /* close range match, overlap */ + static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */ + static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */ + int const sub2 = dec64table[sequence.offset]; + op[0] = match[0]; + op[1] = match[1]; + op[2] = match[2]; + op[3] = match[3]; + match += dec32table[sequence.offset]; + ZSTD_copy4(op+4, match); + match -= sub2; + } else { + ZSTD_copy8(op, match); + } + op += 8; match += 8; + + if (oMatchEnd > oend-(16-MINMATCH)) { + if (op < oend_w) { + ZSTD_wildcopy(op, match, oend_w - op); + match += oend_w - op; + op = oend_w; + } + while (op < oMatchEnd) *op++ = *match++; + } else { + ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */ + } + return sequenceLength; +} + +static void +ZSTD_initFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD, const ZSTD_seqSymbol* dt) +{ + const void* ptr = dt; + const ZSTD_seqSymbol_header* const DTableH = (const ZSTD_seqSymbol_header*)ptr; + DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog); + DEBUGLOG(6, "ZSTD_initFseState : val=%u using %u bits", + (U32)DStatePtr->state, DTableH->tableLog); + BIT_reloadDStream(bitD); + DStatePtr->table = dt + 1; +} + +FORCE_INLINE_TEMPLATE void +ZSTD_updateFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD) +{ + ZSTD_seqSymbol const DInfo = DStatePtr->table[DStatePtr->state]; + U32 const nbBits = DInfo.nbBits; + size_t const lowBits = BIT_readBits(bitD, nbBits); + DStatePtr->state = DInfo.nextState + lowBits; +} + +/* We need to add at most (ZSTD_WINDOWLOG_MAX_32 - 1) bits to read the maximum + * offset bits. But we can only read at most (STREAM_ACCUMULATOR_MIN_32 - 1) + * bits before reloading. This value is the maximum number of bytes we read + * after reloading when we are decoding long offets. + */ +#define LONG_OFFSETS_MAX_EXTRA_BITS_32 \ + (ZSTD_WINDOWLOG_MAX_32 > STREAM_ACCUMULATOR_MIN_32 \ + ? ZSTD_WINDOWLOG_MAX_32 - STREAM_ACCUMULATOR_MIN_32 \ + : 0) + +typedef enum { ZSTD_lo_isRegularOffset, ZSTD_lo_isLongOffset=1 } ZSTD_longOffset_e; + +FORCE_INLINE_TEMPLATE seq_t +ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets) +{ + seq_t seq; + U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits; + U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits; + U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits; + U32 const totalBits = llBits+mlBits+ofBits; + U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue; + U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue; + U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue; + + /* sequence */ + { size_t offset; + if (!ofBits) + offset = 0; + else { + ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1); + ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5); + assert(ofBits <= MaxOff); + if (MEM_32bits() && longOffsets && (ofBits >= STREAM_ACCUMULATOR_MIN_32)) { + U32 const extraBits = ofBits - MIN(ofBits, 32 - seqState->DStream.bitsConsumed); + offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits); + BIT_reloadDStream(&seqState->DStream); + if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits); + assert(extraBits <= LONG_OFFSETS_MAX_EXTRA_BITS_32); /* to avoid another reload */ + } else { + offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits/*>0*/); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */ + if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); + } + } + + if (ofBits <= 1) { + offset += (llBase==0); + if (offset) { + size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset]; + temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */ + if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1]; + seqState->prevOffset[1] = seqState->prevOffset[0]; + seqState->prevOffset[0] = offset = temp; + } else { /* offset == 0 */ + offset = seqState->prevOffset[0]; + } + } else { + seqState->prevOffset[2] = seqState->prevOffset[1]; + seqState->prevOffset[1] = seqState->prevOffset[0]; + seqState->prevOffset[0] = offset; + } + seq.offset = offset; + } + + seq.matchLength = mlBase + + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits/*>0*/) : 0); /* <= 16 bits */ + if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32)) + BIT_reloadDStream(&seqState->DStream); + if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog))) + BIT_reloadDStream(&seqState->DStream); + /* Ensure there are enough bits to read the rest of data in 64-bit mode. */ + ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64); + + seq.litLength = llBase + + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits/*>0*/) : 0); /* <= 16 bits */ + if (MEM_32bits()) + BIT_reloadDStream(&seqState->DStream); + + DEBUGLOG(6, "seq: litL=%u, matchL=%u, offset=%u", + (U32)seq.litLength, (U32)seq.matchLength, (U32)seq.offset); + + /* ANS state update */ + ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */ + ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */ + if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */ + ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */ + + return seq; +} + +FORCE_INLINE_TEMPLATE size_t +ZSTD_decompressSequences_body( ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + const BYTE* ip = (const BYTE*)seqStart; + const BYTE* const iend = ip + seqSize; + BYTE* const ostart = (BYTE* const)dst; + BYTE* const oend = ostart + maxDstSize; + BYTE* op = ostart; + const BYTE* litPtr = dctx->litPtr; + const BYTE* const litEnd = litPtr + dctx->litSize; + const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart); + const BYTE* const vBase = (const BYTE*) (dctx->virtualStart); + const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd); + DEBUGLOG(5, "ZSTD_decompressSequences_body"); + + /* Regen sequences */ + if (nbSeq) { + seqState_t seqState; + dctx->fseEntropy = 1; + { U32 i; for (i=0; ientropy.rep[i]; } + CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected); + ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr); + ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr); + ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr); + + for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq ; ) { + nbSeq--; + { seq_t const sequence = ZSTD_decodeSequence(&seqState, isLongOffset); + size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litEnd, prefixStart, vBase, dictEnd); + DEBUGLOG(6, "regenerated sequence size : %u", (U32)oneSeqSize); + if (ZSTD_isError(oneSeqSize)) return oneSeqSize; + op += oneSeqSize; + } } + + /* check if reached exact end */ + DEBUGLOG(5, "ZSTD_decompressSequences_body: after decode loop, remaining nbSeq : %i", nbSeq); + if (nbSeq) return ERROR(corruption_detected); + /* save reps for next block */ + { U32 i; for (i=0; ientropy.rep[i] = (U32)(seqState.prevOffset[i]); } + } + + /* last literal segment */ + { size_t const lastLLSize = litEnd - litPtr; + if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall); + memcpy(op, litPtr, lastLLSize); + op += lastLLSize; + } + + return op-ostart; +} + +static size_t +ZSTD_decompressSequences_default(ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + + + +FORCE_INLINE_TEMPLATE seq_t +ZSTD_decodeSequenceLong(seqState_t* seqState, ZSTD_longOffset_e const longOffsets) +{ + seq_t seq; + U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits; + U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits; + U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits; + U32 const totalBits = llBits+mlBits+ofBits; + U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue; + U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue; + U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue; + + /* sequence */ + { size_t offset; + if (!ofBits) + offset = 0; + else { + ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1); + ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5); + assert(ofBits <= MaxOff); + if (MEM_32bits() && longOffsets) { + U32 const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN_32-1); + offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits); + if (MEM_32bits() || extraBits) BIT_reloadDStream(&seqState->DStream); + if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits); + } else { + offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */ + if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); + } + } + + if (ofBits <= 1) { + offset += (llBase==0); + if (offset) { + size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset]; + temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */ + if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1]; + seqState->prevOffset[1] = seqState->prevOffset[0]; + seqState->prevOffset[0] = offset = temp; + } else { + offset = seqState->prevOffset[0]; + } + } else { + seqState->prevOffset[2] = seqState->prevOffset[1]; + seqState->prevOffset[1] = seqState->prevOffset[0]; + seqState->prevOffset[0] = offset; + } + seq.offset = offset; + } + + seq.matchLength = mlBase + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits) : 0); /* <= 16 bits */ + if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32)) + BIT_reloadDStream(&seqState->DStream); + if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog))) + BIT_reloadDStream(&seqState->DStream); + /* Verify that there is enough bits to read the rest of the data in 64-bit mode. */ + ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64); + + seq.litLength = llBase + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits) : 0); /* <= 16 bits */ + if (MEM_32bits()) + BIT_reloadDStream(&seqState->DStream); + + { size_t const pos = seqState->pos + seq.litLength; + const BYTE* const matchBase = (seq.offset > pos) ? seqState->dictEnd : seqState->prefixStart; + seq.match = matchBase + pos - seq.offset; /* note : this operation can overflow when seq.offset is really too large, which can only happen when input is corrupted. + * No consequence though : no memory access will occur, overly large offset will be detected in ZSTD_execSequenceLong() */ + seqState->pos = pos + seq.matchLength; + } + + /* ANS state update */ + ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */ + ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */ + if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */ + ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */ + + return seq; +} + +FORCE_INLINE_TEMPLATE size_t +ZSTD_decompressSequencesLong_body( + ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + const BYTE* ip = (const BYTE*)seqStart; + const BYTE* const iend = ip + seqSize; + BYTE* const ostart = (BYTE* const)dst; + BYTE* const oend = ostart + maxDstSize; + BYTE* op = ostart; + const BYTE* litPtr = dctx->litPtr; + const BYTE* const litEnd = litPtr + dctx->litSize; + const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart); + const BYTE* const dictStart = (const BYTE*) (dctx->virtualStart); + const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd); + + /* Regen sequences */ + if (nbSeq) { +#define STORED_SEQS 4 +#define STOSEQ_MASK (STORED_SEQS-1) +#define ADVANCED_SEQS 4 + seq_t sequences[STORED_SEQS]; + int const seqAdvance = MIN(nbSeq, ADVANCED_SEQS); + seqState_t seqState; + int seqNb; + dctx->fseEntropy = 1; + { U32 i; for (i=0; ientropy.rep[i]; } + seqState.prefixStart = prefixStart; + seqState.pos = (size_t)(op-prefixStart); + seqState.dictEnd = dictEnd; + CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected); + ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr); + ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr); + ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr); + + /* prepare in advance */ + for (seqNb=0; (BIT_reloadDStream(&seqState.DStream) <= BIT_DStream_completed) && (seqNbentropy.rep[i] = (U32)(seqState.prevOffset[i]); } +#undef STORED_SEQS +#undef STOSEQ_MASK +#undef ADVANCED_SEQS + } + + /* last literal segment */ + { size_t const lastLLSize = litEnd - litPtr; + if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall); + memcpy(op, litPtr, lastLLSize); + op += lastLLSize; + } + + return op-ostart; +} + +static size_t +ZSTD_decompressSequencesLong_default(ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + + + +#if DYNAMIC_BMI2 + +static TARGET_ATTRIBUTE("bmi2") size_t +ZSTD_decompressSequences_bmi2(ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + +static TARGET_ATTRIBUTE("bmi2") size_t +ZSTD_decompressSequencesLong_bmi2(ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + +#endif + +typedef size_t (*ZSTD_decompressSequences_t)( + ZSTD_DCtx *dctx, void *dst, size_t maxDstSize, + const void *seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset); + +static size_t ZSTD_decompressSequences(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + DEBUGLOG(5, "ZSTD_decompressSequences"); +#if DYNAMIC_BMI2 + if (dctx->bmi2) { + return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); + } +#endif + return ZSTD_decompressSequences_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + +static size_t ZSTD_decompressSequencesLong(ZSTD_DCtx* dctx, + void* dst, size_t maxDstSize, + const void* seqStart, size_t seqSize, int nbSeq, + const ZSTD_longOffset_e isLongOffset) +{ + DEBUGLOG(5, "ZSTD_decompressSequencesLong"); +#if DYNAMIC_BMI2 + if (dctx->bmi2) { + return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); + } +#endif + return ZSTD_decompressSequencesLong_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset); +} + +/* ZSTD_getLongOffsetsShare() : + * condition : offTable must be valid + * @return : "share" of long offsets (arbitrarily defined as > (1<<23)) + * compared to maximum possible of (1< 22) total += 1; + } + + assert(tableLog <= OffFSELog); + total <<= (OffFSELog - tableLog); /* scale to OffFSELog */ + + return total; +} + + +static size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, const int frame) +{ /* blockType == blockCompressed */ + const BYTE* ip = (const BYTE*)src; + /* isLongOffset must be true if there are long offsets. + * Offsets are long if they are larger than 2^STREAM_ACCUMULATOR_MIN. + * We don't expect that to be the case in 64-bit mode. + * In block mode, window size is not known, so we have to be conservative. + * (note: but it could be evaluated from current-lowLimit) + */ + ZSTD_longOffset_e const isLongOffset = (ZSTD_longOffset_e)(MEM_32bits() && (!frame || dctx->fParams.windowSize > (1ULL << STREAM_ACCUMULATOR_MIN))); + DEBUGLOG(5, "ZSTD_decompressBlock_internal (size : %u)", (U32)srcSize); + + if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong); + + /* Decode literals section */ + { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize); + DEBUGLOG(5, "ZSTD_decodeLiteralsBlock : %u", (U32)litCSize); + if (ZSTD_isError(litCSize)) return litCSize; + ip += litCSize; + srcSize -= litCSize; + } + + /* Build Decoding Tables */ + { int nbSeq; + size_t const seqHSize = ZSTD_decodeSeqHeaders(dctx, &nbSeq, ip, srcSize); + if (ZSTD_isError(seqHSize)) return seqHSize; + ip += seqHSize; + srcSize -= seqHSize; + + if ( (!frame || dctx->fParams.windowSize > (1<<24)) + && (nbSeq>0) ) { /* could probably use a larger nbSeq limit */ + U32 const shareLongOffsets = ZSTD_getLongOffsetsShare(dctx->OFTptr); + U32 const minShare = MEM_64bits() ? 7 : 20; /* heuristic values, correspond to 2.73% and 7.81% */ + if (shareLongOffsets >= minShare) + return ZSTD_decompressSequencesLong(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset); + } + + return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset); + } +} + + +static void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst) +{ + if (dst != dctx->previousDstEnd) { /* not contiguous */ + dctx->dictEnd = dctx->previousDstEnd; + dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart)); + dctx->prefixStart = dst; + dctx->previousDstEnd = dst; + } +} + +size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize) +{ + size_t dSize; + ZSTD_checkContinuity(dctx, dst); + dSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 0); + dctx->previousDstEnd = (char*)dst + dSize; + return dSize; +} + + +/** ZSTD_insertBlock() : + insert `src` block into `dctx` history. Useful to track uncompressed blocks. */ +ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize) +{ + ZSTD_checkContinuity(dctx, blockStart); + dctx->previousDstEnd = (const char*)blockStart + blockSize; + return blockSize; +} + + +static size_t ZSTD_generateNxBytes(void* dst, size_t dstCapacity, BYTE value, size_t length) +{ + if (length > dstCapacity) return ERROR(dstSize_tooSmall); + memset(dst, value, length); + return length; +} + +/** ZSTD_findFrameCompressedSize() : + * compatible with legacy mode + * `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame + * `srcSize` must be at least as large as the frame contained + * @return : the compressed size of the frame starting at `src` */ +size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) +{ +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) + if (ZSTD_isLegacy(src, srcSize)) + return ZSTD_findFrameCompressedSizeLegacy(src, srcSize); +#endif + if ( (srcSize >= ZSTD_skippableHeaderSize) + && (MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START ) { + return ZSTD_skippableHeaderSize + MEM_readLE32((const BYTE*)src + ZSTD_FRAMEIDSIZE); + } else { + const BYTE* ip = (const BYTE*)src; + const BYTE* const ipstart = ip; + size_t remainingSize = srcSize; + ZSTD_frameHeader zfh; + + /* Extract Frame Header */ + { size_t const ret = ZSTD_getFrameHeader(&zfh, src, srcSize); + if (ZSTD_isError(ret)) return ret; + if (ret > 0) return ERROR(srcSize_wrong); + } + + ip += zfh.headerSize; + remainingSize -= zfh.headerSize; + + /* Loop on each block */ + while (1) { + blockProperties_t blockProperties; + size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties); + if (ZSTD_isError(cBlockSize)) return cBlockSize; + + if (ZSTD_blockHeaderSize + cBlockSize > remainingSize) + return ERROR(srcSize_wrong); + + ip += ZSTD_blockHeaderSize + cBlockSize; + remainingSize -= ZSTD_blockHeaderSize + cBlockSize; + + if (blockProperties.lastBlock) break; + } + + if (zfh.checksumFlag) { /* Final frame content checksum */ + if (remainingSize < 4) return ERROR(srcSize_wrong); + ip += 4; + } + + return ip - ipstart; + } +} + +/*! ZSTD_decompressFrame() : +* @dctx must be properly initialized */ +static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void** srcPtr, size_t *srcSizePtr) +{ + const BYTE* ip = (const BYTE*)(*srcPtr); + BYTE* const ostart = (BYTE* const)dst; + BYTE* const oend = ostart + dstCapacity; + BYTE* op = ostart; + size_t remainingSize = *srcSizePtr; + + /* check */ + if (remainingSize < ZSTD_frameHeaderSize_min+ZSTD_blockHeaderSize) + return ERROR(srcSize_wrong); + + /* Frame Header */ + { size_t const frameHeaderSize = ZSTD_frameHeaderSize(ip, ZSTD_frameHeaderSize_prefix); + if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize; + if (remainingSize < frameHeaderSize+ZSTD_blockHeaderSize) + return ERROR(srcSize_wrong); + CHECK_F( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) ); + ip += frameHeaderSize; remainingSize -= frameHeaderSize; + } + + /* Loop on each block */ + while (1) { + size_t decodedSize; + blockProperties_t blockProperties; + size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties); + if (ZSTD_isError(cBlockSize)) return cBlockSize; + + ip += ZSTD_blockHeaderSize; + remainingSize -= ZSTD_blockHeaderSize; + if (cBlockSize > remainingSize) return ERROR(srcSize_wrong); + + switch(blockProperties.blockType) + { + case bt_compressed: + decodedSize = ZSTD_decompressBlock_internal(dctx, op, oend-op, ip, cBlockSize, /* frame */ 1); + break; + case bt_raw : + decodedSize = ZSTD_copyRawBlock(op, oend-op, ip, cBlockSize); + break; + case bt_rle : + decodedSize = ZSTD_generateNxBytes(op, oend-op, *ip, blockProperties.origSize); + break; + case bt_reserved : + default: + return ERROR(corruption_detected); + } + + if (ZSTD_isError(decodedSize)) return decodedSize; + if (dctx->fParams.checksumFlag) + XXH64_update(&dctx->xxhState, op, decodedSize); + op += decodedSize; + ip += cBlockSize; + remainingSize -= cBlockSize; + if (blockProperties.lastBlock) break; + } + + if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) { + if ((U64)(op-ostart) != dctx->fParams.frameContentSize) { + return ERROR(corruption_detected); + } } + if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */ + U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState); + U32 checkRead; + if (remainingSize<4) return ERROR(checksum_wrong); + checkRead = MEM_readLE32(ip); + if (checkRead != checkCalc) return ERROR(checksum_wrong); + ip += 4; + remainingSize -= 4; + } + + /* Allow caller to get size read */ + *srcPtr = ip; + *srcSizePtr = remainingSize; + return op-ostart; +} + +static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict, size_t dictSize, + const ZSTD_DDict* ddict) +{ + void* const dststart = dst; + int moreThan1Frame = 0; + + DEBUGLOG(5, "ZSTD_decompressMultiFrame"); + assert(dict==NULL || ddict==NULL); /* either dict or ddict set, not both */ + + if (ddict) { + dict = ZSTD_DDictDictContent(ddict); + dictSize = ZSTD_DDictDictSize(ddict); + } + + while (srcSize >= ZSTD_frameHeaderSize_prefix) { + +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) + if (ZSTD_isLegacy(src, srcSize)) { + size_t decodedSize; + size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize); + if (ZSTD_isError(frameSize)) return frameSize; + /* legacy support is not compatible with static dctx */ + if (dctx->staticSize) return ERROR(memory_allocation); + + decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize); + + dst = (BYTE*)dst + decodedSize; + dstCapacity -= decodedSize; + + src = (const BYTE*)src + frameSize; + srcSize -= frameSize; + + continue; + } +#endif + + { U32 const magicNumber = MEM_readLE32(src); + DEBUGLOG(4, "reading magic number %08X (expecting %08X)", + (U32)magicNumber, (U32)ZSTD_MAGICNUMBER); + if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { + size_t skippableSize; + if (srcSize < ZSTD_skippableHeaderSize) + return ERROR(srcSize_wrong); + skippableSize = MEM_readLE32((const BYTE*)src + ZSTD_FRAMEIDSIZE) + + ZSTD_skippableHeaderSize; + if (srcSize < skippableSize) return ERROR(srcSize_wrong); + + src = (const BYTE *)src + skippableSize; + srcSize -= skippableSize; + continue; + } } + + if (ddict) { + /* we were called from ZSTD_decompress_usingDDict */ + CHECK_F(ZSTD_decompressBegin_usingDDict(dctx, ddict)); + } else { + /* this will initialize correctly with no dict if dict == NULL, so + * use this in all cases but ddict */ + CHECK_F(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize)); + } + ZSTD_checkContinuity(dctx, dst); + + { const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity, + &src, &srcSize); + if ( (ZSTD_getErrorCode(res) == ZSTD_error_prefix_unknown) + && (moreThan1Frame==1) ) { + /* at least one frame successfully completed, + * but following bytes are garbage : + * it's more likely to be a srcSize error, + * specifying more bytes than compressed size of frame(s). + * This error message replaces ERROR(prefix_unknown), + * which would be confusing, as the first header is actually correct. + * Note that one could be unlucky, it might be a corruption error instead, + * happening right at the place where we expect zstd magic bytes. + * But this is _much_ less likely than a srcSize field error. */ + return ERROR(srcSize_wrong); + } + if (ZSTD_isError(res)) return res; + /* no need to bound check, ZSTD_decompressFrame already has */ + dst = (BYTE*)dst + res; + dstCapacity -= res; + } + moreThan1Frame = 1; + } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */ + + if (srcSize) return ERROR(srcSize_wrong); /* input not entirely consumed */ + + return (BYTE*)dst - (BYTE*)dststart; +} + +size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const void* dict, size_t dictSize) +{ + return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL); +} + + +size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize) +{ + return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0); +} + + +size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t srcSize) +{ +#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1) + size_t regenSize; + ZSTD_DCtx* const dctx = ZSTD_createDCtx(); + if (dctx==NULL) return ERROR(memory_allocation); + regenSize = ZSTD_decompressDCtx(dctx, dst, dstCapacity, src, srcSize); + ZSTD_freeDCtx(dctx); + return regenSize; +#else /* stack mode */ + ZSTD_DCtx dctx; + ZSTD_initDCtx_internal(&dctx); + return ZSTD_decompressDCtx(&dctx, dst, dstCapacity, src, srcSize); +#endif +} + + +/*-************************************** +* Advanced Streaming Decompression API +* Bufferless and synchronous +****************************************/ +size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx) { return dctx->expected; } + +ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) { + switch(dctx->stage) + { + default: /* should not happen */ + assert(0); + case ZSTDds_getFrameHeaderSize: + case ZSTDds_decodeFrameHeader: + return ZSTDnit_frameHeader; + case ZSTDds_decodeBlockHeader: + return ZSTDnit_blockHeader; + case ZSTDds_decompressBlock: + return ZSTDnit_block; + case ZSTDds_decompressLastBlock: + return ZSTDnit_lastBlock; + case ZSTDds_checkChecksum: + return ZSTDnit_checksum; + case ZSTDds_decodeSkippableHeader: + case ZSTDds_skipFrame: + return ZSTDnit_skippableFrame; + } +} + +static int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; } + +/** ZSTD_decompressContinue() : + * srcSize : must be the exact nb of bytes expected (see ZSTD_nextSrcSizeToDecompress()) + * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity) + * or an error code, which can be tested using ZSTD_isError() */ +size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize) +{ + DEBUGLOG(5, "ZSTD_decompressContinue (srcSize:%u)", (U32)srcSize); + /* Sanity check */ + if (srcSize != dctx->expected) return ERROR(srcSize_wrong); /* not allowed */ + if (dstCapacity) ZSTD_checkContinuity(dctx, dst); + + switch (dctx->stage) + { + case ZSTDds_getFrameHeaderSize : + assert(src != NULL); + if (dctx->format == ZSTD_f_zstd1) { /* allows header */ + assert(srcSize >= ZSTD_FRAMEIDSIZE); /* to read skippable magic number */ + if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */ + memcpy(dctx->headerBuffer, src, srcSize); + dctx->expected = ZSTD_skippableHeaderSize - srcSize; /* remaining to load to get full skippable frame header */ + dctx->stage = ZSTDds_decodeSkippableHeader; + return 0; + } } + dctx->headerSize = ZSTD_frameHeaderSize_internal(src, srcSize, dctx->format); + if (ZSTD_isError(dctx->headerSize)) return dctx->headerSize; + memcpy(dctx->headerBuffer, src, srcSize); + dctx->expected = dctx->headerSize - srcSize; + dctx->stage = ZSTDds_decodeFrameHeader; + return 0; + + case ZSTDds_decodeFrameHeader: + assert(src != NULL); + memcpy(dctx->headerBuffer + (dctx->headerSize - srcSize), src, srcSize); + CHECK_F(ZSTD_decodeFrameHeader(dctx, dctx->headerBuffer, dctx->headerSize)); + dctx->expected = ZSTD_blockHeaderSize; + dctx->stage = ZSTDds_decodeBlockHeader; + return 0; + + case ZSTDds_decodeBlockHeader: + { blockProperties_t bp; + size_t const cBlockSize = ZSTD_getcBlockSize(src, ZSTD_blockHeaderSize, &bp); + if (ZSTD_isError(cBlockSize)) return cBlockSize; + dctx->expected = cBlockSize; + dctx->bType = bp.blockType; + dctx->rleSize = bp.origSize; + if (cBlockSize) { + dctx->stage = bp.lastBlock ? ZSTDds_decompressLastBlock : ZSTDds_decompressBlock; + return 0; + } + /* empty block */ + if (bp.lastBlock) { + if (dctx->fParams.checksumFlag) { + dctx->expected = 4; + dctx->stage = ZSTDds_checkChecksum; + } else { + dctx->expected = 0; /* end of frame */ + dctx->stage = ZSTDds_getFrameHeaderSize; + } + } else { + dctx->expected = ZSTD_blockHeaderSize; /* jump to next header */ + dctx->stage = ZSTDds_decodeBlockHeader; + } + return 0; + } + + case ZSTDds_decompressLastBlock: + case ZSTDds_decompressBlock: + DEBUGLOG(5, "ZSTD_decompressContinue: case ZSTDds_decompressBlock"); + { size_t rSize; + switch(dctx->bType) + { + case bt_compressed: + DEBUGLOG(5, "ZSTD_decompressContinue: case bt_compressed"); + rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1); + break; + case bt_raw : + rSize = ZSTD_copyRawBlock(dst, dstCapacity, src, srcSize); + break; + case bt_rle : + rSize = ZSTD_setRleBlock(dst, dstCapacity, src, srcSize, dctx->rleSize); + break; + case bt_reserved : /* should never happen */ + default: + return ERROR(corruption_detected); + } + if (ZSTD_isError(rSize)) return rSize; + DEBUGLOG(5, "ZSTD_decompressContinue: decoded size from block : %u", (U32)rSize); + dctx->decodedSize += rSize; + if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize); + + if (dctx->stage == ZSTDds_decompressLastBlock) { /* end of frame */ + DEBUGLOG(4, "ZSTD_decompressContinue: decoded size from frame : %u", (U32)dctx->decodedSize); + if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) { + if (dctx->decodedSize != dctx->fParams.frameContentSize) { + return ERROR(corruption_detected); + } } + if (dctx->fParams.checksumFlag) { /* another round for frame checksum */ + dctx->expected = 4; + dctx->stage = ZSTDds_checkChecksum; + } else { + dctx->expected = 0; /* ends here */ + dctx->stage = ZSTDds_getFrameHeaderSize; + } + } else { + dctx->stage = ZSTDds_decodeBlockHeader; + dctx->expected = ZSTD_blockHeaderSize; + dctx->previousDstEnd = (char*)dst + rSize; + } + return rSize; + } + + case ZSTDds_checkChecksum: + assert(srcSize == 4); /* guaranteed by dctx->expected */ + { U32 const h32 = (U32)XXH64_digest(&dctx->xxhState); + U32 const check32 = MEM_readLE32(src); + DEBUGLOG(4, "ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", h32, check32); + if (check32 != h32) return ERROR(checksum_wrong); + dctx->expected = 0; + dctx->stage = ZSTDds_getFrameHeaderSize; + return 0; + } + + case ZSTDds_decodeSkippableHeader: + assert(src != NULL); + assert(srcSize <= ZSTD_skippableHeaderSize); + memcpy(dctx->headerBuffer + (ZSTD_skippableHeaderSize - srcSize), src, srcSize); /* complete skippable header */ + dctx->expected = MEM_readLE32(dctx->headerBuffer + ZSTD_FRAMEIDSIZE); /* note : dctx->expected can grow seriously large, beyond local buffer size */ + dctx->stage = ZSTDds_skipFrame; + return 0; + + case ZSTDds_skipFrame: + dctx->expected = 0; + dctx->stage = ZSTDds_getFrameHeaderSize; + return 0; + + default: + return ERROR(GENERIC); /* impossible */ + } +} + + +static size_t ZSTD_refDictContent(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) +{ + dctx->dictEnd = dctx->previousDstEnd; + dctx->virtualStart = (const char*)dict - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart)); + dctx->prefixStart = dict; + dctx->previousDstEnd = (const char*)dict + dictSize; + return 0; +} + +/*! ZSTD_loadEntropy() : + * dict : must point at beginning of a valid zstd dictionary. + * @return : size of entropy tables read */ +static size_t ZSTD_loadEntropy(ZSTD_entropyDTables_t* entropy, + const void* const dict, size_t const dictSize) +{ + const BYTE* dictPtr = (const BYTE*)dict; + const BYTE* const dictEnd = dictPtr + dictSize; + + if (dictSize <= 8) return ERROR(dictionary_corrupted); + assert(MEM_readLE32(dict) == ZSTD_MAGIC_DICTIONARY); /* dict must be valid */ + dictPtr += 8; /* skip header = magic + dictID */ + + ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, OFTable) == offsetof(ZSTD_entropyDTables_t, LLTable) + sizeof(entropy->LLTable)); + ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, MLTable) == offsetof(ZSTD_entropyDTables_t, OFTable) + sizeof(entropy->OFTable)); + ZSTD_STATIC_ASSERT(sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable) >= HUF_DECOMPRESS_WORKSPACE_SIZE); + { void* const workspace = &entropy->LLTable; /* use fse tables as temporary workspace; implies fse tables are grouped together */ + size_t const workspaceSize = sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable); + size_t const hSize = HUF_readDTableX2_wksp(entropy->hufTable, + dictPtr, dictEnd - dictPtr, + workspace, workspaceSize); + if (HUF_isError(hSize)) return ERROR(dictionary_corrupted); + dictPtr += hSize; + } + + { short offcodeNCount[MaxOff+1]; + U32 offcodeMaxValue = MaxOff, offcodeLog; + size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr); + if (FSE_isError(offcodeHeaderSize)) return ERROR(dictionary_corrupted); + if (offcodeMaxValue > MaxOff) return ERROR(dictionary_corrupted); + if (offcodeLog > OffFSELog) return ERROR(dictionary_corrupted); + ZSTD_buildFSETable( entropy->OFTable, + offcodeNCount, offcodeMaxValue, + OF_base, OF_bits, + offcodeLog); + dictPtr += offcodeHeaderSize; + } + + { short matchlengthNCount[MaxML+1]; + unsigned matchlengthMaxValue = MaxML, matchlengthLog; + size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr); + if (FSE_isError(matchlengthHeaderSize)) return ERROR(dictionary_corrupted); + if (matchlengthMaxValue > MaxML) return ERROR(dictionary_corrupted); + if (matchlengthLog > MLFSELog) return ERROR(dictionary_corrupted); + ZSTD_buildFSETable( entropy->MLTable, + matchlengthNCount, matchlengthMaxValue, + ML_base, ML_bits, + matchlengthLog); + dictPtr += matchlengthHeaderSize; + } + + { short litlengthNCount[MaxLL+1]; + unsigned litlengthMaxValue = MaxLL, litlengthLog; + size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr); + if (FSE_isError(litlengthHeaderSize)) return ERROR(dictionary_corrupted); + if (litlengthMaxValue > MaxLL) return ERROR(dictionary_corrupted); + if (litlengthLog > LLFSELog) return ERROR(dictionary_corrupted); + ZSTD_buildFSETable( entropy->LLTable, + litlengthNCount, litlengthMaxValue, + LL_base, LL_bits, + litlengthLog); + dictPtr += litlengthHeaderSize; + } + + if (dictPtr+12 > dictEnd) return ERROR(dictionary_corrupted); + { int i; + size_t const dictContentSize = (size_t)(dictEnd - (dictPtr+12)); + for (i=0; i<3; i++) { + U32 const rep = MEM_readLE32(dictPtr); dictPtr += 4; + if (rep==0 || rep >= dictContentSize) return ERROR(dictionary_corrupted); + entropy->rep[i] = rep; + } } + + return dictPtr - (const BYTE*)dict; +} + +static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) +{ + if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize); + { U32 const magic = MEM_readLE32(dict); + if (magic != ZSTD_MAGIC_DICTIONARY) { + return ZSTD_refDictContent(dctx, dict, dictSize); /* pure content mode */ + } } + dctx->dictID = MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE); + + /* load entropy tables */ + { size_t const eSize = ZSTD_loadEntropy(&dctx->entropy, dict, dictSize); + if (ZSTD_isError(eSize)) return ERROR(dictionary_corrupted); + dict = (const char*)dict + eSize; + dictSize -= eSize; + } + dctx->litEntropy = dctx->fseEntropy = 1; + + /* reference dictionary content */ + return ZSTD_refDictContent(dctx, dict, dictSize); +} + +size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx) +{ + assert(dctx != NULL); + dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */ + dctx->stage = ZSTDds_getFrameHeaderSize; + dctx->decodedSize = 0; + dctx->previousDstEnd = NULL; + dctx->prefixStart = NULL; + dctx->virtualStart = NULL; + dctx->dictEnd = NULL; + dctx->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */ + dctx->litEntropy = dctx->fseEntropy = 0; + dctx->dictID = 0; + ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue)); + memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue)); /* initial repcodes */ + dctx->LLTptr = dctx->entropy.LLTable; + dctx->MLTptr = dctx->entropy.MLTable; + dctx->OFTptr = dctx->entropy.OFTable; + dctx->HUFptr = dctx->entropy.hufTable; + return 0; +} + +size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) +{ + CHECK_F( ZSTD_decompressBegin(dctx) ); + if (dict && dictSize) + CHECK_E(ZSTD_decompress_insertDictionary(dctx, dict, dictSize), dictionary_corrupted); + return 0; +} + + +/* ====== ZSTD_DDict ====== */ + +struct ZSTD_DDict_s { + void* dictBuffer; + const void* dictContent; + size_t dictSize; + ZSTD_entropyDTables_t entropy; + U32 dictID; + U32 entropyPresent; + ZSTD_customMem cMem; +}; /* typedef'd to ZSTD_DDict within "zstd.h" */ + +static const void* ZSTD_DDictDictContent(const ZSTD_DDict* ddict) +{ + assert(ddict != NULL); + return ddict->dictContent; +} + +static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict) +{ + assert(ddict != NULL); + return ddict->dictSize; +} + +size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict) +{ + DEBUGLOG(4, "ZSTD_decompressBegin_usingDDict"); + assert(dctx != NULL); + if (ddict) { + dctx->ddictIsCold = (dctx->dictEnd != (const char*)ddict->dictContent + ddict->dictSize); + DEBUGLOG(4, "DDict is %s", + dctx->ddictIsCold ? "~cold~" : "hot!"); + } + CHECK_F( ZSTD_decompressBegin(dctx) ); + if (ddict) { /* NULL ddict is equivalent to no dictionary */ + dctx->dictID = ddict->dictID; + dctx->prefixStart = ddict->dictContent; + dctx->virtualStart = ddict->dictContent; + dctx->dictEnd = (const BYTE*)ddict->dictContent + ddict->dictSize; + dctx->previousDstEnd = dctx->dictEnd; + if (ddict->entropyPresent) { + dctx->litEntropy = 1; + dctx->fseEntropy = 1; + dctx->LLTptr = ddict->entropy.LLTable; + dctx->MLTptr = ddict->entropy.MLTable; + dctx->OFTptr = ddict->entropy.OFTable; + dctx->HUFptr = ddict->entropy.hufTable; + dctx->entropy.rep[0] = ddict->entropy.rep[0]; + dctx->entropy.rep[1] = ddict->entropy.rep[1]; + dctx->entropy.rep[2] = ddict->entropy.rep[2]; + } else { + dctx->litEntropy = 0; + dctx->fseEntropy = 0; + } + } + return 0; +} + +static size_t +ZSTD_loadEntropy_inDDict(ZSTD_DDict* ddict, + ZSTD_dictContentType_e dictContentType) +{ + ddict->dictID = 0; + ddict->entropyPresent = 0; + if (dictContentType == ZSTD_dct_rawContent) return 0; + + if (ddict->dictSize < 8) { + if (dictContentType == ZSTD_dct_fullDict) + return ERROR(dictionary_corrupted); /* only accept specified dictionaries */ + return 0; /* pure content mode */ + } + { U32 const magic = MEM_readLE32(ddict->dictContent); + if (magic != ZSTD_MAGIC_DICTIONARY) { + if (dictContentType == ZSTD_dct_fullDict) + return ERROR(dictionary_corrupted); /* only accept specified dictionaries */ + return 0; /* pure content mode */ + } + } + ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE); + + /* load entropy tables */ + CHECK_E( ZSTD_loadEntropy(&ddict->entropy, + ddict->dictContent, ddict->dictSize), + dictionary_corrupted ); + ddict->entropyPresent = 1; + return 0; +} + + +static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType) +{ + if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) { + ddict->dictBuffer = NULL; + ddict->dictContent = dict; + if (!dict) dictSize = 0; + } else { + void* const internalBuffer = ZSTD_malloc(dictSize, ddict->cMem); + ddict->dictBuffer = internalBuffer; + ddict->dictContent = internalBuffer; + if (!internalBuffer) return ERROR(memory_allocation); + memcpy(internalBuffer, dict, dictSize); + } + ddict->dictSize = dictSize; + ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */ + + /* parse dictionary content */ + CHECK_F( ZSTD_loadEntropy_inDDict(ddict, dictContentType) ); + + return 0; +} + +ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType, + ZSTD_customMem customMem) +{ + if (!customMem.customAlloc ^ !customMem.customFree) return NULL; + + { ZSTD_DDict* const ddict = (ZSTD_DDict*) ZSTD_malloc(sizeof(ZSTD_DDict), customMem); + if (ddict == NULL) return NULL; + ddict->cMem = customMem; + { size_t const initResult = ZSTD_initDDict_internal(ddict, + dict, dictSize, + dictLoadMethod, dictContentType); + if (ZSTD_isError(initResult)) { + ZSTD_freeDDict(ddict); + return NULL; + } } + return ddict; + } +} + +/*! ZSTD_createDDict() : +* Create a digested dictionary, to start decompression without startup delay. +* `dict` content is copied inside DDict. +* Consequently, `dict` can be released after `ZSTD_DDict` creation */ +ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize) +{ + ZSTD_customMem const allocator = { NULL, NULL, NULL }; + return ZSTD_createDDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, allocator); +} + +/*! ZSTD_createDDict_byReference() : + * Create a digested dictionary, to start decompression without startup delay. + * Dictionary content is simply referenced, it will be accessed during decompression. + * Warning : dictBuffer must outlive DDict (DDict must be freed before dictBuffer) */ +ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize) +{ + ZSTD_customMem const allocator = { NULL, NULL, NULL }; + return ZSTD_createDDict_advanced(dictBuffer, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto, allocator); +} + + +const ZSTD_DDict* ZSTD_initStaticDDict( + void* sBuffer, size_t sBufferSize, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType) +{ + size_t const neededSpace = sizeof(ZSTD_DDict) + + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize); + ZSTD_DDict* const ddict = (ZSTD_DDict*)sBuffer; + assert(sBuffer != NULL); + assert(dict != NULL); + if ((size_t)sBuffer & 7) return NULL; /* 8-aligned */ + if (sBufferSize < neededSpace) return NULL; + if (dictLoadMethod == ZSTD_dlm_byCopy) { + memcpy(ddict+1, dict, dictSize); /* local copy */ + dict = ddict+1; + } + if (ZSTD_isError( ZSTD_initDDict_internal(ddict, + dict, dictSize, + ZSTD_dlm_byRef, dictContentType) )) + return NULL; + return ddict; +} + + +size_t ZSTD_freeDDict(ZSTD_DDict* ddict) +{ + if (ddict==NULL) return 0; /* support free on NULL */ + { ZSTD_customMem const cMem = ddict->cMem; + ZSTD_free(ddict->dictBuffer, cMem); + ZSTD_free(ddict, cMem); + return 0; + } +} + +/*! ZSTD_estimateDDictSize() : + * Estimate amount of memory that will be needed to create a dictionary for decompression. + * Note : dictionary created by reference using ZSTD_dlm_byRef are smaller */ +size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod) +{ + return sizeof(ZSTD_DDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize); +} + +size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict) +{ + if (ddict==NULL) return 0; /* support sizeof on NULL */ + return sizeof(*ddict) + (ddict->dictBuffer ? ddict->dictSize : 0) ; +} + +/*! ZSTD_getDictID_fromDict() : + * Provides the dictID stored within dictionary. + * if @return == 0, the dictionary is not conformant with Zstandard specification. + * It can still be loaded, but as a content-only dictionary. */ +unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize) +{ + if (dictSize < 8) return 0; + if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) return 0; + return MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE); +} + +/*! ZSTD_getDictID_fromDDict() : + * Provides the dictID of the dictionary loaded into `ddict`. + * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. + * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ +unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict) +{ + if (ddict==NULL) return 0; + return ZSTD_getDictID_fromDict(ddict->dictContent, ddict->dictSize); +} + +/*! ZSTD_getDictID_fromFrame() : + * Provides the dictID required to decompresse frame stored within `src`. + * If @return == 0, the dictID could not be decoded. + * This could for one of the following reasons : + * - The frame does not require a dictionary (most common case). + * - The frame was built with dictID intentionally removed. + * Needed dictionary is a hidden information. + * Note : this use case also happens when using a non-conformant dictionary. + * - `srcSize` is too small, and as a result, frame header could not be decoded. + * Note : possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`. + * - This is not a Zstandard frame. + * When identifying the exact failure cause, it's possible to use + * ZSTD_getFrameHeader(), which will provide a more precise error code. */ +unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize) +{ + ZSTD_frameHeader zfp = { 0, 0, 0, ZSTD_frame, 0, 0, 0 }; + size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize); + if (ZSTD_isError(hError)) return 0; + return zfp.dictID; +} + + +/*! ZSTD_decompress_usingDDict() : +* Decompression using a pre-digested Dictionary +* Use dictionary without significant overhead. */ +size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_DDict* ddict) +{ + /* pass content and size in case legacy frames are encountered */ + return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, + NULL, 0, + ddict); +} + + +/*===================================== +* Streaming decompression +*====================================*/ + +ZSTD_DStream* ZSTD_createDStream(void) +{ + DEBUGLOG(3, "ZSTD_createDStream"); + return ZSTD_createDStream_advanced(ZSTD_defaultCMem); +} + +ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize) +{ + return ZSTD_initStaticDCtx(workspace, workspaceSize); +} + +ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem) +{ + return ZSTD_createDCtx_advanced(customMem); +} + +size_t ZSTD_freeDStream(ZSTD_DStream* zds) +{ + return ZSTD_freeDCtx(zds); +} + + +/* *** Initialization *** */ + +size_t ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX + ZSTD_blockHeaderSize; } +size_t ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_MAX; } + +size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType) +{ + if (dctx->streamStage != zdss_init) return ERROR(stage_wrong); + ZSTD_freeDDict(dctx->ddictLocal); + if (dict && dictSize >= 8) { + dctx->ddictLocal = ZSTD_createDDict_advanced(dict, dictSize, dictLoadMethod, dictContentType, dctx->customMem); + if (dctx->ddictLocal == NULL) return ERROR(memory_allocation); + } else { + dctx->ddictLocal = NULL; + } + dctx->ddict = dctx->ddictLocal; + return 0; +} + +size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) +{ + return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto); +} + +size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) +{ + return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto); +} + +size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType) +{ + return ZSTD_DCtx_loadDictionary_advanced(dctx, prefix, prefixSize, ZSTD_dlm_byRef, dictContentType); +} + +size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize) +{ + return ZSTD_DCtx_refPrefix_advanced(dctx, prefix, prefixSize, ZSTD_dct_rawContent); +} + + +/* ZSTD_initDStream_usingDict() : + * return : expected size, aka ZSTD_frameHeaderSize_prefix. + * this function cannot fail */ +size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize) +{ + DEBUGLOG(4, "ZSTD_initDStream_usingDict"); + zds->streamStage = zdss_init; + zds->noForwardProgress = 0; + CHECK_F( ZSTD_DCtx_loadDictionary(zds, dict, dictSize) ); + return ZSTD_frameHeaderSize_prefix; +} + +/* note : this variant can't fail */ +size_t ZSTD_initDStream(ZSTD_DStream* zds) +{ + DEBUGLOG(4, "ZSTD_initDStream"); + return ZSTD_initDStream_usingDict(zds, NULL, 0); +} + +/* ZSTD_initDStream_usingDDict() : + * ddict will just be referenced, and must outlive decompression session + * this function cannot fail */ +size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict) +{ + size_t const initResult = ZSTD_initDStream(dctx); + dctx->ddict = ddict; + return initResult; +} + +/* ZSTD_resetDStream() : + * return : expected size, aka ZSTD_frameHeaderSize_prefix. + * this function cannot fail */ +size_t ZSTD_resetDStream(ZSTD_DStream* dctx) +{ + DEBUGLOG(4, "ZSTD_resetDStream"); + dctx->streamStage = zdss_loadHeader; + dctx->lhSize = dctx->inPos = dctx->outStart = dctx->outEnd = 0; + dctx->legacyVersion = 0; + dctx->hostageByte = 0; + return ZSTD_frameHeaderSize_prefix; +} + +size_t ZSTD_setDStreamParameter(ZSTD_DStream* dctx, + ZSTD_DStreamParameter_e paramType, unsigned paramValue) +{ + if (dctx->streamStage != zdss_init) return ERROR(stage_wrong); + switch(paramType) + { + default : return ERROR(parameter_unsupported); + case DStream_p_maxWindowSize : + DEBUGLOG(4, "setting maxWindowSize = %u KB", paramValue >> 10); + dctx->maxWindowSize = paramValue ? paramValue : (U32)(-1); + break; + } + return 0; +} + +size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict) +{ + if (dctx->streamStage != zdss_init) return ERROR(stage_wrong); + dctx->ddict = ddict; + return 0; +} + +size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize) +{ + if (dctx->streamStage != zdss_init) return ERROR(stage_wrong); + dctx->maxWindowSize = maxWindowSize; + return 0; +} + +size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format) +{ + DEBUGLOG(4, "ZSTD_DCtx_setFormat : %u", (unsigned)format); + if (dctx->streamStage != zdss_init) return ERROR(stage_wrong); + dctx->format = format; + return 0; +} + + +size_t ZSTD_sizeof_DStream(const ZSTD_DStream* dctx) +{ + return ZSTD_sizeof_DCtx(dctx); +} + +size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize) +{ + size_t const blockSize = (size_t) MIN(windowSize, ZSTD_BLOCKSIZE_MAX); + unsigned long long const neededRBSize = windowSize + blockSize + (WILDCOPY_OVERLENGTH * 2); + unsigned long long const neededSize = MIN(frameContentSize, neededRBSize); + size_t const minRBSize = (size_t) neededSize; + if ((unsigned long long)minRBSize != neededSize) return ERROR(frameParameter_windowTooLarge); + return minRBSize; +} + +size_t ZSTD_estimateDStreamSize(size_t windowSize) +{ + size_t const blockSize = MIN(windowSize, ZSTD_BLOCKSIZE_MAX); + size_t const inBuffSize = blockSize; /* no block can be larger */ + size_t const outBuffSize = ZSTD_decodingBufferSize_min(windowSize, ZSTD_CONTENTSIZE_UNKNOWN); + return ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize; +} + +size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize) +{ + U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; /* note : should be user-selectable */ + ZSTD_frameHeader zfh; + size_t const err = ZSTD_getFrameHeader(&zfh, src, srcSize); + if (ZSTD_isError(err)) return err; + if (err>0) return ERROR(srcSize_wrong); + if (zfh.windowSize > windowSizeMax) + return ERROR(frameParameter_windowTooLarge); + return ZSTD_estimateDStreamSize((size_t)zfh.windowSize); +} + + +/* ***** Decompression ***** */ + +MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize) +{ + size_t const length = MIN(dstCapacity, srcSize); + memcpy(dst, src, length); + return length; +} + + +size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input) +{ + const char* const istart = (const char*)(input->src) + input->pos; + const char* const iend = (const char*)(input->src) + input->size; + const char* ip = istart; + char* const ostart = (char*)(output->dst) + output->pos; + char* const oend = (char*)(output->dst) + output->size; + char* op = ostart; + U32 someMoreWork = 1; + + DEBUGLOG(5, "ZSTD_decompressStream"); + if (input->pos > input->size) { /* forbidden */ + DEBUGLOG(5, "in: pos: %u vs size: %u", + (U32)input->pos, (U32)input->size); + return ERROR(srcSize_wrong); + } + if (output->pos > output->size) { /* forbidden */ + DEBUGLOG(5, "out: pos: %u vs size: %u", + (U32)output->pos, (U32)output->size); + return ERROR(dstSize_tooSmall); + } + DEBUGLOG(5, "input size : %u", (U32)(input->size - input->pos)); + + while (someMoreWork) { + switch(zds->streamStage) + { + case zdss_init : + DEBUGLOG(5, "stage zdss_init => transparent reset "); + ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */ + /* fall-through */ + + case zdss_loadHeader : + DEBUGLOG(5, "stage zdss_loadHeader (srcSize : %u)", (U32)(iend - ip)); +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1) + if (zds->legacyVersion) { + /* legacy support is incompatible with static dctx */ + if (zds->staticSize) return ERROR(memory_allocation); + { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input); + if (hint==0) zds->streamStage = zdss_init; + return hint; + } } +#endif + { size_t const hSize = ZSTD_getFrameHeader_advanced(&zds->fParams, zds->headerBuffer, zds->lhSize, zds->format); + DEBUGLOG(5, "header size : %u", (U32)hSize); + if (ZSTD_isError(hSize)) { +#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1) + U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart); + if (legacyVersion) { + const void* const dict = zds->ddict ? zds->ddict->dictContent : NULL; + size_t const dictSize = zds->ddict ? zds->ddict->dictSize : 0; + DEBUGLOG(5, "ZSTD_decompressStream: detected legacy version v0.%u", legacyVersion); + /* legacy support is incompatible with static dctx */ + if (zds->staticSize) return ERROR(memory_allocation); + CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext, + zds->previousLegacyVersion, legacyVersion, + dict, dictSize)); + zds->legacyVersion = zds->previousLegacyVersion = legacyVersion; + { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, legacyVersion, output, input); + if (hint==0) zds->streamStage = zdss_init; /* or stay in stage zdss_loadHeader */ + return hint; + } } +#endif + return hSize; /* error */ + } + if (hSize != 0) { /* need more input */ + size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */ + size_t const remainingInput = (size_t)(iend-ip); + assert(iend >= ip); + if (toLoad > remainingInput) { /* not enough input to load full header */ + if (remainingInput > 0) { + memcpy(zds->headerBuffer + zds->lhSize, ip, remainingInput); + zds->lhSize += remainingInput; + } + input->pos = input->size; + return (MAX(ZSTD_frameHeaderSize_min, hSize) - zds->lhSize) + ZSTD_blockHeaderSize; /* remaining header bytes + next block header */ + } + assert(ip != NULL); + memcpy(zds->headerBuffer + zds->lhSize, ip, toLoad); zds->lhSize = hSize; ip += toLoad; + break; + } } + + /* check for single-pass mode opportunity */ + if (zds->fParams.frameContentSize && zds->fParams.windowSize /* skippable frame if == 0 */ + && (U64)(size_t)(oend-op) >= zds->fParams.frameContentSize) { + size_t const cSize = ZSTD_findFrameCompressedSize(istart, iend-istart); + if (cSize <= (size_t)(iend-istart)) { + /* shortcut : using single-pass mode */ + size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, oend-op, istart, cSize, zds->ddict); + if (ZSTD_isError(decompressedSize)) return decompressedSize; + DEBUGLOG(4, "shortcut to single-pass ZSTD_decompress_usingDDict()") + ip = istart + cSize; + op += decompressedSize; + zds->expected = 0; + zds->streamStage = zdss_init; + someMoreWork = 0; + break; + } } + + /* Consume header (see ZSTDds_decodeFrameHeader) */ + DEBUGLOG(4, "Consume header"); + CHECK_F(ZSTD_decompressBegin_usingDDict(zds, zds->ddict)); + + if ((MEM_readLE32(zds->headerBuffer) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */ + zds->expected = MEM_readLE32(zds->headerBuffer + ZSTD_FRAMEIDSIZE); + zds->stage = ZSTDds_skipFrame; + } else { + CHECK_F(ZSTD_decodeFrameHeader(zds, zds->headerBuffer, zds->lhSize)); + zds->expected = ZSTD_blockHeaderSize; + zds->stage = ZSTDds_decodeBlockHeader; + } + + /* control buffer memory usage */ + DEBUGLOG(4, "Control max memory usage (%u KB <= max %u KB)", + (U32)(zds->fParams.windowSize >>10), + (U32)(zds->maxWindowSize >> 10) ); + zds->fParams.windowSize = MAX(zds->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN); + if (zds->fParams.windowSize > zds->maxWindowSize) return ERROR(frameParameter_windowTooLarge); + + /* Adapt buffer sizes to frame header instructions */ + { size_t const neededInBuffSize = MAX(zds->fParams.blockSizeMax, 4 /* frame checksum */); + size_t const neededOutBuffSize = ZSTD_decodingBufferSize_min(zds->fParams.windowSize, zds->fParams.frameContentSize); + if ((zds->inBuffSize < neededInBuffSize) || (zds->outBuffSize < neededOutBuffSize)) { + size_t const bufferSize = neededInBuffSize + neededOutBuffSize; + DEBUGLOG(4, "inBuff : from %u to %u", + (U32)zds->inBuffSize, (U32)neededInBuffSize); + DEBUGLOG(4, "outBuff : from %u to %u", + (U32)zds->outBuffSize, (U32)neededOutBuffSize); + if (zds->staticSize) { /* static DCtx */ + DEBUGLOG(4, "staticSize : %u", (U32)zds->staticSize); + assert(zds->staticSize >= sizeof(ZSTD_DCtx)); /* controlled at init */ + if (bufferSize > zds->staticSize - sizeof(ZSTD_DCtx)) + return ERROR(memory_allocation); + } else { + ZSTD_free(zds->inBuff, zds->customMem); + zds->inBuffSize = 0; + zds->outBuffSize = 0; + zds->inBuff = (char*)ZSTD_malloc(bufferSize, zds->customMem); + if (zds->inBuff == NULL) return ERROR(memory_allocation); + } + zds->inBuffSize = neededInBuffSize; + zds->outBuff = zds->inBuff + zds->inBuffSize; + zds->outBuffSize = neededOutBuffSize; + } } + zds->streamStage = zdss_read; + /* fall-through */ + + case zdss_read: + DEBUGLOG(5, "stage zdss_read"); + { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds); + DEBUGLOG(5, "neededInSize = %u", (U32)neededInSize); + if (neededInSize==0) { /* end of frame */ + zds->streamStage = zdss_init; + someMoreWork = 0; + break; + } + if ((size_t)(iend-ip) >= neededInSize) { /* decode directly from src */ + int const isSkipFrame = ZSTD_isSkipFrame(zds); + size_t const decodedSize = ZSTD_decompressContinue(zds, + zds->outBuff + zds->outStart, (isSkipFrame ? 0 : zds->outBuffSize - zds->outStart), + ip, neededInSize); + if (ZSTD_isError(decodedSize)) return decodedSize; + ip += neededInSize; + if (!decodedSize && !isSkipFrame) break; /* this was just a header */ + zds->outEnd = zds->outStart + decodedSize; + zds->streamStage = zdss_flush; + break; + } } + if (ip==iend) { someMoreWork = 0; break; } /* no more input */ + zds->streamStage = zdss_load; + /* fall-through */ + + case zdss_load: + { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds); + size_t const toLoad = neededInSize - zds->inPos; + int const isSkipFrame = ZSTD_isSkipFrame(zds); + size_t loadedSize; + if (isSkipFrame) { + loadedSize = MIN(toLoad, (size_t)(iend-ip)); + } else { + if (toLoad > zds->inBuffSize - zds->inPos) return ERROR(corruption_detected); /* should never happen */ + loadedSize = ZSTD_limitCopy(zds->inBuff + zds->inPos, toLoad, ip, iend-ip); + } + ip += loadedSize; + zds->inPos += loadedSize; + if (loadedSize < toLoad) { someMoreWork = 0; break; } /* not enough input, wait for more */ + + /* decode loaded input */ + { size_t const decodedSize = ZSTD_decompressContinue(zds, + zds->outBuff + zds->outStart, zds->outBuffSize - zds->outStart, + zds->inBuff, neededInSize); + if (ZSTD_isError(decodedSize)) return decodedSize; + zds->inPos = 0; /* input is consumed */ + if (!decodedSize && !isSkipFrame) { zds->streamStage = zdss_read; break; } /* this was just a header */ + zds->outEnd = zds->outStart + decodedSize; + } } + zds->streamStage = zdss_flush; + /* fall-through */ + + case zdss_flush: + { size_t const toFlushSize = zds->outEnd - zds->outStart; + size_t const flushedSize = ZSTD_limitCopy(op, oend-op, zds->outBuff + zds->outStart, toFlushSize); + op += flushedSize; + zds->outStart += flushedSize; + if (flushedSize == toFlushSize) { /* flush completed */ + zds->streamStage = zdss_read; + if ( (zds->outBuffSize < zds->fParams.frameContentSize) + && (zds->outStart + zds->fParams.blockSizeMax > zds->outBuffSize) ) { + DEBUGLOG(5, "restart filling outBuff from beginning (left:%i, needed:%u)", + (int)(zds->outBuffSize - zds->outStart), + (U32)zds->fParams.blockSizeMax); + zds->outStart = zds->outEnd = 0; + } + break; + } } + /* cannot complete flush */ + someMoreWork = 0; + break; + + default: return ERROR(GENERIC); /* impossible */ + } } + + /* result */ + input->pos = (size_t)(ip - (const char*)(input->src)); + output->pos = (size_t)(op - (char*)(output->dst)); + if ((ip==istart) && (op==ostart)) { /* no forward progress */ + zds->noForwardProgress ++; + if (zds->noForwardProgress >= ZSTD_NO_FORWARD_PROGRESS_MAX) { + if (op==oend) return ERROR(dstSize_tooSmall); + if (ip==iend) return ERROR(srcSize_wrong); + assert(0); + } + } else { + zds->noForwardProgress = 0; + } + { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds); + if (!nextSrcSizeHint) { /* frame fully decoded */ + if (zds->outEnd == zds->outStart) { /* output fully flushed */ + if (zds->hostageByte) { + if (input->pos >= input->size) { + /* can't release hostage (not present) */ + zds->streamStage = zdss_read; + return 1; + } + input->pos++; /* release hostage */ + } /* zds->hostageByte */ + return 0; + } /* zds->outEnd == zds->outStart */ + if (!zds->hostageByte) { /* output not fully flushed; keep last byte as hostage; will be released when all output is flushed */ + input->pos--; /* note : pos > 0, otherwise, impossible to finish reading last block */ + zds->hostageByte=1; + } + return 1; + } /* nextSrcSizeHint==0 */ + nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds) == ZSTDnit_block); /* preload header of next block */ + assert(zds->inPos <= nextSrcSizeHint); + nextSrcSizeHint -= zds->inPos; /* part already loaded*/ + return nextSrcSizeHint; + } +} + + +size_t ZSTD_decompress_generic(ZSTD_DCtx* dctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input) +{ + return ZSTD_decompressStream(dctx, output, input); +} + +size_t ZSTD_decompress_generic_simpleArgs ( + ZSTD_DCtx* dctx, + void* dst, size_t dstCapacity, size_t* dstPos, + const void* src, size_t srcSize, size_t* srcPos) +{ + ZSTD_outBuffer output = { dst, dstCapacity, *dstPos }; + ZSTD_inBuffer input = { src, srcSize, *srcPos }; + /* ZSTD_compress_generic() will check validity of dstPos and srcPos */ + size_t const cErr = ZSTD_decompress_generic(dctx, &output, &input); + *dstPos = output.pos; + *srcPos = input.pos; + return cErr; +} + +void ZSTD_DCtx_reset(ZSTD_DCtx* dctx) +{ + (void)ZSTD_initDStream(dctx); + dctx->format = ZSTD_f_zstd1; + dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT; +} diff --git a/grub-core/lib/zstd/zstd_errors.h b/grub-core/lib/zstd/zstd_errors.h new file mode 100644 index 000000000..57533f286 --- /dev/null +++ b/grub-core/lib/zstd/zstd_errors.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_ERRORS_H_398273423 +#define ZSTD_ERRORS_H_398273423 + +#if defined (__cplusplus) +extern "C" { +#endif + +/*===== dependency =====*/ +#include /* size_t */ + + +/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */ +#ifndef ZSTDERRORLIB_VISIBILITY +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default"))) +# else +# define ZSTDERRORLIB_VISIBILITY +# endif +#endif +#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) +# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY +#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) +# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY +#endif + +/*-********************************************* + * Error codes list + *-********************************************* + * Error codes _values_ are pinned down since v1.3.1 only. + * Therefore, don't rely on values if you may link to any version < v1.3.1. + * + * Only values < 100 are considered stable. + * + * note 1 : this API shall be used with static linking only. + * dynamic linking is not yet officially supported. + * note 2 : Prefer relying on the enum than on its value whenever possible + * This is the only supported way to use the error list < v1.3.1 + * note 3 : ZSTD_isError() is always correct, whatever the library version. + **********************************************/ +typedef enum { + ZSTD_error_no_error = 0, + ZSTD_error_GENERIC = 1, + ZSTD_error_prefix_unknown = 10, + ZSTD_error_version_unsupported = 12, + ZSTD_error_frameParameter_unsupported = 14, + ZSTD_error_frameParameter_windowTooLarge = 16, + ZSTD_error_corruption_detected = 20, + ZSTD_error_checksum_wrong = 22, + ZSTD_error_dictionary_corrupted = 30, + ZSTD_error_dictionary_wrong = 32, + ZSTD_error_dictionaryCreation_failed = 34, + ZSTD_error_parameter_unsupported = 40, + ZSTD_error_parameter_outOfBound = 42, + ZSTD_error_tableLog_tooLarge = 44, + ZSTD_error_maxSymbolValue_tooLarge = 46, + ZSTD_error_maxSymbolValue_tooSmall = 48, + ZSTD_error_stage_wrong = 60, + ZSTD_error_init_missing = 62, + ZSTD_error_memory_allocation = 64, + ZSTD_error_workSpace_tooSmall= 66, + ZSTD_error_dstSize_tooSmall = 70, + ZSTD_error_srcSize_wrong = 72, + /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */ + ZSTD_error_frameIndex_tooLarge = 100, + ZSTD_error_seekableIO = 102, + ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */ +} ZSTD_ErrorCode; + +/*! ZSTD_getErrorCode() : + convert a `size_t` function result into a `ZSTD_ErrorCode` enum type, + which can be used to compare with enum list published above */ +ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); +ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ + + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_ERRORS_H_398273423 */ diff --git a/grub-core/lib/zstd/zstd_internal.h b/grub-core/lib/zstd/zstd_internal.h new file mode 100644 index 000000000..e75adfa61 --- /dev/null +++ b/grub-core/lib/zstd/zstd_internal.h @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + * You may select, at your option, one of the above-listed licenses. + */ + +#ifndef ZSTD_CCOMMON_H_MODULE +#define ZSTD_CCOMMON_H_MODULE + +/* this module contains definitions which must be identical + * across compression, decompression and dictBuilder. + * It also contains a few functions useful to at least 2 of them + * and which benefit from being inlined */ + +/*-************************************* +* Dependencies +***************************************/ +#include "compiler.h" +#include "mem.h" +#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */ +#include "error_private.h" +#define ZSTD_STATIC_LINKING_ONLY +#include "zstd.h" +#define FSE_STATIC_LINKING_ONLY +#include "fse.h" +#define HUF_STATIC_LINKING_ONLY +#include "huf.h" +#ifndef XXH_STATIC_LINKING_ONLY +# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */ +#endif +#include "xxhash.h" /* XXH_reset, update, digest */ + + +#if defined (__cplusplus) +extern "C" { +#endif + +/* ---- static assert (debug) --- */ +#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) + + +/*-************************************* +* shared macros +***************************************/ +#undef MIN +#undef MAX +#define MIN(a,b) ((a)<(b) ? (a) : (b)) +#define MAX(a,b) ((a)>(b) ? (a) : (b)) +#define CHECK_F(f) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; } /* check and Forward error code */ +#define CHECK_E(f, e) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); } /* check and send Error code */ + + +/*-************************************* +* Common constants +***************************************/ +#define ZSTD_OPT_NUM (1<<12) + +#define ZSTD_REP_NUM 3 /* number of repcodes */ +#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1) +static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 }; + +#define KB *(1 <<10) +#define MB *(1 <<20) +#define GB *(1U<<30) + +#define BIT7 128 +#define BIT6 64 +#define BIT5 32 +#define BIT4 16 +#define BIT1 2 +#define BIT0 1 + +#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10 +#define ZSTD_WINDOWLOG_DEFAULTMAX 27 /* Default maximum allowed window log */ +static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 }; +static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 }; + +#define ZSTD_FRAMEIDSIZE 4 /* magic number size */ + +#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */ +static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE; +typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e; + +#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */ +#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */ + +#define HufLog 12 +typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e; + +#define LONGNBSEQ 0x7F00 + +#define MINMATCH 3 + +#define Litbits 8 +#define MaxLit ((1<= 3) /* GCC Intrinsic */ + return 31 - __builtin_clz(val); +# else /* Software version */ + static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; + U32 v = val; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + return DeBruijnClz[(v * 0x07C4ACDDU) >> 27]; +# endif + } +} + + +/* ZSTD_invalidateRepCodes() : + * ensures next compression will not use repcodes from previous block. + * Note : only works with regular variant; + * do not use with extDict variant ! */ +void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */ + + +typedef struct { + blockType_e blockType; + U32 lastBlock; + U32 origSize; +} blockProperties_t; + +/*! ZSTD_getcBlockSize() : + * Provides the size of compressed block from block header `src` */ +/* Used by: decompress, fullbench (does not get its definition from here) */ +size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, + blockProperties_t* bpPtr); + +#if defined (__cplusplus) +} +#endif + +#endif /* ZSTD_CCOMMON_H_MODULE */ From 386128648606a3aa6ae7108d1c9af52258202279 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Mon, 19 Nov 2018 11:20:08 -0800 Subject: [PATCH 0878/1167] btrfs: Add zstd support to grub btrfs - Adds zstd support to the btrfs module. - Adds a test case for btrfs zstd support. - Changes top_srcdir to srcdir in the btrfs module's lzo include following comments from Daniel Kiper about the zstd include. Tested on Ubuntu-18.04 with a btrfs /boot partition with and without zstd compression. A test case was also added to the test suite that fails before the patch, and passes after. Signed-off-by: Nick Terrell Reviewed-by: Daniel Kiper --- Makefile.util.def | 11 +++- grub-core/Makefile.core.def | 2 +- grub-core/fs/btrfs.c | 119 ++++++++++++++++++++++++++++++++++- tests/btrfs_test.in | 1 + tests/util/grub-fs-tester.in | 2 +- 5 files changed, 131 insertions(+), 4 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def index 9ae45f351..a0495a87f 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -54,7 +54,7 @@ library = { library = { name = libgrubmods.a; cflags = '-fno-builtin -Wno-undef'; - cppflags = '-I$(top_srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H'; + cppflags = '-I$(srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -I$(srcdir)/grub-core/lib/zstd -DMINILZO_HAVE_CONFIG_H'; common_nodist = grub_script.tab.c; common_nodist = grub_script.yy.c; @@ -165,6 +165,15 @@ library = { common = grub-core/lib/xzembed/xz_dec_bcj.c; common = grub-core/lib/xzembed/xz_dec_lzma2.c; common = grub-core/lib/xzembed/xz_dec_stream.c; + common = grub-core/lib/zstd/debug.c; + common = grub-core/lib/zstd/entropy_common.c; + common = grub-core/lib/zstd/error_private.c; + common = grub-core/lib/zstd/fse_decompress.c; + common = grub-core/lib/zstd/huf_decompress.c; + common = grub-core/lib/zstd/module.c; + common = grub-core/lib/zstd/xxhash.c; + common = grub-core/lib/zstd/zstd_common.c; + common = grub-core/lib/zstd/zstd_decompress.c; }; program = { diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 829e7bb57..2d75c4daf 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1291,7 +1291,7 @@ module = { common = fs/btrfs.c; common = lib/crc.c; cflags = '$(CFLAGS_POSIX) -Wno-undef'; - cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H'; + cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H'; }; module = { diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index cac9ef588..3d6d11ec5 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -17,6 +17,14 @@ * along with GRUB. If not, see . */ +/* + * Tell zstd to expose functions that aren't part of the stable API, which + * aren't safe to use when linking against a dynamic library. We vendor in a + * specific zstd version, so we know what we're getting. We need these unstable + * functions to provide our own allocator, which uses grub_malloc(), to zstd. + */ +#define ZSTD_STATIC_LINKING_ONLY + #include #include #include @@ -27,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +56,9 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE (GRUB_BTRFS_LZO_BLOCK_SIZE + \ (GRUB_BTRFS_LZO_BLOCK_SIZE / 16) + 64 + 3) +#define ZSTD_BTRFS_MAX_WINDOWLOG 17 +#define ZSTD_BTRFS_MAX_INPUT (1 << ZSTD_BTRFS_MAX_WINDOWLOG) + typedef grub_uint8_t grub_btrfs_checksum_t[0x20]; typedef grub_uint16_t grub_btrfs_uuid_t[8]; @@ -217,6 +229,7 @@ struct grub_btrfs_extent_data #define GRUB_BTRFS_COMPRESSION_NONE 0 #define GRUB_BTRFS_COMPRESSION_ZLIB 1 #define GRUB_BTRFS_COMPRESSION_LZO 2 +#define GRUB_BTRFS_COMPRESSION_ZSTD 3 #define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100 @@ -1216,6 +1229,96 @@ grub_btrfs_read_inode (struct grub_btrfs_data *data, return grub_btrfs_read_logical (data, elemaddr, inode, sizeof (*inode), 0); } +static void *grub_zstd_malloc (void *state __attribute__((unused)), size_t size) +{ + return grub_malloc (size); +} + +static void grub_zstd_free (void *state __attribute__((unused)), void *address) +{ + return grub_free (address); +} + +static ZSTD_customMem grub_zstd_allocator (void) +{ + ZSTD_customMem allocator; + + allocator.customAlloc = &grub_zstd_malloc; + allocator.customFree = &grub_zstd_free; + allocator.opaque = NULL; + + return allocator; +} + +static grub_ssize_t +grub_btrfs_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off, + char *obuf, grub_size_t osize) +{ + void *allocated = NULL; + char *otmpbuf = obuf; + grub_size_t otmpsize = osize; + ZSTD_DCtx *dctx = NULL; + grub_size_t zstd_ret; + grub_ssize_t ret = -1; + + /* + * Zstd will fail if it can't fit the entire output in the destination + * buffer, so if osize isn't large enough, allocate a temporary buffer. + */ + if (otmpsize < ZSTD_BTRFS_MAX_INPUT) + { + allocated = grub_malloc (ZSTD_BTRFS_MAX_INPUT); + if (!allocated) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed allocate a zstd buffer"); + goto err; + } + otmpbuf = (char *) allocated; + otmpsize = ZSTD_BTRFS_MAX_INPUT; + } + + /* Create the ZSTD_DCtx. */ + dctx = ZSTD_createDCtx_advanced (grub_zstd_allocator ()); + if (!dctx) + { + /* ZSTD_createDCtx_advanced() only fails if it is out of memory. */ + grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to create a zstd context"); + goto err; + } + + /* + * Get the real input size, there may be junk at the + * end of the frame. + */ + isize = ZSTD_findFrameCompressedSize (ibuf, isize); + if (ZSTD_isError (isize)) + { + grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted"); + goto err; + } + + /* Decompress and check for errors. */ + zstd_ret = ZSTD_decompressDCtx (dctx, otmpbuf, otmpsize, ibuf, isize); + if (ZSTD_isError (zstd_ret)) + { + grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted"); + goto err; + } + + /* + * Move the requested data into the obuf. obuf may be equal + * to otmpbuf, which is why grub_memmove() is required. + */ + grub_memmove (obuf, otmpbuf + off, osize); + ret = osize; + +err: + grub_free (allocated); + ZSTD_freeDCtx (dctx); + + return ret; +} + static grub_ssize_t grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off, char *obuf, grub_size_t osize) @@ -1391,7 +1494,8 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, if (data->extent->compression != GRUB_BTRFS_COMPRESSION_NONE && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZLIB - && data->extent->compression != GRUB_BTRFS_COMPRESSION_LZO) + && data->extent->compression != GRUB_BTRFS_COMPRESSION_LZO + && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZSTD) { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "compression type 0x%x not supported", @@ -1431,6 +1535,15 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, != (grub_ssize_t) csize) return -1; } + else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZSTD) + { + if (grub_btrfs_zstd_decompress (data->extent->inl, data->extsize - + ((grub_uint8_t *) data->extent->inl + - (grub_uint8_t *) data->extent), + extoff, buf, csize) + != (grub_ssize_t) csize) + return -1; + } else grub_memcpy (buf, data->extent->inl + extoff, csize); break; @@ -1468,6 +1581,10 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, ret = grub_btrfs_lzo_decompress (tmp, zsize, extoff + grub_le_to_cpu64 (data->extent->offset), buf, csize); + else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZSTD) + ret = grub_btrfs_zstd_decompress (tmp, zsize, extoff + + grub_le_to_cpu64 (data->extent->offset), + buf, csize); else ret = -1; diff --git a/tests/btrfs_test.in b/tests/btrfs_test.in index 2b37ddd33..0c9bf3a68 100644 --- a/tests/btrfs_test.in +++ b/tests/btrfs_test.in @@ -18,6 +18,7 @@ fi "@builddir@/grub-fs-tester" btrfs "@builddir@/grub-fs-tester" btrfs_zlib "@builddir@/grub-fs-tester" btrfs_lzo +"@builddir@/grub-fs-tester" btrfs_zstd "@builddir@/grub-fs-tester" btrfs_raid0 "@builddir@/grub-fs-tester" btrfs_raid1 "@builddir@/grub-fs-tester" btrfs_single diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index ef65fbc93..bc14a05ca 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -629,7 +629,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do ;; x"btrfs") "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" ;; - x"btrfs_zlib" | x"btrfs_lzo") + x"btrfs_zlib" | x"btrfs_lzo" | x"btrfs_zstd") "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" MOUNTOPTS="compress=${fs/btrfs_/}," MOUNTFS="btrfs" From 29157553b7fb581fe81b9916f968127f19ef64f3 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 27 Nov 2018 15:17:26 -0800 Subject: [PATCH 0879/1167] ofnet: Fix build regression in grub_ieee1275_parse_bootpath() The grub_ieee1275_parse_bootpath() function (commit a661a32, ofnet: Initialize structs in bootpath parser) introduces a build regression on SPARC: cc1: warnings being treated as errors net/drivers/ieee1275/ofnet.c: In function 'grub_ieee1275_parse_bootpath': net/drivers/ieee1275/ofnet.c:156: error: missing initializer net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'client_addr.type') net/drivers/ieee1275/ofnet.c:156: error: missing initializer net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'gateway_addr.type') net/drivers/ieee1275/ofnet.c:156: error: missing initializer net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'subnet_mask.type') net/drivers/ieee1275/ofnet.c:157: error: missing initializer net/drivers/ieee1275/ofnet.c:157: error: (near initialization for 'hw_addr.type') make[3]: *** [net/drivers/ieee1275/ofnet_module-ofnet.o] Error 1 Initialize the entire structure. More info can be found here: http://lists.gnu.org/archive/html/grub-devel/2018-03/msg00034.html Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/net/drivers/ieee1275/ofnet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 00abc64bb..ac4e62a95 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -153,8 +153,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, char *comma_char = 0; char *equal_char = 0; grub_size_t field_counter = 0; - grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {}; - grub_net_link_level_address_t hw_addr = {}; + grub_net_network_level_address_t client_addr = {0, {0}, 0}, gateway_addr = {0, {0}, 0}, subnet_mask = {0, {0}, 0}; + grub_net_link_level_address_t hw_addr = {0, {{0, 0, 0, 0, 0, 0}}}; grub_net_interface_flags_t flags = 0; struct grub_net_network_level_interface *inter = NULL; grub_uint16_t vlantag = 0; From e5b846333fcb12f3536821fbc28eab88055733b2 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 6 Dec 2018 13:38:15 +0100 Subject: [PATCH 0880/1167] verifiers: Xen fallout cleanup Xen fallout cleanup after commit ca0a4f689 (verifiers: File type for fine-grained signature-verification controlling). Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/loader/i386/xen.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index 1a99ca72c..8f662c8ac 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -645,10 +645,10 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), grub_xen_reset (); - grub_create_loader_cmdline (argc - 1, argv + 1, - (char *) xen_state.next_start.cmd_line, - sizeof (xen_state.next_start.cmd_line) - 1); - err = grub_verify_string (xen_state.next_start.cmd_line, GRUB_VERIFY_MODULE_CMDLINE); + err = grub_create_loader_cmdline (argc - 1, argv + 1, + (char *) xen_state.next_start.cmd_line, + sizeof (xen_state.next_start.cmd_line) - 1, + GRUB_VERIFY_KERNEL_CMDLINE); if (err) return err; @@ -910,9 +910,9 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), if (err) goto fail; - grub_create_loader_cmdline (argc - 1, argv + 1, - get_virtual_current_address (ch), cmdline_len); - err = grub_verify_string (get_virtual_current_address (ch), GRUB_VERIFY_MODULE_CMDLINE); + err = grub_create_loader_cmdline (argc - 1, argv + 1, + get_virtual_current_address (ch), cmdline_len, + GRUB_VERIFY_MODULE_CMDLINE); if (err) goto fail; From 95db97d041800b2298fda3b18fd336588f62d1c1 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 6 Dec 2018 13:43:05 +0100 Subject: [PATCH 0881/1167] verifiers: ARM Xen fallout cleanup ARM Xen fallout cleanup after commit ca0a4f689 (verifiers: File type for fine-grained signature-verification controlling). Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/loader/arm64/xen_boot.c | 8 ++++---- include/grub/file.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 33a855df4..a742868a4 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -429,9 +429,9 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), grub_dprintf ("xen_loader", "Init module and node info\n"); - if (nounzip) - grub_file_filter_disable_compression (); - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_XEN_MODULE + | (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS + : GRUB_FILE_TYPE_NONE)); if (!file) goto fail; @@ -463,7 +463,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), goto fail; } - file = grub_file_open (argv[0]); + file = grub_file_open (argv[0], GRUB_FILE_TYPE_XEN_HYPERVISOR); if (!file) goto fail; diff --git a/include/grub/file.h b/include/grub/file.h index 9aae46355..cbbd29465 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -42,6 +42,11 @@ enum grub_file_type /* Multiboot module. */ GRUB_FILE_TYPE_MULTIBOOT_MODULE, + /* Xen hypervisor - used on ARM only. */ + GRUB_FILE_TYPE_XEN_HYPERVISOR, + /* Xen module - used on ARM only. */ + GRUB_FILE_TYPE_XEN_MODULE, + GRUB_FILE_TYPE_BSD_KERNEL, GRUB_FILE_TYPE_FREEBSD_ENV, GRUB_FILE_TYPE_FREEBSD_MODULE, From 9118effd1b1fb67d82168b37cf6dd1142feced3b Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:29 +0100 Subject: [PATCH 0882/1167] xen: Add some Xen headers In order to support grub2 in Xen PVH environment some additional Xen headers are needed as grub2 will be started in PVH mode requiring to use several HVM hypercalls and structures. Add the needed headers from Xen 4.10 being the first Xen version with full (not only experimental) PVH guest support. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- include/xen/hvm/hvm_op.h | 296 ++++++++++++++++ include/xen/hvm/params.h | 284 +++++++++++++++ include/xen/hvm/start_info.h | 98 ++++++ include/xen/memory.h | 665 +++++++++++++++++++++++++++++++++++ include/xen/physdev.h | 387 ++++++++++++++++++++ include/xen/trace.h | 339 ++++++++++++++++++ include/xen/xen.h | 104 ++++-- 7 files changed, 2142 insertions(+), 31 deletions(-) create mode 100644 include/xen/hvm/hvm_op.h create mode 100644 include/xen/hvm/params.h create mode 100644 include/xen/hvm/start_info.h create mode 100644 include/xen/memory.h create mode 100644 include/xen/physdev.h create mode 100644 include/xen/trace.h diff --git a/include/xen/hvm/hvm_op.h b/include/xen/hvm/hvm_op.h new file mode 100644 index 000000000..0bdafdf59 --- /dev/null +++ b/include/xen/hvm/hvm_op.h @@ -0,0 +1,296 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2007, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__ +#define __XEN_PUBLIC_HVM_HVM_OP_H__ + +#include "../xen.h" +#include "../trace.h" +#include "../event_channel.h" + +/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */ +#define HVMOP_set_param 0 +#define HVMOP_get_param 1 +struct xen_hvm_param { + domid_t domid; /* IN */ + uint32_t index; /* IN */ + uint64_t value; /* IN/OUT */ +}; +typedef struct xen_hvm_param xen_hvm_param_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t); + +#if __XEN_INTERFACE_VERSION__ < 0x00040900 + +/* Set the logical level of one of a domain's PCI INTx wires. */ +#define HVMOP_set_pci_intx_level 2 +struct xen_hvm_set_pci_intx_level { + /* Domain to be updated. */ + domid_t domid; + /* PCI INTx identification in PCI topology (domain:bus:device:intx). */ + uint8_t domain, bus, device, intx; + /* Assertion level (0 = unasserted, 1 = asserted). */ + uint8_t level; +}; +typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t); + +/* Set the logical level of one of a domain's ISA IRQ wires. */ +#define HVMOP_set_isa_irq_level 3 +struct xen_hvm_set_isa_irq_level { + /* Domain to be updated. */ + domid_t domid; + /* ISA device identification, by ISA IRQ (0-15). */ + uint8_t isa_irq; + /* Assertion level (0 = unasserted, 1 = asserted). */ + uint8_t level; +}; +typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t); + +#define HVMOP_set_pci_link_route 4 +struct xen_hvm_set_pci_link_route { + /* Domain to be updated. */ + domid_t domid; + /* PCI link identifier (0-3). */ + uint8_t link; + /* ISA IRQ (1-15), or 0 (disable link). */ + uint8_t isa_irq; +}; +typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t); + +#endif /* __XEN_INTERFACE_VERSION__ < 0x00040900 */ + +/* Flushes all VCPU TLBs: @arg must be NULL. */ +#define HVMOP_flush_tlbs 5 + +typedef enum { + HVMMEM_ram_rw, /* Normal read/write guest RAM */ + HVMMEM_ram_ro, /* Read-only; writes are discarded */ + HVMMEM_mmio_dm, /* Reads and write go to the device model */ +#if __XEN_INTERFACE_VERSION__ < 0x00040700 + HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */ +#else + HVMMEM_unused, /* Placeholder; setting memory to this type + will fail for code after 4.7.0 */ +#endif + HVMMEM_ioreq_server /* Memory type claimed by an ioreq server; type + changes to this value are only allowed after + an ioreq server has claimed its ownership. + Only pages with HVMMEM_ram_rw are allowed to + change to this type; conversely, pages with + this type are only allowed to be changed back + to HVMMEM_ram_rw. */ +} hvmmem_type_t; + +/* Hint from PV drivers for pagetable destruction. */ +#define HVMOP_pagetable_dying 9 +struct xen_hvm_pagetable_dying { + /* Domain with a pagetable about to be destroyed. */ + domid_t domid; + uint16_t pad[3]; /* align next field on 8-byte boundary */ + /* guest physical address of the toplevel pagetable dying */ + uint64_t gpa; +}; +typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t); + +/* Get the current Xen time, in nanoseconds since system boot. */ +#define HVMOP_get_time 10 +struct xen_hvm_get_time { + uint64_t now; /* OUT */ +}; +typedef struct xen_hvm_get_time xen_hvm_get_time_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t); + +#define HVMOP_xentrace 11 +struct xen_hvm_xentrace { + uint16_t event, extra_bytes; + uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)]; +}; +typedef struct xen_hvm_xentrace xen_hvm_xentrace_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t); + +/* Following tools-only interfaces may change in future. */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +/* Deprecated by XENMEM_access_op_set_access */ +#define HVMOP_set_mem_access 12 + +/* Deprecated by XENMEM_access_op_get_access */ +#define HVMOP_get_mem_access 13 + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +#define HVMOP_get_mem_type 15 +/* Return hvmmem_type_t for the specified pfn. */ +struct xen_hvm_get_mem_type { + /* Domain to be queried. */ + domid_t domid; + /* OUT variable. */ + uint16_t mem_type; + uint16_t pad[2]; /* align next field on 8-byte boundary */ + /* IN variable. */ + uint64_t pfn; +}; +typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t); + +/* Following tools-only interfaces may change in future. */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +/* + * Definitions relating to DMOP_create_ioreq_server. (Defined here for + * backwards compatibility). + */ + +#define HVM_IOREQSRV_BUFIOREQ_OFF 0 +#define HVM_IOREQSRV_BUFIOREQ_LEGACY 1 +/* + * Use this when read_pointer gets updated atomically and + * the pointer pair gets read atomically: + */ +#define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2 + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +#if defined(__i386__) || defined(__x86_64__) + +/* + * HVMOP_set_evtchn_upcall_vector: Set a that should be used for event + * channel upcalls on the specified . If set, + * this vector will be used in preference to the + * domain global callback via (see + * HVM_PARAM_CALLBACK_IRQ). + */ +#define HVMOP_set_evtchn_upcall_vector 23 +struct xen_hvm_evtchn_upcall_vector { + uint32_t vcpu; + uint8_t vector; +}; +typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_evtchn_upcall_vector_t); + +#endif /* defined(__i386__) || defined(__x86_64__) */ + +#define HVMOP_guest_request_vm_event 24 + +/* HVMOP_altp2m: perform altp2m state operations */ +#define HVMOP_altp2m 25 + +#define HVMOP_ALTP2M_INTERFACE_VERSION 0x00000001 + +struct xen_hvm_altp2m_domain_state { + /* IN or OUT variable on/off */ + uint8_t state; +}; +typedef struct xen_hvm_altp2m_domain_state xen_hvm_altp2m_domain_state_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_domain_state_t); + +struct xen_hvm_altp2m_vcpu_enable_notify { + uint32_t vcpu_id; + uint32_t pad; + /* #VE info area gfn */ + uint64_t gfn; +}; +typedef struct xen_hvm_altp2m_vcpu_enable_notify xen_hvm_altp2m_vcpu_enable_notify_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_enable_notify_t); + +struct xen_hvm_altp2m_view { + /* IN/OUT variable */ + uint16_t view; + /* Create view only: default access type + * NOTE: currently ignored */ + uint16_t hvmmem_default_access; /* xenmem_access_t */ +}; +typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_view_t); + +struct xen_hvm_altp2m_set_mem_access { + /* view */ + uint16_t view; + /* Memory type */ + uint16_t hvmmem_access; /* xenmem_access_t */ + uint32_t pad; + /* gfn */ + uint64_t gfn; +}; +typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t); + +struct xen_hvm_altp2m_change_gfn { + /* view */ + uint16_t view; + uint16_t pad1; + uint32_t pad2; + /* old gfn */ + uint64_t old_gfn; + /* new gfn, INVALID_GFN (~0UL) means revert */ + uint64_t new_gfn; +}; +typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t); + +struct xen_hvm_altp2m_op { + uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */ + uint32_t cmd; +/* Get/set the altp2m state for a domain */ +#define HVMOP_altp2m_get_domain_state 1 +#define HVMOP_altp2m_set_domain_state 2 +/* Set the current VCPU to receive altp2m event notifications */ +#define HVMOP_altp2m_vcpu_enable_notify 3 +/* Create a new view */ +#define HVMOP_altp2m_create_p2m 4 +/* Destroy a view */ +#define HVMOP_altp2m_destroy_p2m 5 +/* Switch view for an entire domain */ +#define HVMOP_altp2m_switch_p2m 6 +/* Notify that a page of memory is to have specific access types */ +#define HVMOP_altp2m_set_mem_access 7 +/* Change a p2m entry to have a different gfn->mfn mapping */ +#define HVMOP_altp2m_change_gfn 8 + domid_t domain; + uint16_t pad1; + uint32_t pad2; + union { + struct xen_hvm_altp2m_domain_state domain_state; + struct xen_hvm_altp2m_vcpu_enable_notify enable_notify; + struct xen_hvm_altp2m_view view; + struct xen_hvm_altp2m_set_mem_access set_mem_access; + struct xen_hvm_altp2m_change_gfn change_gfn; + uint8_t pad[64]; + } u; +}; +typedef struct xen_hvm_altp2m_op xen_hvm_altp2m_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_op_t); + +#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/hvm/params.h b/include/xen/hvm/params.h new file mode 100644 index 000000000..2ec2e7c80 --- /dev/null +++ b/include/xen/hvm/params.h @@ -0,0 +1,284 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2007, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_HVM_PARAMS_H__ +#define __XEN_PUBLIC_HVM_PARAMS_H__ + +#include "hvm_op.h" + +/* + * Parameter space for HVMOP_{set,get}_param. + */ + +#define HVM_PARAM_CALLBACK_IRQ 0 +#define HVM_PARAM_CALLBACK_IRQ_TYPE_MASK xen_mk_ullong(0xFF00000000000000) +/* + * How should CPU0 event-channel notifications be delivered? + * + * If val == 0 then CPU0 event-channel notifications are not delivered. + * If val != 0, val[63:56] encodes the type, as follows: + */ + +#define HVM_PARAM_CALLBACK_TYPE_GSI 0 +/* + * val[55:0] is a delivery GSI. GSI 0 cannot be used, as it aliases val == 0, + * and disables all notifications. + */ + +#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1 +/* + * val[55:0] is a delivery PCI INTx line: + * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0] + */ + +#if defined(__i386__) || defined(__x86_64__) +#define HVM_PARAM_CALLBACK_TYPE_VECTOR 2 +/* + * val[7:0] is a vector number. Check for XENFEAT_hvm_callback_vector to know + * if this delivery method is available. + */ +#elif defined(__arm__) || defined(__aarch64__) +#define HVM_PARAM_CALLBACK_TYPE_PPI 2 +/* + * val[55:16] needs to be zero. + * val[15:8] is interrupt flag of the PPI used by event-channel: + * bit 8: the PPI is edge(1) or level(0) triggered + * bit 9: the PPI is active low(1) or high(0) + * val[7:0] is a PPI number used by event-channel. + * This is only used by ARM/ARM64 and masking/eoi the interrupt associated to + * the notification is handled by the interrupt controller. + */ +#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK 0xFF00 +#define HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_LOW_LEVEL 2 +#endif + +/* + * These are not used by Xen. They are here for convenience of HVM-guest + * xenbus implementations. + */ +#define HVM_PARAM_STORE_PFN 1 +#define HVM_PARAM_STORE_EVTCHN 2 + +#define HVM_PARAM_PAE_ENABLED 4 + +#define HVM_PARAM_IOREQ_PFN 5 + +#define HVM_PARAM_BUFIOREQ_PFN 6 +#define HVM_PARAM_BUFIOREQ_EVTCHN 26 + +#if defined(__i386__) || defined(__x86_64__) + +/* + * Viridian enlightenments + * + * (See http://download.microsoft.com/download/A/B/4/AB43A34E-BDD0-4FA6-BDEF-79EEF16E880B/Hypervisor%20Top%20Level%20Functional%20Specification%20v4.0.docx) + * + * To expose viridian enlightenments to the guest set this parameter + * to the desired feature mask. The base feature set must be present + * in any valid feature mask. + */ +#define HVM_PARAM_VIRIDIAN 9 + +/* Base+Freq viridian feature sets: + * + * - Hypercall MSRs (HV_X64_MSR_GUEST_OS_ID and HV_X64_MSR_HYPERCALL) + * - APIC access MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and HV_X64_MSR_TPR) + * - Virtual Processor index MSR (HV_X64_MSR_VP_INDEX) + * - Timer frequency MSRs (HV_X64_MSR_TSC_FREQUENCY and + * HV_X64_MSR_APIC_FREQUENCY) + */ +#define _HVMPV_base_freq 0 +#define HVMPV_base_freq (1 << _HVMPV_base_freq) + +/* Feature set modifications */ + +/* Disable timer frequency MSRs (HV_X64_MSR_TSC_FREQUENCY and + * HV_X64_MSR_APIC_FREQUENCY). + * This modification restores the viridian feature set to the + * original 'base' set exposed in releases prior to Xen 4.4. + */ +#define _HVMPV_no_freq 1 +#define HVMPV_no_freq (1 << _HVMPV_no_freq) + +/* Enable Partition Time Reference Counter (HV_X64_MSR_TIME_REF_COUNT) */ +#define _HVMPV_time_ref_count 2 +#define HVMPV_time_ref_count (1 << _HVMPV_time_ref_count) + +/* Enable Reference TSC Page (HV_X64_MSR_REFERENCE_TSC) */ +#define _HVMPV_reference_tsc 3 +#define HVMPV_reference_tsc (1 << _HVMPV_reference_tsc) + +/* Use Hypercall for remote TLB flush */ +#define _HVMPV_hcall_remote_tlb_flush 4 +#define HVMPV_hcall_remote_tlb_flush (1 << _HVMPV_hcall_remote_tlb_flush) + +/* Use APIC assist */ +#define _HVMPV_apic_assist 5 +#define HVMPV_apic_assist (1 << _HVMPV_apic_assist) + +/* Enable crash MSRs */ +#define _HVMPV_crash_ctl 6 +#define HVMPV_crash_ctl (1 << _HVMPV_crash_ctl) + +#define HVMPV_feature_mask \ + (HVMPV_base_freq | \ + HVMPV_no_freq | \ + HVMPV_time_ref_count | \ + HVMPV_reference_tsc | \ + HVMPV_hcall_remote_tlb_flush | \ + HVMPV_apic_assist | \ + HVMPV_crash_ctl) + +#endif + +/* + * Set mode for virtual timers (currently x86 only): + * delay_for_missed_ticks (default): + * Do not advance a vcpu's time beyond the correct delivery time for + * interrupts that have been missed due to preemption. Deliver missed + * interrupts when the vcpu is rescheduled and advance the vcpu's virtual + * time stepwise for each one. + * no_delay_for_missed_ticks: + * As above, missed interrupts are delivered, but guest time always tracks + * wallclock (i.e., real) time while doing so. + * no_missed_ticks_pending: + * No missed interrupts are held pending. Instead, to ensure ticks are + * delivered at some non-zero rate, if we detect missed ticks then the + * internal tick alarm is not disabled if the VCPU is preempted during the + * next tick period. + * one_missed_tick_pending: + * Missed interrupts are collapsed together and delivered as one 'late tick'. + * Guest time always tracks wallclock (i.e., real) time. + */ +#define HVM_PARAM_TIMER_MODE 10 +#define HVMPTM_delay_for_missed_ticks 0 +#define HVMPTM_no_delay_for_missed_ticks 1 +#define HVMPTM_no_missed_ticks_pending 2 +#define HVMPTM_one_missed_tick_pending 3 + +/* Boolean: Enable virtual HPET (high-precision event timer)? (x86-only) */ +#define HVM_PARAM_HPET_ENABLED 11 + +/* Identity-map page directory used by Intel EPT when CR0.PG=0. */ +#define HVM_PARAM_IDENT_PT 12 + +/* Device Model domain, defaults to 0. */ +#define HVM_PARAM_DM_DOMAIN 13 + +/* ACPI S state: currently support S0 and S3 on x86. */ +#define HVM_PARAM_ACPI_S_STATE 14 + +/* TSS used on Intel when CR0.PE=0. */ +#define HVM_PARAM_VM86_TSS 15 + +/* Boolean: Enable aligning all periodic vpts to reduce interrupts */ +#define HVM_PARAM_VPT_ALIGN 16 + +/* Console debug shared memory ring and event channel */ +#define HVM_PARAM_CONSOLE_PFN 17 +#define HVM_PARAM_CONSOLE_EVTCHN 18 + +/* + * Select location of ACPI PM1a and TMR control blocks. Currently two locations + * are supported, specified by version 0 or 1 in this parameter: + * - 0: default, use the old addresses + * PM1A_EVT == 0x1f40; PM1A_CNT == 0x1f44; PM_TMR == 0x1f48 + * - 1: use the new default qemu addresses + * PM1A_EVT == 0xb000; PM1A_CNT == 0xb004; PM_TMR == 0xb008 + * You can find these address definitions in + */ +#define HVM_PARAM_ACPI_IOPORTS_LOCATION 19 + +/* Deprecated */ +#define HVM_PARAM_MEMORY_EVENT_CR0 20 +#define HVM_PARAM_MEMORY_EVENT_CR3 21 +#define HVM_PARAM_MEMORY_EVENT_CR4 22 +#define HVM_PARAM_MEMORY_EVENT_INT3 23 +#define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 +#define HVM_PARAM_MEMORY_EVENT_MSR 30 + +/* Boolean: Enable nestedhvm (hvm only) */ +#define HVM_PARAM_NESTEDHVM 24 + +/* Params for the mem event rings */ +#define HVM_PARAM_PAGING_RING_PFN 27 +#define HVM_PARAM_MONITOR_RING_PFN 28 +#define HVM_PARAM_SHARING_RING_PFN 29 + +/* SHUTDOWN_* action in case of a triple fault */ +#define HVM_PARAM_TRIPLE_FAULT_REASON 31 + +#define HVM_PARAM_IOREQ_SERVER_PFN 32 +#define HVM_PARAM_NR_IOREQ_SERVER_PAGES 33 + +/* Location of the VM Generation ID in guest physical address space. */ +#define HVM_PARAM_VM_GENERATION_ID_ADDR 34 + +/* + * Set mode for altp2m: + * disabled: don't activate altp2m (default) + * mixed: allow access to all altp2m ops for both in-guest and external tools + * external: allow access to external privileged tools only + * limited: guest only has limited access (ie. control VMFUNC and #VE) + */ +#define HVM_PARAM_ALTP2M 35 +#define XEN_ALTP2M_disabled 0 +#define XEN_ALTP2M_mixed 1 +#define XEN_ALTP2M_external 2 +#define XEN_ALTP2M_limited 3 + +/* + * Size of the x87 FPU FIP/FDP registers that the hypervisor needs to + * save/restore. This is a workaround for a hardware limitation that + * does not allow the full FIP/FDP and FCS/FDS to be restored. + * + * Valid values are: + * + * 8: save/restore 64-bit FIP/FDP and clear FCS/FDS (default if CPU + * has FPCSDS feature). + * + * 4: save/restore 32-bit FIP/FDP, FCS/FDS, and clear upper 32-bits of + * FIP/FDP. + * + * 0: allow hypervisor to choose based on the value of FIP/FDP + * (default if CPU does not have FPCSDS). + * + * If FPCSDS (bit 13 in CPUID leaf 0x7, subleaf 0x0) is set, the CPU + * never saves FCS/FDS and this parameter should be left at the + * default of 8. + */ +#define HVM_PARAM_X87_FIP_WIDTH 36 + +/* + * TSS (and its size) used on Intel when CR0.PE=0. The address occupies + * the low 32 bits, while the size is in the high 32 ones. + */ +#define HVM_PARAM_VM86_TSS_SIZED 37 + +/* Enable MCA capabilities. */ +#define HVM_PARAM_MCA_CAP 38 +#define XEN_HVM_MCA_CAP_LMCE (xen_mk_ullong(1) << 0) +#define XEN_HVM_MCA_CAP_MASK XEN_HVM_MCA_CAP_LMCE + +#define HVM_NR_PARAMS 39 + +#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ diff --git a/include/xen/hvm/start_info.h b/include/xen/hvm/start_info.h new file mode 100644 index 000000000..648415976 --- /dev/null +++ b/include/xen/hvm/start_info.h @@ -0,0 +1,98 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2016, Citrix Systems, Inc. + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ +#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ + +/* + * Start of day structure passed to PVH guests and to HVM guests in %ebx. + * + * NOTE: nothing will be loaded at physical address 0, so a 0 value in any + * of the address fields should be treated as not present. + * + * 0 +----------------+ + * | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE + * | | ("xEn3" with the 0x80 bit of the "E" set). + * 4 +----------------+ + * | version | Version of this structure. Current version is 0. New + * | | versions are guaranteed to be backwards-compatible. + * 8 +----------------+ + * | flags | SIF_xxx flags. + * 12 +----------------+ + * | nr_modules | Number of modules passed to the kernel. + * 16 +----------------+ + * | modlist_paddr | Physical address of an array of modules + * | | (layout of the structure below). + * 24 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 32 +----------------+ + * | rsdp_paddr | Physical address of the RSDP ACPI data structure. + * 40 +----------------+ + * + * The layout of each entry in the module structure is the following: + * + * 0 +----------------+ + * | paddr | Physical address of the module. + * 8 +----------------+ + * | size | Size of the module in bytes. + * 16 +----------------+ + * | cmdline_paddr | Physical address of the command line, + * | | a zero-terminated ASCII string. + * 24 +----------------+ + * | reserved | + * 32 +----------------+ + * + * The address and sizes are always a 64bit little endian unsigned integer. + * + * NB: Xen on x86 will always try to place all the data below the 4GiB + * boundary. + */ +#define XEN_HVM_START_MAGIC_VALUE 0x336ec578 + +/* + * C representation of the x86/HVM start info layout. + * + * The canonical definition of this layout is above, this is just a way to + * represent the layout described there using C types. + */ +struct hvm_start_info { + uint32_t magic; /* Contains the magic value 0x336ec578 */ + /* ("xEn3" with the 0x80 bit of the "E" set).*/ + uint32_t version; /* Version of this structure. */ + uint32_t flags; /* SIF_xxx flags. */ + uint32_t nr_modules; /* Number of modules passed to the kernel. */ + uint64_t modlist_paddr; /* Physical address of an array of */ + /* hvm_modlist_entry. */ + uint64_t cmdline_paddr; /* Physical address of the command line. */ + uint64_t rsdp_paddr; /* Physical address of the RSDP ACPI data */ + /* structure. */ +}; + +struct hvm_modlist_entry { + uint64_t paddr; /* Physical address of the module. */ + uint64_t size; /* Size of the module in bytes. */ + uint64_t cmdline_paddr; /* Physical address of the command line. */ + uint64_t reserved; +}; + +#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */ diff --git a/include/xen/memory.h b/include/xen/memory.h new file mode 100644 index 000000000..20deef5cb --- /dev/null +++ b/include/xen/memory.h @@ -0,0 +1,665 @@ +/****************************************************************************** + * memory.h + * + * Memory reservation and information. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2005, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_MEMORY_H__ +#define __XEN_PUBLIC_MEMORY_H__ + +#include "xen.h" +#include "physdev.h" + +/* + * Increase or decrease the specified domain's memory reservation. Returns the + * number of extents successfully allocated or freed. + * arg == addr of struct xen_memory_reservation. + */ +#define XENMEM_increase_reservation 0 +#define XENMEM_decrease_reservation 1 +#define XENMEM_populate_physmap 6 + +#if __XEN_INTERFACE_VERSION__ >= 0x00030209 +/* + * Maximum # bits addressable by the user of the allocated region (e.g., I/O + * devices often have a 32-bit limitation even in 64-bit systems). If zero + * then the user has no addressing restriction. This field is not used by + * XENMEM_decrease_reservation. + */ +#define XENMEMF_address_bits(x) (x) +#define XENMEMF_get_address_bits(x) ((x) & 0xffu) +/* NUMA node to allocate from. */ +#define XENMEMF_node(x) (((x) + 1) << 8) +#define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu) +/* Flag to populate physmap with populate-on-demand entries */ +#define XENMEMF_populate_on_demand (1<<16) +/* Flag to request allocation only from the node specified */ +#define XENMEMF_exact_node_request (1<<17) +#define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request) +/* Flag to indicate the node specified is virtual node */ +#define XENMEMF_vnode (1<<18) +#endif + +struct xen_memory_reservation { + + /* + * XENMEM_increase_reservation: + * OUT: MFN (*not* GMFN) bases of extents that were allocated + * XENMEM_decrease_reservation: + * IN: GMFN bases of extents to free + * XENMEM_populate_physmap: + * IN: GPFN bases of extents to populate with memory + * OUT: GMFN bases of extents that were allocated + * (NB. This command also updates the mach_to_phys translation table) + * XENMEM_claim_pages: + * IN: must be zero + */ + XEN_GUEST_HANDLE(xen_pfn_t) extent_start; + + /* Number of extents, and size/alignment of each (2^extent_order pages). */ + xen_ulong_t nr_extents; + unsigned int extent_order; + +#if __XEN_INTERFACE_VERSION__ >= 0x00030209 + /* XENMEMF flags. */ + unsigned int mem_flags; +#else + unsigned int address_bits; +#endif + + /* + * Domain whose reservation is being changed. + * Unprivileged domains can specify only DOMID_SELF. + */ + domid_t domid; +}; +typedef struct xen_memory_reservation xen_memory_reservation_t; +DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t); + +/* + * An atomic exchange of memory pages. If return code is zero then + * @out.extent_list provides GMFNs of the newly-allocated memory. + * Returns zero on complete success, otherwise a negative error code. + * On complete success then always @nr_exchanged == @in.nr_extents. + * On partial success @nr_exchanged indicates how much work was done. + * + * Note that only PV guests can use this operation. + */ +#define XENMEM_exchange 11 +struct xen_memory_exchange { + /* + * [IN] Details of memory extents to be exchanged (GMFN bases). + * Note that @in.address_bits is ignored and unused. + */ + struct xen_memory_reservation in; + + /* + * [IN/OUT] Details of new memory extents. + * We require that: + * 1. @in.domid == @out.domid + * 2. @in.nr_extents << @in.extent_order == + * @out.nr_extents << @out.extent_order + * 3. @in.extent_start and @out.extent_start lists must not overlap + * 4. @out.extent_start lists GPFN bases to be populated + * 5. @out.extent_start is overwritten with allocated GMFN bases + */ + struct xen_memory_reservation out; + + /* + * [OUT] Number of input extents that were successfully exchanged: + * 1. The first @nr_exchanged input extents were successfully + * deallocated. + * 2. The corresponding first entries in the output extent list correctly + * indicate the GMFNs that were successfully exchanged. + * 3. All other input and output extents are untouched. + * 4. If not all input exents are exchanged then the return code of this + * command will be non-zero. + * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER! + */ + xen_ulong_t nr_exchanged; +}; +typedef struct xen_memory_exchange xen_memory_exchange_t; +DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t); + +/* + * Returns the maximum machine frame number of mapped RAM in this system. + * This command always succeeds (it never returns an error code). + * arg == NULL. + */ +#define XENMEM_maximum_ram_page 2 + +/* + * Returns the current or maximum memory reservation, in pages, of the + * specified domain (may be DOMID_SELF). Returns -ve errcode on failure. + * arg == addr of domid_t. + */ +#define XENMEM_current_reservation 3 +#define XENMEM_maximum_reservation 4 + +/* + * Returns the maximum GPFN in use by the guest, or -ve errcode on failure. + */ +#define XENMEM_maximum_gpfn 14 + +/* + * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys + * mapping table. Architectures which do not have a m2p table do not implement + * this command. + * arg == addr of xen_machphys_mfn_list_t. + */ +#define XENMEM_machphys_mfn_list 5 +struct xen_machphys_mfn_list { + /* + * Size of the 'extent_start' array. Fewer entries will be filled if the + * machphys table is smaller than max_extents * 2MB. + */ + unsigned int max_extents; + + /* + * Pointer to buffer to fill with list of extent starts. If there are + * any large discontiguities in the machine address space, 2MB gaps in + * the machphys table will be represented by an MFN base of zero. + */ + XEN_GUEST_HANDLE(xen_pfn_t) extent_start; + + /* + * Number of extents written to the above array. This will be smaller + * than 'max_extents' if the machphys table is smaller than max_e * 2MB. + */ + unsigned int nr_extents; +}; +typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t; +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t); + +/* + * For a compat caller, this is identical to XENMEM_machphys_mfn_list. + * + * For a non compat caller, this functions similarly to + * XENMEM_machphys_mfn_list, but returns the mfns making up the compatibility + * m2p table. + */ +#define XENMEM_machphys_compat_mfn_list 25 + +/* + * Returns the location in virtual address space of the machine_to_phys + * mapping table. Architectures which do not have a m2p table, or which do not + * map it by default into guest address space, do not implement this command. + * arg == addr of xen_machphys_mapping_t. + */ +#define XENMEM_machphys_mapping 12 +struct xen_machphys_mapping { + xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */ + xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */ +}; +typedef struct xen_machphys_mapping xen_machphys_mapping_t; +DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t); + +/* Source mapping space. */ +/* ` enum phys_map_space { */ +#define XENMAPSPACE_shared_info 0 /* shared info page */ +#define XENMAPSPACE_grant_table 1 /* grant table page */ +#define XENMAPSPACE_gmfn 2 /* GMFN */ +#define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. */ +#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom, + * XENMEM_add_to_physmap_batch only. */ +#define XENMAPSPACE_dev_mmio 5 /* device mmio region + ARM only; the region is mapped in + Stage-2 using the Normal Memory + Inner/Outer Write-Back Cacheable + memory attribute. */ +/* ` } */ + +/* + * Sets the GPFN at which a particular page appears in the specified guest's + * pseudophysical address space. + * arg == addr of xen_add_to_physmap_t. + */ +#define XENMEM_add_to_physmap 7 +struct xen_add_to_physmap { + /* Which domain to change the mapping for. */ + domid_t domid; + + /* Number of pages to go through for gmfn_range */ + uint16_t size; + + unsigned int space; /* => enum phys_map_space */ + +#define XENMAPIDX_grant_table_status 0x80000000 + + /* Index into space being mapped. */ + xen_ulong_t idx; + + /* GPFN in domid where the source mapping page should appear. */ + xen_pfn_t gpfn; +}; +typedef struct xen_add_to_physmap xen_add_to_physmap_t; +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t); + +/* A batched version of add_to_physmap. */ +#define XENMEM_add_to_physmap_batch 23 +struct xen_add_to_physmap_batch { + /* IN */ + /* Which domain to change the mapping for. */ + domid_t domid; + uint16_t space; /* => enum phys_map_space */ + + /* Number of pages to go through */ + uint16_t size; + +#if __XEN_INTERFACE_VERSION__ < 0x00040700 + domid_t foreign_domid; /* IFF gmfn_foreign. Should be 0 for other spaces. */ +#else + union xen_add_to_physmap_batch_extra { + domid_t foreign_domid; /* gmfn_foreign */ + uint16_t res0; /* All the other spaces. Should be 0 */ + } u; +#endif + + /* Indexes into space being mapped. */ + XEN_GUEST_HANDLE(xen_ulong_t) idxs; + + /* GPFN in domid where the source mapping page should appear. */ + XEN_GUEST_HANDLE(xen_pfn_t) gpfns; + + /* OUT */ + + /* Per index error code. */ + XEN_GUEST_HANDLE(int) errs; +}; +typedef struct xen_add_to_physmap_batch xen_add_to_physmap_batch_t; +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_batch_t); + +#if __XEN_INTERFACE_VERSION__ < 0x00040400 +#define XENMEM_add_to_physmap_range XENMEM_add_to_physmap_batch +#define xen_add_to_physmap_range xen_add_to_physmap_batch +typedef struct xen_add_to_physmap_batch xen_add_to_physmap_range_t; +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_range_t); +#endif + +/* + * Unmaps the page appearing at a particular GPFN from the specified guest's + * pseudophysical address space. + * arg == addr of xen_remove_from_physmap_t. + */ +#define XENMEM_remove_from_physmap 15 +struct xen_remove_from_physmap { + /* Which domain to change the mapping for. */ + domid_t domid; + + /* GPFN of the current mapping of the page. */ + xen_pfn_t gpfn; +}; +typedef struct xen_remove_from_physmap xen_remove_from_physmap_t; +DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t); + +/*** REMOVED ***/ +/*#define XENMEM_translate_gpfn_list 8*/ + +/* + * Returns the pseudo-physical memory map as it was when the domain + * was started (specified by XENMEM_set_memory_map). + * arg == addr of xen_memory_map_t. + */ +#define XENMEM_memory_map 9 +struct xen_memory_map { + /* + * On call the number of entries which can be stored in buffer. On + * return the number of entries which have been stored in + * buffer. + */ + unsigned int nr_entries; + + /* + * Entries in the buffer are in the same format as returned by the + * BIOS INT 0x15 EAX=0xE820 call. + */ + XEN_GUEST_HANDLE(void) buffer; +}; +typedef struct xen_memory_map xen_memory_map_t; +DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t); + +/* + * Returns the real physical memory map. Passes the same structure as + * XENMEM_memory_map. + * Specifying buffer as NULL will return the number of entries required + * to store the complete memory map. + * arg == addr of xen_memory_map_t. + */ +#define XENMEM_machine_memory_map 10 + +/* + * Set the pseudo-physical memory map of a domain, as returned by + * XENMEM_memory_map. + * arg == addr of xen_foreign_memory_map_t. + */ +#define XENMEM_set_memory_map 13 +struct xen_foreign_memory_map { + domid_t domid; + struct xen_memory_map map; +}; +typedef struct xen_foreign_memory_map xen_foreign_memory_map_t; +DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t); + +#define XENMEM_set_pod_target 16 +#define XENMEM_get_pod_target 17 +struct xen_pod_target { + /* IN */ + uint64_t target_pages; + /* OUT */ + uint64_t tot_pages; + uint64_t pod_cache_pages; + uint64_t pod_entries; + /* IN */ + domid_t domid; +}; +typedef struct xen_pod_target xen_pod_target_t; + +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +#ifndef uint64_aligned_t +#define uint64_aligned_t uint64_t +#endif + +/* + * Get the number of MFNs saved through memory sharing. + * The call never fails. + */ +#define XENMEM_get_sharing_freed_pages 18 +#define XENMEM_get_sharing_shared_pages 19 + +#define XENMEM_paging_op 20 +#define XENMEM_paging_op_nominate 0 +#define XENMEM_paging_op_evict 1 +#define XENMEM_paging_op_prep 2 + +struct xen_mem_paging_op { + uint8_t op; /* XENMEM_paging_op_* */ + domid_t domain; + + /* PAGING_PREP IN: buffer to immediately fill page in */ + uint64_aligned_t buffer; + /* Other OPs */ + uint64_aligned_t gfn; /* IN: gfn of page being operated on */ +}; +typedef struct xen_mem_paging_op xen_mem_paging_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_mem_paging_op_t); + +#define XENMEM_access_op 21 +#define XENMEM_access_op_set_access 0 +#define XENMEM_access_op_get_access 1 +/* + * XENMEM_access_op_enable_emulate and XENMEM_access_op_disable_emulate are + * currently unused, but since they have been in use please do not reuse them. + * + * #define XENMEM_access_op_enable_emulate 2 + * #define XENMEM_access_op_disable_emulate 3 + */ +#define XENMEM_access_op_set_access_multi 4 + +typedef enum { + XENMEM_access_n, + XENMEM_access_r, + XENMEM_access_w, + XENMEM_access_rw, + XENMEM_access_x, + XENMEM_access_rx, + XENMEM_access_wx, + XENMEM_access_rwx, + /* + * Page starts off as r-x, but automatically + * change to r-w on a write + */ + XENMEM_access_rx2rw, + /* + * Log access: starts off as n, automatically + * goes to rwx, generating an event without + * pausing the vcpu + */ + XENMEM_access_n2rwx, + /* Take the domain default */ + XENMEM_access_default +} xenmem_access_t; + +struct xen_mem_access_op { + /* XENMEM_access_op_* */ + uint8_t op; + /* xenmem_access_t */ + uint8_t access; + domid_t domid; + /* + * Number of pages for set op (or size of pfn_list for + * XENMEM_access_op_set_access_multi) + * Ignored on setting default access and other ops + */ + uint32_t nr; + /* + * First pfn for set op + * pfn for get op + * ~0ull is used to set and get the default access for pages + */ + uint64_aligned_t pfn; + /* + * List of pfns to set access for + * Used only with XENMEM_access_op_set_access_multi + */ + XEN_GUEST_HANDLE(const_uint64) pfn_list; + /* + * Corresponding list of access settings for pfn_list + * Used only with XENMEM_access_op_set_access_multi + */ + XEN_GUEST_HANDLE(const_uint8) access_list; +}; +typedef struct xen_mem_access_op xen_mem_access_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_mem_access_op_t); + +#define XENMEM_sharing_op 22 +#define XENMEM_sharing_op_nominate_gfn 0 +#define XENMEM_sharing_op_nominate_gref 1 +#define XENMEM_sharing_op_share 2 +#define XENMEM_sharing_op_debug_gfn 3 +#define XENMEM_sharing_op_debug_mfn 4 +#define XENMEM_sharing_op_debug_gref 5 +#define XENMEM_sharing_op_add_physmap 6 +#define XENMEM_sharing_op_audit 7 +#define XENMEM_sharing_op_range_share 8 + +#define XENMEM_SHARING_OP_S_HANDLE_INVALID (-10) +#define XENMEM_SHARING_OP_C_HANDLE_INVALID (-9) + +/* The following allows sharing of grant refs. This is useful + * for sharing utilities sitting as "filters" in IO backends + * (e.g. memshr + blktap(2)). The IO backend is only exposed + * to grant references, and this allows sharing of the grefs */ +#define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62) + +#define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \ + (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val) +#define XENMEM_SHARING_OP_FIELD_IS_GREF(field) \ + ((field) & XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG) +#define XENMEM_SHARING_OP_FIELD_GET_GREF(field) \ + ((field) & (~XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG)) + +struct xen_mem_sharing_op { + uint8_t op; /* XENMEM_sharing_op_* */ + domid_t domain; + + union { + struct mem_sharing_op_nominate { /* OP_NOMINATE_xxx */ + union { + uint64_aligned_t gfn; /* IN: gfn to nominate */ + uint32_t grant_ref; /* IN: grant ref to nominate */ + } u; + uint64_aligned_t handle; /* OUT: the handle */ + } nominate; + struct mem_sharing_op_share { /* OP_SHARE/ADD_PHYSMAP */ + uint64_aligned_t source_gfn; /* IN: the gfn of the source page */ + uint64_aligned_t source_handle; /* IN: handle to the source page */ + uint64_aligned_t client_gfn; /* IN: the client gfn */ + uint64_aligned_t client_handle; /* IN: handle to the client page */ + domid_t client_domain; /* IN: the client domain id */ + } share; + struct mem_sharing_op_range { /* OP_RANGE_SHARE */ + uint64_aligned_t first_gfn; /* IN: the first gfn */ + uint64_aligned_t last_gfn; /* IN: the last gfn */ + uint64_aligned_t opaque; /* Must be set to 0 */ + domid_t client_domain; /* IN: the client domain id */ + uint16_t _pad[3]; /* Must be set to 0 */ + } range; + struct mem_sharing_op_debug { /* OP_DEBUG_xxx */ + union { + uint64_aligned_t gfn; /* IN: gfn to debug */ + uint64_aligned_t mfn; /* IN: mfn to debug */ + uint32_t gref; /* IN: gref to debug */ + } u; + } debug; + } u; +}; +typedef struct xen_mem_sharing_op xen_mem_sharing_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t); + +/* + * Attempt to stake a claim for a domain on a quantity of pages + * of system RAM, but _not_ assign specific pageframes. Only + * arithmetic is performed so the hypercall is very fast and need + * not be preemptible, thus sidestepping time-of-check-time-of-use + * races for memory allocation. Returns 0 if the hypervisor page + * allocator has atomically and successfully claimed the requested + * number of pages, else non-zero. + * + * Any domain may have only one active claim. When sufficient memory + * has been allocated to resolve the claim, the claim silently expires. + * Claiming zero pages effectively resets any outstanding claim and + * is always successful. + * + * Note that a valid claim may be staked even after memory has been + * allocated for a domain. In this case, the claim is not incremental, + * i.e. if the domain's tot_pages is 3, and a claim is staked for 10, + * only 7 additional pages are claimed. + * + * Caller must be privileged or the hypercall fails. + */ +#define XENMEM_claim_pages 24 + +/* + * XENMEM_claim_pages flags - the are no flags at this time. + * The zero value is appropriate. + */ + +/* + * With some legacy devices, certain guest-physical addresses cannot safely + * be used for other purposes, e.g. to map guest RAM. This hypercall + * enumerates those regions so the toolstack can avoid using them. + */ +#define XENMEM_reserved_device_memory_map 27 +struct xen_reserved_device_memory { + xen_pfn_t start_pfn; + xen_ulong_t nr_pages; +}; +typedef struct xen_reserved_device_memory xen_reserved_device_memory_t; +DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_t); + +struct xen_reserved_device_memory_map { +#define XENMEM_RDM_ALL 1 /* Request all regions (ignore dev union). */ + /* IN */ + uint32_t flags; + /* + * IN/OUT + * + * Gets set to the required number of entries when too low, + * signaled by error code -ERANGE. + */ + unsigned int nr_entries; + /* OUT */ + XEN_GUEST_HANDLE(xen_reserved_device_memory_t) buffer; + /* IN */ + union { + struct physdev_pci_device pci; + } dev; +}; +typedef struct xen_reserved_device_memory_map xen_reserved_device_memory_map_t; +DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_map_t); + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +/* + * XENMEM_get_vnumainfo used by guest to get + * vNUMA topology from hypervisor. + */ +#define XENMEM_get_vnumainfo 26 + +/* vNUMA node memory ranges */ +struct xen_vmemrange { + uint64_t start, end; + unsigned int flags; + unsigned int nid; +}; +typedef struct xen_vmemrange xen_vmemrange_t; +DEFINE_XEN_GUEST_HANDLE(xen_vmemrange_t); + +/* + * vNUMA topology specifies vNUMA node number, distance table, + * memory ranges and vcpu mapping provided for guests. + * XENMEM_get_vnumainfo hypercall expects to see from guest + * nr_vnodes, nr_vmemranges and nr_vcpus to indicate available memory. + * After filling guests structures, nr_vnodes, nr_vmemranges and nr_vcpus + * copied back to guest. Domain returns expected values of nr_vnodes, + * nr_vmemranges and nr_vcpus to guest if the values where incorrect. + */ +struct xen_vnuma_topology_info { + /* IN */ + domid_t domid; + uint16_t pad; + /* IN/OUT */ + unsigned int nr_vnodes; + unsigned int nr_vcpus; + unsigned int nr_vmemranges; + /* OUT */ + union { + XEN_GUEST_HANDLE(uint) h; + uint64_t pad; + } vdistance; + union { + XEN_GUEST_HANDLE(uint) h; + uint64_t pad; + } vcpu_to_vnode; + union { + XEN_GUEST_HANDLE(xen_vmemrange_t) h; + uint64_t pad; + } vmemrange; +}; +typedef struct xen_vnuma_topology_info xen_vnuma_topology_info_t; +DEFINE_XEN_GUEST_HANDLE(xen_vnuma_topology_info_t); + +/* Next available subop number is 28 */ + +#endif /* __XEN_PUBLIC_MEMORY_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/physdev.h b/include/xen/physdev.h new file mode 100644 index 000000000..b6faf8350 --- /dev/null +++ b/include/xen/physdev.h @@ -0,0 +1,387 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2006, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_PHYSDEV_H__ +#define __XEN_PUBLIC_PHYSDEV_H__ + +#include "xen.h" + +/* + * Prototype for this hypercall is: + * int physdev_op(int cmd, void *args) + * @cmd == PHYSDEVOP_??? (physdev operation). + * @args == Operation-specific extra arguments (NULL if none). + */ + +/* + * Notify end-of-interrupt (EOI) for the specified IRQ. + * @arg == pointer to physdev_eoi structure. + */ +#define PHYSDEVOP_eoi 12 +struct physdev_eoi { + /* IN */ + uint32_t irq; +}; +typedef struct physdev_eoi physdev_eoi_t; +DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); + +/* + * Register a shared page for the hypervisor to indicate whether the guest + * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly + * once the guest used this function in that the associated event channel + * will automatically get unmasked. The page registered is used as a bit + * array indexed by Xen's PIRQ value. + */ +#define PHYSDEVOP_pirq_eoi_gmfn_v1 17 +/* + * Register a shared page for the hypervisor to indicate whether the + * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to + * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of + * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by + * Xen's PIRQ value. + */ +#define PHYSDEVOP_pirq_eoi_gmfn_v2 28 +struct physdev_pirq_eoi_gmfn { + /* IN */ + xen_pfn_t gmfn; +}; +typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t; +DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t); + +/* + * Query the status of an IRQ line. + * @arg == pointer to physdev_irq_status_query structure. + */ +#define PHYSDEVOP_irq_status_query 5 +struct physdev_irq_status_query { + /* IN */ + uint32_t irq; + /* OUT */ + uint32_t flags; /* XENIRQSTAT_* */ +}; +typedef struct physdev_irq_status_query physdev_irq_status_query_t; +DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t); + +/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ +#define _XENIRQSTAT_needs_eoi (0) +#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi) + +/* IRQ shared by multiple guests? */ +#define _XENIRQSTAT_shared (1) +#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared) + +/* + * Set the current VCPU's I/O privilege level. + * @arg == pointer to physdev_set_iopl structure. + */ +#define PHYSDEVOP_set_iopl 6 +struct physdev_set_iopl { + /* IN */ + uint32_t iopl; +}; +typedef struct physdev_set_iopl physdev_set_iopl_t; +DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t); + +/* + * Set the current VCPU's I/O-port permissions bitmap. + * @arg == pointer to physdev_set_iobitmap structure. + */ +#define PHYSDEVOP_set_iobitmap 7 +struct physdev_set_iobitmap { + /* IN */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030205 + XEN_GUEST_HANDLE(uint8) bitmap; +#else + uint8_t *bitmap; +#endif + uint32_t nr_ports; +}; +typedef struct physdev_set_iobitmap physdev_set_iobitmap_t; +DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t); + +/* + * Read or write an IO-APIC register. + * @arg == pointer to physdev_apic structure. + */ +#define PHYSDEVOP_apic_read 8 +#define PHYSDEVOP_apic_write 9 +struct physdev_apic { + /* IN */ + unsigned long apic_physbase; + uint32_t reg; + /* IN or OUT */ + uint32_t value; +}; +typedef struct physdev_apic physdev_apic_t; +DEFINE_XEN_GUEST_HANDLE(physdev_apic_t); + +/* + * Allocate or free a physical upcall vector for the specified IRQ line. + * @arg == pointer to physdev_irq structure. + */ +#define PHYSDEVOP_alloc_irq_vector 10 +#define PHYSDEVOP_free_irq_vector 11 +struct physdev_irq { + /* IN */ + uint32_t irq; + /* IN or OUT */ + uint32_t vector; +}; +typedef struct physdev_irq physdev_irq_t; +DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); + +#define MAP_PIRQ_TYPE_MSI 0x0 +#define MAP_PIRQ_TYPE_GSI 0x1 +#define MAP_PIRQ_TYPE_UNKNOWN 0x2 +#define MAP_PIRQ_TYPE_MSI_SEG 0x3 +#define MAP_PIRQ_TYPE_MULTI_MSI 0x4 + +#define PHYSDEVOP_map_pirq 13 +struct physdev_map_pirq { + domid_t domid; + /* IN */ + int type; + /* IN (ignored for ..._MULTI_MSI) */ + int index; + /* IN or OUT */ + int pirq; + /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */ + int bus; + /* IN */ + int devfn; + /* IN (also OUT for ..._MULTI_MSI) */ + int entry_nr; + /* IN */ + uint64_t table_base; +}; +typedef struct physdev_map_pirq physdev_map_pirq_t; +DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t); + +#define PHYSDEVOP_unmap_pirq 14 +struct physdev_unmap_pirq { + domid_t domid; + /* IN */ + int pirq; +}; + +typedef struct physdev_unmap_pirq physdev_unmap_pirq_t; +DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t); + +#define PHYSDEVOP_manage_pci_add 15 +#define PHYSDEVOP_manage_pci_remove 16 +struct physdev_manage_pci { + /* IN */ + uint8_t bus; + uint8_t devfn; +}; + +typedef struct physdev_manage_pci physdev_manage_pci_t; +DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); + +#define PHYSDEVOP_restore_msi 19 +struct physdev_restore_msi { + /* IN */ + uint8_t bus; + uint8_t devfn; +}; +typedef struct physdev_restore_msi physdev_restore_msi_t; +DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t); + +#define PHYSDEVOP_manage_pci_add_ext 20 +struct physdev_manage_pci_ext { + /* IN */ + uint8_t bus; + uint8_t devfn; + unsigned is_extfn; + unsigned is_virtfn; + struct { + uint8_t bus; + uint8_t devfn; + } physfn; +}; + +typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t; +DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t); + +/* + * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() + * hypercall since 0x00030202. + */ +struct physdev_op { + uint32_t cmd; + union { + struct physdev_irq_status_query irq_status_query; + struct physdev_set_iopl set_iopl; + struct physdev_set_iobitmap set_iobitmap; + struct physdev_apic apic_op; + struct physdev_irq irq_op; + } u; +}; +typedef struct physdev_op physdev_op_t; +DEFINE_XEN_GUEST_HANDLE(physdev_op_t); + +#define PHYSDEVOP_setup_gsi 21 +struct physdev_setup_gsi { + int gsi; + /* IN */ + uint8_t triggering; + /* IN */ + uint8_t polarity; + /* IN */ +}; + +typedef struct physdev_setup_gsi physdev_setup_gsi_t; +DEFINE_XEN_GUEST_HANDLE(physdev_setup_gsi_t); + +/* leave PHYSDEVOP 22 free */ + +/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI + * the hypercall returns a free pirq */ +#define PHYSDEVOP_get_free_pirq 23 +struct physdev_get_free_pirq { + /* IN */ + int type; + /* OUT */ + uint32_t pirq; +}; + +typedef struct physdev_get_free_pirq physdev_get_free_pirq_t; +DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t); + +#define XEN_PCI_MMCFG_RESERVED 0x1 + +#define PHYSDEVOP_pci_mmcfg_reserved 24 +struct physdev_pci_mmcfg_reserved { + uint64_t address; + uint16_t segment; + uint8_t start_bus; + uint8_t end_bus; + uint32_t flags; +}; +typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t; +DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t); + +#define XEN_PCI_DEV_EXTFN 0x1 +#define XEN_PCI_DEV_VIRTFN 0x2 +#define XEN_PCI_DEV_PXM 0x4 + +#define PHYSDEVOP_pci_device_add 25 +struct physdev_pci_device_add { + /* IN */ + uint16_t seg; + uint8_t bus; + uint8_t devfn; + uint32_t flags; + struct { + uint8_t bus; + uint8_t devfn; + } physfn; + /* + * Optional parameters array. + * First element ([0]) is PXM domain associated with the device (if + * XEN_PCI_DEV_PXM is set) + */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + uint32_t optarr[]; +#elif defined(__GNUC__) + uint32_t optarr[0]; +#endif +}; +typedef struct physdev_pci_device_add physdev_pci_device_add_t; +DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t); + +#define PHYSDEVOP_pci_device_remove 26 +#define PHYSDEVOP_restore_msi_ext 27 +/* + * Dom0 should use these two to announce MMIO resources assigned to + * MSI-X capable devices won't (prepare) or may (release) change. + */ +#define PHYSDEVOP_prepare_msix 30 +#define PHYSDEVOP_release_msix 31 +struct physdev_pci_device { + /* IN */ + uint16_t seg; + uint8_t bus; + uint8_t devfn; +}; +typedef struct physdev_pci_device physdev_pci_device_t; +DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t); + +#define PHYSDEVOP_DBGP_RESET_PREPARE 1 +#define PHYSDEVOP_DBGP_RESET_DONE 2 + +#define PHYSDEVOP_DBGP_BUS_UNKNOWN 0 +#define PHYSDEVOP_DBGP_BUS_PCI 1 + +#define PHYSDEVOP_dbgp_op 29 +struct physdev_dbgp_op { + /* IN */ + uint8_t op; + uint8_t bus; + union { + struct physdev_pci_device pci; + } u; +}; +typedef struct physdev_dbgp_op physdev_dbgp_op_t; +DEFINE_XEN_GUEST_HANDLE(physdev_dbgp_op_t); + +/* + * Notify that some PIRQ-bound event channels have been unmasked. + * ** This command is obsolete since interface version 0x00030202 and is ** + * ** unsupported by newer versions of Xen. ** + */ +#define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4 + +#if __XEN_INTERFACE_VERSION__ < 0x00040600 +/* + * These all-capitals physdev operation names are superceded by the new names + * (defined above) since interface version 0x00030202. The guard above was + * added post-4.5 only though and hence shouldn't check for 0x00030202. + */ +#define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query +#define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl +#define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap +#define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read +#define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write +#define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector +#define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector +#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi +#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared +#endif + +#if __XEN_INTERFACE_VERSION__ < 0x00040200 +#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1 +#else +#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2 +#endif + +#endif /* __XEN_PUBLIC_PHYSDEV_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/trace.h b/include/xen/trace.h new file mode 100644 index 000000000..a00c01733 --- /dev/null +++ b/include/xen/trace.h @@ -0,0 +1,339 @@ +/****************************************************************************** + * include/public/trace.h + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Mark Williamson, (C) 2004 Intel Research Cambridge + * Copyright (C) 2005 Bin Ren + */ + +#ifndef __XEN_PUBLIC_TRACE_H__ +#define __XEN_PUBLIC_TRACE_H__ + +#define TRACE_EXTRA_MAX 7 +#define TRACE_EXTRA_SHIFT 28 + +/* Trace classes */ +#define TRC_CLS_SHIFT 16 +#define TRC_GEN 0x0001f000 /* General trace */ +#define TRC_SCHED 0x0002f000 /* Xen Scheduler trace */ +#define TRC_DOM0OP 0x0004f000 /* Xen DOM0 operation trace */ +#define TRC_HVM 0x0008f000 /* Xen HVM trace */ +#define TRC_MEM 0x0010f000 /* Xen memory trace */ +#define TRC_PV 0x0020f000 /* Xen PV traces */ +#define TRC_SHADOW 0x0040f000 /* Xen shadow tracing */ +#define TRC_HW 0x0080f000 /* Xen hardware-related traces */ +#define TRC_GUEST 0x0800f000 /* Guest-generated traces */ +#define TRC_ALL 0x0ffff000 +#define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff) +#define TRC_HD_CYCLE_FLAG (1UL<<31) +#define TRC_HD_INCLUDES_CYCLE_COUNT(x) ( !!( (x) & TRC_HD_CYCLE_FLAG ) ) +#define TRC_HD_EXTRA(x) (((x)>>TRACE_EXTRA_SHIFT)&TRACE_EXTRA_MAX) + +/* Trace subclasses */ +#define TRC_SUBCLS_SHIFT 12 + +/* trace subclasses for SVM */ +#define TRC_HVM_ENTRYEXIT 0x00081000 /* VMENTRY and #VMEXIT */ +#define TRC_HVM_HANDLER 0x00082000 /* various HVM handlers */ +#define TRC_HVM_EMUL 0x00084000 /* emulated devices */ + +#define TRC_SCHED_MIN 0x00021000 /* Just runstate changes */ +#define TRC_SCHED_CLASS 0x00022000 /* Scheduler-specific */ +#define TRC_SCHED_VERBOSE 0x00028000 /* More inclusive scheduling */ + +/* + * The highest 3 bits of the last 12 bits of TRC_SCHED_CLASS above are + * reserved for encoding what scheduler produced the information. The + * actual event is encoded in the last 9 bits. + * + * This means we have 8 scheduling IDs available (which means at most 8 + * schedulers generating events) and, in each scheduler, up to 512 + * different events. + */ +#define TRC_SCHED_ID_BITS 3 +#define TRC_SCHED_ID_SHIFT (TRC_SUBCLS_SHIFT - TRC_SCHED_ID_BITS) +#define TRC_SCHED_ID_MASK (((1UL<cpu_offset[cpu]). + */ +struct t_info { + uint16_t tbuf_size; /* Size in pages of each trace buffer */ + uint16_t mfn_offset[]; /* Offset within t_info structure of the page list per cpu */ + /* MFN lists immediately after the header */ +}; + +#endif /* __XEN_PUBLIC_TRACE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/xen.h b/include/xen/xen.h index 6c9e42b2b..308109f17 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -53,17 +53,22 @@ DEFINE_XEN_GUEST_HANDLE(uint64_t); DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); -/* Turn a plain number into a C unsigned (long) constant. */ +/* Turn a plain number into a C unsigned (long (long)) constant. */ #define __xen_mk_uint(x) x ## U #define __xen_mk_ulong(x) x ## UL +#ifndef __xen_mk_ullong +# define __xen_mk_ullong(x) x ## ULL +#endif #define xen_mk_uint(x) __xen_mk_uint(x) #define xen_mk_ulong(x) __xen_mk_ulong(x) +#define xen_mk_ullong(x) __xen_mk_ullong(x) #else /* In assembly code we cannot use C numeric constant suffixes. */ -#define xen_mk_uint(x) x -#define xen_mk_ulong(x) x +#define xen_mk_uint(x) x +#define xen_mk_ulong(x) x +#define xen_mk_ullong(x) x #endif @@ -115,6 +120,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_tmem_op 38 #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40 +#define __HYPERVISOR_dm_op 41 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 @@ -501,6 +507,21 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); /* x86/PAE guests: support PDPTs above 4GB. */ #define VMASST_TYPE_pae_extended_cr3 3 +/* + * x86 guests: Sane behaviour for virtual iopl + * - virtual iopl updated from do_iret() hypercalls. + * - virtual iopl reported in bounce frames. + * - guest kernels assumed to be level 0 for the purpose of iopl checks. + */ +#define VMASST_TYPE_architectural_iopl 4 + +/* + * All guests: activate update indicator in vcpu_runstate_info + * Enable setting the XEN_RUNSTATE_UPDATE flag in guest memory mapped + * vcpu_runstate_info during updates of the runstate information. + */ +#define VMASST_TYPE_runstate_update_flag 5 + /* * x86/64 guests: strictly hide M2P from user mode. * This allows the guest to control respective hypervisor behavior: @@ -529,16 +550,21 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); * is useful to ensure that no mappings to the OS's own heap are accidentally * installed. (e.g., in Linux this could cause havoc as reference counts * aren't adjusted on the I/O-mapping code path). - * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can - * be specified by any calling domain. + * This only makes sense as HYPERVISOR_mmu_update()'s and + * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument. For + * HYPERVISOR_mmu_update() context it can be specified by any calling domain, + * otherwise it's only permitted if the caller is privileged. */ #define DOMID_IO xen_mk_uint(0x7FF1) /* * DOMID_XEN is used to allow privileged domains to map restricted parts of * Xen's heap space (e.g., the machine_to_phys table). - * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if - * the caller is privileged. + * This only makes sense as + * - HYPERVISOR_mmu_update()'s, HYPERVISOR_mmuext_op()'s, or + * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument, + * - with XENMAPSPACE_gmfn_foreign, + * and is only permitted if the caller is privileged. */ #define DOMID_XEN xen_mk_uint(0x7FF2) @@ -614,10 +640,18 @@ struct vcpu_time_info { */ uint32_t tsc_to_system_mul; int8_t tsc_shift; +#if __XEN_INTERFACE_VERSION__ > 0x040600 + uint8_t flags; + uint8_t pad1[2]; +#else int8_t pad1[3]; +#endif }; /* 32 bytes */ typedef struct vcpu_time_info vcpu_time_info_t; +#define XEN_PVCLOCK_TSC_STABLE_BIT (1 << 0) +#define XEN_PVCLOCK_GUEST_STOPPED (1 << 1) + struct vcpu_info { /* * 'evtchn_upcall_pending' is written non-zero by Xen to indicate @@ -736,7 +770,7 @@ typedef struct shared_info shared_info_t; * (may be omitted) * c. list of allocated page frames [mfn_list, nr_pages] * (unless relocated due to XEN_ELFNOTE_INIT_P2M) - * d. start_info_t structure [register ESI (x86)] + * d. start_info_t structure [register rSI (x86)] * in case of dom0 this page contains the console info, too * e. unless dom0: xenstore ring page * f. unless dom0: console ring page @@ -797,29 +831,6 @@ struct start_info { }; typedef struct start_info start_info_t; -/* - * Start of day structure passed to PVH guests in %ebx. - * - * NOTE: nothing will be loaded at physical address 0, so - * a 0 value in any of the address fields should be treated - * as not present. - */ -struct hvm_start_info { -#define HVM_START_MAGIC_VALUE 0x336ec578 - uint32_t magic; /* Contains the magic value 0x336ec578 */ - /* ("xEn3" with the 0x80 bit of the "E" set).*/ - uint32_t flags; /* SIF_xxx flags. */ - uint32_t cmdline_paddr; /* Physical address of the command line. */ - uint32_t nr_modules; /* Number of modules passed to the kernel. */ - uint32_t modlist_paddr; /* Physical address of an array of */ - /* hvm_modlist_entry. */ -}; - -struct hvm_modlist_entry { - uint32_t paddr; /* Physical address of the module. */ - uint32_t size; /* Size of the module in bytes. */ -}; - /* New console union for dom0 introduced in 0x00030203. */ #if __XEN_INTERFACE_VERSION__ < 0x00030203 #define console_mfn console.domU.mfn @@ -919,6 +930,37 @@ __DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t); __DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t); __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); +typedef struct { + uint8_t a[16]; +} xen_uuid_t; + +/* + * XEN_DEFINE_UUID(0x00112233, 0x4455, 0x6677, 0x8899, + * 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff) + * will construct UUID 00112233-4455-6677-8899-aabbccddeeff presented as + * {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + * 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; + * + * NB: This is compatible with Linux kernel and with libuuid, but it is not + * compatible with Microsoft, as they use mixed-endian encoding (some + * components are little-endian, some are big-endian). + */ +#define XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6) \ + {{((a) >> 24) & 0xFF, ((a) >> 16) & 0xFF, \ + ((a) >> 8) & 0xFF, ((a) >> 0) & 0xFF, \ + ((b) >> 8) & 0xFF, ((b) >> 0) & 0xFF, \ + ((c) >> 8) & 0xFF, ((c) >> 0) & 0xFF, \ + ((d) >> 8) & 0xFF, ((d) >> 0) & 0xFF, \ + e1, e2, e3, e4, e5, e6}} + +#if defined(__STDC_VERSION__) ? __STDC_VERSION__ >= 199901L : defined(__GNUC__) +#define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \ + ((xen_uuid_t)XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6)) +#else +#define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \ + XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6) +#endif /* __STDC_VERSION__ / __GNUC__ */ + #endif /* !__ASSEMBLY__ */ /* Default definitions for macros used by domctl/sysctl. */ From d170be42f12b0b2ab91d8d943d7b0bf563c906dd Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:30 +0100 Subject: [PATCH 0883/1167] loader/linux: Support passing RSDP address via boot params Xen PVH guests will have the RSDP at an arbitrary address. Support that by passing the RSDP address via the boot parameters to Linux. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/loader/i386/linux.c | 4 ++++ include/grub/i386/linux.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index c408b10d8..375ee80dc 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -508,6 +508,10 @@ grub_linux_boot (void) } } +#ifdef GRUB_KERNEL_USE_RSDP_ADDR + linux_params.acpi_rsdp_addr = grub_le_to_cpu64 (grub_rsdp_addr); +#endif + mmap_size = find_mmap_size (); /* Make sure that each size is aligned to a page boundary. */ cl_offset = ALIGN_UP (mmap_size + sizeof (linux_params), 4096); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 60c7c3b5e..a96059311 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -210,8 +210,9 @@ struct linux_kernel_params grub_uint32_t ist_command; /* 64 */ grub_uint32_t ist_event; /* 68 */ grub_uint32_t ist_perf_level; /* 6c */ + grub_uint64_t acpi_rsdp_addr; /* 70 */ - grub_uint8_t padding5[0x80 - 0x70]; + grub_uint8_t padding5[0x80 - 0x78]; grub_uint8_t hd0_drive_info[0x10]; /* 80 */ grub_uint8_t hd1_drive_info[0x10]; /* 90 */ From c84927272cea59084ad5b0705c55547e8c85b28d Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:31 +0100 Subject: [PATCH 0884/1167] xen: Carve out grant tab initialization into dedicated function Initialize the grant tab in a dedicated function. This will enable using it for PVH guests, too. Call the new function from grub_machine_init() as this will later be common between Xen PV and Xen PVH mode. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/xen/init.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c index 0559c033c..29f5bc23d 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -318,6 +318,25 @@ grub_xenstore_dir (const char *dir, unsigned long gntframe = 0; +static void +grub_xen_setup_gnttab (void) +{ + struct gnttab_set_version gnttab_setver; + struct gnttab_setup_table gnttab_setup; + + grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); + + gnttab_setver.version = 1; + grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1); + + grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup)); + gnttab_setup.dom = DOMID_SELF; + gnttab_setup.nr_frames = 1; + gnttab_setup.frame_list.p = &gntframe; + + grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1); +} + #define MAX_N_UNUSABLE_PAGES 4 static int @@ -357,26 +376,12 @@ map_all_pages (void) (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; grub_uint64_t *pg = (grub_uint64_t *) window; grub_uint64_t oldpgstart, oldpgend; - struct gnttab_setup_table gnttab_setup; - struct gnttab_set_version gnttab_setver; grub_size_t n_unusable_pages = 0; struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES]; if (total_pages > MAX_TOTAL_PAGES - 4) total_pages = MAX_TOTAL_PAGES - 4; - grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); - - gnttab_setver.version = 1; - grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1); - - grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup)); - gnttab_setup.dom = DOMID_SELF; - gnttab_setup.nr_frames = 1; - gnttab_setup.frame_list.p = &gntframe; - - grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1); - for (j = 0; j < total_pages - n_unusable_pages; j++) while (!grub_xen_is_page_usable (mfn_list[j])) { @@ -537,6 +542,8 @@ grub_machine_init (void) + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN); + grub_xen_setup_gnttab (); + map_all_pages (); grub_console_init (); From fc9d47ead56365c3335bb42cf651008c9ac1f494 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:32 +0100 Subject: [PATCH 0885/1167] xen: Prepare common code for Xen PVH support Some common code needs to be special cased for Xen PVH mode. This hits mostly Xen PV mode specific areas. Split include/grub/i386/pc/int_types.h off from include/grub/i386/pc/int.h to support including this file later from xen_pvh code without the grub_bios_interrupt definition. Move definition of struct grub_e820_mmap_entry from grub-core/mmap/i386/pc/mmap.c to include/grub/i386/memory.h in order to make it usable from xen_pvh code. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/i386/tsc.c | 2 +- grub-core/mmap/i386/pc/mmap.c | 8 ----- include/grub/i386/memory.h | 7 ++++ include/grub/i386/pc/int.h | 36 +------------------ include/grub/i386/pc/int_types.h | 59 +++++++++++++++++++++++++++++++ include/grub/i386/tsc.h | 2 +- include/grub/i386/xen/hypercall.h | 5 ++- include/grub/kernel.h | 4 ++- 8 files changed, 76 insertions(+), 47 deletions(-) create mode 100644 include/grub/i386/pc/int_types.h diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index f266eb131..9293b161d 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -65,7 +65,7 @@ grub_tsc_init (void) tsc_boot_time = grub_get_tsc (); -#ifdef GRUB_MACHINE_XEN +#if defined (GRUB_MACHINE_XEN) || defined (GRUB_MACHINE_XEN_PVH) (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); #elif defined (GRUB_MACHINE_EFI) (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); diff --git a/grub-core/mmap/i386/pc/mmap.c b/grub-core/mmap/i386/pc/mmap.c index 609994516..6ab4f6730 100644 --- a/grub-core/mmap/i386/pc/mmap.c +++ b/grub-core/mmap/i386/pc/mmap.c @@ -42,14 +42,6 @@ extern grub_uint16_t grub_machine_mmaphook_kblow; extern grub_uint16_t grub_machine_mmaphook_kbin16mb; extern grub_uint16_t grub_machine_mmaphook_64kbin4gb; -struct grub_e820_mmap_entry -{ - grub_uint64_t addr; - grub_uint64_t len; - grub_uint32_t type; -} GRUB_PACKED; - - /* Helper for preboot. */ static int fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data) diff --git a/include/grub/i386/memory.h b/include/grub/i386/memory.h index 8bb6e1cbb..5cb607fb4 100644 --- a/include/grub/i386/memory.h +++ b/include/grub/i386/memory.h @@ -44,6 +44,13 @@ #include +struct grub_e820_mmap_entry +{ + grub_uint64_t addr; + grub_uint64_t len; + grub_uint32_t type; +} GRUB_PACKED; + grub_uint64_t grub_mmap_get_upper (void); grub_uint64_t grub_mmap_get_lower (void); grub_uint64_t grub_mmap_get_post64 (void); diff --git a/include/grub/i386/pc/int.h b/include/grub/i386/pc/int.h index 16a53e4fe..a60104001 100644 --- a/include/grub/i386/pc/int.h +++ b/include/grub/i386/pc/int.h @@ -20,45 +20,11 @@ #define GRUB_INTERRUPT_MACHINE_HEADER 1 #include -#include - -struct grub_bios_int_registers -{ - grub_uint32_t eax; - grub_uint16_t es; - grub_uint16_t ds; - grub_uint16_t flags; - grub_uint16_t dummy; - grub_uint32_t ebx; - grub_uint32_t ecx; - grub_uint32_t edi; - grub_uint32_t esi; - grub_uint32_t edx; -}; - -#define GRUB_CPU_INT_FLAGS_CARRY 0x1 -#define GRUB_CPU_INT_FLAGS_PARITY 0x4 -#define GRUB_CPU_INT_FLAGS_ADJUST 0x10 -#define GRUB_CPU_INT_FLAGS_ZERO 0x40 -#define GRUB_CPU_INT_FLAGS_SIGN 0x80 -#define GRUB_CPU_INT_FLAGS_TRAP 0x100 -#define GRUB_CPU_INT_FLAGS_INTERRUPT 0x200 -#define GRUB_CPU_INT_FLAGS_DIRECTION 0x400 -#define GRUB_CPU_INT_FLAGS_OVERFLOW 0x800 -#ifdef GRUB_MACHINE_PCBIOS -#define GRUB_CPU_INT_FLAGS_DEFAULT GRUB_CPU_INT_FLAGS_INTERRUPT -#else -#define GRUB_CPU_INT_FLAGS_DEFAULT 0 -#endif +#include void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno, struct grub_bios_int_registers *regs) __attribute__ ((regparm(3))); -struct grub_i386_idt -{ - grub_uint16_t limit; - grub_uint32_t base; -} GRUB_PACKED; #ifdef GRUB_MACHINE_PCBIOS extern struct grub_i386_idt *EXPORT_VAR(grub_realidt); diff --git a/include/grub/i386/pc/int_types.h b/include/grub/i386/pc/int_types.h new file mode 100644 index 000000000..2c5a69b63 --- /dev/null +++ b/include/grub/i386/pc/int_types.h @@ -0,0 +1,59 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_INTERRUPT_TYPES_MACHINE_HEADER +#define GRUB_INTERRUPT_TYPES_MACHINE_HEADER 1 + +#include + +#define GRUB_CPU_INT_FLAGS_CARRY 0x1 +#define GRUB_CPU_INT_FLAGS_PARITY 0x4 +#define GRUB_CPU_INT_FLAGS_ADJUST 0x10 +#define GRUB_CPU_INT_FLAGS_ZERO 0x40 +#define GRUB_CPU_INT_FLAGS_SIGN 0x80 +#define GRUB_CPU_INT_FLAGS_TRAP 0x100 +#define GRUB_CPU_INT_FLAGS_INTERRUPT 0x200 +#define GRUB_CPU_INT_FLAGS_DIRECTION 0x400 +#define GRUB_CPU_INT_FLAGS_OVERFLOW 0x800 +#ifdef GRUB_MACHINE_PCBIOS +#define GRUB_CPU_INT_FLAGS_DEFAULT GRUB_CPU_INT_FLAGS_INTERRUPT +#else +#define GRUB_CPU_INT_FLAGS_DEFAULT 0 +#endif + +struct grub_bios_int_registers +{ + grub_uint32_t eax; + grub_uint16_t es; + grub_uint16_t ds; + grub_uint16_t flags; + grub_uint16_t dummy; + grub_uint32_t ebx; + grub_uint32_t ecx; + grub_uint32_t edi; + grub_uint32_t esi; + grub_uint32_t edx; +}; + +struct grub_i386_idt +{ + grub_uint16_t limit; + grub_uint32_t base; +} GRUB_PACKED; + +#endif diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index a0aa2c573..324174ded 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -54,7 +54,7 @@ grub_get_tsc (void) static __inline int grub_cpu_is_tsc_supported (void) { -#ifndef GRUB_MACHINE_XEN +#if !defined(GRUB_MACHINE_XEN) && !defined(GRUB_MACHINE_XEN_PVH) grub_uint32_t a,b,c,d; if (! grub_cpu_is_cpuid_supported ()) return 0; diff --git a/include/grub/i386/xen/hypercall.h b/include/grub/i386/xen/hypercall.h index 198ee94af..4e4c12a49 100644 --- a/include/grub/i386/xen/hypercall.h +++ b/include/grub/i386/xen/hypercall.h @@ -26,7 +26,10 @@ EXPORT_FUNC (grub_xen_hypercall) (grub_uint32_t callno, grub_uint32_t a0, grub_uint32_t a1, grub_uint32_t a2, grub_uint32_t a3, grub_uint32_t a4, grub_uint32_t a5) -__attribute__ ((regparm (3), cdecl)); +#ifdef GRUB_MACHINE_XEN + __attribute__ ((regparm (3), cdecl)) +#endif + ; static inline int grub_xen_sched_op (int cmd, void *arg) diff --git a/include/grub/kernel.h b/include/grub/kernel.h index ecd88ca72..133a37c8d 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -79,7 +79,9 @@ struct grub_module_info64 #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) \ || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) \ || defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_ARC) \ - || (defined (__sparc__) && defined (GRUB_MACHINE_IEEE1275)) || defined (GRUB_MACHINE_UBOOT) || defined (GRUB_MACHINE_XEN) + || (defined (__sparc__) && defined (GRUB_MACHINE_IEEE1275)) \ + || defined (GRUB_MACHINE_UBOOT) || defined (GRUB_MACHINE_XEN) \ + || defined(GRUB_MACHINE_XEN_PVH) /* FIXME: stack is between 2 heap regions. Move it. */ #define GRUB_KERNEL_PRELOAD_SPACE_REUSABLE 1 #endif From 408de833bbd1ccad39ad439eaf3cddd528b039b5 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:33 +0100 Subject: [PATCH 0886/1167] xen: Add some dummy headers for PVH mode With Xen PVH mode adding a new machine type the machine related headers need to be present for the build to succeed. Most of the headers just need to include the related common i386 headers. Add those to the tree. Note that xen_pvh/int.h needs to include pc/int_types.h instead of pc/int.h in order to avoid the definition of grub_bios_interrupt(). xen_pvh/memory.h needs to include coreboot/memory.h (like some other /memory.h do as well) as this contains just the needed stubs. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- include/grub/i386/xen_pvh/boot.h | 1 + include/grub/i386/xen_pvh/console.h | 1 + include/grub/i386/xen_pvh/int.h | 1 + include/grub/i386/xen_pvh/memory.h | 1 + include/grub/i386/xen_pvh/time.h | 1 + 5 files changed, 5 insertions(+) create mode 100644 include/grub/i386/xen_pvh/boot.h create mode 100644 include/grub/i386/xen_pvh/console.h create mode 100644 include/grub/i386/xen_pvh/int.h create mode 100644 include/grub/i386/xen_pvh/memory.h create mode 100644 include/grub/i386/xen_pvh/time.h diff --git a/include/grub/i386/xen_pvh/boot.h b/include/grub/i386/xen_pvh/boot.h new file mode 100644 index 000000000..6cd23aa83 --- /dev/null +++ b/include/grub/i386/xen_pvh/boot.h @@ -0,0 +1 @@ +#include diff --git a/include/grub/i386/xen_pvh/console.h b/include/grub/i386/xen_pvh/console.h new file mode 100644 index 000000000..305a46d8e --- /dev/null +++ b/include/grub/i386/xen_pvh/console.h @@ -0,0 +1 @@ +#include diff --git a/include/grub/i386/xen_pvh/int.h b/include/grub/i386/xen_pvh/int.h new file mode 100644 index 000000000..0f1f9ee62 --- /dev/null +++ b/include/grub/i386/xen_pvh/int.h @@ -0,0 +1 @@ +#include diff --git a/include/grub/i386/xen_pvh/memory.h b/include/grub/i386/xen_pvh/memory.h new file mode 100644 index 000000000..8dd6f7c8c --- /dev/null +++ b/include/grub/i386/xen_pvh/memory.h @@ -0,0 +1 @@ +#include diff --git a/include/grub/i386/xen_pvh/time.h b/include/grub/i386/xen_pvh/time.h new file mode 100644 index 000000000..2298ee8f4 --- /dev/null +++ b/include/grub/i386/xen_pvh/time.h @@ -0,0 +1 @@ +#include From bec9edf53f4d0b629a52a7d1145f38f88df8dd1d Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:34 +0100 Subject: [PATCH 0887/1167] xen: Rearrange xen/init.c to prepare it for Xen PVH mode Rearrange grub-core/kern/xen/init.c to prepare adding PVH mode support to it. This includes putting some code under #ifdef GRUB_MACHINE_XEN as it will not be used when running as PVH. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/xen/init.c | 60 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c index 29f5bc23d..10007b411 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -41,9 +41,11 @@ grub_size_t grub_xen_n_allocated_shared_pages; static grub_xen_mfn_t grub_xen_ptr2mfn (void *ptr) { +#ifdef GRUB_MACHINE_XEN grub_xen_mfn_t *mfn_list = (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; return mfn_list[(grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE]; +#endif } void * @@ -104,18 +106,6 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)), { } -static grub_uint8_t window[GRUB_XEN_PAGE_SIZE] - __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE))); - -#ifdef __x86_64__ -#define NUMBER_OF_LEVELS 4 -#else -#define NUMBER_OF_LEVELS 3 -#endif - -#define LOG_POINTERS_PER_PAGE 9 -#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE) - void grub_xen_store_send (const void *buf_, grub_size_t len) { @@ -337,6 +327,19 @@ grub_xen_setup_gnttab (void) grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1); } +#ifdef GRUB_MACHINE_XEN +static grub_uint8_t window[GRUB_XEN_PAGE_SIZE] + __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE))); + +#ifdef __x86_64__ +#define NUMBER_OF_LEVELS 4 +#else +#define NUMBER_OF_LEVELS 3 +#endif + +#define LOG_POINTERS_PER_PAGE 9 +#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE) + #define MAX_N_UNUSABLE_PAGES 4 static int @@ -529,13 +532,30 @@ map_all_pages (void) grub_mm_init_region ((void *) heap_start, heap_end - heap_start); } +grub_err_t +grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) +{ + grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages; + grub_uint64_t usable_pages = grub_xen_start_page_addr->pt_base >> 12; + if (hook (0, page2offset (usable_pages), GRUB_MEMORY_AVAILABLE, hook_data)) + return GRUB_ERR_NONE; + + hook (page2offset (usable_pages), page2offset (total_pages - usable_pages), + GRUB_MEMORY_RESERVED, hook_data); + + return GRUB_ERR_NONE; +} +#endif + extern char _end[]; void grub_machine_init (void) { +#ifdef GRUB_MACHINE_XEN #ifdef __i386__ grub_xen_vm_assist (VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3); +#endif #endif grub_modbase = ALIGN_UP ((grub_addr_t) _end @@ -544,7 +564,9 @@ grub_machine_init (void) grub_xen_setup_gnttab (); +#ifdef GRUB_MACHINE_XEN map_all_pages (); +#endif grub_console_init (); @@ -571,17 +593,3 @@ grub_machine_fini (int flags __attribute__ ((unused))) grub_xendisk_fini (); grub_boot_fini (); } - -grub_err_t -grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) -{ - grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages; - grub_uint64_t usable_pages = grub_xen_start_page_addr->pt_base >> 12; - if (hook (0, page2offset (usable_pages), GRUB_MEMORY_AVAILABLE, hook_data)) - return GRUB_ERR_NONE; - - hook (page2offset (usable_pages), page2offset (total_pages - usable_pages), - GRUB_MEMORY_RESERVED, hook_data); - - return GRUB_ERR_NONE; -} From 3b8d09c7742a1890eadad6987852c82947ea5d4a Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:35 +0100 Subject: [PATCH 0888/1167] xen: Modify grub_xen_ptr2mfn() for Xen PVH grub_xen_ptr2mfn() returns the machine frame number for a given pointer value. For Xen-PVH guests this is just the PFN. Add the PVH specific variant. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/xen/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c index 10007b411..a23dad633 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -45,6 +45,8 @@ grub_xen_ptr2mfn (void *ptr) grub_xen_mfn_t *mfn_list = (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; return mfn_list[(grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE]; +#else + return (grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE; #endif } From 53a92dea8b675afb3f46aed15c04528695d46d59 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:36 +0100 Subject: [PATCH 0889/1167] xen: Add PVH specific defines to offset.h include/grub/offsets.h needs some defines for Xen PVH mode. Add them. While at it line up the values in the surrounding lines to start at the same column. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- include/grub/offsets.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/include/grub/offsets.h b/include/grub/offsets.h index 330e4c707..871e1cd4c 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -36,9 +36,10 @@ #define GRUB_DECOMPRESSOR_I386_PC_MAX_DECOMPRESSOR_SIZE (0x9000-0x8200) /* The segment where the kernel is loaded. */ -#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800 +#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800 -#define GRUB_KERNEL_I386_PC_LINK_ADDR 0x9000 +#define GRUB_KERNEL_I386_PC_LINK_ADDR 0x9000 +#define GRUB_KERNEL_I386_XEN_PVH_LINK_ADDR 0x100000 /* The upper memory area (starting at 640 kiB). */ #define GRUB_MEMORY_I386_PC_UPPER 0xa0000 @@ -101,15 +102,17 @@ #define GRUB_KERNEL_I386_MULTIBOOT_MOD_ALIGN GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN #define GRUB_KERNEL_X86_64_XEN_MOD_ALIGN 0x8 -#define GRUB_KERNEL_I386_XEN_MOD_ALIGN 0x8 +#define GRUB_KERNEL_I386_XEN_MOD_ALIGN 0x8 +#define GRUB_KERNEL_I386_XEN_PVH_MOD_ALIGN 0x8 /* Non-zero value is only needed for PowerMacs. */ -#define GRUB_KERNEL_X86_64_XEN_MOD_GAP 0x0 -#define GRUB_KERNEL_I386_XEN_MOD_GAP 0x0 -#define GRUB_KERNEL_I386_IEEE1275_MOD_GAP 0x0 -#define GRUB_KERNEL_I386_COREBOOT_MOD_GAP 0x0 -#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_GAP 0x0 -#define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0 +#define GRUB_KERNEL_X86_64_XEN_MOD_GAP 0x0 +#define GRUB_KERNEL_I386_XEN_MOD_GAP 0x0 +#define GRUB_KERNEL_I386_XEN_PVH_MOD_GAP 0x0 +#define GRUB_KERNEL_I386_IEEE1275_MOD_GAP 0x0 +#define GRUB_KERNEL_I386_COREBOOT_MOD_GAP 0x0 +#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_GAP 0x0 +#define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0 #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000 #define GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN 3 From 0b3e4eb2d2e1875e6045e838962f769f2ce161dd Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:37 +0100 Subject: [PATCH 0890/1167] xen: Add basic hooks for PVH in current code Add the hooks to current code needed for Xen PVH. They will be filled with code later when the related functionality is being added. loader/i386/linux.c needs to include machine/kernel.h now as it needs to get GRUB_KERNEL_USE_RSDP_ADDR from there. This in turn requires to add an empty kernel.h header for some i386 platforms (efi, coreboot, ieee1275, xen) and for x86_64 efi. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/Makefile.am | 6 +++++ grub-core/kern/i386/xen/pvh.c | 37 +++++++++++++++++++++++++++ grub-core/kern/i386/xen/startup_pvh.S | 29 +++++++++++++++++++++ grub-core/kern/xen/init.c | 4 +++ grub-core/loader/i386/linux.c | 1 + include/grub/i386/coreboot/kernel.h | 0 include/grub/i386/efi/kernel.h | 0 include/grub/i386/ieee1275/kernel.h | 0 include/grub/i386/xen/kernel.h | 0 include/grub/i386/xen_pvh/kernel.h | 30 ++++++++++++++++++++++ include/grub/x86_64/efi/kernel.h | 0 include/grub/xen.h | 5 ++++ 12 files changed, 112 insertions(+) create mode 100644 grub-core/kern/i386/xen/pvh.c create mode 100644 grub-core/kern/i386/xen/startup_pvh.S create mode 100644 include/grub/i386/coreboot/kernel.h create mode 100644 include/grub/i386/efi/kernel.h create mode 100644 include/grub/i386/ieee1275/kernel.h create mode 100644 include/grub/i386/xen/kernel.h create mode 100644 include/grub/i386/xen_pvh/kernel.h create mode 100644 include/grub/x86_64/efi/kernel.h diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index f4ff62b76..a27786ab0 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -102,6 +102,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h endif if COND_i386_efi +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h @@ -111,6 +112,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h endif if COND_i386_coreboot +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/coreboot/lbio.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h @@ -122,6 +124,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_multiboot +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif @@ -132,6 +135,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h endif if COND_i386_ieee1275 +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h @@ -140,6 +144,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h endif if COND_i386_xen +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h @@ -158,6 +163,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h endif if COND_x86_64_efi +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c new file mode 100644 index 000000000..4f629b15e --- /dev/null +++ b/grub-core/kern/i386/xen/pvh.c @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +grub_uint64_t grub_rsdp_addr; + +void +grub_xen_setup_pvh (void) +{ +} + +grub_err_t +grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) +{ +} diff --git a/grub-core/kern/i386/xen/startup_pvh.S b/grub-core/kern/i386/xen/startup_pvh.S new file mode 100644 index 000000000..69b8fdcca --- /dev/null +++ b/grub-core/kern/i386/xen/startup_pvh.S @@ -0,0 +1,29 @@ +/* startup.S - bootstrap GRUB itself */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include + + .file "startup_pvh.S" + .text + +/* Saved pointer to start info structure. */ + .globl pvh_start_info +pvh_start_info: + .long 0 diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c index a23dad633..782ca7295 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -564,6 +564,10 @@ grub_machine_init (void) + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN); +#ifdef GRUB_MACHINE_XEN_PVH + grub_xen_setup_pvh (); +#endif + grub_xen_setup_gnttab (); #ifdef GRUB_MACHINE_XEN diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 375ee80dc..b6015913b 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -35,6 +35,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/include/grub/i386/coreboot/kernel.h b/include/grub/i386/coreboot/kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/grub/i386/efi/kernel.h b/include/grub/i386/efi/kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/grub/i386/ieee1275/kernel.h b/include/grub/i386/ieee1275/kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/grub/i386/xen/kernel.h b/include/grub/i386/xen/kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/grub/i386/xen_pvh/kernel.h b/include/grub/i386/xen_pvh/kernel.h new file mode 100644 index 000000000..2b7b8a129 --- /dev/null +++ b/include/grub/i386/xen_pvh/kernel.h @@ -0,0 +1,30 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_KERNEL_MACHINE_HEADER +#define GRUB_KERNEL_MACHINE_HEADER 1 + +#ifndef ASM_FILE + +#define GRUB_KERNEL_USE_RSDP_ADDR 1 + +extern grub_uint64_t EXPORT_VAR(grub_rsdp_addr); + +#endif /* ! ASM_FILE */ + +#endif /* GRUB_KERNEL_MACHINE_HEADER */ diff --git a/include/grub/x86_64/efi/kernel.h b/include/grub/x86_64/efi/kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/grub/xen.h b/include/grub/xen.h index c31cc10c7..91cb7cf81 100644 --- a/include/grub/xen.h +++ b/include/grub/xen.h @@ -95,6 +95,11 @@ typedef grub_uint64_t grub_xen_mfn_t; typedef grub_uint32_t grub_xen_mfn_t; #endif typedef unsigned int grub_xen_evtchn_t; + +#ifdef GRUB_MACHINE_XEN_PVH +extern struct hvm_start_info *pvh_start_info; +void grub_xen_setup_pvh (void); +#endif #endif #endif From 1a4d83af2fc1eb0a0951775a2b86860ab074c699 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:38 +0100 Subject: [PATCH 0891/1167] xen: Add PVH boot entry code Add the code for the Xen PVH mode boot entry. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/i386/xen/startup_pvh.S | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/grub-core/kern/i386/xen/startup_pvh.S b/grub-core/kern/i386/xen/startup_pvh.S index 69b8fdcca..363c31858 100644 --- a/grub-core/kern/i386/xen/startup_pvh.S +++ b/grub-core/kern/i386/xen/startup_pvh.S @@ -19,11 +19,63 @@ #include #include +#include .file "startup_pvh.S" .text + .globl start, _start + .code32 +start: +_start: + cld + lgdt gdtdesc + ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $1f +1: + movl $GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %eax + mov %eax, %ds + mov %eax, %es + mov %eax, %fs + mov %eax, %gs + mov %eax, %ss + leal LOCAL(stack_end), %esp + + /* Save address of start info structure. */ + mov %ebx, pvh_start_info + call EXT_C(grub_main) + /* Doesn't return. */ + + .p2align 3 +gdt: + .word 0, 0 + .byte 0, 0, 0, 0 + + /* -- code segment -- + * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present + * type = 32bit code execute/read, DPL = 0 + */ + .word 0xFFFF, 0 + .byte 0, 0x9A, 0xCF, 0 + + /* -- data segment -- + * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present + * type = 32 bit data read/write, DPL = 0 + */ + .word 0xFFFF, 0 + .byte 0, 0x92, 0xCF, 0 + + .p2align 3 +/* this is the GDT descriptor */ +gdtdesc: + .word 0x17 /* limit */ + .long gdt /* addr */ + + .p2align 2 /* Saved pointer to start info structure. */ .globl pvh_start_info pvh_start_info: .long 0 + + .bss + .space GRUB_MEMORY_MACHINE_PROT_STACK_SIZE +LOCAL(stack_end): From da81e42a7ccb545513368ec7488cdf5019c1c2ba Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:39 +0100 Subject: [PATCH 0892/1167] xen: Setup hypercall page for PVH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the needed code to setup the hypercall page for calling into the Xen hypervisor. Import the XEN_HVM_DEBUGCONS_IOPORT define from Xen unstable into include/xen/arch-x86/xen.h Signed-off-by: Juergen Gross Reviewed-by: Roger Pau Monné Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/i386/xen/pvh.c | 80 +++++++++++++++++++++++++++++++++++ include/xen/arch-x86/xen.h | 7 +++ 2 files changed, 87 insertions(+) diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c index 4f629b15e..a2554fb1d 100644 --- a/grub-core/kern/i386/xen/pvh.c +++ b/grub-core/kern/i386/xen/pvh.c @@ -20,15 +20,95 @@ #include #include #include +#include +#include #include #include #include grub_uint64_t grub_rsdp_addr; +static char hypercall_page[GRUB_XEN_PAGE_SIZE] + __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE))); + +static grub_uint32_t xen_cpuid_base; + +static void +grub_xen_cons_msg (const char *msg) +{ + const char *c; + + for (c = msg; *c; c++) + grub_outb (*c, XEN_HVM_DEBUGCONS_IOPORT); +} + +static void +grub_xen_panic (const char *msg) +{ + grub_xen_cons_msg (msg); + grub_xen_cons_msg ("System halted!\n"); + + asm volatile ("cli"); + + while (1) + { + asm volatile ("hlt"); + } +} + +static void +grub_xen_cpuid_base (void) +{ + grub_uint32_t base, eax, signature[3]; + + for (base = 0x40000000; base < 0x40010000; base += 0x100) + { + grub_cpuid (base, eax, signature[0], signature[1], signature[2]); + if (!grub_memcmp ("XenVMMXenVMM", signature, 12) && (eax - base) >= 2) + { + xen_cpuid_base = base; + return; + } + } + + grub_xen_panic ("Found no Xen signature!\n"); +} + +static void +grub_xen_setup_hypercall_page (void) +{ + grub_uint32_t msr, addr, eax, ebx, ecx, edx; + + /* Get base address of Xen-specific MSRs. */ + grub_cpuid (xen_cpuid_base + 2, eax, ebx, ecx, edx); + msr = ebx; + addr = (grub_uint32_t) (&hypercall_page); + + /* Specify hypercall page address for Xen. */ + asm volatile ("wrmsr" : : "c" (msr), "a" (addr), "d" (0) : "memory"); +} + +int +grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0, + grub_uint32_t a1, grub_uint32_t a2, + grub_uint32_t a3, grub_uint32_t a4, + grub_uint32_t a5 __attribute__ ((unused))) +{ + grub_uint32_t res; + + asm volatile ("call *%[callno]" + : "=a" (res), "+b" (a0), "+c" (a1), "+d" (a2), + "+S" (a3), "+D" (a4) + : [callno] "a" (&hypercall_page[callno * 32]) + : "memory"); + return res; +} + void grub_xen_setup_pvh (void) { + grub_xen_cpuid_base (); + grub_xen_setup_hypercall_page (); } grub_err_t diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h index f35804b88..56be26cb6 100644 --- a/include/xen/arch-x86/xen.h +++ b/include/xen/arch-x86/xen.h @@ -260,6 +260,13 @@ typedef struct arch_shared_info arch_shared_info_t; #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" #endif +/* + * Debug console IO port, also called "port E9 hack". Each character written + * to this IO port will be printed on the hypervisor console, subject to log + * level restrictions. + */ +#define XEN_HVM_DEBUGCONS_IOPORT 0xe9 + #endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ /* From 2b7a21afd319b829941a928f5763e017d1cc2951 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:40 +0100 Subject: [PATCH 0893/1167] xen: Get memory map from hypervisor for PVH Retrieve the memory map from the hypervisor and normalize it to contain no overlapping entries and to be sorted by address. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/i386/xen/pvh.c | 94 +++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c index a2554fb1d..2b68ac333 100644 --- a/grub-core/kern/i386/xen/pvh.c +++ b/grub-core/kern/i386/xen/pvh.c @@ -24,7 +24,12 @@ #include #include #include +#include #include +#include +#include + +#define XEN_MEMORY_MAP_SIZE 128 grub_uint64_t grub_rsdp_addr; @@ -32,6 +37,8 @@ static char hypercall_page[GRUB_XEN_PAGE_SIZE] __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE))); static grub_uint32_t xen_cpuid_base; +static struct grub_e820_mmap_entry map[XEN_MEMORY_MAP_SIZE]; +static unsigned int nr_map_entries; static void grub_xen_cons_msg (const char *msg) @@ -104,11 +111,98 @@ grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0, return res; } +static void +grub_xen_sort_mmap (void) +{ + grub_uint64_t from, to; + unsigned int i; + struct grub_e820_mmap_entry tmp; + + /* Align map entries to page boundaries. */ + for (i = 0; i < nr_map_entries; i++) + { + from = map[i].addr; + to = from + map[i].len; + if (map[i].type == GRUB_MEMORY_AVAILABLE) + { + from = ALIGN_UP (from, GRUB_XEN_PAGE_SIZE); + to = ALIGN_DOWN (to, GRUB_XEN_PAGE_SIZE); + } + else + { + from = ALIGN_DOWN (from, GRUB_XEN_PAGE_SIZE); + to = ALIGN_UP (to, GRUB_XEN_PAGE_SIZE); + } + map[i].addr = from; + map[i].len = to - from; + } + + again: + /* Sort entries by start address. */ + for (i = 1; i < nr_map_entries; i++) + { + if (map[i].addr >= map[i - 1].addr) + continue; + tmp = map[i]; + map[i] = map[i - 1]; + map[i - 1] = tmp; + i = 0; + } + + /* Detect overlapping areas. */ + for (i = 1; i < nr_map_entries; i++) + { + if (map[i].addr >= map[i - 1].addr + map[i - 1].len) + continue; + tmp = map[i - 1]; + map[i - 1].len = map[i].addr - map[i - 1].addr; + if (map[i].addr + map[i].len >= tmp.addr + tmp.len) + continue; + if (nr_map_entries < ARRAY_SIZE (map)) + { + map[nr_map_entries].addr = map[i].addr + map[i].len; + map[nr_map_entries].len = tmp.addr + tmp.len - map[nr_map_entries].addr; + map[nr_map_entries].type = tmp.type; + nr_map_entries++; + goto again; + } + } + + /* Merge adjacent entries. */ + for (i = 1; i < nr_map_entries; i++) + { + if (map[i].type == map[i - 1].type && + map[i].addr == map[i - 1].addr + map[i - 1].len) + { + map[i - 1].len += map[i].len; + map[i] = map[nr_map_entries - 1]; + nr_map_entries--; + goto again; + } + } +} + +static void +grub_xen_get_mmap (void) +{ + struct xen_memory_map memmap; + + memmap.nr_entries = ARRAY_SIZE (map); + set_xen_guest_handle (memmap.buffer, map); + if (grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_memory_map, + (grub_uint32_t) (&memmap), 0, 0, 0, 0)) + grub_xen_panic ("Could not get memory map from Xen!\n"); + nr_map_entries = memmap.nr_entries; + + grub_xen_sort_mmap (); +} + void grub_xen_setup_pvh (void) { grub_xen_cpuid_base (); grub_xen_setup_hypercall_page (); + grub_xen_get_mmap (); } grub_err_t From 4c9b4a7c92c9373315fd8b0f8f889275814bba41 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:41 +0100 Subject: [PATCH 0894/1167] xen: Setup Xen specific data for PVH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize the needed Xen specific data. This is: - the Xen start of day page containing the console and Xenstore ring page PFN and event channel - the grant table - the shared info page Write back the possibly modified memory map to the hypervisor in case the guest is reading it from there again. Set the RSDP address for the guest from the start_info page passed as boot parameter. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Reviewed-by: Roger Pau Monné Tested-by: Hans van Kranenburg --- grub-core/kern/i386/xen/pvh.c | 123 ++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c index 2b68ac333..472085ed1 100644 --- a/grub-core/kern/i386/xen/pvh.c +++ b/grub-core/kern/i386/xen/pvh.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #define XEN_MEMORY_MAP_SIZE 128 @@ -37,6 +38,7 @@ static char hypercall_page[GRUB_XEN_PAGE_SIZE] __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE))); static grub_uint32_t xen_cpuid_base; +static struct start_info grub_xen_start_page; static struct grub_e820_mmap_entry map[XEN_MEMORY_MAP_SIZE]; static unsigned int nr_map_entries; @@ -111,6 +113,36 @@ grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0, return res; } +static grub_uint32_t +grub_xen_get_param (int idx) +{ + struct xen_hvm_param xhv; + int r; + + xhv.domid = DOMID_SELF; + xhv.index = idx; + r = grub_xen_hypercall (__HYPERVISOR_hvm_op, HVMOP_get_param, + (grub_uint32_t) (&xhv), 0, 0, 0, 0); + if (r < 0) + grub_xen_panic ("Could not get parameter from Xen!\n"); + return xhv.value; +} + +static void * +grub_xen_add_physmap (unsigned int space, void *addr) +{ + struct xen_add_to_physmap xatp; + + xatp.domid = DOMID_SELF; + xatp.idx = 0; + xatp.space = space; + xatp.gpfn = (grub_addr_t) addr >> GRUB_XEN_LOG_PAGE_SIZE; + if (grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_add_to_physmap, + (grub_uint32_t) (&xatp), 0, 0, 0, 0)) + grub_xen_panic ("Memory_op hypercall failed!\n"); + return addr; +} + static void grub_xen_sort_mmap (void) { @@ -197,12 +229,103 @@ grub_xen_get_mmap (void) grub_xen_sort_mmap (); } +static void +grub_xen_set_mmap (void) +{ + struct xen_foreign_memory_map memmap; + + memmap.domid = DOMID_SELF; + memmap.map.nr_entries = nr_map_entries; + set_xen_guest_handle (memmap.map.buffer, map); + grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_set_memory_map, + (grub_uint32_t) (&memmap), 0, 0, 0, 0); +} + +static grub_uint64_t +grub_xen_find_page (grub_uint64_t start) +{ + unsigned int i, j; + grub_uint64_t last = start; + + /* + * Try to find a e820 map hole below 4G. + * Relies on page-aligned entries (addr and len) and input (start). + */ + + for (i = 0; i < nr_map_entries; i++) + { + if (last > map[i].addr + map[i].len) + continue; + if (last < map[i].addr) + return last; + if ((map[i].addr >> 32) || ((map[i].addr + map[i].len) >> 32)) + break; + last = map[i].addr + map[i].len; + } + if (i == nr_map_entries) + return last; + + /* No hole found, use the highest RAM page below 4G and reserve it. */ + if (nr_map_entries == ARRAY_SIZE (map)) + grub_xen_panic ("Memory map size limit reached!\n"); + for (i = 0, j = 0; i < nr_map_entries; i++) + { + if (map[i].type != GRUB_MEMORY_AVAILABLE) + continue; + if (map[i].addr >> 32) + break; + j = i; + if ((map[i].addr + map[i].len) >> 32) + break; + } + if (map[j].type != GRUB_MEMORY_AVAILABLE) + grub_xen_panic ("No free memory page found!\n"); + if ((map[j].addr + map[j].len) >> 32) + last = (1ULL << 32) - GRUB_XEN_PAGE_SIZE; + else + last = map[j].addr + map[j].len - GRUB_XEN_PAGE_SIZE; + map[nr_map_entries].addr = last; + map[nr_map_entries].len = GRUB_XEN_PAGE_SIZE; + map[nr_map_entries].type = GRUB_MEMORY_RESERVED; + nr_map_entries++; + grub_xen_sort_mmap (); + + return last; +} + void grub_xen_setup_pvh (void) { + grub_addr_t par; + grub_xen_cpuid_base (); grub_xen_setup_hypercall_page (); grub_xen_get_mmap (); + + /* Setup Xen data. */ + grub_xen_start_page_addr = &grub_xen_start_page; + + par = grub_xen_get_param (HVM_PARAM_CONSOLE_PFN); + grub_xen_start_page_addr->console.domU.mfn = par; + grub_xen_xcons = (void *) (grub_addr_t) (par << GRUB_XEN_LOG_PAGE_SIZE); + par = grub_xen_get_param (HVM_PARAM_CONSOLE_EVTCHN); + grub_xen_start_page_addr->console.domU.evtchn = par; + + par = grub_xen_get_param (HVM_PARAM_STORE_PFN); + grub_xen_start_page_addr->store_mfn = par; + grub_xen_xenstore = (void *) (grub_addr_t) (par << GRUB_XEN_LOG_PAGE_SIZE); + par = grub_xen_get_param (HVM_PARAM_STORE_EVTCHN); + grub_xen_start_page_addr->store_evtchn = par; + + par = grub_xen_find_page (0); + grub_xen_grant_table = grub_xen_add_physmap (XENMAPSPACE_grant_table, + (void *) par); + par = grub_xen_find_page (par + GRUB_XEN_PAGE_SIZE); + grub_xen_shared_info = grub_xen_add_physmap (XENMAPSPACE_shared_info, + (void *) par); + grub_xen_set_mmap (); + + grub_rsdp_addr = pvh_start_info->rsdp_paddr; } grub_err_t From 1d2473a024a9e1f46a7caa75d5c8186ed2cdb6e1 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:42 +0100 Subject: [PATCH 0895/1167] xen: Init memory regions for PVH Add all usable memory regions to grub memory management and add the needed mmap iterate code, which will be used by grub core (e.g. grub-core/lib/relocator.c or grub-core/mmap/mmap.c). As we are running in 32-bit mode don't add memory above 4GB. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- grub-core/kern/i386/xen/pvh.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c index 472085ed1..91fbca859 100644 --- a/grub-core/kern/i386/xen/pvh.c +++ b/grub-core/kern/i386/xen/pvh.c @@ -241,6 +241,30 @@ grub_xen_set_mmap (void) (grub_uint32_t) (&memmap), 0, 0, 0, 0); } +static void +grub_xen_mm_init_regions (void) +{ + grub_uint64_t modend, from, to; + unsigned int i; + + modend = grub_modules_get_end (); + + for (i = 0; i < nr_map_entries; i++) + { + if (map[i].type != GRUB_MEMORY_AVAILABLE) + continue; + from = map[i].addr; + to = from + map[i].len; + if (from < modend) + from = modend; + if (from >= to || from >= (1ULL << 32)) + continue; + if (to > (1ULL << 32)) + to = 1ULL << 32; + grub_mm_init_region ((void *) (grub_addr_t) from, to - from); + } +} + static grub_uint64_t grub_xen_find_page (grub_uint64_t start) { @@ -325,10 +349,21 @@ grub_xen_setup_pvh (void) (void *) par); grub_xen_set_mmap (); + grub_xen_mm_init_regions (); + grub_rsdp_addr = pvh_start_info->rsdp_paddr; } grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) { + unsigned int i; + + for (i = 0; i < nr_map_entries; i++) + { + if (map[i].len && hook (map[i].addr, map[i].len, map[i].type, hook_data)) + break; + } + + return GRUB_ERR_NONE; } From 9c062ad42c32a42b677da4b066cb33debf1dfe30 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:43 +0100 Subject: [PATCH 0896/1167] xen_pvh: Add build runes for grub-core Add the modifications to the build system needed to build a xen_pvh grub. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- gentpl.py | 4 ++-- grub-core/Makefile.am | 12 ++++++++++++ grub-core/Makefile.core.def | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/gentpl.py b/gentpl.py index da67965a4..e8439484a 100644 --- a/gentpl.py +++ b/gentpl.py @@ -28,7 +28,7 @@ import re GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275", "x86_64_efi", - "i386_xen", "x86_64_xen", + "i386_xen", "x86_64_xen", "i386_xen_pvh", "mips_loongson", "sparc64_ieee1275", "powerpc_ieee1275", "mips_arc", "ia64_efi", "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi", @@ -71,7 +71,7 @@ GROUPS["videomodules"] = GRUB_PLATFORMS[:]; for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) # Similar for terminfo -GROUPS["terminfoinkernel"] = [ "emu", "mips_loongson", "mips_arc", "mips_qemu_mips" ] + GROUPS["xen"] + GROUPS["ieee1275"] + GROUPS["uboot"]; +GROUPS["terminfoinkernel"] = [ "emu", "mips_loongson", "mips_arc", "mips_qemu_mips", "i386_xen_pvh" ] + GROUPS["xen"] + GROUPS["ieee1275"] + GROUPS["uboot"]; GROUPS["terminfomodule"] = GRUB_PLATFORMS[:]; for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index a27786ab0..df8dbe2fb 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -101,6 +101,18 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h endif +if COND_i386_xen_pvh +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h +endif + if COND_i386_efi KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2d75c4daf..f31301e04 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -79,6 +79,8 @@ kernel = { i386_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0'; x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0'; + i386_xen_pvh_ldflags = '$(TARGET_IMG_LDFLAGS)'; + i386_xen_pvh_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x100000'; mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; @@ -100,6 +102,7 @@ kernel = { x86_64_efi_startup = kern/x86_64/efi/startup.S; i386_xen_startup = kern/i386/xen/startup.S; x86_64_xen_startup = kern/x86_64/xen/startup.S; + i386_xen_pvh_startup = kern/i386/xen/startup_pvh.S; i386_qemu_startup = kern/i386/qemu/startup.S; i386_ieee1275_startup = kern/i386/ieee1275/startup.S; i386_coreboot_startup = kern/i386/coreboot/startup.S; @@ -177,6 +180,7 @@ kernel = { i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; + i386_xen_pvh = kern/i386/dl.c; i386_coreboot = kern/i386/coreboot/init.c; i386_multiboot = kern/i386/coreboot/init.c; @@ -222,6 +226,14 @@ kernel = { xen = disk/xen/xendisk.c; xen = commands/boot.c; + i386_xen_pvh = commands/boot.c; + i386_xen_pvh = disk/xen/xendisk.c; + i386_xen_pvh = kern/i386/tsc.c; + i386_xen_pvh = kern/i386/xen/tsc.c; + i386_xen_pvh = kern/i386/xen/pvh.c; + i386_xen_pvh = kern/xen/init.c; + i386_xen_pvh = term/xen/console.c; + ia64_efi = kern/ia64/efi/startup.S; ia64_efi = kern/ia64/efi/init.c; ia64_efi = kern/ia64/dl.c; @@ -801,6 +813,7 @@ module = { name = cpuid; common = commands/i386/cpuid.c; enable = x86; + enable = i386_xen_pvh; enable = i386_xen; enable = x86_64_xen; }; @@ -860,6 +873,7 @@ module = { i386_coreboot = lib/i386/halt.c; i386_qemu = lib/i386/halt.c; xen = lib/xen/halt.c; + i386_xen_pvh = lib/xen/halt.c; efi = lib/efi/halt.c; ieee1275 = lib/ieee1275/halt.c; emu = lib/emu/halt.c; @@ -877,6 +891,7 @@ module = { mips_loongson = lib/mips/loongson/reboot.c; mips_qemu_mips = lib/mips/qemu_mips/reboot.c; xen = lib/xen/reboot.c; + i386_xen_pvh = lib/xen/reboot.c; uboot = lib/uboot/reboot.c; arm_coreboot = lib/dummy/reboot.c; common = commands/reboot.c; @@ -1571,12 +1586,18 @@ module = { x86 = lib/i386/relocator16.S; x86 = lib/i386/relocator32.S; x86 = lib/i386/relocator64.S; + i386_xen_pvh = lib/i386/relocator16.S; + i386_xen_pvh = lib/i386/relocator32.S; + i386_xen_pvh = lib/i386/relocator64.S; i386 = lib/i386/relocator_asm.S; + i386_xen_pvh = lib/i386/relocator_asm.S; x86_64 = lib/x86_64/relocator_asm.S; i386_xen = lib/i386/relocator_asm.S; x86_64_xen = lib/x86_64/relocator_asm.S; x86 = lib/i386/relocator.c; x86 = lib/i386/relocator_common_c.c; + i386_xen_pvh = lib/i386/relocator.c; + i386_xen_pvh = lib/i386/relocator_common_c.c; ieee1275 = lib/ieee1275/relocator.c; efi = lib/efi/relocator.c; mips = lib/mips/relocator_asm.S; @@ -1595,6 +1616,7 @@ module = { enable = mips; enable = powerpc; enable = x86; + enable = i386_xen_pvh; enable = xen; }; @@ -1609,6 +1631,7 @@ module = { sparc64_ieee1275 = lib/ieee1275/cmos.c; powerpc_ieee1275 = lib/ieee1275/cmos.c; xen = lib/xen/datetime.c; + i386_xen_pvh = lib/xen/datetime.c; mips_arc = lib/arc/datetime.c; enable = noemu; @@ -1692,6 +1715,7 @@ module = { common = loader/multiboot.c; common = loader/multiboot_mbi2.c; enable = x86; + enable = i386_xen_pvh; enable = mips; }; @@ -1699,8 +1723,10 @@ module = { name = multiboot; common = loader/multiboot.c; x86 = loader/i386/multiboot_mbi.c; + i386_xen_pvh = loader/i386/multiboot_mbi.c; extra_dist = loader/multiboot_elfxx.c; enable = x86; + enable = i386_xen_pvh; }; module = { @@ -1712,8 +1738,10 @@ module = { module = { name = linux; x86 = loader/i386/linux.c; + i386_xen_pvh = loader/i386/linux.c; xen = loader/i386/xen.c; i386_pc = lib/i386/pc/vesa_modes_table.c; + i386_xen_pvh = lib/i386/pc/vesa_modes_table.c; mips = loader/mips/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; @@ -1801,6 +1829,8 @@ module = { common = mmap/mmap.c; x86 = mmap/i386/uppermem.c; x86 = mmap/i386/mmap.c; + i386_xen_pvh = mmap/i386/uppermem.c; + i386_xen_pvh = mmap/i386/mmap.c; i386_pc = mmap/i386/pc/mmap.c; i386_pc = mmap/i386/pc/mmap_helper.S; @@ -1810,6 +1840,7 @@ module = { mips = mmap/mips/uppermem.c; enable = x86; + enable = i386_xen_pvh; enable = ia64_efi; enable = arm_efi; enable = arm64_efi; @@ -2049,6 +2080,7 @@ module = { name = legacy_password_test; common = tests/legacy_password_test.c; enable = i386_pc; + enable = i386_xen_pvh; enable = i386_efi; enable = x86_64_efi; enable = emu; @@ -2247,6 +2279,7 @@ module = { xen = lib/i386/pc/vesa_modes_table.c; enable = i386_pc; + enable = i386_xen_pvh; enable = i386_efi; enable = x86_64_efi; enable = emu; @@ -2290,10 +2323,12 @@ module = { module = { name = backtrace; x86 = lib/i386/backtrace.c; + i386_xen_pvh = lib/i386/backtrace.c; i386_xen = lib/i386/backtrace.c; x86_64_xen = lib/i386/backtrace.c; common = lib/backtrace.c; enable = x86; + enable = i386_xen_pvh; enable = i386_xen; enable = x86_64_xen; }; From a40b219e269ac407c10a569ce6b0c5d7f419d127 Mon Sep 17 00:00:00 2001 From: Hans van Kranenburg Date: Fri, 7 Dec 2018 13:11:44 +0100 Subject: [PATCH 0897/1167] grub-module-verifier: Ignore all_video for xen_pvh This solves the build failing with "Error: no symbol table and no .moddeps section" Also see: - 6371e9c10433578bb236a8284ddb9ce9e201eb59 - https://savannah.gnu.org/bugs/?49012 Signed-off-by: Hans van Kranenburg Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- util/grub-module-verifier.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 03ba1ab43..979999cb9 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -129,6 +129,7 @@ struct platform_whitelist { static struct platform_whitelist whitelists[] = { {"i386", "xen", (const char *[]) {"all_video", 0}}, + {"i386", "xen_pvh", (const char *[]) {"all_video", 0}}, {"x86_64", "xen", (const char *[]) {"all_video", 0}}, {"sparc64", "ieee1275", (const char *[]) {"all_video", 0}}, From 9bce25213a44553c71527776f65fabc3b729c2f3 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:45 +0100 Subject: [PATCH 0898/1167] xen: Use elfnote defines instead of plain numbers In order to avoid using plain integers for the ELF notes use the available Xen include instead. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- util/grub-mkimagexx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a483c674c..784ed1a52 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -48,6 +48,8 @@ #include #include +#include + #pragma GCC diagnostic ignored "-Wcast-align" #define GRUB_MKIMAGEXX @@ -341,7 +343,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof (PACKAGE_NAME)); - note_ptr->n_type = grub_host_to_target32 (6); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_GUEST_OS); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -352,7 +354,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("generic")); - note_ptr->n_type = grub_host_to_target32 (8); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_LOADER); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -363,7 +365,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("xen-3.0")); - note_ptr->n_type = grub_host_to_target32 (5); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_XEN_VERSION); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -374,7 +376,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof); - note_ptr->n_type = grub_host_to_target32 (1); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_ENTRY); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -385,7 +387,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof); - note_ptr->n_type = grub_host_to_target32 (3); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_VIRT_BASE); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -398,7 +400,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("yes,bimodal")); - note_ptr->n_type = grub_host_to_target32 (9); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_PAE_MODE); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); From 78899c42d74d638a48c9b3f0f25f39445b3c1d4c Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:46 +0100 Subject: [PATCH 0899/1167] xen_pvh: Support building a standalone image Support mkimage for xen_pvh. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- include/grub/util/mkimage.h | 3 ++- util/grub-mkimage32.c | 4 +++- util/grub-mkimage64.c | 4 +++- util/grub-mkimagexx.c | 44 +++++++++++++++++++++++++++++++++---- util/mkimage.c | 23 ++++++++++++++++++- 5 files changed, 70 insertions(+), 8 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index b3a5ca132..ba9f568f6 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -71,7 +71,8 @@ struct grub_install_image_target_desc IMAGE_I386_IEEE1275, IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, - IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO + IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO, + IMAGE_XEN_PVH } id; enum { diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c index 1f2ccccd2..026a2dd59 100644 --- a/util/grub-mkimage32.c +++ b/util/grub-mkimage32.c @@ -17,7 +17,9 @@ # define ELF_R_SYM(val) ELF32_R_SYM(val) # define ELF_R_TYPE(val) ELF32_R_TYPE(val) # define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) -#define XEN_NOTE_SIZE 132 + +#define XEN_NOTE_SIZE 132 +#define XEN_PVH_NOTE_SIZE 20 #ifndef GRUB_MKIMAGEXX #include "grub-mkimagexx.c" diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c index 4ff72a625..170defb40 100644 --- a/util/grub-mkimage64.c +++ b/util/grub-mkimage64.c @@ -17,7 +17,9 @@ # define ELF_R_SYM(val) ELF64_R_SYM(val) # define ELF_R_TYPE(val) ELF64_R_TYPE(val) # define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) -#define XEN_NOTE_SIZE 120 + +#define XEN_NOTE_SIZE 120 +#define XEN_PVH_NOTE_SIZE 24 #ifndef GRUB_MKIMAGEXX #include "grub-mkimagexx.c" diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 784ed1a52..e94a721b4 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -229,12 +229,12 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc phnum++; footer_size += sizeof (struct grub_ieee1275_note); } - if (image_target->id == IMAGE_XEN) + if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XEN_PVH) { phnum++; shnum++; string_size += sizeof (".xen"); - footer_size += XEN_NOTE_SIZE; + footer_size += (image_target->id == IMAGE_XEN) ? XEN_NOTE_SIZE : XEN_PVH_NOTE_SIZE; } header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr) + shnum * sizeof (*shdr) + string_size, layout->align); @@ -421,6 +421,39 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc phdr->p_offset = grub_host_to_target32 (header_size + program_size); } + if (image_target->id == IMAGE_XEN_PVH) + { + char *note_start = (elf_img + program_size + header_size); + Elf_Nhdr *note_ptr; + char *ptr = (char *) note_start; + + grub_util_info ("adding XEN NOTE segment"); + + /* Phys32 Entry. */ + note_ptr = (Elf_Nhdr *) ptr; + note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); + note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_PHYS32_ENTRY); + ptr += sizeof (Elf_Nhdr); + memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); + ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); + memset (ptr, 0, image_target->voidp_sizeof); + *(grub_uint32_t *) ptr = GRUB_KERNEL_I386_XEN_PVH_LINK_ADDR; + ptr += image_target->voidp_sizeof; + + assert (XEN_PVH_NOTE_SIZE == (ptr - note_start)); + + phdr++; + phdr->p_type = grub_host_to_target32 (PT_NOTE); + phdr->p_flags = grub_host_to_target32 (PF_R); + phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof); + phdr->p_vaddr = 0; + phdr->p_paddr = 0; + phdr->p_filesz = grub_host_to_target32 (XEN_PVH_NOTE_SIZE); + phdr->p_memsz = 0; + phdr->p_offset = grub_host_to_target32 (header_size + program_size); + } + if (note) { int note_size = sizeof (struct grub_ieee1275_note); @@ -496,7 +529,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_entsize = grub_host_to_target32 (0); shdr++; - if (image_target->id == IMAGE_XEN) + if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XEN_PVH) { memcpy (ptr, ".xen", sizeof (".xen")); shdr->sh_name = grub_host_to_target32 (ptr - str_start); @@ -504,7 +537,10 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size); shdr->sh_offset = grub_host_to_target_addr (program_size + header_size); - shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE); + if (image_target->id == IMAGE_XEN) + shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE); + else + shdr->sh_size = grub_host_to_target32 (XEN_PVH_NOTE_SIZE); shdr->sh_link = grub_host_to_target32 (0); shdr->sh_info = grub_host_to_target32 (0); shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof); diff --git a/util/mkimage.c b/util/mkimage.c index b2f43fea6..353bb1098 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -132,6 +132,24 @@ static const struct grub_install_image_target_desc image_targets[] = .link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR, .default_compression = GRUB_COMPRESSION_LZMA }, + { + .dirname = "i386-xen_pvh", + .names = { "i386-xen_pvh", NULL }, + .voidp_sizeof = 4, + .bigendian = 0, + .id = IMAGE_XEN_PVH, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = TARGET_NO_FIELD, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .elf_target = EM_386, + .section_align = 1, + .vaddr_offset = 0, + .link_addr = GRUB_KERNEL_I386_XEN_PVH_LINK_ADDR, + .mod_align = GRUB_KERNEL_I386_XEN_PVH_MOD_ALIGN, + .link_align = 4 + }, { .dirname = "i386-pc", .names = { "i386-pc-pxe", NULL }, @@ -860,7 +878,8 @@ grub_install_generate_image (const char *dir, const char *prefix, else kernel_img = grub_mkimage_load_image64 (kernel_path, total_module_size, &layout, image_target); - if (image_target->id == IMAGE_XEN && layout.align < 4096) + if ((image_target->id == IMAGE_XEN || image_target->id == IMAGE_XEN_PVH) && + layout.align < 4096) layout.align = 4096; if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS) @@ -1103,6 +1122,7 @@ grub_install_generate_image (const char *dir, const char *prefix, case IMAGE_MIPS_ARC: case IMAGE_QEMU_MIPS_FLASH: case IMAGE_XEN: + case IMAGE_XEN_PVH: break; case IMAGE_SPARC64_AOUT: case IMAGE_SPARC64_RAW: @@ -1679,6 +1699,7 @@ grub_install_generate_image (const char *dir, const char *prefix, case IMAGE_LOONGSON_ELF: case IMAGE_PPC: case IMAGE_XEN: + case IMAGE_XEN_PVH: case IMAGE_COREBOOT: case IMAGE_I386_IEEE1275: { From 90b7b14fa5293c83c0645bfdcf4ef0cdac230d09 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:47 +0100 Subject: [PATCH 0900/1167] xen_pvh: Support grub-install for xen_pvh Add xen_pvh support to grub-install. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- include/grub/util/install.h | 1 + util/grub-install-common.c | 1 + util/grub-install.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 0dba8b67f..af2bf65d7 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -100,6 +100,7 @@ enum grub_install_plat GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS, GRUB_INSTALL_PLATFORM_I386_XEN, GRUB_INSTALL_PLATFORM_X86_64_XEN, + GRUB_INSTALL_PLATFORM_I386_XEN_PVH, GRUB_INSTALL_PLATFORM_ARM64_EFI, GRUB_INSTALL_PLATFORM_ARM_COREBOOT, GRUB_INSTALL_PLATFORM_MAX diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 0a2e24a79..1b1cb43b4 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -716,6 +716,7 @@ static struct [GRUB_INSTALL_PLATFORM_X86_64_EFI] = { "x86_64", "efi" }, [GRUB_INSTALL_PLATFORM_I386_XEN] = { "i386", "xen" }, [GRUB_INSTALL_PLATFORM_X86_64_XEN] = { "x86_64", "xen" }, + [GRUB_INSTALL_PLATFORM_I386_XEN_PVH] = { "i386", "xen_pvh" }, [GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON] = { "mipsel", "loongson" }, [GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS] = { "mipsel", "qemu_mips" }, [GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS] = { "mips", "qemu_mips" }, diff --git a/util/grub-install.c b/util/grub-install.c index 78d0138cb..4a0a66168 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -496,6 +496,7 @@ have_bootdev (enum grub_install_plat pl) case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: return 0; /* pacify warning. */ @@ -908,6 +909,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_ARM_UBOOT: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: break; case GRUB_INSTALL_PLATFORM_I386_QEMU: @@ -955,6 +957,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: free (install_device); install_device = NULL; break; @@ -1462,6 +1465,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_ARM_UBOOT: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: grub_util_warn ("%s", _("no hints available for your platform. Expect reduced performance")); break; /* pacify warning. */ @@ -1553,6 +1557,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: core_name = "core.elf"; snprintf (mkimage_target, sizeof (mkimage_target), "%s-%s", @@ -1645,6 +1650,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: break; /* pacify warning. */ case GRUB_INSTALL_PLATFORM_MAX: @@ -1911,6 +1917,7 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_I386_QEMU: case GRUB_INSTALL_PLATFORM_I386_XEN: case GRUB_INSTALL_PLATFORM_X86_64_XEN: + case GRUB_INSTALL_PLATFORM_I386_XEN_PVH: grub_util_warn ("%s", _("WARNING: no platform-specific install was performed")); break; From d789e70e26340bd35b36d595a948dbc399b9ffba Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:48 +0100 Subject: [PATCH 0901/1167] xen_pvh: Add support to configure Support platform i386/xen_pvh in configure. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 5e63c4af3..81a19afd5 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,7 @@ case "$target_cpu"-"$platform" in i386-efi) ;; x86_64-efi) ;; i386-xen) ;; + i386-xen_pvh) ;; x86_64-xen) ;; i386-pc) ;; i386-multiboot) ;; @@ -219,6 +220,7 @@ case "$platform" in multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;; efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;; xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;; + xen_pvh) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN_PVH=1" ;; ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;; uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;; qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;; @@ -1897,6 +1899,7 @@ AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot]) AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen]) +AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh]) AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson]) AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips]) From d3a5e812c5da935eba5bb283792cf820ffc85ac6 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 29 Nov 2018 11:28:08 -0800 Subject: [PATCH 0902/1167] verifiers: Verify commands executed by grub Pass all commands executed by GRUB to the verifiers layer. Most verifiers will ignore this, but some (such as the TPM verifier) want to be able to measure and log each command executed in order to ensure that the boot state is as expected. Signed-off-by: Matthew Garrett Reviewed-by: Daniel Kiper --- grub-core/script/execute.c | 27 ++++++++++++++++++++++++--- include/grub/verify.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index a8502d907..ee299fd0e 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -27,6 +27,7 @@ #include #include #include +#include /* Max digits for a char is 3 (0xFF is 255), similarly for an int it is sizeof (int) * 3, and one extra for a possible -ve sign. */ @@ -929,8 +930,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_err_t ret = 0; grub_script_function_t func = 0; char errnobuf[18]; - char *cmdname; - int argc; + char *cmdname, *cmdstring; + int argc, offset = 0, cmdlen = 0; + unsigned int i; char **args; int invert; struct grub_script_argv argv = { 0, 0, 0 }; @@ -939,6 +941,26 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args[0]) return grub_errno; + for (i = 0; i < argv.argc; i++) + { + cmdlen += grub_strlen (argv.args[i]) + 1; + } + + cmdstring = grub_malloc (cmdlen); + if (!cmdstring) + { + return grub_error (GRUB_ERR_OUT_OF_MEMORY, + N_("cannot allocate command buffer")); + } + + for (i = 0; i < argv.argc; i++) + { + offset += grub_snprintf (cmdstring + offset, cmdlen - offset, "%s ", + argv.args[i]); + } + cmdstring[cmdlen - 1] = '\0'; + grub_verify_string (cmdstring, GRUB_VERIFY_COMMAND); + grub_free (cmdstring); invert = 0; argc = argv.argc - 1; args = argv.args + 1; @@ -1163,4 +1185,3 @@ grub_script_execute (struct grub_script *script) return grub_script_execute_cmd (script->cmd); } - diff --git a/include/grub/verify.h b/include/grub/verify.h index 3d8f3e1a4..ea0491433 100644 --- a/include/grub/verify.h +++ b/include/grub/verify.h @@ -34,6 +34,7 @@ enum grub_verify_string_type { GRUB_VERIFY_KERNEL_CMDLINE, GRUB_VERIFY_MODULE_CMDLINE, + GRUB_VERIFY_COMMAND, }; struct grub_file_verifier From d6ca0a90cac78f40ea4a04ac6894784c5313cbe9 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 29 Nov 2018 11:28:09 -0800 Subject: [PATCH 0903/1167] verifiers: Core TPM support Add support for performing basic TPM measurements. Right now this only supports extending PCRs statically and only on UEFI. In future we might want to have some sort of mechanism for choosing which events get logged to which PCRs, but this seems like a good default policy and we can wait to see whether anyone has a use case before adding more complexity. Signed-off-by: Matthew Garrett Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 7 + grub-core/commands/efi/tpm.c | 333 +++++++++++++++++++++++++++++++++ grub-core/commands/tpm.c | 102 ++++++++++ grub-core/kern/i386/efi/init.c | 1 + include/grub/efi/tpm.h | 198 ++++++++++++++++++++ include/grub/tpm.h | 82 ++++++++ 6 files changed, 723 insertions(+) create mode 100644 grub-core/commands/efi/tpm.c create mode 100644 grub-core/commands/tpm.c create mode 100644 include/grub/efi/tpm.h create mode 100644 include/grub/tpm.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index f31301e04..e16fb06ba 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -2427,6 +2427,13 @@ module = { common = commands/testspeed.c; }; +module = { + name = tpm; + common = commands/tpm.c; + efi = commands/efi/tpm.c; + enable = x86_64_efi; +}; + module = { name = tr; common = commands/tr.c; diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c new file mode 100644 index 000000000..563ceba7a --- /dev/null +++ b/grub-core/commands/efi/tpm.c @@ -0,0 +1,333 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + * + * EFI TPM support code. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef TCG_PCR_EVENT grub_tpm_event_t; + +static grub_efi_guid_t tpm_guid = EFI_TPM_GUID; +static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID; + +static grub_efi_handle_t *grub_tpm_handle; +static grub_uint8_t grub_tpm_version; + +static grub_int8_t tpm1_present = -1; +static grub_int8_t tpm2_present = -1; + +static grub_efi_boolean_t +grub_tpm1_present (grub_efi_tpm_protocol_t *tpm) +{ + grub_efi_status_t status; + TCG_EFI_BOOT_SERVICE_CAPABILITY caps; + grub_uint32_t flags; + grub_efi_physical_address_t eventlog, lastevent; + + if (tpm1_present != -1) + return (grub_efi_boolean_t) tpm1_present; + + caps.Size = (grub_uint8_t) sizeof (caps); + + status = efi_call_5 (tpm->status_check, tpm, &caps, &flags, &eventlog, + &lastevent); + + if (status != GRUB_EFI_SUCCESS || caps.TPMDeactivatedFlag + || !caps.TPMPresentFlag) + return tpm1_present = 0; + + return tpm1_present = 1; +} + +static grub_efi_boolean_t +grub_tpm2_present (grub_efi_tpm2_protocol_t *tpm) +{ + grub_efi_status_t status; + EFI_TCG2_BOOT_SERVICE_CAPABILITY caps; + + caps.Size = (grub_uint8_t) sizeof (caps); + + if (tpm2_present != -1) + return (grub_efi_boolean_t) tpm2_present; + + status = efi_call_2 (tpm->get_capability, tpm, &caps); + + if (status != GRUB_EFI_SUCCESS || !caps.TPMPresentFlag) + return tpm2_present = 0; + + return tpm2_present = 1; +} + +static grub_efi_boolean_t +grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, + grub_efi_uint8_t *protocol_version) +{ + grub_efi_handle_t *handles; + grub_efi_uintn_t num_handles; + + if (grub_tpm_handle != NULL) + { + *tpm_handle = &grub_tpm_handle; + *protocol_version = grub_tpm_version; + return 1; + } + + handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm_guid, NULL, + &num_handles); + if (handles && num_handles > 0) + { + grub_tpm_handle = handles[0]; + *tpm_handle = handles[0]; + grub_tpm_version = 1; + *protocol_version = 1; + return 1; + } + + handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm2_guid, NULL, + &num_handles); + if (handles && num_handles > 0) + { + grub_tpm_handle = handles[0]; + *tpm_handle = handles[0]; + grub_tpm_version = 2; + *protocol_version = 2; + return 1; + } + + return 0; +} + +static grub_err_t +grub_tpm1_execute (grub_efi_handle_t tpm_handle, + PassThroughToTPM_InputParamBlock *inbuf, + PassThroughToTPM_OutputParamBlock *outbuf) +{ + grub_efi_status_t status; + grub_efi_tpm_protocol_t *tpm; + grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn); + grub_uint32_t outhdrsize = + sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut); + + tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!grub_tpm1_present (tpm)) + return 0; + + /* UEFI TPM protocol takes the raw operand block, no param block header. */ + status = efi_call_5 (tpm->pass_through_to_tpm, tpm, + inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, + outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); + + switch (status) + { + case GRUB_EFI_SUCCESS: + return 0; + case GRUB_EFI_DEVICE_ERROR: + return grub_error (GRUB_ERR_IO, N_("Command failed")); + case GRUB_EFI_INVALID_PARAMETER: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); + case GRUB_EFI_BUFFER_TOO_SMALL: + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("Output buffer too small")); + case GRUB_EFI_NOT_FOUND: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); + default: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); + } +} + +static grub_err_t +grub_tpm2_execute (grub_efi_handle_t tpm_handle, + PassThroughToTPM_InputParamBlock *inbuf, + PassThroughToTPM_OutputParamBlock *outbuf) +{ + grub_efi_status_t status; + grub_efi_tpm2_protocol_t *tpm; + grub_uint32_t inhdrsize = sizeof (*inbuf) - sizeof (inbuf->TPMOperandIn); + grub_uint32_t outhdrsize = + sizeof (*outbuf) - sizeof (outbuf->TPMOperandOut); + + tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!grub_tpm2_present (tpm)) + return 0; + + /* UEFI TPM protocol takes the raw operand block, no param block header. */ + status = efi_call_5 (tpm->submit_command, tpm, + inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, + outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); + + switch (status) + { + case GRUB_EFI_SUCCESS: + return 0; + case GRUB_EFI_DEVICE_ERROR: + return grub_error (GRUB_ERR_IO, N_("Command failed")); + case GRUB_EFI_INVALID_PARAMETER: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); + case GRUB_EFI_BUFFER_TOO_SMALL: + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("Output buffer too small")); + case GRUB_EFI_NOT_FOUND: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); + default: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); + } +} + +grub_err_t +grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, + PassThroughToTPM_OutputParamBlock *outbuf) +{ + grub_efi_handle_t tpm_handle; + grub_uint8_t protocol_version; + + /* Absence of a TPM isn't a failure. */ + if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) + return 0; + + if (protocol_version == 1) + return grub_tpm1_execute (tpm_handle, inbuf, outbuf); + else + return grub_tpm2_execute (tpm_handle, inbuf, outbuf); +} + +static grub_err_t +grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, + grub_size_t size, grub_uint8_t pcr, + const char *description) +{ + grub_tpm_event_t *event; + grub_efi_status_t status; + grub_efi_tpm_protocol_t *tpm; + grub_efi_physical_address_t lastevent; + grub_uint32_t algorithm; + grub_uint32_t eventnum = 0; + + tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!grub_tpm1_present (tpm)) + return 0; + + event = grub_zalloc (sizeof (*event) + grub_strlen (description) + 1); + if (!event) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, + N_("cannot allocate TPM event buffer")); + + event->PCRIndex = pcr; + event->EventType = EV_IPL; + event->EventSize = grub_strlen (description) + 1; + grub_memcpy (event->Event, description, event->EventSize); + + algorithm = TCG_ALG_SHA; + status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, + algorithm, event, &eventnum, &lastevent); + + switch (status) + { + case GRUB_EFI_SUCCESS: + return 0; + case GRUB_EFI_DEVICE_ERROR: + return grub_error (GRUB_ERR_IO, N_("Command failed")); + case GRUB_EFI_INVALID_PARAMETER: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); + case GRUB_EFI_BUFFER_TOO_SMALL: + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("Output buffer too small")); + case GRUB_EFI_NOT_FOUND: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); + default: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); + } +} + +static grub_err_t +grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, + grub_size_t size, grub_uint8_t pcr, + const char *description) +{ + EFI_TCG2_EVENT *event; + grub_efi_status_t status; + grub_efi_tpm2_protocol_t *tpm; + + tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!grub_tpm2_present (tpm)) + return 0; + + event = + grub_zalloc (sizeof (EFI_TCG2_EVENT) + grub_strlen (description) + 1); + if (!event) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, + N_("cannot allocate TPM event buffer")); + + event->Header.HeaderSize = sizeof (EFI_TCG2_EVENT_HEADER); + event->Header.HeaderVersion = 1; + event->Header.PCRIndex = pcr; + event->Header.EventType = EV_IPL; + event->Size = + sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1; + grub_memcpy (event->Event, description, grub_strlen (description) + 1); + + status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, + (grub_uint64_t) size, event); + + switch (status) + { + case GRUB_EFI_SUCCESS: + return 0; + case GRUB_EFI_DEVICE_ERROR: + return grub_error (GRUB_ERR_IO, N_("Command failed")); + case GRUB_EFI_INVALID_PARAMETER: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); + case GRUB_EFI_BUFFER_TOO_SMALL: + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("Output buffer too small")); + case GRUB_EFI_NOT_FOUND: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); + default: + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); + } +} + +grub_err_t +grub_tpm_log_event (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, + const char *description) +{ + grub_efi_handle_t tpm_handle; + grub_efi_uint8_t protocol_version; + + if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) + return 0; + + if (protocol_version == 1) + return grub_tpm1_log_event (tpm_handle, buf, size, pcr, description); + else + return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); +} diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c new file mode 100644 index 000000000..1441c494d --- /dev/null +++ b/grub-core/commands/tpm.c @@ -0,0 +1,102 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + * + * Core TPM support code. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +grub_err_t +grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, + const char *description) +{ + return grub_tpm_log_event (buf, size, pcr, description); +} + +static grub_err_t +grub_tpm_verify_init (grub_file_t io, + enum grub_file_type type __attribute__ ((unused)), + void **context, enum grub_verify_flags *flags) +{ + *context = io->name; + *flags |= GRUB_VERIFY_FLAGS_SINGLE_CHUNK; + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_tpm_verify_write (void *context, void *buf, grub_size_t size) +{ + return grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context); +} + +static grub_err_t +grub_tpm_verify_string (char *str, enum grub_verify_string_type type) +{ + const char *prefix = NULL; + char *description; + grub_err_t status; + + switch (type) + { + case GRUB_VERIFY_KERNEL_CMDLINE: + prefix = "kernel_cmdline: "; + break; + case GRUB_VERIFY_MODULE_CMDLINE: + prefix = "module_cmdline: "; + break; + case GRUB_VERIFY_COMMAND: + prefix = "grub_cmd: "; + break; + } + description = grub_malloc (grub_strlen (str) + grub_strlen (prefix) + 1); + if (!description) + return grub_errno; + grub_memcpy (description, prefix, grub_strlen (prefix)); + grub_memcpy (description + grub_strlen (prefix), str, + grub_strlen (str) + 1); + status = + grub_tpm_measure ((unsigned char *) str, grub_strlen (str), + GRUB_STRING_PCR, description); + grub_free (description); + return status; +} + +struct grub_file_verifier grub_tpm_verifier = { + .name = "tpm", + .init = grub_tpm_verify_init, + .write = grub_tpm_verify_write, + .verify_string = grub_tpm_verify_string, +}; + +GRUB_MOD_INIT (tpm) +{ + grub_verifier_register (&grub_tpm_verifier); +} + +GRUB_MOD_FINI (tpm) +{ + grub_verifier_unregister (&grub_tpm_verifier); +} diff --git a/grub-core/kern/i386/efi/init.c b/grub-core/kern/i386/efi/init.c index a28316cc6..da499aba0 100644 --- a/grub-core/kern/i386/efi/init.c +++ b/grub-core/kern/i386/efi/init.c @@ -27,6 +27,7 @@ #include #include #include +#include void grub_machine_init (void) diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h new file mode 100644 index 000000000..79c478832 --- /dev/null +++ b/include/grub/efi/tpm.h @@ -0,0 +1,198 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_EFI_TPM_HEADER +#define GRUB_EFI_TPM_HEADER 1 + +#define EFI_TPM_GUID {0xf541796d, 0xa62e, 0x4954, {0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }}; +#define EFI_TPM2_GUID {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }}; + +#define TCG_ALG_SHA 0x00000004 + +/* These structs are as defined in the TCG EFI Protocol Specification, family 2.0. */ + +struct __TCG_VERSION +{ + grub_efi_uint8_t Major; + grub_efi_uint8_t Minor; + grub_efi_uint8_t RevMajor; + grub_efi_uint8_t RevMinor; +}; +typedef struct __TCG_VERSION TCG_VERSION; + +struct __TCG_EFI_BOOT_SERVICE_CAPABILITY +{ + /* Size of this structure. */ + grub_efi_uint8_t Size; + TCG_VERSION StructureVersion; + TCG_VERSION ProtocolSpecVersion; + /* Hash algorithms supported by this TPM. */ + grub_efi_uint8_t HashAlgorithmBitmap; + /* 1 if TPM present. */ + char TPMPresentFlag; + /* 1 if TPM deactivated. */ + char TPMDeactivatedFlag; +}; +typedef struct __TCG_EFI_BOOT_SERVICE_CAPABILITY TCG_EFI_BOOT_SERVICE_CAPABILITY; + +struct tdTCG_PCR_EVENT +{ + grub_efi_uint32_t PCRIndex; + grub_efi_uint32_t EventType; + grub_efi_uint8_t digest[20]; + grub_efi_uint32_t EventSize; + grub_efi_uint8_t Event[1]; +}; +typedef struct tdTCG_PCR_EVENT TCG_PCR_EVENT; + +struct grub_efi_tpm_protocol +{ + grub_efi_status_t (*status_check) (struct grub_efi_tpm_protocol *this, + TCG_EFI_BOOT_SERVICE_CAPABILITY * + ProtocolCapability, + grub_efi_uint32_t *TCGFeatureFlags, + grub_efi_physical_address_t * + EventLogLocation, + grub_efi_physical_address_t * + EventLogLastEntry); + grub_efi_status_t (*hash_all) (struct grub_efi_tpm_protocol *this, + grub_efi_uint8_t *HashData, + grub_efi_uint64_t HashLen, + grub_efi_uint32_t AlgorithmId, + grub_efi_uint64_t *HashedDataLen, + grub_efi_uint8_t **HashedDataResult); + grub_efi_status_t (*log_event) (struct grub_efi_tpm_protocol *this, + TCG_PCR_EVENT *TCGLogData, + grub_efi_uint32_t *EventNumber, + grub_efi_uint32_t Flags); + grub_efi_status_t (*pass_through_to_tpm) (struct grub_efi_tpm_protocol * + this, + grub_efi_uint32_t + TpmInputParameterBlockSize, + grub_efi_uint8_t * + TpmInputParameterBlock, + grub_efi_uint32_t + TpmOutputParameterBlockSize, + grub_efi_uint8_t * + TpmOutputParameterBlock); + grub_efi_status_t (*log_extend_event) (struct grub_efi_tpm_protocol *this, + grub_efi_physical_address_t HashData, + grub_efi_uint64_t HashDataLen, + grub_efi_uint32_t AlgorithmId, + TCG_PCR_EVENT *TCGLogData, + grub_efi_uint32_t *EventNumber, + grub_efi_physical_address_t * + EventLogLastEntry); +}; + +typedef struct grub_efi_tpm_protocol grub_efi_tpm_protocol_t; + +typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_BITMAP; +typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_FORMAT; +typedef grub_efi_uint32_t EFI_TCG2_EVENT_ALGORITHM_BITMAP; + +struct tdEFI_TCG2_VERSION +{ + grub_efi_uint8_t Major; + grub_efi_uint8_t Minor; +} GRUB_PACKED; +typedef struct tdEFI_TCG2_VERSION EFI_TCG2_VERSION; + +struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY +{ + grub_efi_uint8_t Size; + EFI_TCG2_VERSION StructureVersion; + EFI_TCG2_VERSION ProtocolVersion; + EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; + EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs; + grub_efi_boolean_t TPMPresentFlag; + grub_efi_uint16_t MaxCommandSize; + grub_efi_uint16_t MaxResponseSize; + grub_efi_uint32_t ManufacturerID; + grub_efi_uint32_t NumberOfPcrBanks; + EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks; +}; +typedef struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY EFI_TCG2_BOOT_SERVICE_CAPABILITY; + +typedef grub_efi_uint32_t TCG_PCRINDEX; +typedef grub_efi_uint32_t TCG_EVENTTYPE; + +struct tdEFI_TCG2_EVENT_HEADER +{ + grub_efi_uint32_t HeaderSize; + grub_efi_uint16_t HeaderVersion; + TCG_PCRINDEX PCRIndex; + TCG_EVENTTYPE EventType; +} GRUB_PACKED; +typedef struct tdEFI_TCG2_EVENT_HEADER EFI_TCG2_EVENT_HEADER; + +struct tdEFI_TCG2_EVENT +{ + grub_efi_uint32_t Size; + EFI_TCG2_EVENT_HEADER Header; + grub_efi_uint8_t Event[1]; +} GRUB_PACKED; +typedef struct tdEFI_TCG2_EVENT EFI_TCG2_EVENT; + +struct grub_efi_tpm2_protocol +{ + grub_efi_status_t (*get_capability) (struct grub_efi_tpm2_protocol *this, + EFI_TCG2_BOOT_SERVICE_CAPABILITY * + ProtocolCapability); + grub_efi_status_t (*get_event_log) (struct grub_efi_tpm2_protocol *this, + EFI_TCG2_EVENT_LOG_FORMAT + EventLogFormat, + grub_efi_physical_address_t * + EventLogLocation, + grub_efi_physical_address_t * + EventLogLastEntry, + grub_efi_boolean_t * EventLogTruncated); + grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol * + this, grub_efi_uint64_t Flags, + grub_efi_physical_address_t * + DataToHash, + grub_efi_uint64_t DataToHashLen, + EFI_TCG2_EVENT *EfiTcgEvent); + grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, + grub_efi_uint32_t + InputParameterBlockSize, + grub_efi_uint8_t *InputParameterBlock, + grub_efi_uint32_t + OutputParameterBlockSize, + grub_efi_uint8_t * + OutputParameterBlock); + grub_efi_status_t (*get_active_pcr_blanks) (struct grub_efi_tpm2_protocol * + this, + grub_efi_uint32_t * + ActivePcrBanks); + grub_efi_status_t (*set_active_pcr_banks) (struct grub_efi_tpm2_protocol * + this, + grub_efi_uint32_t + ActivePcrBanks); + grub_efi_status_t (*get_result_of_set_active_pcr_banks) (struct + grub_efi_tpm2_protocol + *this, + grub_efi_uint32_t * + OperationPresent, + grub_efi_uint32_t * + Response); +}; + +typedef struct grub_efi_tpm2_protocol grub_efi_tpm2_protocol_t; + +#endif diff --git a/include/grub/tpm.h b/include/grub/tpm.h new file mode 100644 index 000000000..dfcbe8372 --- /dev/null +++ b/include/grub/tpm.h @@ -0,0 +1,82 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_TPM_HEADER +#define GRUB_TPM_HEADER 1 + +#define GRUB_STRING_PCR 8 +#define GRUB_BINARY_PCR 9 + +#define SHA1_DIGEST_SIZE 20 + +#define TPM_BASE 0x0 +#define TPM_SUCCESS TPM_BASE +#define TPM_AUTHFAIL (TPM_BASE + 0x1) +#define TPM_BADINDEX (TPM_BASE + 0x2) + +#define TPM_TAG_RQU_COMMAND 0x00C1 +#define TPM_ORD_Extend 0x14 + +#define EV_IPL 0x0d + +/* TCG_PassThroughToTPM Input Parameter Block. */ +typedef struct +{ + grub_uint16_t IPBLength; + grub_uint16_t Reserved1; + grub_uint16_t OPBLength; + grub_uint16_t Reserved2; + grub_uint8_t TPMOperandIn[1]; +} GRUB_PACKED PassThroughToTPM_InputParamBlock; + +/* TCG_PassThroughToTPM Output Parameter Block. */ +typedef struct +{ + grub_uint16_t OPBLength; + grub_uint16_t Reserved; + grub_uint8_t TPMOperandOut[1]; +} GRUB_PACKED PassThroughToTPM_OutputParamBlock; + +typedef struct +{ + grub_uint16_t tag; + grub_uint32_t paramSize; + grub_uint32_t ordinal; + grub_uint32_t pcrNum; + /* The 160 bit value representing the event to be recorded. */ + grub_uint8_t inDigest[SHA1_DIGEST_SIZE]; +} GRUB_PACKED ExtendIncoming; + +/* TPM_Extend Outgoing Operand. */ +typedef struct +{ + grub_uint16_t tag; + grub_uint32_t paramSize; + grub_uint32_t returnCode; + /* The PCR value after execution of the command. */ + grub_uint8_t outDigest[SHA1_DIGEST_SIZE]; +} GRUB_PACKED ExtendOutgoing; + +grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, + grub_uint8_t pcr, const char *description); +grub_err_t grub_tpm_init (void); +grub_err_t grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, + PassThroughToTPM_OutputParamBlock *outbuf); +grub_err_t grub_tpm_log_event (unsigned char *buf, grub_size_t size, + grub_uint8_t pcr, const char *description); +#endif From a791dc0e3501e2932321a257564a3f27a50673bf Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 29 Nov 2018 11:28:10 -0800 Subject: [PATCH 0904/1167] verifiers: Add TPM documentation Describe the behaviour of GRUB when the TPM module is in use. Signed-off-by: Matthew Garrett Reviewed-by: Daniel Kiper --- docs/grub.texi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 471d97c95..ecaba9d5c 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5545,6 +5545,7 @@ environment variables and commands are listed in the same order. * Authentication and authorisation:: Users and access control * Using digital signatures:: Booting digitally signed code * UEFI secure boot and shim:: Booting digitally signed PE files +* Measured Boot:: Measuring boot components @end menu @node Authentication and authorisation @@ -5721,6 +5722,43 @@ mentioned requirements are enforced by the shim_lock module. And itself it is a persistent module which means that it cannot be unloaded if it was loaded into the memory. +@node Measured Boot +@section Measuring boot components + +If the tpm module is loaded and the platform has a Trusted Platform Module +installed, GRUB will log each command executed and each file loaded into the +TPM event log and extend the PCR values in the TPM correspondingly. All events +will be logged into the PCR described below with a type of EV_IPL and an +event description as described below. + +@multitable @columnfractions 0.3 0.1 0.6 +@headitem Event type @tab PCR @tab Description +@item Command +@tab 8 +@tab All executed commands (including those from configuration files) will be +logged and measured as entered with a prefix of ``grub_cmd: `` +@item Kernel command line +@tab 8 +@tab Any command line passed to a kernel will be logged and measured as entered +with a prefix of ``kernel_cmdline: '' +@item Module command line +@tab 8 +@tab Any command line passed to a kernel module will be logged and measured as +entered with a prefix of ``module_cmdline: `` +@item Files +@tab 9 +@tab Any file read by GRUB will be logged and measured with a descriptive text +corresponding to the filename. +@end multitable + +GRUB will not measure its own @file{core.img} - it is expected that firmware +will carry this out. GRUB will also not perform any measurements until the +tpm module is loaded. As such it is recommended that the tpm module be built +into @file{core.img} in order to avoid a potential gap in measurement between +@file{core.img} being loaded and the tpm module being loaded. + +Measured boot is currently only supported on EFI platforms. + @node Platform limitations @chapter Platform limitations From ad0ea7c444234ca519a3b528ddc70fff45810e25 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 17 Dec 2018 22:00:24 +0100 Subject: [PATCH 0905/1167] grub-core/loader/efi/fdt.c: Do not copy random memory We should not try to copy any memory area which is outside of the original fdt. If this extra memory is controlled by a hypervisor this might end with a crash. Signed-off-by: Heinrich Schuchardt Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/efi/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index a18ca8ccb..ee9c5592c 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -66,7 +66,7 @@ grub_fdt_load (grub_size_t additional_size) if (raw_fdt) { - grub_memmove (fdt, raw_fdt, size); + grub_memmove (fdt, raw_fdt, size - additional_size); grub_fdt_set_totalsize (fdt, size); } else From e86f6aafb8de4123a8738e540f83afc9f407399a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Gro=C3=9Fe?= Date: Sat, 8 Dec 2018 14:35:03 +0100 Subject: [PATCH 0906/1167] grub-mkconfig/20_linux_xen: Support multiple early initrd images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for multiple, shared, early initrd images. These early images will be loaded in the order declared, and all will be loaded before the initrd image. While many classes of data can be provided by early images, the immediate use case would be for distributions to provide CPU microcode to mitigate the Meltdown and Spectre vulnerabilities. Xen has also support to load microcode updates provided as additional modules by the bootloader. There are two environment variables provided for declaring the early images. * GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare images that are provided by the distribution or installed packages. If undeclared, this will default to a set of common microcode image names. * GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User images will be loaded after the stock images. These separate configurations allow the distribution and user to declare different image sets without clobbering each other. This also makes a minor update to ensure that UUID partition labels stay disabled when no initrd image is found, even if early images are present. This is basically a copy of a698240d "grub-mkconfig/10_linux: Support multiple early initrd images" by Matthew S. Turnbull. Signed-off-by: Peter Große Reviewed-by: Daniel Kiper --- util/grub.d/20_linux_xen.in | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index d22626e30..96179ea61 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -139,9 +139,13 @@ EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" + initrd_path= + for i in ${initrd}; do + initrd_path="${initrd_path} ${rel_dirname}/${i}" + done sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - ${module_loader} --nounzip ${rel_dirname}/${initrd} + ${module_loader} --nounzip $(echo $initrd_path) EOF fi sed "s/^/$submenu_indentation/" << EOF @@ -228,6 +232,15 @@ while [ "x${xen_list}" != "x" ] ; do module_loader="module" fi fi + + initrd_early= + for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ + ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do + if test -e "${xen_dirname}/${i}" ; then + initrd_early="${initrd_early} ${i}" + fi + done + while [ "x$list" != "x" ] ; do linux=`version_find_latest $list` gettext_printf "Found linux image: %s\n" "$linux" >&2 @@ -238,7 +251,7 @@ while [ "x${xen_list}" != "x" ] ; do alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" - initrd= + initrd_real= for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ "initrd-${version}" "initramfs-${version}.img" \ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ @@ -248,13 +261,23 @@ while [ "x${xen_list}" != "x" ] ; do "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" ; do if test -e "${dirname}/${i}" ; then - initrd="$i" + initrd_real="$i" break fi done - if test -n "${initrd}" ; then - gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 - else + + initrd= + if test -n "${initrd_early}" || test -n "${initrd_real}"; then + initrd="${initrd_early} ${initrd_real}" + + initrd_display= + for i in ${initrd}; do + initrd_display="${initrd_display} ${dirname}/${i}" + done + gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 + fi + + if test -z "${initrd_real}"; then # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then From ed087f0460516737e174222f01e2bf6ccbd45674 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Jan 2019 14:54:39 +0000 Subject: [PATCH 0907/1167] pgp: Fix emu build and tests after pgp module renaming Commit b07feb8746c3bb845e3f0d33d37c0bded704d14d (verifiers: Rename verify module to pgp module) renamed the "verify" module to "pgp", but the GRUB_MOD_INIT and GRUB_MOD_FINI macros were left as "verify", which broke the emu target build; and file_filter_test still referred to the now non-existent "verify" module. Fix both of these. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/commands/pgp.c | 4 ++-- tests/file_filter_test.in | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c index 0487479af..d39846d8c 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -949,7 +949,7 @@ struct grub_file_verifier grub_pubkey_verifier = static grub_extcmd_t cmd, cmd_trust; static grub_command_t cmd_distrust, cmd_list; -GRUB_MOD_INIT(verify) +GRUB_MOD_INIT(pgp) { const char *val; struct grub_module_header *header; @@ -1008,7 +1008,7 @@ GRUB_MOD_INIT(verify) grub_verifier_register (&grub_pubkey_verifier); } -GRUB_MOD_FINI(verify) +GRUB_MOD_FINI(pgp) { grub_verifier_unregister (&grub_pubkey_verifier); grub_unregister_extcmd (cmd); diff --git a/tests/file_filter_test.in b/tests/file_filter_test.in index bfb638227..ed6abcb5a 100644 --- a/tests/file_filter_test.in +++ b/tests/file_filter_test.in @@ -19,7 +19,7 @@ grubshell=@builddir@/grub-shell . "@builddir@/grub-core/modinfo.sh" -filters="gzio xzio lzopio verify" +filters="gzio xzio lzopio pgp" modules="cat mpi" for mod in $(cut -d ' ' -f 2 "@builddir@/grub-core/crypto.lst" | sort -u); do From f8d1ad26781e8624092d4d9fef7238348a8f30b5 Mon Sep 17 00:00:00 2001 From: Max Tottenham Date: Mon, 14 Jan 2019 14:03:29 +0000 Subject: [PATCH 0908/1167] tpm: Fix bug in GRUB2 TPM module The value of tpm_handle changes between successive calls to grub_tpm_handle_find(), as instead of simply copying the stored pointer we end up taking the address of said pointer when using the cached value of grub_tpm_handle. This causes grub_efi_open_protocol() to return a nullptr in grub_tpm2_execute() and grub_tpm2_log_event(). Said nullptr goes unchecked and efi_call_5(tpm->hash_log_extend_event,...) ends up jumping to 0x0, Qemu crashes once video ROM is reached at 0xb0000. This patch seems to do the trick of fixing that bug, but we should also ensure that all calls to grub_efi_open_protocol() are checked so that we don't start executing low memory. Signed-off-by: Max Tottenham Reviewed-by: Matthew Garrett Reviewed-by: Daniel Kiper --- grub-core/commands/efi/tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index 563ceba7a..7475fd87b 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -89,7 +89,7 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, if (grub_tpm_handle != NULL) { - *tpm_handle = &grub_tpm_handle; + *tpm_handle = grub_tpm_handle; *protocol_version = grub_tpm_version; return 1; } From 088f7f56e5481ec6608d1268fa2c5cb4e2ff0ccf Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Tue, 22 Jan 2019 12:02:10 +0200 Subject: [PATCH 0909/1167] uboot: Add the missing disk write operation support uboot_disk_write() is currently lacking the write support to storage devices because, historically, those devices did not implement block_write() in U-Boot. The solution has been tested using a patched U-Boot loading and booting GRUB in a QEMU vexpress-a9 environment. The disk write operations were triggered with GRUB's save_env command. Signed-off-by: Cristian Ciocaltea Reviewed-by: Daniel Kiper --- grub-core/disk/uboot/ubootdisk.c | 22 ++++++++++++++++------ grub-core/kern/uboot/uboot.c | 16 ++++++++++++++++ include/grub/uboot/uboot.h | 3 ++- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/uboot/ubootdisk.c b/grub-core/disk/uboot/ubootdisk.c index a5ce07a99..584a9cbdf 100644 --- a/grub-core/disk/uboot/ubootdisk.c +++ b/grub-core/disk/uboot/ubootdisk.c @@ -264,13 +264,23 @@ uboot_disk_read (struct grub_disk *disk, } static grub_err_t -uboot_disk_write (struct grub_disk *disk __attribute__ ((unused)), - grub_disk_addr_t sector __attribute__ ((unused)), - grub_size_t size __attribute__ ((unused)), - const char *buf __attribute__ ((unused))) +uboot_disk_write (struct grub_disk *disk, + grub_disk_addr_t offset, grub_size_t numblocks, const char *buf) { - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "attempt to write (not supported)"); + struct ubootdisk_data *d; + int retval; + + d = disk->data; + + retval = grub_uboot_dev_write (d->dev, buf, numblocks, offset); + grub_dprintf ("ubootdisk", + "retval=%d, numblocks=%d, sector=%llu\n", + retval, numblocks, (grub_uint64_t) offset); + + if (retval != 0) + return grub_error (GRUB_ERR_IO, "U-Boot disk write error"); + + return GRUB_ERR_NONE; } static struct grub_disk_dev grub_ubootdisk_dev = { diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c index cf0168e62..be4816fe6 100644 --- a/grub-core/kern/uboot/uboot.c +++ b/grub-core/kern/uboot/uboot.c @@ -243,6 +243,22 @@ grub_uboot_dev_read (struct device_info *dev, void *buf, grub_size_t blocks, return retval; } +int +grub_uboot_dev_write (struct device_info *dev, const void *buf, + grub_size_t blocks, grub_uint32_t start) +{ + int retval; + + if (!OPEN_DEV (dev)) + return -1; + + if (!grub_uboot_syscall (API_DEV_WRITE, &retval, dev, buf, + &blocks, &start)) + return -1; + + return retval; +} + int grub_uboot_dev_recv (struct device_info *dev, void *buf, int size, int *real_size) diff --git a/include/grub/uboot/uboot.h b/include/grub/uboot/uboot.h index c122de6ab..194130345 100644 --- a/include/grub/uboot/uboot.h +++ b/include/grub/uboot/uboot.h @@ -72,7 +72,8 @@ int EXPORT_FUNC (grub_uboot_dev_enum) (void); struct device_info * EXPORT_FUNC (grub_uboot_dev_get) (int index); int EXPORT_FUNC (grub_uboot_dev_open) (struct device_info *dev); int EXPORT_FUNC (grub_uboot_dev_close) (struct device_info *dev); -int grub_uboot_dev_write (struct device_info *dev, void *buf, int *len); +int grub_uboot_dev_write (struct device_info *dev, const void *buf, + grub_size_t blocks, grub_uint32_t start); int grub_uboot_dev_read (struct device_info *dev, void *buf, grub_size_t blocks, grub_uint32_t start, grub_size_t * real_blocks); int EXPORT_FUNC (grub_uboot_dev_recv) (struct device_info *dev, void *buf, From a0e4ee533dc0c6a78ecc55e97ac0fb98755f7fe7 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 22 Jan 2019 16:59:41 +0000 Subject: [PATCH 0910/1167] linux, efi, arm*, fdt: Break FDT extra allocation space out into a #define A certain amount of dynamic space is required for the handover from GRUB/Linux-EFI-stub. This entails things like initrd addresses, address-cells entries and associated strings. But move this into a proper centralised #define rather than live-code it in the loader. Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 2 +- include/grub/fdt.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index c37295c0b..7c6d8daa1 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -71,7 +71,7 @@ finalize_params_linux (void) void *fdt; - fdt = grub_fdt_load (0x400); + fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); if (!fdt) goto failure; diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 158b1bc4b..e609c7e41 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -22,6 +22,9 @@ #include #include +/* Space required when preparing the /chosen node after boot has been called. */ +#define GRUB_EFI_LINUX_FDT_EXTRA_SPACE 0x400 + #define FDT_MAGIC 0xD00DFEED typedef struct { From 748e544fd0eb5fb618c4613f69612bc8c2eb65b6 Mon Sep 17 00:00:00 2001 From: Guillaume GARDET Date: Tue, 29 Jan 2019 09:09:45 +0100 Subject: [PATCH 0911/1167] arm: Move initrd upper to leave more space for kernel This patch allows to have bigger kernels. If the kernel grows, then it will overwrite the initrd when it is extracted. Signed-off-by: Guillaume GARDET Acked-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/loader/arm/linux.c | 2 +- include/grub/arm/linux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 67ed79359..51684914c 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -48,7 +48,7 @@ static const void *current_fdt; typedef void (*kernel_entry_t) (int, unsigned long, void *); #define LINUX_PHYS_OFFSET (0x00008000) -#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) +#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x03000000) #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) static grub_size_t diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 712ba17b9..d0b24d474 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -42,7 +42,7 @@ struct linux_arm_kernel_header { #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000) -# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) +# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000) # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type @@ -50,7 +50,7 @@ struct linux_arm_kernel_header { #include #include # define LINUX_ADDRESS (start_of_ram + 0x8000) -# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) +# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000) # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) static inline const void * grub_arm_firmware_get_boot_data (void) From e347f40c1af2457a634af71e3cc75e851c641847 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 28 Jan 2019 14:35:27 +0100 Subject: [PATCH 0912/1167] mkimage: Use EFI32_HEADER_SIZE define in arm-efi case The efi-arm case was defining its own header size calculation, even though it's 100% identical to the common EFI32_HEADER_SIZE definition. So let's clean it up to use the common define. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper Tested-by: Julien ROBIN --- util/mkimage.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index 353bb1098..16af12e0c 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -602,12 +602,7 @@ static const struct grub_install_image_target_desc image_targets[] = .decompressor_uncompressed_size = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD, .section_align = GRUB_PE32_SECTION_ALIGNMENT, - .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE - + GRUB_PE32_SIGNATURE_SIZE - + sizeof (struct grub_pe32_coff_header) - + sizeof (struct grub_pe32_optional_header) - + 4 * sizeof (struct grub_pe32_section_table), - GRUB_PE32_SECTION_ALIGNMENT), + .vaddr_offset = EFI32_HEADER_SIZE, .pe_target = GRUB_PE32_MACHINE_ARMTHUMB_MIXED, .elf_target = EM_ARM, }, From a51f953f4ee87cbfbf25a7df564304c5e9fea6a0 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 28 Jan 2019 14:35:28 +0100 Subject: [PATCH 0913/1167] mkimage: Align efi sections on 4k boundary There is UEFI firmware popping up in the wild now that implements stricter permission checks using NX and write protect page table entry bits. This means that firmware now may fail to load binaries if its individual sections are not page aligned, as otherwise it can not ensure permission boundaries. So let's bump all efi section alignments up to 4k (EFI page size). That way we will stay compatible going forward. Unfortunately our internals can't deal very well with a mismatch of alignment between the virtual and file offsets, so we have to also pad our target binary a bit. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper Tested-by: Julien ROBIN --- include/grub/efi/pe32.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 7d44732d2..207b0382e 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -20,6 +20,7 @@ #define GRUB_EFI_PE32_HEADER 1 #include +#include /* The MSDOS compatibility stub. This was copied from the output of objcopy, and it is not necessary to care about what this means. */ @@ -50,8 +51,14 @@ /* According to the spec, the minimal alignment is 512 bytes... But some examples (such as EFI drivers in the Intel Sample Implementation) use 32 bytes (0x20) instead, and it seems - to be working. For now, GRUB uses 512 bytes for safety. */ -#define GRUB_PE32_SECTION_ALIGNMENT 0x200 + to be working. + + However, there is firmware showing up in the field now with + page alignment constraints to guarantee that page protection + bits take effect. Because currently existing GRUB code can not + properly distinguish between in-memory and in-file layout, let's + bump all alignment to GRUB_EFI_PAGE_SIZE. */ +#define GRUB_PE32_SECTION_ALIGNMENT GRUB_EFI_PAGE_SIZE #define GRUB_PE32_FILE_ALIGNMENT GRUB_PE32_SECTION_ALIGNMENT struct grub_pe32_coff_header From 9223eff8f8025511938c7eec908d60bdaa74106a Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 28 Jan 2019 14:35:29 +0100 Subject: [PATCH 0914/1167] mkimage: Clarify file alignment in efi case There are a few spots in the PE generation code for EFI binaries that uses the section alignment rather than file alignment, even though the alignment is really only file bound. Replace those cases with the file alignment constant instead. Reported-by: Daniel Kiper Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper Tested-by: Julien ROBIN --- util/mkimage.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index 16af12e0c..cf1a47c94 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -66,14 +66,14 @@ + sizeof (struct grub_pe32_coff_header) \ + sizeof (struct grub_pe32_optional_header) \ + 4 * sizeof (struct grub_pe32_section_table), \ - GRUB_PE32_SECTION_ALIGNMENT) + GRUB_PE32_FILE_ALIGNMENT) #define EFI64_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \ + GRUB_PE32_SIGNATURE_SIZE \ + sizeof (struct grub_pe32_coff_header) \ + sizeof (struct grub_pe64_optional_header) \ + 4 * sizeof (struct grub_pe32_section_table), \ - GRUB_PE32_SECTION_ALIGNMENT) + GRUB_PE32_FILE_ALIGNMENT) static const struct grub_install_image_target_desc image_targets[] = { @@ -1227,10 +1227,10 @@ grub_install_generate_image (const char *dir, const char *prefix, header_size = EFI64_HEADER_SIZE; reloc_addr = ALIGN_UP (header_size + core_size, - image_target->section_align); + GRUB_PE32_FILE_ALIGNMENT); pe_size = ALIGN_UP (reloc_addr + layout.reloc_size, - image_target->section_align); + GRUB_PE32_FILE_ALIGNMENT); pe_img = xmalloc (reloc_addr + layout.reloc_size); memset (pe_img, 0, header_size); memcpy ((char *) pe_img + header_size, core_img, core_size); @@ -1280,7 +1280,7 @@ grub_install_generate_image (const char *dir, const char *prefix, o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); - o->file_alignment = grub_host_to_target32 (image_target->section_align); + o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT); o->image_size = grub_host_to_target32 (pe_size); o->header_size = grub_host_to_target32 (header_size); o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION); @@ -1315,7 +1315,7 @@ grub_install_generate_image (const char *dir, const char *prefix, o->code_base = grub_cpu_to_le32 (header_size); o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); - o->file_alignment = grub_host_to_target32 (image_target->section_align); + o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT); o->image_size = grub_host_to_target32 (pe_size); o->header_size = grub_host_to_target32 (header_size); o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION); From e4b84a0d7c1340f2e317cd05f5fcc607f6047d0d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:30:58 +0100 Subject: [PATCH 0915/1167] efi: Rename armxx to arch Some architectures want to boot Linux as plain UEFI binary. Today that really only encompasses ARM and AArch64, but going forward more architectures may adopt that model. So rename our internal API accordingly. Signed-off-by: Alexander Graf Acked-by: Leif Lindholm Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- grub-core/loader/arm64/linux.c | 10 +++++----- grub-core/loader/arm64/xen_boot.c | 6 +++--- include/grub/arm/linux.h | 2 +- include/grub/arm64/linux.h | 2 +- include/grub/efi/efi.h | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 7c6d8daa1..ef3e9f944 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -49,7 +49,7 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_armxx_efi_linux_check_image (struct linux_armxx_kernel_header * lh) +grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) { if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); @@ -110,7 +110,7 @@ failure: } grub_err_t -grub_armxx_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) +grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; @@ -173,7 +173,7 @@ grub_linux_boot (void) if (finalize_params_linux () != GRUB_ERR_NONE) return grub_errno; - return (grub_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, + return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, kernel_size, linux_args)); } @@ -287,7 +287,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_armxx_kernel_header lh; + struct linux_arch_kernel_header lh; grub_err_t err; grub_dl_ref (my_mod); @@ -307,7 +307,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (grub_armxx_efi_linux_check_image (&lh) != GRUB_ERR_NONE) + if (grub_arch_efi_linux_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index a742868a4..22cc25ecc 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -265,7 +265,7 @@ xen_boot (void) if (err) return err; - return grub_armxx_efi_linux_boot_image (xen_hypervisor->start, + return grub_arch_efi_linux_boot_image (xen_hypervisor->start, xen_hypervisor->size, xen_hypervisor->cmdline); } @@ -469,8 +469,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) goto fail; - if (grub_armxx_efi_linux_check_image - ((struct linux_armxx_kernel_header *) &sh) != GRUB_ERR_NONE) + if (grub_arch_efi_linux_check_image + ((struct linux_arch_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index d0b24d474..2e98a6689 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -36,7 +36,7 @@ struct linux_arm_kernel_header { #if defined(__arm__) # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE -# define linux_armxx_kernel_header linux_arm_kernel_header +# define linux_arch_kernel_header linux_arm_kernel_header #endif #if defined GRUB_MACHINE_UBOOT diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 8655067e0..4269adc6d 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -38,7 +38,7 @@ struct linux_arm64_kernel_header #if defined(__aarch64__) # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE -# define linux_armxx_kernel_header linux_arm64_kernel_header +# define linux_arch_kernel_header linux_arm64_kernel_header #endif #endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 2c6648d46..ec44aef7e 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -94,8 +94,8 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include -grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); -grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, +grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); +grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, char *args); #endif From 7b0f169c8054ac8b396adb8793784ad3007ba658 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:30:59 +0100 Subject: [PATCH 0916/1167] PE: Add RISC-V definitions The PE format defines magic numbers as well as relocation identifiers for RISC-V. Add them to our include file, so we can make use of them. Signed-off-by: Alexander Graf Reviewed-by: Leif Lindholm Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- include/grub/efi/pe32.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 207b0382e..0ed8781f0 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -77,6 +77,8 @@ struct grub_pe32_coff_header #define GRUB_PE32_MACHINE_X86_64 0x8664 #define GRUB_PE32_MACHINE_ARMTHUMB_MIXED 0x01c2 #define GRUB_PE32_MACHINE_ARM64 0xAA64 +#define GRUB_PE32_MACHINE_RISCV32 0x5032 +#define GRUB_PE32_MACHINE_RISCV64 0x5064 #define GRUB_PE32_RELOCS_STRIPPED 0x0001 #define GRUB_PE32_EXECUTABLE_IMAGE 0x0002 @@ -288,9 +290,12 @@ struct grub_pe32_fixup_block #define GRUB_PE32_REL_BASED_HIGHADJ 4 #define GRUB_PE32_REL_BASED_MIPS_JMPADDR 5 #define GRUB_PE32_REL_BASED_ARM_MOV32A 5 +#define GRUB_PE32_REL_BASED_RISCV_HI20 5 #define GRUB_PE32_REL_BASED_SECTION 6 #define GRUB_PE32_REL_BASED_REL 7 #define GRUB_PE32_REL_BASED_ARM_MOV32T 7 +#define GRUB_PE32_REL_BASED_RISCV_LOW12I 7 +#define GRUB_PE32_REL_BASED_RISCV_LOW12S 8 #define GRUB_PE32_REL_BASED_IA64_IMM64 9 #define GRUB_PE32_REL_BASED_DIR64 10 #define GRUB_PE32_REL_BASED_HIGH3ADJ 11 From cfec2093709e5a2a781f44422e15d5009be3d4f8 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:00 +0100 Subject: [PATCH 0917/1167] elf.h: Add RISC-V definitions The RISC-V ABI document outlines ELF header structure and relocation information. Pull the respective magic numbers into our elf header so we can make use of them. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- include/grub/elf.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/include/grub/elf.h b/include/grub/elf.h index c8492f9dc..c478933ee 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -247,6 +247,7 @@ typedef struct #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ #define EM_NUM 95 #define EM_AARCH64 183 /* ARM 64-bit architecture */ +#define EM_RISCV 243 /* RISC-V */ /* If it is necessary to assign new unofficial EM_* values, please pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the @@ -2473,6 +2474,63 @@ typedef Elf32_Addr Elf32_Conflict; #define R_X86_64_NUM 24 +/* RISC-V relocations */ +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JUMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +#define R_RISCV_BRANCH 16 +#define R_RISCV_JAL 17 +#define R_RISCV_CALL 18 +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 +#define R_RISCV_LO12_I 27 +#define R_RISCV_LO12_S 28 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 +#define R_RISCV_GNU_VTENTRY 42 +#define R_RISCV_ALIGN 43 +#define R_RISCV_RVC_BRANCH 44 +#define R_RISCV_RVC_JUMP 45 +#define R_RISCV_LUI 46 +#define R_RISCV_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 + #ifdef GRUB_TARGET_WORDSIZE #if GRUB_TARGET_WORDSIZE == 32 From ff6871831d085fbaedc72de3bfd86783e339ab29 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:01 +0100 Subject: [PATCH 0918/1167] RISC-V: Add setjmp implementation This patch adds a 32/64 capable setjmp implementation for RISC-V. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- grub-core/lib/riscv/setjmp.S | 84 +++++++++++++++++++++++++++++++++++ include/grub/riscv32/setjmp.h | 27 +++++++++++ include/grub/riscv64/setjmp.h | 27 +++++++++++ 3 files changed, 138 insertions(+) create mode 100644 grub-core/lib/riscv/setjmp.S create mode 100644 include/grub/riscv32/setjmp.h create mode 100644 include/grub/riscv64/setjmp.h diff --git a/grub-core/lib/riscv/setjmp.S b/grub-core/lib/riscv/setjmp.S new file mode 100644 index 000000000..b48ef29ea --- /dev/null +++ b/grub-core/lib/riscv/setjmp.S @@ -0,0 +1,84 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include + + .file "setjmp.S" + +GRUB_MOD_LICENSE "GPLv3+" + + .text + +#if __riscv_xlen == 64 +#define STORE_IDX(reg, idx) sd reg, (idx*8)(a0) +#define LOAD_IDX(reg, idx) ld reg, (idx*8)(a0) +#else +#define STORE_IDX(reg, idx) sw reg, (idx*4)(a0) +#define LOAD_IDX(reg, idx) lw reg, (idx*4)(a0) +#endif + +/* + * int grub_setjmp (grub_jmp_buf env) + */ +FUNCTION(grub_setjmp) + /* Preserve all callee-saved registers and the SP */ + STORE_IDX(s0, 0) + STORE_IDX(s1, 1) + STORE_IDX(s2, 2) + STORE_IDX(s3, 3) + STORE_IDX(s4, 4) + STORE_IDX(s5, 5) + STORE_IDX(s6, 6) + STORE_IDX(s7, 7) + STORE_IDX(s8, 8) + STORE_IDX(s9, 9) + STORE_IDX(s10, 10) + STORE_IDX(s11, 11) + STORE_IDX(ra, 12) + STORE_IDX(sp, 13) + li a0, 0 + ret + +/* + * int grub_longjmp (grub_jmp_buf env, int val) + */ +FUNCTION(grub_longjmp) + LOAD_IDX(s0, 0) + LOAD_IDX(s1, 1) + LOAD_IDX(s2, 2) + LOAD_IDX(s3, 3) + LOAD_IDX(s4, 4) + LOAD_IDX(s5, 5) + LOAD_IDX(s6, 6) + LOAD_IDX(s7, 7) + LOAD_IDX(s8, 8) + LOAD_IDX(s9, 9) + LOAD_IDX(s10, 10) + LOAD_IDX(s11, 11) + LOAD_IDX(ra, 12) + LOAD_IDX(sp, 13) + + /* Move the return value in place, but return 1 if passed 0. */ + beq a1, zero, longjmp_1 + mv a0, a1 + ret + + longjmp_1: + li a0, 1 + ret diff --git a/include/grub/riscv32/setjmp.h b/include/grub/riscv32/setjmp.h new file mode 100644 index 000000000..5a2123846 --- /dev/null +++ b/include/grub/riscv32/setjmp.h @@ -0,0 +1,27 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_SETJMP_CPU_HEADER +#define GRUB_SETJMP_CPU_HEADER 1 + +typedef unsigned long long grub_jmp_buf[14]; + +int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; +void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn)); + +#endif /* ! GRUB_SETJMP_CPU_HEADER */ diff --git a/include/grub/riscv64/setjmp.h b/include/grub/riscv64/setjmp.h new file mode 100644 index 000000000..5a2123846 --- /dev/null +++ b/include/grub/riscv64/setjmp.h @@ -0,0 +1,27 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_SETJMP_CPU_HEADER +#define GRUB_SETJMP_CPU_HEADER 1 + +typedef unsigned long long grub_jmp_buf[14]; + +int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; +void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn)); + +#endif /* ! GRUB_SETJMP_CPU_HEADER */ From 4bcb1ac4f792985651b55d025cf86d6008ff4475 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:02 +0100 Subject: [PATCH 0919/1167] RISC-V: Add early startup code On entry, we need to save the system table pointer as well as our image handle. Add an early startup file that saves them and then brings us into our main function. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- grub-core/kern/riscv/efi/startup.S | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 grub-core/kern/riscv/efi/startup.S diff --git a/grub-core/kern/riscv/efi/startup.S b/grub-core/kern/riscv/efi/startup.S new file mode 100644 index 000000000..f2a7b2b1e --- /dev/null +++ b/grub-core/kern/riscv/efi/startup.S @@ -0,0 +1,48 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include + +#if __riscv_xlen == 64 +#define sl sd +#define ll ld +#else +#define sl sw +#define ll lw +#endif + + + .file "startup.S" + .text +FUNCTION(_start) + /* + * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in a1/a0. + */ + + ll a2, efi_image_handle_val + sl a0, 0(a2) + ll a2, efi_system_table_val + sl a1, 0(a2) + ll a2, grub_main_val + jr a2 +grub_main_val: + .quad EXT_C(grub_main) +efi_system_table_val: + .quad EXT_C(grub_efi_system_table) +efi_image_handle_val: + .quad EXT_C(grub_efi_image_handle) From 222a34304cf409ebcc2dab8ce022d50eb6f9c2fa Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:03 +0100 Subject: [PATCH 0920/1167] RISC-V: Add Linux load logic We currently only support to run grub on RISC-V as UEFI payload. Ideally, we also only want to support running Linux underneath as UEFI payload. Prepare that with some Linux boot stub code. Once the arm64 target is generalized, we can hook into that one and gain boot functionality. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Daniel Kiper --- grub-core/loader/riscv/linux.c | 59 ++++++++++++++++++++++++++++++++++ include/grub/riscv32/linux.h | 41 +++++++++++++++++++++++ include/grub/riscv64/linux.h | 43 +++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 grub-core/loader/riscv/linux.c create mode 100644 include/grub/riscv32/linux.h create mode 100644 include/grub/riscv64/linux.h diff --git a/grub-core/loader/riscv/linux.c b/grub-core/loader/riscv/linux.c new file mode 100644 index 000000000..d17c488e1 --- /dev/null +++ b/grub-core/loader/riscv/linux.c @@ -0,0 +1,59 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_err_t +grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet")); + + return grub_errno; +} + +static grub_err_t +grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet")); + + return grub_errno; +} + +static grub_command_t cmd_linux, cmd_initrd; + +GRUB_MOD_INIT (linux) +{ + cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, + N_("Load Linux.")); + cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, + N_("Load initrd.")); +} + +GRUB_MOD_FINI (linux) +{ + grub_unregister_command (cmd_linux); + grub_unregister_command (cmd_initrd); +} diff --git a/include/grub/riscv32/linux.h b/include/grub/riscv32/linux.h new file mode 100644 index 000000000..512b777c8 --- /dev/null +++ b/include/grub/riscv32/linux.h @@ -0,0 +1,41 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_RISCV32_LINUX_HEADER +#define GRUB_RISCV32_LINUX_HEADER 1 + +#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */ + +/* From linux/Documentation/riscv/booting.txt */ +struct linux_riscv_kernel_header +{ + grub_uint32_t code0; /* Executable code */ + grub_uint32_t code1; /* Executable code */ + grub_uint64_t text_offset; /* Image load offset */ + grub_uint64_t res0; /* reserved */ + grub_uint64_t res1; /* reserved */ + grub_uint64_t res2; /* reserved */ + grub_uint64_t res3; /* reserved */ + grub_uint64_t res4; /* reserved */ + grub_uint32_t magic; /* Magic number, little endian, "RSCV" */ + grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ +}; + +#define linux_arch_kernel_header linux_riscv_kernel_header + +#endif /* ! GRUB_RISCV32_LINUX_HEADER */ diff --git a/include/grub/riscv64/linux.h b/include/grub/riscv64/linux.h new file mode 100644 index 000000000..3630c30fb --- /dev/null +++ b/include/grub/riscv64/linux.h @@ -0,0 +1,43 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_RISCV64_LINUX_HEADER +#define GRUB_RISCV64_LINUX_HEADER 1 + +#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */ + +#define GRUB_EFI_PE_MAGIC 0x5A4D + +/* From linux/Documentation/riscv/booting.txt */ +struct linux_riscv_kernel_header +{ + grub_uint32_t code0; /* Executable code */ + grub_uint32_t code1; /* Executable code */ + grub_uint64_t text_offset; /* Image load offset */ + grub_uint64_t res0; /* reserved */ + grub_uint64_t res1; /* reserved */ + grub_uint64_t res2; /* reserved */ + grub_uint64_t res3; /* reserved */ + grub_uint64_t res4; /* reserved */ + grub_uint32_t magic; /* Magic number, little endian, "RSCV" */ + grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ +}; + +#define linux_arch_kernel_header linux_riscv_kernel_header + +#endif /* ! GRUB_RISCV64_LINUX_HEADER */ From e0d32cca1d5a0d8db9fb2e0fa43c86599c79f6a7 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:04 +0100 Subject: [PATCH 0921/1167] RISC-V: Add awareness for RISC-V reloations This patch adds awareness of RISC-V relocations throughout the grub tools as well as dynamic linkage and elf->PE relocation conversion support. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Daniel Kiper --- grub-core/kern/dl.c | 6 +- grub-core/kern/riscv/dl.c | 340 ++++++++++++++++++++++++++++++++++++ include/grub/dl.h | 6 +- util/grub-mkimagexx.c | 259 +++++++++++++++++++++++++++ util/grub-module-verifier.c | 56 ++++++ 5 files changed, 662 insertions(+), 5 deletions(-) create mode 100644 grub-core/kern/riscv/dl.c diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index f8d58f029..48eb5e7b6 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -225,7 +225,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) unsigned i; const Elf_Shdr *s; grub_size_t tsize = 0, talign = 1; -#if !defined (__i386__) && !defined (__x86_64__) +#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) grub_size_t tramp; grub_size_t got; grub_err_t err; @@ -241,7 +241,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) talign = s->sh_addralign; } -#if !defined (__i386__) && !defined (__x86_64__) +#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got); if (err) return err; @@ -304,7 +304,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) mod->segment = seg; } } -#if !defined (__i386__) && !defined (__x86_64__) +#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); mod->tramp = ptr; mod->trampptr = ptr; diff --git a/grub-core/kern/riscv/dl.c b/grub-core/kern/riscv/dl.c new file mode 100644 index 000000000..6fb8385ef --- /dev/null +++ b/grub-core/kern/riscv/dl.c @@ -0,0 +1,340 @@ +/* dl.c - arch-dependent part of loadable module support */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include +#include +#include +#include +#include + +/* + * Instructions and instruction encoding are documented in the RISC-V + * specification. This file is based on version 2.2: + * + * https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf + */ +#define LDR 0x58000050 +#define BR 0xd61f0200 + +/* + * Check if EHDR is a valid ELF header. + */ +grub_err_t +grub_arch_dl_check_header (void *ehdr) +{ + Elf_Ehdr *e = ehdr; + + /* Check the magic numbers. */ + if (e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_RISCV) + return grub_error (GRUB_ERR_BAD_OS, + N_("invalid arch-dependent ELF magic")); + + return GRUB_ERR_NONE; +} + +#pragma GCC diagnostic ignored "-Wcast-align" + +/* Relocate symbols. */ +grub_err_t +grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, + Elf_Shdr *s, grub_dl_segment_t seg) +{ + Elf_Rel *rel, *max; + + for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset), + max = (Elf_Rel *) ((char *) rel + s->sh_size); + rel < max; + rel = (Elf_Rel *) ((char *) rel + s->sh_entsize)) + { + Elf_Sym *sym; + void *place; + grub_size_t sym_addr; + + if (rel->r_offset >= seg->size) + return grub_error (GRUB_ERR_BAD_MODULE, + "reloc offset is out of the segment"); + + sym = (Elf_Sym *) ((char *) mod->symtab + + mod->symsize * ELF_R_SYM (rel->r_info)); + + sym_addr = sym->st_value; + if (s->sh_type == SHT_RELA) + sym_addr += ((Elf_Rela *) rel)->r_addend; + + place = (void *) ((grub_addr_t) seg->addr + rel->r_offset); + + switch (ELF_R_TYPE (rel->r_info)) + { + case R_RISCV_32: + { + grub_uint32_t *abs_place = place; + + grub_dprintf ("dl", " reloc_abs32 %p => 0x%016llx\n", + place, (unsigned long long) sym_addr); + + *abs_place = (grub_uint32_t) sym_addr; + } + break; + case R_RISCV_64: + { + grub_size_t *abs_place = place; + + grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n", + place, (unsigned long long) sym_addr); + + *abs_place = (grub_size_t) sym_addr; + } + break; + + case R_RISCV_ADD8: + { + grub_uint8_t *abs_place = place; + + *abs_place += (grub_uint8_t) sym_addr; + } + break; + case R_RISCV_ADD16: + { + grub_uint16_t *abs_place = place; + + *abs_place += (grub_uint16_t) sym_addr; + } + break; + case R_RISCV_ADD32: + { + grub_uint32_t *abs_place = place; + + *abs_place += (grub_uint32_t) sym_addr; + } + break; + case R_RISCV_ADD64: + { + grub_size_t *abs_place = place; + + *abs_place += (grub_size_t) sym_addr; + } + break; + + case R_RISCV_SUB8: + { + grub_uint8_t *abs_place = place; + + *abs_place -= (grub_uint8_t) sym_addr; + } + break; + case R_RISCV_SUB16: + { + grub_uint16_t *abs_place = place; + + *abs_place -= (grub_uint16_t) sym_addr; + } + break; + case R_RISCV_SUB32: + { + grub_uint32_t *abs_place = place; + + *abs_place -= (grub_uint32_t) sym_addr; + } + break; + case R_RISCV_SUB64: + { + grub_size_t *abs_place = place; + + *abs_place -= (grub_size_t) sym_addr; + } + break; + + case R_RISCV_BRANCH: + { + grub_uint32_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_uint32_t imm12 = (off & 0x1000) << (31 - 12); + grub_uint32_t imm11 = (off & 0x800) >> (11 - 7); + grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10); + grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4); + *abs_place = (*abs_place & 0x1fff07f) + | imm12 | imm11 | imm10_5 | imm4_1; + } + break; + + case R_RISCV_JAL: + { + grub_uint32_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_uint32_t imm20 = (off & 0x100000) << (31 - 20); + grub_uint32_t imm19_12 = (off & 0xff000); + grub_uint32_t imm11 = (off & 0x800) << (20 - 11); + grub_uint32_t imm10_1 = (off & 0x7fe) << (30 - 10); + *abs_place = (*abs_place & 0xfff) + | imm20 | imm19_12 | imm11 | imm10_1; + } + break; + + case R_RISCV_CALL: + { + grub_uint32_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_uint32_t hi20, lo12; + + if (off != (grub_int32_t) off) + return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow"); + + hi20 = (off + 0x800) & 0xfffff000; + lo12 = (off - hi20) & 0xfff; + abs_place[0] = (abs_place[0] & 0xfff) | hi20; + abs_place[1] = (abs_place[1] & 0xfffff) | (lo12 << 20); + } + break; + + case R_RISCV_RVC_BRANCH: + { + grub_uint16_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_uint16_t imm8 = (off & 0x100) << (12 - 8); + grub_uint16_t imm7_6 = (off & 0xc0) >> (6 - 5); + grub_uint16_t imm5 = (off & 0x20) >> (5 - 2); + grub_uint16_t imm4_3 = (off & 0x18) << (12 - 5); + grub_uint16_t imm2_1 = (off & 0x6) << (12 - 10); + *abs_place = (*abs_place & 0xe383) + | imm8 | imm7_6 | imm5 | imm4_3 | imm2_1; + } + break; + + case R_RISCV_RVC_JUMP: + { + grub_uint16_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_uint16_t imm11 = (off & 0x800) << (12 - 11); + grub_uint16_t imm10 = (off & 0x400) >> (10 - 8); + grub_uint16_t imm9_8 = (off & 0x300) << (12 - 11); + grub_uint16_t imm7 = (off & 0x80) >> (7 - 6); + grub_uint16_t imm6 = (off & 0x40) << (12 - 11); + grub_uint16_t imm5 = (off & 0x20) >> (5 - 2); + grub_uint16_t imm4 = (off & 0x10) << (12 - 5); + grub_uint16_t imm3_1 = (off & 0xe) << (12 - 10); + *abs_place = ((*abs_place & 0xe003) + | imm11 | imm10 | imm9_8 | imm7 | imm6 + | imm5 | imm4 | imm3_1); + } + break; + + case R_RISCV_PCREL_HI20: + { + grub_uint32_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; + grub_int32_t hi20; + + if (off != (grub_int32_t)off) + return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow"); + + hi20 = (off + 0x800) & 0xfffff000; + *abs_place = (*abs_place & 0xfff) | hi20; + } + break; + + case R_RISCV_PCREL_LO12_I: + case R_RISCV_PCREL_LO12_S: + { + grub_uint32_t *t32 = place; + Elf_Rela *rel2; + /* Search backwards for matching HI20 reloc. */ + for (rel2 = (Elf_Rela *) ((char *) rel - s->sh_entsize); + (unsigned long)rel2 >= ((unsigned long)ehdr + s->sh_offset); + rel2 = (Elf_Rela *) ((char *) rel2 - s->sh_entsize)) + { + Elf_Addr rel2_info; + Elf_Addr rel2_offset; + Elf_Addr rel2_sym_addr; + Elf_Addr rel2_loc; + grub_ssize_t rel2_off; + grub_ssize_t off; + Elf_Sym *sym2; + + rel2_offset = rel2->r_offset; + rel2_info = rel2->r_info; + rel2_loc = (grub_addr_t) seg->addr + rel2_offset; + + if (ELF_R_TYPE (rel2_info) == R_RISCV_PCREL_HI20 + && rel2_loc == sym_addr) + { + sym2 = (Elf_Sym *) ((char *) mod->symtab + + mod->symsize * ELF_R_SYM (rel2->r_info)); + rel2_sym_addr = sym2->st_value; + if (s->sh_type == SHT_RELA) + rel2_sym_addr += ((Elf_Rela *) rel2)->r_addend; + + rel2_off = rel2_sym_addr - rel2_loc; + off = rel2_off - ((rel2_off + 0x800) & 0xfffff000); + + if (ELF_R_TYPE (rel->r_info) == R_RISCV_PCREL_LO12_I) + *t32 = (*t32 & 0xfffff) | (off & 0xfff) << 20; + else + { + grub_uint32_t imm11_5 = (off & 0xfe0) << (31 - 11); + grub_uint32_t imm4_0 = (off & 0x1f) << (11 - 4); + *t32 = (*t32 & 0x1fff07f) | imm11_5 | imm4_0; + } + break; + } + } + if ((unsigned long)rel2 < ((unsigned long)ehdr + s->sh_offset)) + return grub_error (GRUB_ERR_BAD_MODULE, "cannot find matching HI20 relocation"); + } + break; + + case R_RISCV_HI20: + { + grub_uint32_t *abs_place = place; + *abs_place = (*abs_place & 0xfff) | + (((grub_int32_t) sym_addr + 0x800) & 0xfffff000); + } + break; + + case R_RISCV_LO12_I: + { + grub_uint32_t *abs_place = place; + grub_int32_t lo12 = (grub_int32_t) sym_addr - + (((grub_int32_t) sym_addr + 0x800) & 0xfffff000); + *abs_place = (*abs_place & 0xfffff) | ((lo12 & 0xfff) << 20); + } + break; + + case R_RISCV_LO12_S: + { + grub_uint32_t *abs_place = place; + grub_int32_t lo12 = (grub_int32_t) sym_addr - + (((grub_int32_t) sym_addr + 0x800) & 0xfffff000); + grub_uint32_t imm11_5 = (lo12 & 0xfe0) << (31 - 11); + grub_uint32_t imm4_0 = (lo12 & 0x1f) << (11 - 4); + *abs_place = (*abs_place & 0x1fff07f) | imm11_5 | imm4_0; + } + break; + + case R_RISCV_RELAX: + break; + default: + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + N_("relocation 0x%x is not implemented yet"), + ELF_R_TYPE (rel->r_info)); + } + } + + return GRUB_ERR_NONE; +} diff --git a/include/grub/dl.h b/include/grub/dl.h index fee27a14c..f03c03561 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -292,12 +292,14 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, grub_size_t *got); #endif -#if defined (__powerpc__) || defined (__mips__) || defined (__arm__) +#if defined (__powerpc__) || defined (__mips__) || defined (__arm__) || \ + (defined(__riscv) && (__riscv_xlen == 32)) #define GRUB_ARCH_DL_TRAMP_ALIGN 4 #define GRUB_ARCH_DL_GOT_ALIGN 4 #endif -#if defined (__aarch64__) || defined (__sparc__) +#if defined (__aarch64__) || defined (__sparc__) || \ + (defined(__riscv) && (__riscv_xlen == 64)) #define GRUB_ARCH_DL_TRAMP_ALIGN 8 #define GRUB_ARCH_DL_GOT_ALIGN 8 #endif diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index e94a721b4..c04f17d4e 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1226,6 +1226,196 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, break; } #endif /* MKIMAGE_ELF32 */ + case EM_RISCV: + { + grub_uint64_t *t64 = (grub_uint64_t *) target; + grub_uint32_t *t32 = (grub_uint32_t *) target; + grub_uint16_t *t16 = (grub_uint16_t *) target; + grub_uint8_t *t8 = (grub_uint8_t *) target; + grub_int64_t off = (long)sym_addr - target_section_addr - offset + - image_target->vaddr_offset; + + /* + * Instructions and instruction encoding are documented in the RISC-V + * specification. This file is based on version 2.2: + * + * https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf + */ + + sym_addr += addend; + + switch (ELF_R_TYPE (info)) + { + case R_RISCV_ADD8: + *t8 = *t8 + sym_addr; + break; + case R_RISCV_ADD16: + *t16 = grub_host_to_target16 (grub_target_to_host16 (*t16) + sym_addr); + break; + case R_RISCV_32: + case R_RISCV_ADD32: + *t32 = grub_host_to_target32 (grub_target_to_host32 (*t32) + sym_addr); + break; + case R_RISCV_64: + case R_RISCV_ADD64: + *t64 = grub_host_to_target64 (grub_target_to_host64 (*t64) + sym_addr); + break; + + case R_RISCV_SUB8: + *t8 = sym_addr - *t8; + break; + case R_RISCV_SUB16: + *t16 = grub_host_to_target16 (grub_target_to_host16 (*t16) - sym_addr); + break; + case R_RISCV_SUB32: + *t32 = grub_host_to_target32 (grub_target_to_host32 (*t32) - sym_addr); + break; + case R_RISCV_SUB64: + *t64 = grub_host_to_target64 (grub_target_to_host64 (*t64) - sym_addr); + break; + case R_RISCV_BRANCH: + { + grub_uint32_t imm12 = (off & 0x1000) << (31 - 12); + grub_uint32_t imm11 = (off & 0x800) >> (11 - 7); + grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10); + grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4); + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f) + | imm12 | imm11 | imm10_5 | imm4_1); + } + break; + case R_RISCV_JAL: + { + grub_uint32_t imm20 = (off & 0x100000) << (31 - 20); + grub_uint32_t imm19_12 = (off & 0xff000); + grub_uint32_t imm11 = (off & 0x800) << (20 - 11); + grub_uint32_t imm10_1 = (off & 0x7fe) << (30 - 10); + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) + | imm20 | imm19_12 | imm11 | imm10_1); + } + break; + case R_RISCV_CALL: + { + grub_uint32_t hi20, lo12; + + if (off != (grub_int32_t)off) + grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)target); + + hi20 = (off + 0x800) & 0xfffff000; + lo12 = (off - hi20) & 0xfff; + t32[0] = grub_host_to_target32 ((grub_target_to_host32 (t32[0]) & 0xfff) | hi20); + t32[1] = grub_host_to_target32 ((grub_target_to_host32 (t32[1]) & 0xfffff) | (lo12 << 20)); + } + break; + case R_RISCV_RVC_BRANCH: + { + grub_uint16_t imm8 = (off & 0x100) << (12 - 8); + grub_uint16_t imm7_6 = (off & 0xc0) >> (6 - 5); + grub_uint16_t imm5 = (off & 0x20) >> (5 - 2); + grub_uint16_t imm4_3 = (off & 0x18) << (12 - 5); + grub_uint16_t imm2_1 = (off & 0x6) << (12 - 10); + *t16 = grub_host_to_target16 ((grub_target_to_host16 (*t16) & 0xe383) + | imm8 | imm7_6 | imm5 | imm4_3 | imm2_1); + } + break; + case R_RISCV_RVC_JUMP: + { + grub_uint16_t imm11 = (off & 0x800) << (12 - 11); + grub_uint16_t imm10 = (off & 0x400) >> (10 - 8); + grub_uint16_t imm9_8 = (off & 0x300) << (12 - 11); + grub_uint16_t imm7 = (off & 0x80) >> (7 - 6); + grub_uint16_t imm6 = (off & 0x40) << (12 - 11); + grub_uint16_t imm5 = (off & 0x20) >> (5 - 2); + grub_uint16_t imm4 = (off & 0x10) << (12 - 5); + grub_uint16_t imm3_1 = (off & 0xe) << (12 - 10); + *t16 = grub_host_to_target16 ((grub_target_to_host16 (*t16) & 0xe003) + | imm11 | imm10 | imm9_8 | imm7 | imm6 + | imm5 | imm4 | imm3_1); + } + break; + case R_RISCV_PCREL_HI20: + { + grub_int32_t hi20; + + if (off != (grub_int32_t)off) + grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)target); + + hi20 = (off + 0x800) & 0xfffff000; + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20); + } + break; + case R_RISCV_PCREL_LO12_I: + case R_RISCV_PCREL_LO12_S: + { + Elf_Rela *rel2; + Elf_Word k; + /* Search backwards for matching HI20 reloc. */ + for (k = j, rel2 = (Elf_Rela *) ((char *) r - r_size); + k > 0; + k--, rel2 = (Elf_Rela *) ((char *) rel2 - r_size)) + { + Elf_Addr rel2_info; + Elf_Addr rel2_offset; + Elf_Addr rel2_sym_addr; + Elf_Addr rel2_addend; + Elf_Addr rel2_loc; + grub_int64_t rel2_off; + + rel2_offset = grub_target_to_host (rel2->r_offset); + rel2_info = grub_target_to_host (rel2->r_info); + rel2_loc = target_section_addr + rel2_offset + image_target->vaddr_offset; + + if (ELF_R_TYPE (rel2_info) == R_RISCV_PCREL_HI20 + && rel2_loc == sym_addr) + { + rel2_sym_addr = SUFFIX (get_symbol_address) + (e, smd->symtab, ELF_R_SYM (rel2_info), + image_target); + rel2_addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ? + grub_target_to_host (rel2->r_addend) : 0; + rel2_off = rel2_sym_addr + rel2_addend - rel2_loc; + off = rel2_off - ((rel2_off + 0x800) & 0xfffff000); + + if (ELF_R_TYPE (info) == R_RISCV_PCREL_LO12_I) + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfffff) | (off & 0xfff) << 20); + else + { + grub_uint32_t imm11_5 = (off & 0xfe0) << (31 - 11); + grub_uint32_t imm4_0 = (off & 0x1f) << (11 - 4); + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f) | imm11_5 | imm4_0); + } + break; + } + } + if (k == 0) + grub_util_error ("cannot find matching HI20 relocation"); + } + break; + case R_RISCV_HI20: + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | (((grub_int32_t) sym_addr + 0x800) & 0xfffff000)); + break; + case R_RISCV_LO12_I: + { + grub_int32_t lo12 = (grub_int32_t) sym_addr - (((grub_int32_t) sym_addr + 0x800) & 0xfffff000); + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfffff) | ((lo12 & 0xfff) << 20)); + } + break; + case R_RISCV_LO12_S: + { + grub_int32_t lo12 = (grub_int32_t) sym_addr - (((grub_int32_t) sym_addr + 0x800) & 0xfffff000); + grub_uint32_t imm11_5 = (lo12 & 0xfe0) << (31 - 11); + grub_uint32_t imm4_0 = (lo12 & 0x1f) << (11 - 4); + *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f) | imm11_5 | imm4_0); + } + break; + case R_RISCV_RELAX: + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + } default: grub_util_error ("unknown architecture type %d", image_target->elf_target); @@ -1510,6 +1700,75 @@ translate_relocation_pe (struct translate_context *ctx, } break; #endif /* defined(MKIMAGE_ELF32) */ + case EM_RISCV: + switch (ELF_R_TYPE (info)) + { + case R_RISCV_32: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_HIGHLOW, + addr, 0, ctx->current_address, + image_target); + } + break; + case R_RISCV_64: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, 0, ctx->current_address, + image_target); + } + break; + /* Relative relocations do not require fixup entries. */ + case R_RISCV_BRANCH: + case R_RISCV_JAL: + case R_RISCV_CALL: + case R_RISCV_PCREL_HI20: + case R_RISCV_PCREL_LO12_I: + case R_RISCV_PCREL_LO12_S: + case R_RISCV_RVC_BRANCH: + case R_RISCV_RVC_JUMP: + case R_RISCV_ADD32: + case R_RISCV_SUB32: + grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address); + break; + case R_RISCV_HI20: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_RISCV_HI20, + addr, 0, ctx->current_address, + image_target); + } + break; + case R_RISCV_LO12_I: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_RISCV_LOW12I, + addr, 0, ctx->current_address, + image_target); + } + break; + case R_RISCV_LO12_S: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_RISCV_LOW12S, + addr, 0, ctx->current_address, + image_target); + } + break; + case R_RISCV_RELAX: + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; default: grub_util_error ("unknown machine type 0x%x", image_target->elf_target); } diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 979999cb9..60e4d2c06 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -117,6 +117,62 @@ struct grub_module_verifier_arch archs[] = { R_AARCH64_LDST64_ABS_LO12_NC, R_AARCH64_PREL32, -1 + } }, + { "riscv32", 4, 0, EM_RISCV, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_RISCV_32, + R_RISCV_64, + R_RISCV_ADD8, + R_RISCV_ADD16, + R_RISCV_ADD32, + R_RISCV_ADD64, + R_RISCV_SUB8, + R_RISCV_SUB16, + R_RISCV_SUB32, + R_RISCV_SUB64, + R_RISCV_ALIGN, + R_RISCV_BRANCH, + R_RISCV_CALL, + R_RISCV_CALL_PLT, + R_RISCV_GOT_HI20, + R_RISCV_HI20, + R_RISCV_JAL, + R_RISCV_LO12_I, + R_RISCV_LO12_S, + R_RISCV_PCREL_HI20, + R_RISCV_PCREL_LO12_I, + R_RISCV_PCREL_LO12_S, + R_RISCV_RELAX, + R_RISCV_RVC_BRANCH, + R_RISCV_RVC_JUMP, + -1 + } }, + { "riscv64", 8, 0, EM_RISCV, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_RISCV_32, + R_RISCV_64, + R_RISCV_ADD8, + R_RISCV_ADD16, + R_RISCV_ADD32, + R_RISCV_ADD64, + R_RISCV_SUB8, + R_RISCV_SUB16, + R_RISCV_SUB32, + R_RISCV_SUB64, + R_RISCV_ALIGN, + R_RISCV_BRANCH, + R_RISCV_CALL, + R_RISCV_CALL_PLT, + R_RISCV_GOT_HI20, + R_RISCV_HI20, + R_RISCV_JAL, + R_RISCV_LO12_I, + R_RISCV_LO12_S, + R_RISCV_PCREL_HI20, + R_RISCV_PCREL_LO12_I, + R_RISCV_PCREL_LO12_S, + R_RISCV_RELAX, + R_RISCV_RVC_BRANCH, + R_RISCV_RVC_JUMP, + -1 } }, }; From 861212333e09a455dd3b7eaab71f1eefb676b39e Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:05 +0100 Subject: [PATCH 0922/1167] RISC-V: Add auxiliary files To support a new architecture we need to provide a few helper functions for memory, cache, timer, etc support. This patch adds the remainders of those. Some bits are still disabled, as I couldn't guarantee that we're always running on models / in modes where the respective hardware is available. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Daniel Kiper --- grub-core/kern/riscv/cache.c | 63 +++++++++++++++++++++++++ grub-core/kern/riscv/cache_flush.S | 44 +++++++++++++++++ grub-core/kern/riscv/efi/init.c | 76 ++++++++++++++++++++++++++++++ include/grub/riscv32/efi/memory.h | 6 +++ include/grub/riscv32/time.h | 28 +++++++++++ include/grub/riscv32/types.h | 34 +++++++++++++ include/grub/riscv64/efi/memory.h | 6 +++ include/grub/riscv64/time.h | 28 +++++++++++ include/grub/riscv64/types.h | 34 +++++++++++++ 9 files changed, 319 insertions(+) create mode 100644 grub-core/kern/riscv/cache.c create mode 100644 grub-core/kern/riscv/cache_flush.S create mode 100644 grub-core/kern/riscv/efi/init.c create mode 100644 include/grub/riscv32/efi/memory.h create mode 100644 include/grub/riscv32/time.h create mode 100644 include/grub/riscv32/types.h create mode 100644 include/grub/riscv64/efi/memory.h create mode 100644 include/grub/riscv64/time.h create mode 100644 include/grub/riscv64/types.h diff --git a/grub-core/kern/riscv/cache.c b/grub-core/kern/riscv/cache.c new file mode 100644 index 000000000..47777a033 --- /dev/null +++ b/grub-core/kern/riscv/cache.c @@ -0,0 +1,63 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include + +static grub_int64_t dlinesz; +static grub_int64_t ilinesz; + +/* Prototypes for asm functions. */ +void grub_arch_clean_dcache_range (grub_addr_t beg, grub_addr_t end, + grub_size_t line_size); +void grub_arch_invalidate_icache_range (grub_addr_t beg, grub_addr_t end, + grub_size_t line_size); + +static void +probe_caches (void) +{ + /* TODO */ + dlinesz = 32; + ilinesz = 32; +} + +void +grub_arch_sync_caches (void *address, grub_size_t len) +{ + grub_size_t start, end, max_align; + + if (dlinesz == 0) + probe_caches(); + if (dlinesz == 0) + grub_fatal ("Unknown cache line size!"); + + max_align = dlinesz > ilinesz ? dlinesz : ilinesz; + + start = ALIGN_DOWN ((grub_size_t) address, max_align); + end = ALIGN_UP ((grub_size_t) address + len, max_align); + + grub_arch_clean_dcache_range (start, end, dlinesz); + grub_arch_invalidate_icache_range (start, end, ilinesz); +} + +void +grub_arch_sync_dma_caches (volatile void *address __attribute__((unused)), + grub_size_t len __attribute__((unused))) +{ + /* DMA incoherent devices not supported yet */ +} diff --git a/grub-core/kern/riscv/cache_flush.S b/grub-core/kern/riscv/cache_flush.S new file mode 100644 index 000000000..41de6e411 --- /dev/null +++ b/grub-core/kern/riscv/cache_flush.S @@ -0,0 +1,44 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include + + .file "cache_flush.S" + .text + +/* + * Simple cache maintenance functions + */ + +/* + * a0 - *beg (inclusive) + * a1 - *end (exclusive) + * a2 - line size +*/ +FUNCTION(grub_arch_clean_dcache_range) + /* TODO */ + ret + +/* + * a0 - *beg (inclusive) + * a1 - *end (exclusive) + * a2 - line size + */ +FUNCTION(grub_arch_invalidate_icache_range) + fence.i + ret diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c new file mode 100644 index 000000000..7eb1969d0 --- /dev/null +++ b/grub-core/kern/riscv/efi/init.c @@ -0,0 +1,76 @@ +/* init.c - initialize a riscv-based EFI system */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +static grub_uint64_t timer_frequency_in_khz; + +static grub_uint64_t +grub_efi_get_time_ms (void) +{ + grub_uint64_t tmr; + +#if __riscv_xlen == 64 + asm volatile ("rdcycle %0" : "=r" (tmr)); +#else + grub_uint32_t lo, hi, tmp; + asm volatile ( + "1:\n" + "rdcycleh %0\n" + "rdcycle %1\n" + "rdcycleh %2\n" + "bne %0, %2, 1b" + : "=&r" (hi), "=&r" (lo), "=&r" (tmp)); + tmr = ((grub_uint64_t)hi << 32) | lo; +#endif + + return tmr / timer_frequency_in_khz; +} + +void +grub_machine_init (void) +{ + grub_uint64_t time_before, time_after; + + grub_efi_init (); + + /* Calculate timer frequency */ + timer_frequency_in_khz = 1; + time_before = grub_efi_get_time_ms(); + grub_efi_stall(1000); + time_after = grub_efi_get_time_ms(); + timer_frequency_in_khz = time_after - time_before; + + grub_install_get_time_ms (grub_efi_get_time_ms); +} + +void +grub_machine_fini (int flags) +{ + if (!(flags & GRUB_LOADER_FLAG_NORETURN)) + return; + + grub_efi_fini (); +} diff --git a/include/grub/riscv32/efi/memory.h b/include/grub/riscv32/efi/memory.h new file mode 100644 index 000000000..e61c474ff --- /dev/null +++ b/include/grub/riscv32/efi/memory.h @@ -0,0 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER +#include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffUL + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/riscv32/time.h b/include/grub/riscv32/time.h new file mode 100644 index 000000000..20abd648b --- /dev/null +++ b/include/grub/riscv32/time.h @@ -0,0 +1,28 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +static __inline void +grub_cpu_idle (void) +{ + /* TODO */ +} + +#endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/include/grub/riscv32/types.h b/include/grub/riscv32/types.h new file mode 100644 index 000000000..fac57a752 --- /dev/null +++ b/include/grub/riscv32/types.h @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 4 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 4 + +/* currently only support little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN + +/* Unaligned accesses can be very slow, so avoid them */ +#undef GRUB_HAVE_UNALIGNED_ACCESS + +#endif /* ! GRUB_TYPES_CPU_HEADER */ diff --git a/include/grub/riscv64/efi/memory.h b/include/grub/riscv64/efi/memory.h new file mode 100644 index 000000000..c6cb32417 --- /dev/null +++ b/include/grub/riscv64/efi/memory.h @@ -0,0 +1,6 @@ +#ifndef GRUB_MEMORY_CPU_HEADER +#include + +#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL + +#endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/riscv64/time.h b/include/grub/riscv64/time.h new file mode 100644 index 000000000..20abd648b --- /dev/null +++ b/include/grub/riscv64/time.h @@ -0,0 +1,28 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +static __inline void +grub_cpu_idle (void) +{ + /* TODO */ +} + +#endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/include/grub/riscv64/types.h b/include/grub/riscv64/types.h new file mode 100644 index 000000000..c6bcad470 --- /dev/null +++ b/include/grub/riscv64/types.h @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2018 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 . + */ + +#ifndef GRUB_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 8 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 8 + +/* currently only support little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN + +/* Unaligned accesses can be very slow, so avoid them */ +#undef GRUB_HAVE_UNALIGNED_ACCESS + +#endif /* ! GRUB_TYPES_CPU_HEADER */ From e795b9011fdb7208cccb1804d9bbc81a6cd251c6 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:06 +0100 Subject: [PATCH 0923/1167] RISC-V: Add libgcc helpers for clz Gcc may decide it wants to call helper functions to execute clz. Provide them in our own copy of libgcc. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- grub-core/kern/compiler-rt.c | 42 ++++++++++++++++++++++++++++++++++++ include/grub/compiler-rt.h | 7 ++++++ 2 files changed, 49 insertions(+) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index 5cfcb3907..7438a507e 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -417,3 +417,45 @@ __aeabi_llsl (grub_uint64_t u, int b) __attribute__ ((alias ("__ashldi3"))); #endif + +#ifdef __riscv + +/* Based on libgcc from gcc suite. */ +int +__clzsi2 (grub_uint32_t val) +{ + int i = 32; + int j = 16; + int temp; + + for (; j; j >>= 1) + { + if ((temp = val) >> j) + { + if (j == 1) + { + return (i - 2); + } + else + { + i -= j; + val = temp; + } + } + } + return (i - val); +} + +int +__clzdi2 (grub_uint64_t val) +{ + if (val >> 32) + { + return __clzsi2 (val >> 32); + } + else + { + return __clzsi2 (val) + 32; + } +} +#endif diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index dc73649a5..2cc69e239 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -108,6 +108,13 @@ EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); #endif +#ifdef __riscv +int +EXPORT_FUNC (__clzsi2) (grub_uint32_t val); + +int +EXPORT_FUNC (__clzdi2) (grub_uint64_t val); +#endif #if defined (__powerpc__) From f1957dc8a3347278a095bc8f44197662559a8ba3 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:07 +0100 Subject: [PATCH 0924/1167] RISC-V: Add to build system This patch adds support for RISC-V to the grub build system. With this patch, I can successfully build grub on RISC-V as a UEFI application. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- configure.ac | 28 ++++++++++++++++++++++++++-- gentpl.py | 11 +++++++---- grub-core/Makefile.am | 12 ++++++++++++ grub-core/Makefile.core.def | 29 +++++++++++++++++++++++++++++ grub-core/commands/file.c | 14 +++++++++++++- grub-core/kern/compiler-rt.c | 6 ++++-- grub-core/kern/efi/mm.c | 2 +- grub-core/kern/emu/cache.c | 6 ++++++ grub-core/kern/emu/cache_s.S | 3 ++- grub-core/kern/emu/lite.c | 2 ++ grub-core/lib/efi/halt.c | 3 ++- grub-core/lib/setjmp.S | 2 ++ include/grub/compiler-rt.h | 12 ++++++++---- include/grub/efi/api.h | 3 ++- include/grub/efi/efi.h | 2 +- include/grub/misc.h | 3 ++- include/grub/util/install.h | 2 ++ util/grub-install-common.c | 2 ++ util/grub-install.c | 28 ++++++++++++++++++++++++++++ util/grub-mknetdir.c | 4 +++- util/grub-mkrescue.c | 16 +++++++++++++++- util/mkimage.c | 32 ++++++++++++++++++++++++++++++++ 22 files changed, 201 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index 81a19afd5..e36195266 100644 --- a/configure.ac +++ b/configure.ac @@ -104,6 +104,12 @@ case "$target_cpu" in aarch64*) target_cpu=arm64 ;; + riscv32*) + target_cpu=riscv32 + ;; + riscv64*) + target_cpu=riscv64 + ;; esac # Specify the platform (such as firmware). @@ -127,6 +133,8 @@ if test "x$with_platform" = x; then ia64-*) platform=efi ;; arm-*) platform=uboot ;; arm64-*) platform=efi ;; + riscv32-*) platform=efi ;; + riscv64-*) platform=efi ;; *) AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities]) platform=none @@ -175,6 +183,8 @@ case "$target_cpu"-"$platform" in arm-coreboot) ;; arm-efi) ;; arm64-efi) ;; + riscv32-efi) ;; + riscv64-efi) ;; *-emu) ;; *-none) ;; *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; @@ -828,6 +838,16 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], []) fi + if test "x$target_cpu" = xriscv32; then + CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], []) + fi + if test "x$target_cpu" = xriscv64; then + CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], []) + fi if test "x$target_cpu" = xia64; then CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], @@ -1143,7 +1163,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) LDFLAGS="$TARGET_LDFLAGS" -if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then +if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then # Use large model to support 4G memory AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ CFLAGS="$TARGET_CFLAGS -mcmodel=large" @@ -1153,7 +1173,7 @@ if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then ]) if test "x$grub_cv_cc_mcmodel" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" - elif test "$target_cpu" = sparc64; then + elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" fi fi @@ -1916,6 +1936,10 @@ AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xc AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) +AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ]) +AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ]) +AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi]) +AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi]) AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux]) diff --git a/gentpl.py b/gentpl.py index e8439484a..387588c05 100644 --- a/gentpl.py +++ b/gentpl.py @@ -32,7 +32,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "mips_loongson", "sparc64_ieee1275", "powerpc_ieee1275", "mips_arc", "ia64_efi", "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi", - "arm_coreboot"] + "arm_coreboot", "riscv32_efi", "riscv64_efi" ] GROUPS = {} @@ -47,9 +47,12 @@ GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ] GROUPS["arm"] = [ "arm_uboot", "arm_efi", "arm_coreboot" ] GROUPS["arm64"] = [ "arm64_efi" ] +GROUPS["riscv32"] = [ "riscv32_efi" ] +GROUPS["riscv64"] = [ "riscv64_efi" ] # Groups based on firmware -GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ] +GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi", + "riscv32_efi", "riscv64_efi" ] GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] GROUPS["uboot"] = [ "arm_uboot" ] GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ] @@ -76,11 +79,11 @@ GROUPS["terminfomodule"] = GRUB_PLATFORMS[:]; for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) # Flattened Device Trees (FDT) -GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ] +GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi", "riscv32_efi", "riscv64_efi" ] # Needs software helpers for division # Must match GRUB_DIVISION_IN_SOFTWARE in misc.h -GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] +GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] + GROUPS["riscv32"] GROUPS["no_softdiv"] = GRUB_PLATFORMS[:] for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index df8dbe2fb..3ea8e7ff4 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -284,6 +284,18 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif +if COND_riscv32_efi +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h +endif + +if COND_riscv64_efi +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h +endif + if COND_emu KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index e16fb06ba..2346bd291 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -65,6 +65,12 @@ kernel = { arm64_efi_ldflags = '-Wl,-r,-d'; arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; + riscv32_efi_ldflags = '-Wl,-r,-d'; + riscv32_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; + + riscv64_efi_ldflags = '-Wl,-r,-d'; + riscv64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; + i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)'; @@ -114,6 +120,8 @@ kernel = { arm_coreboot_startup = kern/arm/startup.S; arm_efi_startup = kern/arm/efi/startup.S; arm64_efi_startup = kern/arm64/efi/startup.S; + riscv32_efi_startup = kern/riscv/efi/startup.S; + riscv64_efi_startup = kern/riscv/efi/startup.S; common = kern/command.c; common = kern/corecmd.c; @@ -246,6 +254,12 @@ kernel = { arm64_efi = kern/arm64/efi/init.c; arm64_efi = kern/efi/fdt.c; + riscv32_efi = kern/riscv/efi/init.c; + riscv32_efi = kern/efi/fdt.c; + + riscv64_efi = kern/riscv/efi/init.c; + riscv64_efi = kern/efi/fdt.c; + i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/mmap.c; i386_pc = term/i386/pc/console.c; @@ -317,6 +331,14 @@ kernel = { arm64 = kern/arm64/dl.c; arm64 = kern/arm64/dl_helper.c; + riscv32 = kern/riscv/cache.c; + riscv32 = kern/riscv/cache_flush.S; + riscv32 = kern/riscv/dl.c; + + riscv64 = kern/riscv/cache.c; + riscv64 = kern/riscv/cache_flush.S; + riscv64 = kern/riscv/dl.c; + emu = disk/host.c; emu = kern/emu/cache_s.S; emu = kern/emu/hostdisk.c; @@ -792,6 +814,8 @@ module = { enable = arm64_efi; enable = arm_uboot; enable = arm_coreboot; + enable = riscv32_efi; + enable = riscv64_efi; }; module = { @@ -1649,6 +1673,7 @@ module = { extra_dist = lib/ia64/longjmp.S; extra_dist = lib/arm/setjmp.S; extra_dist = lib/arm64/setjmp.S; + extra_dist = lib/riscv/setjmp.S; }; module = { @@ -1750,6 +1775,8 @@ module = { arm_efi = loader/arm64/linux.c; arm_uboot = loader/arm/linux.c; arm64 = loader/arm64/linux.c; + riscv32 = loader/riscv/linux.c; + riscv64 = loader/riscv/linux.c; common = loader/linux.c; common = lib/cmdline.c; enable = noemu; @@ -1844,6 +1871,8 @@ module = { enable = ia64_efi; enable = arm_efi; enable = arm64_efi; + enable = riscv32_efi; + enable = riscv64_efi; enable = mips; }; diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 4f81aa1f9..2574e6685 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -90,6 +90,10 @@ static const struct grub_arg_option options[] = { N_("Check if FILE is ARM64 EFI file"), 0, 0}, {"is-arm-efi", 0, 0, N_("Check if FILE is ARM EFI file"), 0, 0}, + {"is-riscv32-efi", 0, 0, + N_("Check if FILE is RISC-V 32bit EFI file"), 0, 0}, + {"is-riscv64-efi", 0, 0, + N_("Check if FILE is RISC-V 64bit EFI file"), 0, 0}, {"is-hibernated-hiberfil", 0, 0, N_("Check if FILE is hiberfil.sys in hibernated state"), 0, 0}, {"is-x86_64-xnu", 0, 0, @@ -130,6 +134,7 @@ enum IS_IA_EFI, IS_ARM64_EFI, IS_ARM_EFI, + IS_RISCV_EFI, IS_HIBERNATED, IS_XNU64, IS_XNU32, @@ -571,6 +576,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) case IS_IA_EFI: case IS_ARM64_EFI: case IS_ARM_EFI: + case IS_RISCV_EFI: { char signature[4]; grub_uint32_t pe_offset; @@ -616,7 +622,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) && coff_head.machine != grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARMTHUMB_MIXED)) break; - if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI) + if (type == IS_RISCV_EFI + && coff_head.machine != + grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_RISCV64)) + /* TODO: Determine bitness dynamically */ + break; + if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI || + type == IS_RISCV_EFI) { struct grub_pe64_optional_header o64; if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64)) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index 7438a507e..e10b6668c 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -237,7 +237,8 @@ union component64 }; }; -#if defined (__powerpc__) || defined (__arm__) || defined(__mips__) +#if defined (__powerpc__) || defined (__arm__) || defined(__mips__) || \ + (defined(__riscv) && (__riscv_xlen == 32)) /* Based on libgcc2.c from gcc suite. */ grub_uint64_t @@ -343,7 +344,8 @@ __ucmpdi2 (grub_uint64_t a, grub_uint64_t b) #endif -#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined(__arm__) +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || \ + defined(__arm__) || defined(__riscv) /* Based on libgcc2.c from gcc suite. */ grub_uint32_t diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 42ad7c570..a29af9fa5 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -634,7 +634,7 @@ grub_efi_mm_init (void) 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } -#if defined (__aarch64__) || defined (__arm__) +#if defined (__aarch64__) || defined (__arm__) || defined (__riscv) grub_err_t grub_efi_get_ram_base(grub_addr_t *base_addr) { diff --git a/grub-core/kern/emu/cache.c b/grub-core/kern/emu/cache.c index 6f89e871a..113682cc4 100644 --- a/grub-core/kern/emu/cache.c +++ b/grub-core/kern/emu/cache.c @@ -25,5 +25,11 @@ grub_arch_sync_caches (void *address, grub_size_t len) return _flush_cache (address, len, 0); } +#elif defined(__riscv) +void +grub_arch_sync_caches (void *address, grub_size_t len) +{ +} + #endif diff --git a/grub-core/kern/emu/cache_s.S b/grub-core/kern/emu/cache_s.S index 76cf7560d..2245cddc3 100644 --- a/grub-core/kern/emu/cache_s.S +++ b/grub-core/kern/emu/cache_s.S @@ -8,7 +8,8 @@ #include "../sparc64/cache.S" #elif defined(__powerpc__) #include "../powerpc/cache.S" -#elif defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) +#elif defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ + defined(__mips__) || defined(__riscv) #else #error "No target cpu type is defined" #endif diff --git a/grub-core/kern/emu/lite.c b/grub-core/kern/emu/lite.c index b2fc93d7f..b327d4e41 100644 --- a/grub-core/kern/emu/lite.c +++ b/grub-core/kern/emu/lite.c @@ -24,6 +24,8 @@ #elif defined(__aarch64__) #include "../arm64/dl_helper.c" #include "../arm64/dl.c" +#elif defined(__riscv) +#include "../riscv/dl.c" #else #error "No target cpu type is defined" #endif diff --git a/grub-core/lib/efi/halt.c b/grub-core/lib/efi/halt.c index e9441c844..5859f0498 100644 --- a/grub-core/lib/efi/halt.c +++ b/grub-core/lib/efi/halt.c @@ -29,7 +29,8 @@ void grub_halt (void) { grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); -#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) +#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) && \ + !defined(__riscv) grub_acpi_halt (); #endif efi_call_4 (grub_efi_system_table->runtime_services->reset_system, diff --git a/grub-core/lib/setjmp.S b/grub-core/lib/setjmp.S index f6e4905e2..aa297ab0a 100644 --- a/grub-core/lib/setjmp.S +++ b/grub-core/lib/setjmp.S @@ -15,6 +15,8 @@ #include "./arm/setjmp.S" #elif defined(__aarch64__) #include "./arm64/setjmp.S" +#elif defined(__riscv) +#include "./riscv/setjmp.S" #else #error "Unknown target cpu type" #endif diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index 2cc69e239..e6a25c6ea 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -53,13 +53,15 @@ EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); #endif -#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || defined (__arm__) +#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || \ + defined (__arm__) || defined(__riscv) unsigned EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); #define NEED_CTZDI2 1 #endif -#if defined (__mips__) || defined (__arm__) +#if defined (__mips__) || defined (__arm__) || \ + (defined(__riscv) && (__riscv_xlen == 32)) unsigned EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); #define NEED_CTZSI2 1 @@ -157,7 +159,8 @@ void EXPORT_FUNC (_savegpr_31) (void); #endif -#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) +#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) || \ + (defined(__riscv) && (__riscv_xlen == 32)) int EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b); @@ -172,7 +175,8 @@ grub_uint64_t EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b); #endif -#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined (__arm__) +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || \ + defined (__arm__) || defined(__riscv) grub_uint32_t EXPORT_FUNC(__bswapsi2) (grub_uint32_t u); diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index c7c9f0e1d..addcbfa8f 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1686,7 +1686,8 @@ struct grub_efi_block_io typedef struct grub_efi_block_io grub_efi_block_io_t; #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) + || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ + || defined(__riscv) #define efi_call_0(func) func() #define efi_call_1(func, a) func(a) diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index ec44aef7e..e90e00dc4 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -90,7 +90,7 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, char **device, char **path); -#if defined(__arm__) || defined(__aarch64__) +#if defined(__arm__) || defined(__aarch64__) || defined(__riscv) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include diff --git a/include/grub/misc.h b/include/grub/misc.h index 372f009e8..ee48eb7a7 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -340,7 +340,8 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t *r); /* Must match softdiv group in gentpl.py. */ -#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__)) +#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__) || \ + (defined(__riscv) && (__riscv_xlen == 32))) #define GRUB_DIVISION_IN_SOFTWARE 1 #else #define GRUB_DIVISION_IN_SOFTWARE 0 diff --git a/include/grub/util/install.h b/include/grub/util/install.h index af2bf65d7..b1a00154f 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -103,6 +103,8 @@ enum grub_install_plat GRUB_INSTALL_PLATFORM_I386_XEN_PVH, GRUB_INSTALL_PLATFORM_ARM64_EFI, GRUB_INSTALL_PLATFORM_ARM_COREBOOT, + GRUB_INSTALL_PLATFORM_RISCV32_EFI, + GRUB_INSTALL_PLATFORM_RISCV64_EFI, GRUB_INSTALL_PLATFORM_MAX }; diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 1b1cb43b4..0a7d68b9b 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -729,6 +729,8 @@ static struct [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64", "efi" }, [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, [GRUB_INSTALL_PLATFORM_ARM_COREBOOT] = { "arm", "coreboot" }, + [GRUB_INSTALL_PLATFORM_RISCV32_EFI] = { "riscv32", "efi" }, + [GRUB_INSTALL_PLATFORM_RISCV64_EFI] = { "riscv64", "efi" }, }; char * diff --git a/util/grub-install.c b/util/grub-install.c index 4a0a66168..c6c3da331 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -477,6 +477,8 @@ have_bootdev (enum grub_install_plat pl) case GRUB_INSTALL_PLATFORM_IA64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_I386_IEEE1275: case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275: case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275: @@ -900,6 +902,8 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_X86_64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: case GRUB_INSTALL_PLATFORM_I386_IEEE1275: case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275: @@ -945,6 +949,8 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_X86_64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: case GRUB_INSTALL_PLATFORM_I386_IEEE1275: case GRUB_INSTALL_PLATFORM_ARM_UBOOT: @@ -998,6 +1004,8 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_X86_64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: is_efi = 1; break; @@ -1111,6 +1119,12 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_ARM64_EFI: efi_file = "BOOTAA64.EFI"; break; + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + efi_file = "BOOTRISCV32.EFI"; + break; + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: + efi_file = "BOOTRISCV64.EFI"; + break; default: grub_util_error ("%s", _("You've found a bug")); break; @@ -1138,6 +1152,12 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_ARM64_EFI: efi_file = "grubaa64.efi"; break; + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + efi_file = "grubriscv32.efi"; + break; + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: + efi_file = "grubriscv64.efi"; + break; default: efi_file = "grub.efi"; break; @@ -1440,6 +1460,8 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_X86_64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: g = grub_util_guess_efi_drive (*curdev); break; @@ -1533,6 +1555,8 @@ main (int argc, char *argv[]) case GRUB_INSTALL_PLATFORM_X86_64_EFI: case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: core_name = "core.efi"; snprintf (mkimage_target, sizeof (mkimage_target), @@ -1636,6 +1660,8 @@ main (int argc, char *argv[]) break; case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: @@ -1871,6 +1897,8 @@ main (int argc, char *argv[]) /* FALLTHROUGH */ case GRUB_INSTALL_PLATFORM_ARM_EFI: case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: case GRUB_INSTALL_PLATFORM_IA64_EFI: { char *dst = grub_util_path_concat (2, efidir, efi_file); diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c index 82073d5cc..602574d52 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -107,7 +107,9 @@ static const struct [GRUB_INSTALL_PLATFORM_X86_64_EFI] = { "x86_64-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_IA64_EFI] = { "ia64-efi", "efinet", ".efi" }, [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm-efi", "efinet", ".efi" }, - [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64-efi", "efinet", ".efi" } + [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64-efi", "efinet", ".efi" }, + [GRUB_INSTALL_PLATFORM_RISCV32_EFI] = { "riscv32-efi", "efinet", ".efi" }, + [GRUB_INSTALL_PLATFORM_RISCV64_EFI] = { "riscv64-efi", "efinet", ".efi" }, }; static void diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 9545945d8..21e5ce4e4 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -538,6 +538,8 @@ main (int argc, char *argv[]) || source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_RISCV32_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_RISCV64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI]) system_area = SYS_AREA_COMMON; else if (source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275]) @@ -735,7 +737,9 @@ main (int argc, char *argv[]) || source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI] || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI] - || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI]) + || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_RISCV32_EFI] + || source_dirs[GRUB_INSTALL_PLATFORM_RISCV64_EFI]) { char *efidir = grub_util_make_temporary_dir (); char *efidir_efi = grub_util_path_concat (2, efidir, "efi"); @@ -770,6 +774,16 @@ main (int argc, char *argv[]) imgname); free (imgname); + imgname = grub_util_path_concat (2, efidir_efi_boot, "bootriscv32.efi"); + make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_RISCV32_EFI, "riscv32-efi", + imgname); + free (imgname); + + imgname = grub_util_path_concat (2, efidir_efi_boot, "bootriscv64.efi"); + make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_RISCV64_EFI, "riscv64-efi", + imgname); + free (imgname); + if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI]) { imgname = grub_util_path_concat (2, efidir_efi_boot, "boot.efi"); diff --git a/util/mkimage.c b/util/mkimage.c index cf1a47c94..37d6249f1 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -622,6 +622,38 @@ static const struct grub_install_image_target_desc image_targets[] = .pe_target = GRUB_PE32_MACHINE_ARM64, .elf_target = EM_AARCH64, }, + { + .dirname = "riscv32-efi", + .names = { "riscv32-efi", NULL }, + .voidp_sizeof = 4, + .bigendian = 0, + .id = IMAGE_EFI, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = TARGET_NO_FIELD, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = GRUB_PE32_SECTION_ALIGNMENT, + .vaddr_offset = EFI32_HEADER_SIZE, + .pe_target = GRUB_PE32_MACHINE_RISCV32, + .elf_target = EM_RISCV, + }, + { + .dirname = "riscv64-efi", + .names = { "riscv64-efi", NULL }, + .voidp_sizeof = 8, + .bigendian = 0, + .id = IMAGE_EFI, + .flags = PLATFORM_FLAGS_NONE, + .total_module_size = TARGET_NO_FIELD, + .decompressor_compressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_size = TARGET_NO_FIELD, + .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .section_align = GRUB_PE32_SECTION_ALIGNMENT, + .vaddr_offset = EFI64_HEADER_SIZE, + .pe_target = GRUB_PE32_MACHINE_RISCV64, + .elf_target = EM_RISCV, + }, }; #include From c956126a51f5c08e34ed1be15462ab73a36bdf76 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Feb 2019 11:31:08 +0100 Subject: [PATCH 0925/1167] fdt: Treat device tree file type like ACPI We now have signature check logic in grub which allows us to treat files differently depending on their file type. Treat a loaded device tree like an overlayed ACPI table. Both describe hardware, so I suppose their threat level is the same. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper Reviewed-by: Alistair Francis --- grub-core/commands/efi/shim_lock.c | 1 + include/grub/file.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c index 01246b0fc..83568cb2b 100644 --- a/grub-core/commands/efi/shim_lock.c +++ b/grub-core/commands/efi/shim_lock.c @@ -81,6 +81,7 @@ shim_lock_init (grub_file_t io, enum grub_file_type type, /* Fall through. */ case GRUB_FILE_TYPE_ACPI_TABLE: + case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE: *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH; return GRUB_ERR_NONE; diff --git a/include/grub/file.h b/include/grub/file.h index cbbd29465..31567483c 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -74,8 +74,6 @@ enum grub_file_type GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE, - GRUB_FILE_TYPE_DEVICE_TREE_IMAGE, - /* File holding signature. */ GRUB_FILE_TYPE_SIGNATURE, /* File holding public key to verify signature once. */ @@ -100,6 +98,8 @@ enum grub_file_type GRUB_FILE_TYPE_FILE_ID, /* File holding ACPI table. */ GRUB_FILE_TYPE_ACPI_TABLE, + /* File holding Device Tree. */ + GRUB_FILE_TYPE_DEVICE_TREE_IMAGE, /* File we intend show to user. */ GRUB_FILE_TYPE_CAT, GRUB_FILE_TYPE_HEXCAT, From d3a3543a5666c1dd180ae6027948ca753dcffc18 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Tue, 5 Feb 2019 17:29:13 +0100 Subject: [PATCH 0926/1167] normal/menu: Do not treat error values as key presses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some terminals, like `grub-core/term/at_keyboard.c`, return `-1` in case they are not ready yet. if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) return -1; Currently, that is treated as a key press, and the menu time-out is cancelled/cleared. This is unwanted, as the boot is stopped and the user manually has to select a menu entry. Therefore, adapt the condition to require the key value also to be greater than 0. `GRUB_TERM_NO_KEY` is defined as 0, so the condition could be collapsed to greater or equal than (≥) 0, but the compiler will probably do that for us anyway, so keep the cases separate for clarity. This is tested with coreboot, the GRUB default payload, and the configuration file `grub.cfg` below. For GRUB: $ ./autogen.sh $ ./configure --with-platform=coreboot $ make -j`nproc` $ make default_payload.elf For coreboot: $ more grub.cfg serial --unit 0 --speed 115200 set timeout=5 menuentry 'halt' { halt } $ build/cbfstool build/coreboot.rom add-payload \ -f /dev/shm/grub/default_payload.elf -n fallback/payload -c lzma $ build/cbfstool build/coreboot.rom add -f grub.cfg -n etc/grub.cfg -t raw $ qemu-system-x86_64 --version QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2+b1) Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers $ qemu-system-x86_64 -M pc -bios build/coreboot.rom -serial stdio -nic none Currently, the time-out is cancelled/cleared. With the commit, it is not. With a small GRUB payload, this the problem is also reproducible on the ASRock E350M1. Link: http://lists.gnu.org/archive/html/grub-devel/2019-01/msg00037.html Signed-off-by: Paul Menzel Reviewed-by: Daniel Kiper --- grub-core/normal/menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index e7a83c2d6..d5e0c79a7 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -698,7 +698,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) c = grub_getkey_noblock (); - if (c != GRUB_TERM_NO_KEY) + /* Negative values are returned on error. */ + if ((c != GRUB_TERM_NO_KEY) && (c > 0)) { if (timeout >= 0) { From 566b16a0dc23d72357d2d75b781d3c7895b8a234 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 21 Feb 2019 10:15:08 +0000 Subject: [PATCH 0927/1167] arm64/efi: Fix grub_efi_get_ram_base() grub_efi_get_ram_base() looks for the lowest available RAM address by traversing the memory map, comparing lowest address found so far. Due to a brain glitch, that "so far" was initialized to GRUB_UINT_MAX - completely preventing boot on systems without RAM below 4GB. Change the initial value to GRUB_EFI_MAX_USABLE_ADDRESS, as originally intended. Reported-by: Steve McIntyre <93sam@debian.org> Signed-off-by: Leif Lindholm Tested-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Daniel Kiper --- grub-core/kern/efi/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index a29af9fa5..b02fab1b1 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -653,7 +653,7 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) if (ret < 1) return GRUB_ERR_BUG; - for (desc = memory_map, *base_addr = GRUB_UINT_MAX; + for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS; (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size); desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) if (desc->attribute & GRUB_EFI_MEMORY_WB) From 082fd84d525f8d6602f892160b77c0a948308a78 Mon Sep 17 00:00:00 2001 From: Steve McIntyre <93sam@debian.org> Date: Mon, 11 Feb 2019 02:42:34 +0000 Subject: [PATCH 0928/1167] grub-install: Check for arm-efi as a default target Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously. Heavily inspired by the existing code for x86. Signed-off-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/osdep/basic/platform.c | 6 ++++++ grub-core/osdep/linux/platform.c | 22 ++++++++++++++++++++++ include/grub/util/install.h | 3 +++ util/grub-install.c | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c index 4b5502aeb..a7dafd85a 100644 --- a/grub-core/osdep/basic/platform.c +++ b/grub-core/osdep/basic/platform.c @@ -18,6 +18,12 @@ #include +const char * +grub_install_get_default_arm_platform (void) +{ + return "arm-uboot"; +} + const char * grub_install_get_default_x86_platform (void) { diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c index 775b6c031..6dee798e3 100644 --- a/grub-core/osdep/linux/platform.c +++ b/grub-core/osdep/linux/platform.c @@ -97,6 +97,28 @@ read_platform_size (void) return ret; } +const char * +grub_install_get_default_arm_platform (void) +{ + /* + * On Linux, we need the efivars kernel modules. If no EFI is available this + * module just does nothing besides a small hello and if we detect efi we'll + * load it anyway later. So it should be safe to try to load it here. + */ + grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL }, + NULL, NULL, "/dev/null"); + + grub_util_info ("Looking for /sys/firmware/efi .."); + if (is_not_empty_directory ("/sys/firmware/efi")) + { + grub_util_info ("...found"); + return "arm-efi"; + } + + grub_util_info ("... not found"); + return "arm-uboot"; +} + const char * grub_install_get_default_x86_platform (void) { diff --git a/include/grub/util/install.h b/include/grub/util/install.h index b1a00154f..2631b1074 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -210,6 +210,9 @@ grub_util_get_target_dirname (const struct grub_install_image_target_desc *t); void grub_install_create_envblk_file (const char *name); +const char * +grub_install_get_default_arm_platform (void); + const char * grub_install_get_default_x86_platform (void); diff --git a/util/grub-install.c b/util/grub-install.c index c6c3da331..264f9ecdc 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -319,7 +319,7 @@ get_default_platform (void) #elif defined (__ia64__) return "ia64-efi"; #elif defined (__arm__) - return "arm-uboot"; + return grub_install_get_default_arm_platform (); #elif defined (__aarch64__) return "arm64-efi"; #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) From 7f6cfc5f40341c6aaa04fe2afd938834dc30ae1e Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 23 Feb 2019 16:22:19 +0100 Subject: [PATCH 0929/1167] travis: Add Travis CI config file There is a really convenient service for open source project from Travis CI: They allow for free CI testing using their infrastructure. GRUB has had issues with broken builds for various targets for a long time already. The main reason is a lack of CI to just do smoke tests on whether all targets still at least compile. This patch adds a Travis config file which builds (almost) all currently available targets. On top of that, this Travis config also runs a small execution test on the x86_64-efi target. All of this config file can easily be extended further on. It probably makes sense to do something similar to the u-boot test infrastructure that communicates with the payload properly. Going forward, we also will want to do more QEMU runtime checks for other targets. Currently, with this config alone, I already see about half of the available targets as broken. So it's definitely desperately needed :). Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- .travis.yml | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..81de20fa3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,108 @@ +# SPDX-License-Identifier: GPL-3.0+ +# Originally Copyright Roger Meier +# Adapted for GRUB by Alexander Graf +# +# Build GRUB on Travis CI - https://www.travis-ci.org/ +# + +dist: xenial + +language: c + +addons: + apt: + packages: + - libsdl1.2-dev + - lzop + - ovmf + - python + - qemu-system + - unifont + +env: + global: + # Include all cross toolchain paths, so we can just call them later down. + - PATH=/tmp/qemu-install/bin:/tmp/grub/bin:/usr/bin:/bin:/tmp/cross/gcc-8.1.0-nolibc/aarch64-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/arm-linux-gnueabi/bin:/tmp/cross/gcc-8.1.0-nolibc/ia64-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/mips64-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/powerpc64-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/riscv32-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/riscv64-linux/bin:/tmp/cross/gcc-8.1.0-nolibc/sparc64-linux/bin + +before_script: + # Install necessary toolchains based on $CROSS_TARGETS variable. + - mkdir /tmp/cross + # These give us binaries like /tmp/cross/gcc-8.1.0-nolibc/ia64-linux/bin/ia64-linux-gcc + - for i in $CROSS_TARGETS; do + ( cd /tmp/cross; wget -t 3 -O - https://mirrors.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.1.0/x86_64-gcc-8.1.0-nolibc-$i.tar.xz | tar xJ ); + done + +script: + # Comments must be outside the command strings below, or the Travis parser + # will get confused. + - ./autogen.sh + + # Build all selected GRUB targets. + - for target in $GRUB_TARGETS; do + plat=${target#*-}; + arch=${target%-*}; + [ "$arch" = "arm64" ] && arch=aarch64-linux; + [ "$arch" = "arm" ] && arch=arm-linux-gnueabi; + [ "$arch" = "ia64" ] && arch=ia64-linux; + [ "$arch" = "mipsel" ] && arch=mips64-linux; + [ "$arch" = "powerpc" ] && arch=powerpc64-linux; + [ "$arch" = "riscv32" ] && arch=riscv32-linux; + [ "$arch" = "riscv64" ] && arch=riscv64-linux; + [ "$arch" = "sparc64" ] && arch=sparc64-linux; + echo "Building $target"; + mkdir obj-$target; + JOBS=`getconf _NPROCESSORS_ONLN 2> /dev/null || echo 1`; + [ "$JOBS" == 1 ] || JOBS=$(($JOBS + 1)); + ( cd obj-$target && ../configure --target=$arch --with-platform=$plat --prefix=/tmp/grub && make -j$JOBS && make -j$JOBS install ) &> log || ( cat log; false ); + done + + # Our test canary. + - echo -e "insmod echo\\ninsmod reboot\\necho hello world\\nreboot" > grub.cfg + + # Assemble images and possibly run them. + - for target in $GRUB_TARGETS; do grub-mkimage -c grub.cfg -p / -O $target -o grub-$target echo reboot normal; done + + # Run images we know how to run. + - if [[ "$GRUB_TARGETS" == *"x86_64-efi"* ]]; then qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -m 512 -no-reboot -nographic -net nic -net user,tftp=.,bootfile=grub-x86_64-efi | tee grub.log && grep "hello world" grub.log; fi + +matrix: + include: + # Each env setting here is a dedicated build. + - name: "x86_64" + env: + - GRUB_TARGETS="x86_64-efi x86_64-xen" + - name: "i386" + env: + - GRUB_TARGETS="i386-coreboot i386-efi i386-ieee1275 i386-multiboot i386-pc i386-qemu i386-xen i386-xen_pvh" + - name: "powerpc" + env: + - GRUB_TARGETS="powerpc-ieee1275" + - CROSS_TARGETS="powerpc64-linux" + - name: "sparc64" + env: + - GRUB_TARGETS="sparc64-ieee1275" + - CROSS_TARGETS="sparc64-linux" + - name: "ia64" + env: + - GRUB_TARGETS="ia64-efi" + - CROSS_TARGETS="ia64-linux" + - name: "mips" + env: + - GRUB_TARGETS="mips-arc mipsel-arc mipsel-qemu_mips mips-qemu_mips" + - CROSS_TARGETS="mips64-linux" + - name: "arm" + env: + - GRUB_TARGETS="arm-coreboot arm-efi arm-uboot" + - CROSS_TARGETS="arm-linux-gnueabi" + - name: "arm64" + env: + - GRUB_TARGETS="arm64-efi" + - CROSS_TARGETS="aarch64-linux" + - name: "riscv32" + env: + - GRUB_TARGETS="riscv32-efi" + - CROSS_TARGETS="riscv32-linux" + - name: "riscv64" + env: + - GRUB_TARGETS="riscv64-efi" + - CROSS_TARGETS="riscv64-linux" From 718b3fb1dc59d94619ca828d1a58cb6f8303d3ef Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 26 Feb 2019 15:07:28 +0100 Subject: [PATCH 0930/1167] Revert "grub-install: Check for arm-efi as a default target" This reverts commit 082fd84d525f8d6602f892160b77c0a948308a78. Incorrect version of the patch was pushed into the git repo. Reported-by: Leif Lindholm Signed-off-by: Daniel Kiper --- grub-core/osdep/basic/platform.c | 6 ------ grub-core/osdep/linux/platform.c | 22 ---------------------- include/grub/util/install.h | 3 --- util/grub-install.c | 2 +- 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c index a7dafd85a..4b5502aeb 100644 --- a/grub-core/osdep/basic/platform.c +++ b/grub-core/osdep/basic/platform.c @@ -18,12 +18,6 @@ #include -const char * -grub_install_get_default_arm_platform (void) -{ - return "arm-uboot"; -} - const char * grub_install_get_default_x86_platform (void) { diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c index 6dee798e3..775b6c031 100644 --- a/grub-core/osdep/linux/platform.c +++ b/grub-core/osdep/linux/platform.c @@ -97,28 +97,6 @@ read_platform_size (void) return ret; } -const char * -grub_install_get_default_arm_platform (void) -{ - /* - * On Linux, we need the efivars kernel modules. If no EFI is available this - * module just does nothing besides a small hello and if we detect efi we'll - * load it anyway later. So it should be safe to try to load it here. - */ - grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL }, - NULL, NULL, "/dev/null"); - - grub_util_info ("Looking for /sys/firmware/efi .."); - if (is_not_empty_directory ("/sys/firmware/efi")) - { - grub_util_info ("...found"); - return "arm-efi"; - } - - grub_util_info ("... not found"); - return "arm-uboot"; -} - const char * grub_install_get_default_x86_platform (void) { diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 2631b1074..b1a00154f 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -210,9 +210,6 @@ grub_util_get_target_dirname (const struct grub_install_image_target_desc *t); void grub_install_create_envblk_file (const char *name); -const char * -grub_install_get_default_arm_platform (void); - const char * grub_install_get_default_x86_platform (void); diff --git a/util/grub-install.c b/util/grub-install.c index 264f9ecdc..c6c3da331 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -319,7 +319,7 @@ get_default_platform (void) #elif defined (__ia64__) return "ia64-efi"; #elif defined (__arm__) - return grub_install_get_default_arm_platform (); + return "arm-uboot"; #elif defined (__aarch64__) return "arm64-efi"; #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) From 686db9664654fd54da0e5ba136322dd9a9423930 Mon Sep 17 00:00:00 2001 From: Steve McIntyre <93sam@debian.org> Date: Thu, 21 Feb 2019 14:46:11 +0000 Subject: [PATCH 0931/1167] grub-install: Check for arm-efi as a default target Much like on x86, we can work out if the system is running on top of EFI firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as previously. Split out the code to (maybe) load the efivar module and check for /sys/firmware/efi into a common helper routine is_efi_system(). Signed-off-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/osdep/basic/platform.c | 6 +++++ grub-core/osdep/linux/platform.c | 42 +++++++++++++++++++++++++------- include/grub/util/install.h | 3 +++ util/grub-install.c | 2 +- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c index 4b5502aeb..a7dafd85a 100644 --- a/grub-core/osdep/basic/platform.c +++ b/grub-core/osdep/basic/platform.c @@ -18,6 +18,12 @@ #include +const char * +grub_install_get_default_arm_platform (void) +{ + return "arm-uboot"; +} + const char * grub_install_get_default_x86_platform (void) { diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c index 775b6c031..e28a79dab 100644 --- a/grub-core/osdep/linux/platform.c +++ b/grub-core/osdep/linux/platform.c @@ -97,15 +97,16 @@ read_platform_size (void) return ret; } -const char * -grub_install_get_default_x86_platform (void) -{ +/* Are we running on an EFI-based system? */ +static int +is_efi_system (void) +{ /* - On Linux, we need the efivars kernel modules. - If no EFI is available this module just does nothing - besides a small hello and if we detect efi we'll load it - anyway later. So it should be safe to - try to load it here. + * Linux uses efivarfs (mounted on /sys/firmware/efi/efivars) to access the + * EFI variable store. Some legacy systems may still use the deprecated + * efivars interface (accessed through /sys/firmware/efi/vars). Where both + * are present, libefivar will use the former in preference, so attempting + * to load efivars will not interfere with later operations. */ grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL }, NULL, NULL, "/dev/null"); @@ -114,13 +115,36 @@ grub_install_get_default_x86_platform (void) if (is_not_empty_directory ("/sys/firmware/efi")) { grub_util_info ("...found"); + return 1; + } + else + { + grub_util_info ("... not found"); + return 0; + } +} + +const char * +grub_install_get_default_arm_platform (void) +{ + if (is_efi_system()) + return "arm-efi"; + else + return "arm-uboot"; +} + +const char * +grub_install_get_default_x86_platform (void) +{ + if (is_efi_system()) + { if (read_platform_size() == 64) return "x86_64-efi"; else return "i386-efi"; } - grub_util_info ("... not found. Looking for /proc/device-tree .."); + grub_util_info ("Looking for /proc/device-tree .."); if (is_not_empty_directory ("/proc/device-tree")) { grub_util_info ("...found"); diff --git a/include/grub/util/install.h b/include/grub/util/install.h index b1a00154f..2631b1074 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -210,6 +210,9 @@ grub_util_get_target_dirname (const struct grub_install_image_target_desc *t); void grub_install_create_envblk_file (const char *name); +const char * +grub_install_get_default_arm_platform (void); + const char * grub_install_get_default_x86_platform (void); diff --git a/util/grub-install.c b/util/grub-install.c index c6c3da331..264f9ecdc 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -319,7 +319,7 @@ get_default_platform (void) #elif defined (__ia64__) return "ia64-efi"; #elif defined (__arm__) - return "arm-uboot"; + return grub_install_get_default_arm_platform (); #elif defined (__aarch64__) return "arm64-efi"; #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) From 222cb8f6df4f0e5964a5dfcdc9a4eb9ad2e631a6 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 26 Feb 2019 18:40:14 +0000 Subject: [PATCH 0932/1167] osdep/freebsd: Fix partition calculation for EBR entries For EBR partitions, "start" is the relative starting sector of the EBR header itself, whereas "offset" is the relative starting byte of the partition's contents, excluding the EBR header and any padding. Thus we must use "offset", and divide by the sector size to convert to sectors. Fixes Debian bug #923253. Signed-off-by: James Clarke Reviewed-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/osdep/freebsd/getroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/freebsd/getroot.c b/grub-core/osdep/freebsd/getroot.c index ccc1d7028..b1e824495 100644 --- a/grub-core/osdep/freebsd/getroot.c +++ b/grub-core/osdep/freebsd/getroot.c @@ -338,8 +338,8 @@ grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **n grub_util_follow_gpart_up (name_tmp, &off, name_out); free (name_tmp); LIST_FOREACH (config, &provider->lg_config, lg_config) - if (strcasecmp (config->lg_name, "start") == 0) - off += strtoull (config->lg_val, 0, 10); + if (strcasecmp (config->lg_name, "offset") == 0) + off += strtoull (config->lg_val, 0, 10) / provider->lg_sectorsize; if (off_out) *off_out = off; return; From 62daa27056b2af38cd65bfb482e4429fb660db6d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 27 Feb 2019 09:10:08 +0000 Subject: [PATCH 0933/1167] util: Detect more I/O errors Many of GRUB's utilities don't check anywhere near all the possible write errors. For example, if grub-install runs out of space when copying a file, it won't notice. There were missing checks for the return values of write, fflush, fsync, and close (or the equivalents on other OSes), all of which must be checked. I tried to be consistent with the existing logging practices of the various hostdisk implementations, but they weren't entirely consistent to start with so I used my judgement. The result at least looks reasonable on GNU/Linux when I provoke a write error: Installing for x86_64-efi platform. grub-install: error: cannot copy `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' to `/boot/efi/EFI/debian/grubx64.efi': No space left on device. There are more missing checks in other utilities, but this should fix the most critical ones. Fixes Debian bug #922741. Signed-off-by: Colin Watson Reviewed-by: Steve McIntyre <93sam@debian.org> Reviewed-by: Daniel Kiper --- grub-core/osdep/aros/hostdisk.c | 38 ++++++++++++++++++------------ grub-core/osdep/unix/hostdisk.c | 18 +++++++------- grub-core/osdep/windows/hostdisk.c | 37 ++++++++++++++++++++++------- include/grub/emu/hostfile.h | 4 ++-- include/grub/emu/misc.h | 2 +- util/editenv.c | 3 ++- util/grub-editenv.c | 3 ++- util/grub-install-common.c | 16 +++++++++---- util/grub-mkimage.c | 8 +++++-- util/setup.c | 6 +++-- 10 files changed, 90 insertions(+), 45 deletions(-) diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c index 7d99b54b8..2be654ca3 100644 --- a/grub-core/osdep/aros/hostdisk.c +++ b/grub-core/osdep/aros/hostdisk.c @@ -439,36 +439,44 @@ grub_util_get_fd_size (grub_util_fd_t fd, return -1; } -void +int grub_util_fd_close (grub_util_fd_t fd) { switch (fd->type) { case GRUB_UTIL_FD_FILE: - close (fd->fd); - return; + return close (fd->fd); case GRUB_UTIL_FD_DISK: CloseDevice ((struct IORequest *) fd->ioreq); DeleteIORequest((struct IORequest *) fd->ioreq); DeleteMsgPort (fd->mp); - return; + return 0; } + return 0; } static int allow_fd_syncs = 1; -static void +static int grub_util_fd_sync_volume (grub_util_fd_t fd) { + LONG err; + fd->ioreq->iotd_Req.io_Command = CMD_UPDATE; fd->ioreq->iotd_Req.io_Length = 0; fd->ioreq->iotd_Req.io_Data = 0; fd->ioreq->iotd_Req.io_Offset = 0; fd->ioreq->iotd_Req.io_Actual = 0; - DoIO ((struct IORequest *) fd->ioreq); + err = DoIO ((struct IORequest *) fd->ioreq); + if (err) + { + grub_util_info ("I/O failed with error %d, IoErr=%d", (int)err, (int) IoErr ()); + return -1; + } + return 0; } -void +int grub_util_fd_sync (grub_util_fd_t fd) { if (allow_fd_syncs) @@ -476,22 +484,22 @@ grub_util_fd_sync (grub_util_fd_t fd) switch (fd->type) { case GRUB_UTIL_FD_FILE: - fsync (fd->fd); - return; + return fsync (fd->fd); case GRUB_UTIL_FD_DISK: - grub_util_fd_sync_volume (fd); - return; + return grub_util_fd_sync_volume (fd); } } + return 0; } -void +int grub_util_file_sync (FILE *f) { - fflush (f); + if (fflush (f) != 0) + return -1; if (!allow_fd_syncs) - return; - fsync (fileno (f)); + return 0; + return fsync (fileno (f)); } void diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index 5450cf416..91150969b 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -177,20 +177,22 @@ grub_util_fd_strerror (void) static int allow_fd_syncs = 1; -void +int grub_util_fd_sync (grub_util_fd_t fd) { if (allow_fd_syncs) - fsync (fd); + return fsync (fd); + return 0; } -void +int grub_util_file_sync (FILE *f) { - fflush (f); + if (fflush (f) != 0) + return -1; if (!allow_fd_syncs) - return; - fsync (fileno (f)); + return 0; + return fsync (fileno (f)); } void @@ -199,10 +201,10 @@ grub_util_disable_fd_syncs (void) allow_fd_syncs = 0; } -void +int grub_util_fd_close (grub_util_fd_t fd) { - close (fd); + return close (fd); } char * diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c index 85507af88..355100789 100644 --- a/grub-core/osdep/windows/hostdisk.c +++ b/grub-core/osdep/windows/hostdisk.c @@ -275,11 +275,18 @@ grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len) static int allow_fd_syncs = 1; -void +int grub_util_fd_sync (grub_util_fd_t fd) { if (allow_fd_syncs) - FlushFileBuffers (fd); + { + if (!FlushFileBuffers (fd)) + { + grub_util_info ("flush err %x", (int) GetLastError ()); + return -1; + } + } + return 0; } void @@ -288,10 +295,15 @@ grub_util_disable_fd_syncs (void) allow_fd_syncs = 0; } -void +int grub_util_fd_close (grub_util_fd_t fd) { - CloseHandle (fd); + if (!CloseHandle (fd)) + { + grub_util_info ("close err %x", (int) GetLastError ()); + return -1; + } + return 0; } const char * @@ -620,16 +632,25 @@ grub_util_fopen (const char *path, const char *mode) return ret; } -void +int grub_util_file_sync (FILE *f) { HANDLE hnd; - fflush (f); + if (fflush (f) != 0) + { + grub_util_info ("fflush err %x", (int) GetLastError ()); + return -1; + } if (!allow_fd_syncs) - return; + return 0; hnd = (HANDLE) _get_osfhandle (fileno (f)); - FlushFileBuffers (hnd); + if (!FlushFileBuffers (hnd)) + { + grub_util_info ("flush err %x", (int) GetLastError ()); + return -1; + } + return 0; } int diff --git a/include/grub/emu/hostfile.h b/include/grub/emu/hostfile.h index 8e37d5acb..cfb1e2b56 100644 --- a/include/grub/emu/hostfile.h +++ b/include/grub/emu/hostfile.h @@ -47,11 +47,11 @@ grub_util_fd_t EXPORT_FUNC(grub_util_fd_open) (const char *os_dev, int flags); const char * EXPORT_FUNC(grub_util_fd_strerror) (void); -void +int grub_util_fd_sync (grub_util_fd_t fd); void grub_util_disable_fd_syncs (void); -void +int EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd); grub_uint64_t diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index df6085bcb..59b8b35fc 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -73,6 +73,6 @@ FILE * grub_util_fopen (const char *path, const char *mode); #endif -void grub_util_file_sync (FILE *f); +int grub_util_file_sync (FILE *f); #endif /* GRUB_EMU_MISC_H */ diff --git a/util/editenv.c b/util/editenv.c index c6f8d2298..eb2d0c03a 100644 --- a/util/editenv.c +++ b/util/editenv.c @@ -55,7 +55,8 @@ grub_util_create_envblk_file (const char *name) strerror (errno)); - grub_util_file_sync (fp); + if (grub_util_file_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), namenew, strerror (errno)); free (buf); fclose (fp); diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 118e89fe5..f3662c95b 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -197,7 +197,8 @@ write_envblk (const char *name, grub_envblk_t envblk) grub_util_error (_("cannot write to `%s': %s"), name, strerror (errno)); - grub_util_file_sync (fp); + if (grub_util_file_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), name, strerror (errno)); fclose (fp); } diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 0a7d68b9b..ca0ac612a 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -112,11 +112,16 @@ grub_install_copy_file (const char *src, r = grub_util_fd_read (in, grub_install_copy_buffer, GRUB_INSTALL_COPY_BUFFER_SIZE); if (r <= 0) break; - grub_util_fd_write (out, grub_install_copy_buffer, r); + r = grub_util_fd_write (out, grub_install_copy_buffer, r); + if (r <= 0) + break; } - grub_util_fd_sync (out); - grub_util_fd_close (in); - grub_util_fd_close (out); + if (grub_util_fd_sync (out) < 0) + r = -1; + if (grub_util_fd_close (in) < 0) + r = -1; + if (grub_util_fd_close (out) < 0) + r = -1; if (r < 0) grub_util_error (_("cannot copy `%s' to `%s': %s"), @@ -526,7 +531,8 @@ grub_install_make_image_wrap (const char *dir, const char *prefix, grub_install_make_image_wrap_file (dir, prefix, fp, outname, memdisk_path, config_path, mkimage_target, note); - grub_util_file_sync (fp); + if (grub_util_file_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), outname, strerror (errno)); fclose (fp); } diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 98d24cc06..912564e36 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -311,8 +311,12 @@ main (int argc, char *argv[]) arguments.image_target, arguments.note, arguments.comp, arguments.dtb); - grub_util_file_sync (fp); - fclose (fp); + if (grub_util_file_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), arguments.output ? : "stdout", + strerror (errno)); + if (fclose (fp) == EOF) + grub_util_error (_("cannot close `%s': %s"), arguments.output ? : "stdout", + strerror (errno)); for (i = 0; i < arguments.nmodules; i++) free (arguments.modules[i]); diff --git a/util/setup.c b/util/setup.c index 9c1e1b7da..8954dd479 100644 --- a/util/setup.c +++ b/util/setup.c @@ -728,8 +728,10 @@ unable_to_embed: != GRUB_DISK_SECTOR_SIZE * 2) grub_util_error (_("cannot write to `%s': %s"), core_path, strerror (errno)); - grub_util_fd_sync (fp); - grub_util_fd_close (fp); + if (grub_util_fd_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), core_path, strerror (errno)); + if (grub_util_fd_close (fp) < 0) + grub_util_error (_("cannot close `%s': %s"), core_path, strerror (errno)); grub_util_biosdisk_flush (root_dev->disk); grub_disk_cache_invalidate_all (); From f8f35acb5b05d40e3707a9d2db9ede60023e4cac Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 27 Feb 2019 10:26:30 +0000 Subject: [PATCH 0934/1167] syslinux: Fix syslinux_test in out-of-tree builds syslinux_parse simplifies some filenames by removing things like ".." segments, but the tests assumed that @abs_top_srcdir@ would be untouched, which is not true in the case of out-of-tree builds where @abs_top_srcdir@ may contain ".." segments. Performing the substitution requires some awkwardness in Makefile.am due to details of how config.status works. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- Makefile.am | 7 ++++++- grub-core/lib/syslinux_parse.c | 4 ++++ tests/syslinux/ubuntu10.04_grub.cfg.in | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index a52a998a1..5b3cf5b4d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -476,6 +476,11 @@ EXTRA_DIST += ChangeLog ChangeLog-2015 syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg +# Mimic simplify_filename from grub-core/lib/syslinux_parse.c, so that we +# can predict its behaviour in tests. We have to pre-substitute this before +# calling config.status, as config.status offers no reliable way to hook in +# a command between setting ac_abs_top_srcdir and emitting output files. tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in - (for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:- + simplified_abs_top_srcdir=`echo "$(abs_top_srcdir)" | sed 's,//,/,g; s,/\./,/,g; :loop; s,/[^/][^/]*/\.\.\(/\|$$\),\1,; t loop'`; \ + sed "s,@simplified_abs_top_srcdir@,$$simplified_abs_top_srcdir,g" $(srcdir)/tests/syslinux/ubuntu10.04_grub.cfg.in | $(top_builddir)/config.status --file=$@:- CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index c96d85ee5..4afa99279 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -807,6 +807,10 @@ print_file (struct output_buffer *outbuf, return print_escaped (outbuf, from, to); } +/* + * Makefile.am mimics this when generating tests/syslinux/ubuntu10.04_grub.cfg, + * so changes here may need to be reflected there too. + */ static void simplify_filename (char *str) { diff --git a/tests/syslinux/ubuntu10.04_grub.cfg.in b/tests/syslinux/ubuntu10.04_grub.cfg.in index 846e4acf0..441dec045 100644 --- a/tests/syslinux/ubuntu10.04_grub.cfg.in +++ b/tests/syslinux/ubuntu10.04_grub.cfg.in @@ -41,7 +41,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -63,14 +63,14 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' # UNSUPPORTED command 'display f1.txt' # UNSUPPORTED command 'menu hshift 13' @@ -114,7 +114,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -136,13 +136,13 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { -#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' } menuentry 'menu' --id 'menu' { @@ -156,7 +156,7 @@ menuentry 'menu' --id 'menu' { # UNSUPPORTED command 'f8 f8.txt' # UNSUPPORTED command 'f9 f9.txt' # UNSUPPORTED command 'f0 f10.txt' -#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' # D-I config version 2.0 # UNSUPPORTED command 'menu hshift 13' @@ -200,7 +200,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -222,14 +222,14 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found +# File (host)/@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)@simplified_abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' } } From 35b909062e7b334eb4af372be3260d0f62d85375 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 27 Feb 2019 10:03:55 +0000 Subject: [PATCH 0935/1167] gnulib: Upgrade Gnulib and switch to bootstrap tool Upgrade Gnulib files to 20190105. It's much easier to maintain GRUB's use of portability support files from Gnulib when the process is automatic and driven by a single configuration file, rather than by maintainers occasionally running gnulib-tool and committing the result. Removing these automatically-copied files from revision control also removes the temptation to hack the output in ways that are difficult for future maintainers to follow. Gnulib includes a "bootstrap" program which is designed for this. The canonical way to bootstrap GRUB from revision control is now "./bootstrap", but "./autogen.sh" is still useful if you just want to generate the GRUB-specific parts of the build system. GRUB now requires Autoconf >= 2.63 and Automake >= 1.11, in line with Gnulib. Gnulib source code is now placed in grub-core/lib/gnulib/ (which should not be edited directly), and GRUB's patches are in grub-core/lib/gnulib-patches/. I've added a few notes to the developer manual on how to maintain this. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- .gitignore | 34 +- ABOUT-NLS | 223 - INSTALL | 11 +- Makefile.am | 2 +- Makefile.util.def | 56 +- autogen.sh | 20 +- bootstrap | 1073 ++++ bootstrap.conf | 90 + build-aux/config.rpath | 690 -- build-aux/gitlog-to-changelog | 432 -- build-aux/snippet/_Noreturn.h | 10 - build-aux/snippet/arg-nonnull.h | 26 - build-aux/snippet/c++defs.h | 271 - build-aux/snippet/warn-on-use.h | 109 - conf/Makefile.common | 4 +- conf/Makefile.extra-dist | 7 +- configure.ac | 7 +- docs/grub-dev.texi | 32 +- grub-core/Makefile.core.def | 6 +- grub-core/gnulib-fix-gcc7-fallthrough.diff | 14 - grub-core/gnulib-no-abort.diff | 30 - grub-core/gnulib-no-gets.diff | 10 - grub-core/gnulib/Makefile.am | 1747 ----- grub-core/gnulib/alloca.c | 478 -- grub-core/gnulib/alloca.in.h | 63 - grub-core/gnulib/argp-ba.c | 34 - grub-core/gnulib/argp-eexst.c | 30 - grub-core/gnulib/argp-fmtstream.c | 488 -- grub-core/gnulib/argp-fmtstream.h | 359 -- grub-core/gnulib/argp-fs-xinl.c | 46 - grub-core/gnulib/argp-help.c | 1960 ------ grub-core/gnulib/argp-namefrob.h | 157 - grub-core/gnulib/argp-parse.c | 953 --- grub-core/gnulib/argp-pin.c | 26 - grub-core/gnulib/argp-pv.c | 34 - grub-core/gnulib/argp-pvh.c | 31 - grub-core/gnulib/argp-xinl.c | 46 - grub-core/gnulib/argp.h | 650 -- grub-core/gnulib/asnprintf.c | 34 - grub-core/gnulib/basename-lgpl.c | 75 - grub-core/gnulib/btowc.c | 39 - grub-core/gnulib/config.charset | 684 -- grub-core/gnulib/dirname-lgpl.c | 86 - grub-core/gnulib/dirname.h | 46 - grub-core/gnulib/dosname.h | 53 - grub-core/gnulib/errno.in.h | 279 - grub-core/gnulib/error.c | 401 -- grub-core/gnulib/error.h | 65 - grub-core/gnulib/float+.h | 147 - grub-core/gnulib/float.c | 33 - grub-core/gnulib/float.in.h | 188 - grub-core/gnulib/fnmatch.c | 350 - grub-core/gnulib/fnmatch.in.h | 67 - grub-core/gnulib/fnmatch_loop.c | 1219 ---- grub-core/gnulib/getdelim.c | 135 - grub-core/gnulib/getline.c | 27 - grub-core/gnulib/getopt.c | 1245 ---- grub-core/gnulib/getopt.in.h | 255 - grub-core/gnulib/getopt1.c | 170 - grub-core/gnulib/getopt_int.h | 135 - grub-core/gnulib/gettext.h | 288 - grub-core/gnulib/intprops.h | 319 - grub-core/gnulib/itold.c | 28 - grub-core/gnulib/langinfo.in.h | 176 - grub-core/gnulib/localcharset.c | 553 -- grub-core/gnulib/localcharset.h | 40 - grub-core/gnulib/locale.in.h | 216 - grub-core/gnulib/localeconv.c | 103 - grub-core/gnulib/malloc.c | 56 - grub-core/gnulib/mbrtowc.c | 402 -- grub-core/gnulib/mbsinit.c | 61 - grub-core/gnulib/mbsrtowcs-impl.h | 122 - grub-core/gnulib/mbsrtowcs-state.c | 37 - grub-core/gnulib/mbsrtowcs.c | 32 - grub-core/gnulib/mbswidth.c | 199 - grub-core/gnulib/mbswidth.h | 63 - grub-core/gnulib/mbtowc-impl.h | 44 - grub-core/gnulib/mbtowc.c | 26 - grub-core/gnulib/memchr.c | 172 - grub-core/gnulib/memchr.valgrind | 14 - grub-core/gnulib/mempcpy.c | 28 - grub-core/gnulib/msvc-inval.c | 129 - grub-core/gnulib/msvc-inval.h | 222 - grub-core/gnulib/msvc-nothrow.c | 49 - grub-core/gnulib/msvc-nothrow.h | 43 - grub-core/gnulib/nl_langinfo.c | 271 - grub-core/gnulib/printf-args.c | 187 - grub-core/gnulib/printf-args.h | 158 - grub-core/gnulib/printf-parse.c | 638 -- grub-core/gnulib/printf-parse.h | 193 - grub-core/gnulib/progname.c | 92 - grub-core/gnulib/progname.h | 62 - grub-core/gnulib/rawmemchr.c | 136 - grub-core/gnulib/rawmemchr.valgrind | 12 - grub-core/gnulib/realloc.c | 79 - grub-core/gnulib/ref-add.sin | 29 - grub-core/gnulib/ref-del.sin | 24 - grub-core/gnulib/regcomp.c | 3913 ------------ grub-core/gnulib/regex.c | 81 - grub-core/gnulib/regex.h | 667 -- grub-core/gnulib/regex_internal.c | 1741 ----- grub-core/gnulib/regex_internal.h | 873 --- grub-core/gnulib/regexec.c | 4417 ------------- grub-core/gnulib/size_max.h | 30 - grub-core/gnulib/sleep.c | 76 - grub-core/gnulib/stdalign.in.h | 90 - grub-core/gnulib/stdbool.in.h | 132 - grub-core/gnulib/stddef.in.h | 86 - grub-core/gnulib/stdint.in.h | 636 -- grub-core/gnulib/stdio.in.h | 1333 ---- grub-core/gnulib/stdlib.in.h | 954 --- grub-core/gnulib/strcasecmp.c | 62 - grub-core/gnulib/strchrnul.c | 142 - grub-core/gnulib/strchrnul.valgrind | 12 - grub-core/gnulib/streq.h | 176 - grub-core/gnulib/strerror-override.c | 302 - grub-core/gnulib/strerror-override.h | 56 - grub-core/gnulib/strerror.c | 70 - grub-core/gnulib/string.in.h | 1029 --- grub-core/gnulib/strings.in.h | 122 - grub-core/gnulib/stripslash.c | 45 - grub-core/gnulib/strncasecmp.c | 62 - grub-core/gnulib/strndup.c | 36 - grub-core/gnulib/strnlen.c | 30 - grub-core/gnulib/strnlen1.c | 35 - grub-core/gnulib/strnlen1.h | 40 - grub-core/gnulib/sys_types.in.h | 51 - grub-core/gnulib/sysexits.in.h | 72 - grub-core/gnulib/unistd.c | 3 - grub-core/gnulib/unistd.in.h | 1530 ----- grub-core/gnulib/unitypes.in.h | 46 - grub-core/gnulib/uniwidth.in.h | 72 - grub-core/gnulib/uniwidth/cjk.h | 37 - grub-core/gnulib/uniwidth/width.c | 368 -- grub-core/gnulib/vasnprintf.c | 5606 ----------------- grub-core/gnulib/vasnprintf.h | 79 - grub-core/gnulib/verify.h | 245 - grub-core/gnulib/vsnprintf.c | 70 - grub-core/gnulib/wchar.in.h | 1028 --- grub-core/gnulib/wcrtomb.c | 53 - grub-core/gnulib/wctype-h.c | 4 - grub-core/gnulib/wctype.in.h | 504 -- grub-core/gnulib/wcwidth.c | 50 - grub-core/gnulib/xsize.c | 3 - grub-core/gnulib/xsize.h | 114 - .../gnulib-patches/fix-null-deref.patch} | 10 +- .../gnulib-patches/fix-width.patch} | 96 +- grub-core/lib/gnulib-patches/no-abort.patch | 26 + m4/00gnulib.m4 | 30 - m4/alloca.m4 | 121 - m4/argp.m4 | 61 - m4/btowc.m4 | 116 - m4/codeset.m4 | 23 - m4/configmake.m4 | 50 - m4/dirname.m4 | 19 - m4/double-slash-root.m4 | 38 - m4/eealloc.m4 | 31 - m4/errno_h.m4 | 137 - m4/error.m4 | 27 - m4/exponentd.m4 | 116 - m4/extensions.m4 | 138 - m4/extern-inline.m4 | 100 - m4/fcntl-o.m4 | 134 - m4/float_h.m4 | 98 - m4/fnmatch.m4 | 156 - m4/getdelim.m4 | 88 - m4/getline.m4 | 96 - m4/getopt.m4 | 368 -- m4/gettext.m4 | 401 -- m4/glibc2.m4 | 31 - m4/glibc21.m4 | 34 - m4/gnulib-cache.m4 | 55 - m4/gnulib-common.m4 | 377 -- m4/gnulib-comp.m4 | 756 --- m4/gnulib-tool.m4 | 57 - m4/iconv.m4 | 268 - m4/include_next.m4 | 270 - m4/intdiv0.m4 | 87 - m4/intl.m4 | 300 - m4/intldir.m4 | 19 - m4/intlmacosx.m4 | 56 - m4/intmax.m4 | 36 - m4/intmax_t.m4 | 67 - m4/inttypes-pri.m4 | 42 - m4/inttypes_h.m4 | 29 - m4/langinfo_h.m4 | 105 - m4/lcmessage.m4 | 35 - m4/lib-ld.m4 | 119 - m4/lib-link.m4 | 777 --- m4/lib-prefix.m4 | 224 - m4/libunistring-base.m4 | 141 - m4/localcharset.m4 | 17 - m4/locale-fr.m4 | 250 - m4/locale-ja.m4 | 136 - m4/locale-zh.m4 | 130 - m4/locale_h.m4 | 122 - m4/localeconv.m4 | 22 - m4/lock.m4 | 39 - m4/longlong.m4 | 113 - m4/malloc.m4 | 98 - m4/math_h.m4 | 353 -- m4/mbrtowc.m4 | 572 -- m4/mbsinit.m4 | 51 - m4/mbsrtowcs.m4 | 155 - m4/mbstate_t.m4 | 41 - m4/mbswidth.m4 | 46 - m4/mbtowc.m4 | 19 - m4/memchr.m4 | 88 - m4/mempcpy.m4 | 26 - m4/mmap-anon.m4 | 55 - m4/msvc-inval.m4 | 19 - m4/msvc-nothrow.m4 | 10 - m4/multiarch.m4 | 62 - m4/nl_langinfo.m4 | 50 - m4/nls.m4 | 32 - m4/nocrash.m4 | 130 - m4/off_t.m4 | 18 - m4/po.m4 | 452 -- m4/printf-posix.m4 | 48 - m4/printf.m4 | 1570 ----- m4/progtest.m4 | 91 - m4/rawmemchr.m4 | 20 - m4/realloc.m4 | 76 - m4/regex.m4 | 261 - m4/size_max.m4 | 79 - m4/sleep.m4 | 62 - m4/ssize_t.m4 | 23 - m4/stdalign.m4 | 52 - m4/stdbool.m4 | 100 - m4/stddef_h.m4 | 47 - m4/stdint.m4 | 484 -- m4/stdint_h.m4 | 27 - m4/stdio_h.m4 | 194 - m4/stdlib_h.m4 | 117 - m4/strcase.m4 | 45 - m4/strchrnul.m4 | 50 - m4/strerror.m4 | 96 - m4/string_h.m4 | 120 - m4/strings_h.m4 | 52 - m4/strndup.m4 | 55 - m4/strnlen.m4 | 30 - m4/sys_socket_h.m4 | 176 - m4/sys_types_h.m4 | 24 - m4/sysexits.m4 | 44 - m4/threadlib.m4 | 371 -- m4/uintmax_t.m4 | 30 - m4/unistd_h.m4 | 186 - m4/vasnprintf.m4 | 291 - m4/visibility.m4 | 77 - m4/vsnprintf.m4 | 54 - m4/warn-on-use.m4 | 47 - m4/wchar_h.m4 | 225 - m4/wchar_t.m4 | 24 - m4/wcrtomb.m4 | 112 - m4/wctype_h.m4 | 209 - m4/wcwidth.m4 | 101 - m4/wint_t.m4 | 32 - m4/xsize.m4 | 12 - po/Makefile.in.in | 469 -- po/Makevars | 41 - po/Rules-quot | 47 - util/grub-setup.c | 2 +- 262 files changed, 1343 insertions(+), 62879 deletions(-) delete mode 100644 ABOUT-NLS create mode 100755 bootstrap create mode 100644 bootstrap.conf delete mode 100755 build-aux/config.rpath delete mode 100755 build-aux/gitlog-to-changelog delete mode 100644 build-aux/snippet/_Noreturn.h delete mode 100644 build-aux/snippet/arg-nonnull.h delete mode 100644 build-aux/snippet/c++defs.h delete mode 100644 build-aux/snippet/warn-on-use.h delete mode 100644 grub-core/gnulib-fix-gcc7-fallthrough.diff delete mode 100644 grub-core/gnulib-no-abort.diff delete mode 100644 grub-core/gnulib-no-gets.diff delete mode 100644 grub-core/gnulib/Makefile.am delete mode 100644 grub-core/gnulib/alloca.c delete mode 100644 grub-core/gnulib/alloca.in.h delete mode 100644 grub-core/gnulib/argp-ba.c delete mode 100644 grub-core/gnulib/argp-eexst.c delete mode 100644 grub-core/gnulib/argp-fmtstream.c delete mode 100644 grub-core/gnulib/argp-fmtstream.h delete mode 100644 grub-core/gnulib/argp-fs-xinl.c delete mode 100644 grub-core/gnulib/argp-help.c delete mode 100644 grub-core/gnulib/argp-namefrob.h delete mode 100644 grub-core/gnulib/argp-parse.c delete mode 100644 grub-core/gnulib/argp-pin.c delete mode 100644 grub-core/gnulib/argp-pv.c delete mode 100644 grub-core/gnulib/argp-pvh.c delete mode 100644 grub-core/gnulib/argp-xinl.c delete mode 100644 grub-core/gnulib/argp.h delete mode 100644 grub-core/gnulib/asnprintf.c delete mode 100644 grub-core/gnulib/basename-lgpl.c delete mode 100644 grub-core/gnulib/btowc.c delete mode 100644 grub-core/gnulib/config.charset delete mode 100644 grub-core/gnulib/dirname-lgpl.c delete mode 100644 grub-core/gnulib/dirname.h delete mode 100644 grub-core/gnulib/dosname.h delete mode 100644 grub-core/gnulib/errno.in.h delete mode 100644 grub-core/gnulib/error.c delete mode 100644 grub-core/gnulib/error.h delete mode 100644 grub-core/gnulib/float+.h delete mode 100644 grub-core/gnulib/float.c delete mode 100644 grub-core/gnulib/float.in.h delete mode 100644 grub-core/gnulib/fnmatch.c delete mode 100644 grub-core/gnulib/fnmatch.in.h delete mode 100644 grub-core/gnulib/fnmatch_loop.c delete mode 100644 grub-core/gnulib/getdelim.c delete mode 100644 grub-core/gnulib/getline.c delete mode 100644 grub-core/gnulib/getopt.c delete mode 100644 grub-core/gnulib/getopt.in.h delete mode 100644 grub-core/gnulib/getopt1.c delete mode 100644 grub-core/gnulib/getopt_int.h delete mode 100644 grub-core/gnulib/gettext.h delete mode 100644 grub-core/gnulib/intprops.h delete mode 100644 grub-core/gnulib/itold.c delete mode 100644 grub-core/gnulib/langinfo.in.h delete mode 100644 grub-core/gnulib/localcharset.c delete mode 100644 grub-core/gnulib/localcharset.h delete mode 100644 grub-core/gnulib/locale.in.h delete mode 100644 grub-core/gnulib/localeconv.c delete mode 100644 grub-core/gnulib/malloc.c delete mode 100644 grub-core/gnulib/mbrtowc.c delete mode 100644 grub-core/gnulib/mbsinit.c delete mode 100644 grub-core/gnulib/mbsrtowcs-impl.h delete mode 100644 grub-core/gnulib/mbsrtowcs-state.c delete mode 100644 grub-core/gnulib/mbsrtowcs.c delete mode 100644 grub-core/gnulib/mbswidth.c delete mode 100644 grub-core/gnulib/mbswidth.h delete mode 100644 grub-core/gnulib/mbtowc-impl.h delete mode 100644 grub-core/gnulib/mbtowc.c delete mode 100644 grub-core/gnulib/memchr.c delete mode 100644 grub-core/gnulib/memchr.valgrind delete mode 100644 grub-core/gnulib/mempcpy.c delete mode 100644 grub-core/gnulib/msvc-inval.c delete mode 100644 grub-core/gnulib/msvc-inval.h delete mode 100644 grub-core/gnulib/msvc-nothrow.c delete mode 100644 grub-core/gnulib/msvc-nothrow.h delete mode 100644 grub-core/gnulib/nl_langinfo.c delete mode 100644 grub-core/gnulib/printf-args.c delete mode 100644 grub-core/gnulib/printf-args.h delete mode 100644 grub-core/gnulib/printf-parse.c delete mode 100644 grub-core/gnulib/printf-parse.h delete mode 100644 grub-core/gnulib/progname.c delete mode 100644 grub-core/gnulib/progname.h delete mode 100644 grub-core/gnulib/rawmemchr.c delete mode 100644 grub-core/gnulib/rawmemchr.valgrind delete mode 100644 grub-core/gnulib/realloc.c delete mode 100644 grub-core/gnulib/ref-add.sin delete mode 100644 grub-core/gnulib/ref-del.sin delete mode 100644 grub-core/gnulib/regcomp.c delete mode 100644 grub-core/gnulib/regex.c delete mode 100644 grub-core/gnulib/regex.h delete mode 100644 grub-core/gnulib/regex_internal.c delete mode 100644 grub-core/gnulib/regex_internal.h delete mode 100644 grub-core/gnulib/regexec.c delete mode 100644 grub-core/gnulib/size_max.h delete mode 100644 grub-core/gnulib/sleep.c delete mode 100644 grub-core/gnulib/stdalign.in.h delete mode 100644 grub-core/gnulib/stdbool.in.h delete mode 100644 grub-core/gnulib/stddef.in.h delete mode 100644 grub-core/gnulib/stdint.in.h delete mode 100644 grub-core/gnulib/stdio.in.h delete mode 100644 grub-core/gnulib/stdlib.in.h delete mode 100644 grub-core/gnulib/strcasecmp.c delete mode 100644 grub-core/gnulib/strchrnul.c delete mode 100644 grub-core/gnulib/strchrnul.valgrind delete mode 100644 grub-core/gnulib/streq.h delete mode 100644 grub-core/gnulib/strerror-override.c delete mode 100644 grub-core/gnulib/strerror-override.h delete mode 100644 grub-core/gnulib/strerror.c delete mode 100644 grub-core/gnulib/string.in.h delete mode 100644 grub-core/gnulib/strings.in.h delete mode 100644 grub-core/gnulib/stripslash.c delete mode 100644 grub-core/gnulib/strncasecmp.c delete mode 100644 grub-core/gnulib/strndup.c delete mode 100644 grub-core/gnulib/strnlen.c delete mode 100644 grub-core/gnulib/strnlen1.c delete mode 100644 grub-core/gnulib/strnlen1.h delete mode 100644 grub-core/gnulib/sys_types.in.h delete mode 100644 grub-core/gnulib/sysexits.in.h delete mode 100644 grub-core/gnulib/unistd.c delete mode 100644 grub-core/gnulib/unistd.in.h delete mode 100644 grub-core/gnulib/unitypes.in.h delete mode 100644 grub-core/gnulib/uniwidth.in.h delete mode 100644 grub-core/gnulib/uniwidth/cjk.h delete mode 100644 grub-core/gnulib/uniwidth/width.c delete mode 100644 grub-core/gnulib/vasnprintf.c delete mode 100644 grub-core/gnulib/vasnprintf.h delete mode 100644 grub-core/gnulib/verify.h delete mode 100644 grub-core/gnulib/vsnprintf.c delete mode 100644 grub-core/gnulib/wchar.in.h delete mode 100644 grub-core/gnulib/wcrtomb.c delete mode 100644 grub-core/gnulib/wctype-h.c delete mode 100644 grub-core/gnulib/wctype.in.h delete mode 100644 grub-core/gnulib/wcwidth.c delete mode 100644 grub-core/gnulib/xsize.c delete mode 100644 grub-core/gnulib/xsize.h rename grub-core/{gnulib-fix-null-deref.diff => lib/gnulib-patches/fix-null-deref.patch} (52%) rename grub-core/{gnulib-fix-width.diff => lib/gnulib-patches/fix-width.patch} (75%) create mode 100644 grub-core/lib/gnulib-patches/no-abort.patch delete mode 100644 m4/00gnulib.m4 delete mode 100644 m4/alloca.m4 delete mode 100644 m4/argp.m4 delete mode 100644 m4/btowc.m4 delete mode 100644 m4/codeset.m4 delete mode 100644 m4/configmake.m4 delete mode 100644 m4/dirname.m4 delete mode 100644 m4/double-slash-root.m4 delete mode 100644 m4/eealloc.m4 delete mode 100644 m4/errno_h.m4 delete mode 100644 m4/error.m4 delete mode 100644 m4/exponentd.m4 delete mode 100644 m4/extensions.m4 delete mode 100644 m4/extern-inline.m4 delete mode 100644 m4/fcntl-o.m4 delete mode 100644 m4/float_h.m4 delete mode 100644 m4/fnmatch.m4 delete mode 100644 m4/getdelim.m4 delete mode 100644 m4/getline.m4 delete mode 100644 m4/getopt.m4 delete mode 100644 m4/gettext.m4 delete mode 100644 m4/glibc2.m4 delete mode 100644 m4/glibc21.m4 delete mode 100644 m4/gnulib-cache.m4 delete mode 100644 m4/gnulib-common.m4 delete mode 100644 m4/gnulib-comp.m4 delete mode 100644 m4/gnulib-tool.m4 delete mode 100644 m4/iconv.m4 delete mode 100644 m4/include_next.m4 delete mode 100644 m4/intdiv0.m4 delete mode 100644 m4/intl.m4 delete mode 100644 m4/intldir.m4 delete mode 100644 m4/intlmacosx.m4 delete mode 100644 m4/intmax.m4 delete mode 100644 m4/intmax_t.m4 delete mode 100644 m4/inttypes-pri.m4 delete mode 100644 m4/inttypes_h.m4 delete mode 100644 m4/langinfo_h.m4 delete mode 100644 m4/lcmessage.m4 delete mode 100644 m4/lib-ld.m4 delete mode 100644 m4/lib-link.m4 delete mode 100644 m4/lib-prefix.m4 delete mode 100644 m4/libunistring-base.m4 delete mode 100644 m4/localcharset.m4 delete mode 100644 m4/locale-fr.m4 delete mode 100644 m4/locale-ja.m4 delete mode 100644 m4/locale-zh.m4 delete mode 100644 m4/locale_h.m4 delete mode 100644 m4/localeconv.m4 delete mode 100644 m4/lock.m4 delete mode 100644 m4/longlong.m4 delete mode 100644 m4/malloc.m4 delete mode 100644 m4/math_h.m4 delete mode 100644 m4/mbrtowc.m4 delete mode 100644 m4/mbsinit.m4 delete mode 100644 m4/mbsrtowcs.m4 delete mode 100644 m4/mbstate_t.m4 delete mode 100644 m4/mbswidth.m4 delete mode 100644 m4/mbtowc.m4 delete mode 100644 m4/memchr.m4 delete mode 100644 m4/mempcpy.m4 delete mode 100644 m4/mmap-anon.m4 delete mode 100644 m4/msvc-inval.m4 delete mode 100644 m4/msvc-nothrow.m4 delete mode 100644 m4/multiarch.m4 delete mode 100644 m4/nl_langinfo.m4 delete mode 100644 m4/nls.m4 delete mode 100644 m4/nocrash.m4 delete mode 100644 m4/off_t.m4 delete mode 100644 m4/po.m4 delete mode 100644 m4/printf-posix.m4 delete mode 100644 m4/printf.m4 delete mode 100644 m4/progtest.m4 delete mode 100644 m4/rawmemchr.m4 delete mode 100644 m4/realloc.m4 delete mode 100644 m4/regex.m4 delete mode 100644 m4/size_max.m4 delete mode 100644 m4/sleep.m4 delete mode 100644 m4/ssize_t.m4 delete mode 100644 m4/stdalign.m4 delete mode 100644 m4/stdbool.m4 delete mode 100644 m4/stddef_h.m4 delete mode 100644 m4/stdint.m4 delete mode 100644 m4/stdint_h.m4 delete mode 100644 m4/stdio_h.m4 delete mode 100644 m4/stdlib_h.m4 delete mode 100644 m4/strcase.m4 delete mode 100644 m4/strchrnul.m4 delete mode 100644 m4/strerror.m4 delete mode 100644 m4/string_h.m4 delete mode 100644 m4/strings_h.m4 delete mode 100644 m4/strndup.m4 delete mode 100644 m4/strnlen.m4 delete mode 100644 m4/sys_socket_h.m4 delete mode 100644 m4/sys_types_h.m4 delete mode 100644 m4/sysexits.m4 delete mode 100644 m4/threadlib.m4 delete mode 100644 m4/uintmax_t.m4 delete mode 100644 m4/unistd_h.m4 delete mode 100644 m4/vasnprintf.m4 delete mode 100644 m4/visibility.m4 delete mode 100644 m4/vsnprintf.m4 delete mode 100644 m4/warn-on-use.m4 delete mode 100644 m4/wchar_h.m4 delete mode 100644 m4/wchar_t.m4 delete mode 100644 m4/wcrtomb.m4 delete mode 100644 m4/wctype_h.m4 delete mode 100644 m4/wcwidth.m4 delete mode 100644 m4/wint_t.m4 delete mode 100644 m4/xsize.m4 delete mode 100644 po/Makefile.in.in delete mode 100644 po/Makevars delete mode 100644 po/Rules-quot diff --git a/.gitignore b/.gitignore index eca17bec9..819cd185d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ 00_header 10_* 20_linux_xen @@ -6,11 +7,13 @@ 41_custom *.1 *.8 +ABOUT-NLS aclocal.m4 ahci_test ascii.bitmaps ascii.h autom4te.cache +build-aux build-grub-gen-asciih build-grub-gen-widthspec build-grub-mkfont @@ -42,6 +45,7 @@ gensymlist.sh gentrigtables gentrigtables.exe gettext_strings_test +/gnulib grub-bin2h /grub-bios-setup /grub-bios-setup.exe @@ -134,6 +138,7 @@ help_test *.image.exe include/grub/cpu include/grub/machine +INSTALL.grub install-sh lib/libgcrypt-grub libgrub_a_init.c @@ -142,6 +147,7 @@ libgrub_a_init.c lzocompress_test *.marker Makefile +/m4 *.mod mod-*.c missing @@ -155,7 +161,11 @@ pata_test *.pp po/*.mo po/grub.pot +po/Makefile.in.in +po/Makevars +po/Makevars.template po/POTFILES +po/Rules-quot po/stamp-po printf_test priority_queue_unit_test @@ -202,25 +212,7 @@ grub-core/*.module.exe grub-core/*.pp grub-core/kernel.img.bin util/bash-completion.d/grub -grub-core/gnulib/alloca.h -grub-core/gnulib/arg-nonnull.h -grub-core/gnulib/c++defs.h -grub-core/gnulib/charset.alias -grub-core/gnulib/configmake.h -grub-core/gnulib/float.h -grub-core/gnulib/getopt.h -grub-core/gnulib/langinfo.h -grub-core/gnulib/ref-add.sed -grub-core/gnulib/ref-del.sed -grub-core/gnulib/stdio.h -grub-core/gnulib/stdlib.h -grub-core/gnulib/string.h -grub-core/gnulib/strings.h -grub-core/gnulib/sys -grub-core/gnulib/unistd.h -grub-core/gnulib/warn-on-use.h -grub-core/gnulib/wchar.h -grub-core/gnulib/wctype.h +grub-core/lib/gnulib grub-core/rs_decoder.h widthspec.bin widthspec.h @@ -239,10 +231,6 @@ po/POTFILES-shell.in /grub-render-label /grub-glue-efi.exe /grub-render-label.exe -grub-core/gnulib/locale.h -grub-core/gnulib/unitypes.h -grub-core/gnulib/uniwidth.h -build-aux/test-driver /garbage-gen /garbage-gen.exe /grub-fs-tester diff --git a/ABOUT-NLS b/ABOUT-NLS deleted file mode 100644 index 866b904ec..000000000 --- a/ABOUT-NLS +++ /dev/null @@ -1,223 +0,0 @@ -1 Notes on the Free Translation Project -*************************************** - -Free software is going international! The Free Translation Project is -a way to get maintainers of free software, translators, and users all -together, so that free software will gradually become able to speak many -languages. A few packages already provide translations for their -messages. - - If you found this `ABOUT-NLS' file inside a distribution, you may -assume that the distributed package does use GNU `gettext' internally, -itself available at your nearest GNU archive site. But you do _not_ -need to install GNU `gettext' prior to configuring, installing or using -this package with messages translated. - - Installers will find here some useful hints. These notes also -explain how users should proceed for getting the programs to use the -available translations. They tell how people wanting to contribute and -work on translations can contact the appropriate team. - - When reporting bugs in the `intl/' directory or bugs which may be -related to internationalization, you should tell about the version of -`gettext' which is used. The information can be found in the -`intl/VERSION' file, in internationalized packages. - -1.1 Quick configuration advice -============================== - -If you want to exploit the full power of internationalization, you -should configure it using - - ./configure --with-included-gettext - -to force usage of internationalizing routines provided within this -package, despite the existence of internationalizing capabilities in the -operating system where this package is being installed. So far, only -the `gettext' implementation in the GNU C library version 2 provides as -many features (such as locale alias, message inheritance, automatic -charset conversion or plural form handling) as the implementation here. -It is also not possible to offer this additional functionality on top -of a `catgets' implementation. Future versions of GNU `gettext' will -very likely convey even more functionality. So it might be a good idea -to change to GNU `gettext' as soon as possible. - - So you need _not_ provide this option if you are using GNU libc 2 or -you have installed a recent copy of the GNU gettext package with the -included `libintl'. - -1.2 INSTALL Matters -=================== - -Some packages are "localizable" when properly installed; the programs -they contain can be made to speak your own native language. Most such -packages use GNU `gettext'. Other packages have their own ways to -internationalization, predating GNU `gettext'. - - By default, this package will be installed to allow translation of -messages. It will automatically detect whether the system already -provides the GNU `gettext' functions. If not, the included GNU -`gettext' library will be used. This library is wholly contained -within this package, usually in the `intl/' subdirectory, so prior -installation of the GNU `gettext' package is _not_ required. -Installers may use special options at configuration time for changing -the default behaviour. The commands: - - ./configure --with-included-gettext - ./configure --disable-nls - -will, respectively, bypass any pre-existing `gettext' to use the -internationalizing routines provided within this package, or else, -_totally_ disable translation of messages. - - When you already have GNU `gettext' installed on your system and run -configure without an option for your new package, `configure' will -probably detect the previously built and installed `libintl.a' file and -will decide to use this. This might not be desirable. You should use -the more recent version of the GNU `gettext' library. I.e. if the file -`intl/VERSION' shows that the library which comes with this package is -more recent, you should use - - ./configure --with-included-gettext - -to prevent auto-detection. - - The configuration process will not test for the `catgets' function -and therefore it will not be used. The reason is that even an -emulation of `gettext' on top of `catgets' could not provide all the -extensions of the GNU `gettext' library. - - Internationalized packages usually have many `po/LL.po' files, where -LL gives an ISO 639 two-letter code identifying the language. Unless -translations have been forbidden at `configure' time by using the -`--disable-nls' switch, all available translations are installed -together with the package. However, the environment variable `LINGUAS' -may be set, prior to configuration, to limit the installed set. -`LINGUAS' should then contain a space separated list of two-letter -codes, stating which languages are allowed. - -1.3 Using This Package -====================== - -As a user, if your language has been installed for this package, you -only have to set the `LANG' environment variable to the appropriate -`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, -and `CC' is an ISO 3166 two-letter country code. For example, let's -suppose that you speak German and live in Germany. At the shell -prompt, merely execute `setenv LANG de_DE' (in `csh'), -`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). -This can be done from your `.login' or `.profile' file, once and for -all. - - You might think that the country code specification is redundant. -But in fact, some languages have dialects in different countries. For -example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The -country code serves to distinguish the dialects. - - The locale naming convention of `LL_CC', with `LL' denoting the -language and `CC' denoting the country, is the one use on systems based -on GNU libc. On other systems, some variations of this scheme are -used, such as `LL' or `LL_CC.ENCODING'. You can get the list of -locales supported by your system for your language by running the -command `locale -a | grep '^LL''. - - Not all programs have translations for all languages. By default, an -English message is shown in place of a nonexistent translation. If you -understand other languages, you can set up a priority list of languages. -This is done through a different environment variable, called -`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' -for the purpose of message handling, but you still need to have `LANG' -set to the primary language; this is required by other parts of the -system libraries. For example, some Swedish users who would rather -read translations in German than English for when Swedish is not -available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. - - Special advice for Norwegian users: The language code for Norwegian -bokma*l changed from `no' to `nb' recently (in 2003). During the -transition period, while some message catalogs for this language are -installed under `nb' and some older ones under `no', it's recommended -for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and -older translations are used. - - In the `LANGUAGE' environment variable, but not in the `LANG' -environment variable, `LL_CC' combinations can be abbreviated as `LL' -to denote the language's main dialect. For example, `de' is equivalent -to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' -(Portuguese as spoken in Portugal) in this context. - -1.4 Translating Teams -===================== - -For the Free Translation Project to be a success, we need interested -people who like their own language and write it well, and who are also -able to synergize with other translators speaking the same language. -Each translation team has its own mailing list. The up-to-date list of -teams can be found at the Free Translation Project's homepage, -`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" -area. - - If you'd like to volunteer to _work_ at translating messages, you -should become a member of the translating team for your own language. -The subscribing address is _not_ the same as the list itself, it has -`-request' appended. For example, speakers of Swedish can send a -message to `sv-request@li.org', having this message body: - - subscribe - - Keep in mind that team members are expected to participate -_actively_ in translations, or at solving translational difficulties, -rather than merely lurking around. If your team does not exist yet and -you want to start one, or if you are unsure about what to do or how to -get started, please write to `translation@iro.umontreal.ca' to reach the -coordinator for all translator teams. - - The English team is special. It works at improving and uniformizing -the terminology in use. Proven linguistic skills are praised more than -programming skills, here. - -1.5 Available Packages -====================== - -Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of October -2006. The matrix shows, in regard of each package, for which languages -PO files have been submitted to translation coordination, with a -translation percentage of at least 50%. - -# Matrix here is removed! - - Some counters in the preceding matrix are higher than the number of -visible blocks let us expect. This is because a few extra PO files are -used for implementing regional variants of languages, or language -dialects. - - For a PO file in the matrix above to be effective, the package to -which it applies should also have been internationalized and -distributed as such by its maintainer. There might be an observable -lag between the mere existence a PO file and its wide availability in a -distribution. - - If October 2006 seems to be old, you may fetch a more recent copy of -this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date -matrix with full percentage details can be found at -`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. - -1.6 Using `gettext' in new packages -=================================== - -If you are writing a freely available program and want to -internationalize it you are welcome to use GNU `gettext' in your -package. Of course you have to respect the GNU Library General Public -License which covers the use of the GNU `gettext' library. This means -in particular that even non-free programs can use `libintl' as a shared -library, whereas only free software can use `libintl' as a static -library or use modified versions of `libintl'. - - Once the sources are changed appropriately and the setup can handle -the use of `gettext' the only thing missing are the translations. The -Free Translation Project is also available for packages which are not -developed inside the GNU project. Therefore the information given above -applies also for every other Free Software Project. Contact -`translation@iro.umontreal.ca' to make the `.pot' files available to -the translation teams. - diff --git a/INSTALL b/INSTALL index b370d7753..8acb40902 100644 --- a/INSTALL +++ b/INSTALL @@ -60,8 +60,8 @@ If you use a development snapshot or want to hack on GRUB you may need the following. * Python 2.6 or later -* Autoconf 2.60 or later -* Automake 1.10.1 or later +* Autoconf 2.63 or later +* Automake 1.11 or later Prerequisites for make-check: @@ -102,10 +102,11 @@ The simplest way to compile this package is: 2. Skip this and following step if you use release tarball and proceed to step 4. If you want translations type `./linguas.sh'. - 3. Type `./autogen.sh'. + 3. Type `./bootstrap'. - * autogen.sh uses python. By default invocation is "python" but can be - overriden by setting variable $PYTHON. + * autogen.sh (called by bootstrap) uses python. By default the + invocation is "python", but it can be overridden by setting the + variable $PYTHON. 4. Type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might diff --git a/Makefile.am b/Makefile.am index 5b3cf5b4d..94296a37e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = subdir-objects -Wno-portability DEPDIR = .deps-util -SUBDIRS = grub-core/gnulib . +SUBDIRS = grub-core/lib/gnulib . if COND_real_platform SUBDIRS += grub-core endif diff --git a/Makefile.util.def b/Makefile.util.def index a0495a87f..969d32f00 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -198,7 +198,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBLZMA)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; cppflags = '-DGRUB_PKGLIBDIR=\"$(pkglibdir)\"'; @@ -215,7 +215,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -230,7 +230,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -245,7 +245,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -261,7 +261,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -284,7 +284,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -300,7 +300,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) -lfuse'; condition = COND_GRUB_MOUNT; }; @@ -318,7 +318,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(FREETYPE_LIBS)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; condition = COND_GRUB_MKFONT; @@ -337,7 +337,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -359,7 +359,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = libgrubgcry.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; cppflags = '-DGRUB_SETUP_FUNC=grub_util_bios_setup'; }; @@ -379,7 +379,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = libgrubgcry.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; cppflags = '-DGRUB_SETUP_FUNC=grub_util_sparc_setup'; }; @@ -395,7 +395,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -410,7 +410,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -425,7 +425,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -552,7 +552,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; condition = COND_HAVE_EXEC; @@ -599,7 +599,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -638,7 +638,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -674,7 +674,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1204,7 +1204,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1219,7 +1219,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1234,7 +1234,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1250,7 +1250,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; condition = COND_HAVE_CXX; }; @@ -1266,7 +1266,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1281,7 +1281,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1299,7 +1299,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1315,7 +1315,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1333,7 +1333,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -1362,6 +1362,6 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; - ldadd = grub-core/gnulib/libgnu.a; + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; diff --git a/autogen.sh b/autogen.sh index 7537561ad..d9df5f9be 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,11 @@ set -e +if [ ! -e grub-core/lib/gnulib/stdlib.in.h ]; then + echo "Gnulib not yet bootstrapped; run ./bootstrap instead." >&2 + exit 1 +fi + # Set ${PYTHON} to plain 'python' if not set already : ${PYTHON:=python} @@ -82,6 +87,17 @@ done echo "Saving timestamps..." echo timestamp > stamp-h.in -echo "Running autoreconf..." -autoreconf -vi +if [ -z "$FROM_BOOTSTRAP" ]; then + # Unaided autoreconf is likely to install older versions of many files + # than the ones provided by Gnulib, but in most cases this won't matter + # very much. This mode is provided so that you can run ./autogen.sh to + # regenerate the GRUB build system in an unpacked release tarball (perhaps + # after patching it), even on systems that don't have access to + # gnulib.git. + echo "Running autoreconf..." + cp -a INSTALL INSTALL.grub + autoreconf -vif + mv INSTALL.grub INSTALL +fi + exit 0 diff --git a/bootstrap b/bootstrap new file mode 100755 index 000000000..5b08e7e2d --- /dev/null +++ b/bootstrap @@ -0,0 +1,1073 @@ +#! /bin/sh +# Print a version string. +scriptversion=2019-01-04.17; # UTC + +# Bootstrap this package from checked-out sources. + +# Copyright (C) 2003-2019 Free Software Foundation, Inc. + +# This program 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. + +# 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Originally written by Paul Eggert. The canonical version of this +# script is maintained as build-aux/bootstrap in gnulib, however, to +# be useful to your project, you should place a copy of it under +# version control in the top-level directory of your project. The +# intent is that all customization can be done with a bootstrap.conf +# file also maintained in your version control; gnulib comes with a +# template build-aux/bootstrap.conf to get you started. + +# Please report bugs or propose patches to bug-gnulib@gnu.org. + +nl=' +' + +# Ensure file names are sorted consistently across platforms. +LC_ALL=C +export LC_ALL + +# Ensure that CDPATH is not set. Otherwise, the output from cd +# would cause trouble in at least one use below. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +local_gl_dir=gl + +# Honor $PERL, but work even if there is none. +PERL="${PERL-perl}" + +me=$0 + +default_gnulib_url=git://git.sv.gnu.org/gnulib + +usage() { + cat <&2 +} + +# warn_ WORD1... +warn_ () +{ + # If IFS does not start with ' ', set it and emit the warning in a subshell. + case $IFS in + ' '*) warnf_ '%s\n' "$*";; + *) (IFS=' '; warn_ "$@");; + esac +} + +# die WORD1... +die() { warn_ "$@"; exit 1; } + +# Configuration. + +# Name of the Makefile.am +gnulib_mk=gnulib.mk + +# List of gnulib modules needed. +gnulib_modules= + +# Any gnulib files needed that are not in modules. +gnulib_files= + +: ${AUTOPOINT=autopoint} +: ${AUTORECONF=autoreconf} + +# A function to be called right after gnulib-tool is run. +# Override it via your own definition in bootstrap.conf. +bootstrap_post_import_hook() { :; } + +# A function to be called after everything else in this script. +# Override it via your own definition in bootstrap.conf. +bootstrap_epilogue() { :; } + +# The command to download all .po files for a specified domain into a +# specified directory. Fill in the first %s with the destination +# directory and the second with the domain name. +po_download_command_format=\ +"wget --mirror --level=1 -nd -q -A.po -P '%s' \ + https://translationproject.org/latest/%s/" + +# Prefer a non-empty tarname (4th argument of AC_INIT if given), else +# fall back to the package name (1st argument with munging) +extract_package_name=' + /^AC_INIT(\[*/{ + s/// + /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{ + s//\1/ + s/[],)].*// + p + q + } + s/[],)].*// + s/^GNU // + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g + p + } +' +package=$(sed -n "$extract_package_name" configure.ac) \ + || die 'cannot find package name in configure.ac' +gnulib_name=lib$package + +build_aux=build-aux +source_base=lib +m4_base=m4 +doc_base=doc +tests_base=tests +gnulib_extra_files=" + build-aux/install-sh + build-aux/mdate-sh + build-aux/texinfo.tex + build-aux/depcomp + build-aux/config.guess + build-aux/config.sub + doc/INSTALL +" + +# Additional gnulib-tool options to use. Use "\newline" to break lines. +gnulib_tool_option_extras= + +# Other locale categories that need message catalogs. +EXTRA_LOCALE_CATEGORIES= + +# Additional xgettext options to use. Use "\\\newline" to break lines. +XGETTEXT_OPTIONS='\\\ + --flag=_:1:pass-c-format\\\ + --flag=N_:1:pass-c-format\\\ + --flag=error:3:c-format --flag=error_at_line:5:c-format\\\ +' + +# Package bug report address and copyright holder for gettext files +COPYRIGHT_HOLDER='Free Software Foundation, Inc.' +MSGID_BUGS_ADDRESS=bug-$package@gnu.org + +# Files we don't want to import. +excluded_files= + +# File that should exist in the top directory of a checked out hierarchy, +# but not in a distribution tarball. +checkout_only_file=README-hacking + +# Whether to use copies instead of symlinks. +copy=false + +# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want +# those files to be generated in directories like lib/, m4/, and po/. +# Or set it to 'auto' to make this script select which to use based +# on which version control system (if any) is used in the source directory. +vc_ignore=auto + +# Set this to true in bootstrap.conf to enable --bootstrap-sync by +# default. +bootstrap_sync=false + +# Use git to update gnulib sources +use_git=true + +check_exists() { + if test "$1" = "--verbose"; then + ($2 --version /dev/null 2>&1 + if test $? -ge 126; then + # If not found, run with diagnostics as one may be + # presented with env variables to set to find the right version + ($2 --version /dev/null 2>&1 + fi + + test $? -lt 126 +} + +# find_tool ENVVAR NAMES... +# ------------------------- +# Search for a required program. Use the value of ENVVAR, if set, +# otherwise find the first of the NAMES that can be run. +# If found, set ENVVAR to the program name, die otherwise. +# +# FIXME: code duplication, see also gnu-web-doc-update. +find_tool () +{ + find_tool_envvar=$1 + shift + find_tool_names=$@ + eval "find_tool_res=\$$find_tool_envvar" + if test x"$find_tool_res" = x; then + for i; do + if check_exists $i; then + find_tool_res=$i + break + fi + done + fi + if test x"$find_tool_res" = x; then + warn_ "one of these is required: $find_tool_names;" + die "alternatively set $find_tool_envvar to a compatible tool" + fi + eval "$find_tool_envvar=\$find_tool_res" + eval "export $find_tool_envvar" +} + +# Override the default configuration, if necessary. +# Make sure that bootstrap.conf is sourced from the current directory +# if we were invoked as "sh bootstrap". +case "$0" in + */*) test -r "$0.conf" && . "$0.conf" ;; + *) test -r "$0.conf" && . ./"$0.conf" ;; +esac + +if test "$vc_ignore" = auto; then + vc_ignore= + test -d .git && vc_ignore=.gitignore + test -d CVS && vc_ignore="$vc_ignore .cvsignore" +fi + +if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then + use_gnulib=false +else + use_gnulib=true +fi + +# Translate configuration into internal form. + +# Parse options. + +for option +do + case $option in + --help) + usage + exit;; + --gnulib-srcdir=*) + GNULIB_SRCDIR=${option#--gnulib-srcdir=};; + --skip-po) + SKIP_PO=t;; + --force) + checkout_only_file=;; + --copy) + copy=true;; + --bootstrap-sync) + bootstrap_sync=true;; + --no-bootstrap-sync) + bootstrap_sync=false;; + --no-git) + use_git=false;; + *) + die "$option: unknown option";; + esac +done + +$use_git || test -d "$GNULIB_SRCDIR" \ + || die "Error: --no-git requires --gnulib-srcdir" + +if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then + die "Bootstrapping from a non-checked-out distribution is risky." +fi + +# Strip blank and comment lines to leave significant entries. +gitignore_entries() { + sed '/^#/d; /^$/d' "$@" +} + +# If $STR is not already on a line by itself in $FILE, insert it at the start. +# Entries are inserted at the start of the ignore list to ensure existing +# entries starting with ! are not overridden. Such entries support +# whitelisting exceptions after a more generic blacklist pattern. +insert_if_absent() { + file=$1 + str=$2 + test -f $file || touch $file + test -r $file || die "Error: failed to read ignore file: $file" + duplicate_entries=$(gitignore_entries $file | sort | uniq -d) + if [ "$duplicate_entries" ] ; then + die "Error: Duplicate entries in $file: " $duplicate_entries + fi + linesold=$(gitignore_entries $file | wc -l) + linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) + if [ $linesold != $linesnew ] ; then + { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ + || die "insert_if_absent $file $str: failed" + fi +} + +# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with +# insert_if_absent. +insert_vc_ignore() { + vc_ignore_file="$1" + pattern="$2" + case $vc_ignore_file in + *.gitignore) + # A .gitignore entry that does not start with '/' applies + # recursively to subdirectories, so prepend '/' to every + # .gitignore entry. + pattern=$(echo "$pattern" | sed s,^,/,);; + esac + insert_if_absent "$vc_ignore_file" "$pattern" +} + +# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. +found_aux_dir=no +grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ + >/dev/null && found_aux_dir=yes +grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \ + >/dev/null && found_aux_dir=yes +test $found_aux_dir = yes \ + || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it" + +# If $build_aux doesn't exist, create it now, otherwise some bits +# below will malfunction. If creating it, also mark it as ignored. +if test ! -d $build_aux; then + mkdir $build_aux + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + insert_vc_ignore $dot_ig $build_aux + done +fi + +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +sort_ver() { # sort -V is not generally available + ver1="$1" + ver2="$2" + + # split on '.' and compare each component + i=1 + while : ; do + p1=$(echo "$ver1" | cut -d. -f$i) + p2=$(echo "$ver2" | cut -d. -f$i) + if [ ! "$p1" ]; then + echo "$1 $2" + break + elif [ ! "$p2" ]; then + echo "$2 $1" + break + elif [ ! "$p1" = "$p2" ]; then + if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison + echo "$2 $1" + elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison + echo "$1 $2" + else # numeric, then lexicographic comparison + lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1) + if [ "$lp" = "$p2" ]; then + echo "$1 $2" + else + echo "$2 $1" + fi + fi + break + fi + i=$(($i+1)) + done +} + +get_version_sed=' +# Move version to start of line. +s/.*[v ]\([0-9]\)/\1/ + +# Skip lines that do not start with version. +/^[0-9]/!d + +# Remove characters after the version. +s/[^.a-z0-9-].*// + +# The first component must be digits only. +s/^\([0-9]*\)[a-z-].*/\1/ + +#the following essentially does s/5.005/5.5/ +s/\.0*\([1-9]\)/.\1/g +p +q' + +get_version() { + app=$1 + + $app --version >/dev/null 2>&1 || { $app --version; return 1; } + + $app --version 2>&1 | sed -n "$get_version_sed" +} + +check_versions() { + ret=0 + + while read app req_ver; do + # We only need libtoolize from the libtool package. + if test "$app" = libtool; then + app=libtoolize + fi + # Exempt git if --no-git is in effect. + if test "$app" = git; then + $use_git || continue + fi + # Honor $APP variables ($TAR, $AUTOCONF, etc.) + appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_') + test "$appvar" = TAR && appvar=AMTAR + case $appvar in + GZIP) ;; # Do not use $GZIP: it contains gzip options. + PERL::*) ;; # Keep perl modules as-is + *) eval "app=\${$appvar-$app}" ;; + esac + + # Handle the still-experimental Automake-NG programs specially. + # They remain named as the mainstream Automake programs ("automake", + # and "aclocal") to avoid gratuitous incompatibilities with + # pre-existing usages (by, say, autoreconf, or custom autogen.sh + # scripts), but correctly identify themselves (as being part of + # "GNU automake-ng") when asked their version. + case $app in + automake-ng|aclocal-ng) + app=${app%-ng} + ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || { + warn_ "Error: '$app' not found or not from Automake-NG" + ret=1 + continue + } ;; + # Another check is for perl modules. These can be written as + # e.g. perl::XML::XPath in case of XML::XPath module, etc. + perl::*) + # Extract module name + app="${app#perl::}" + if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then + warn_ "Error: perl module '$app' not found" + ret=1 + fi + continue + ;; + esac + if [ "$req_ver" = "-" ]; then + # Merely require app to exist; not all prereq apps are well-behaved + # so we have to rely on $? rather than get_version. + if ! check_exists --verbose $app; then + warn_ "Error: '$app' not found" + ret=1 + fi + else + # Require app to produce a new enough version string. + inst_ver=$(get_version $app) + if [ ! "$inst_ver" ]; then + warn_ "Error: '$app' not found" + ret=1 + else + latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2) + if [ ! "$latest_ver" = "$inst_ver" ]; then + warnf_ '%s\n' \ + "Error: '$app' version == $inst_ver is too old" \ + " '$app' version >= $req_ver is required" + ret=1 + fi + fi + fi + done + + return $ret +} + +print_versions() { + echo "Program Min_version" + echo "----------------------" + printf %s "$buildreq" + echo "----------------------" + # can't depend on column -t +} + +# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. +# Also find the compatible sha1 utility on the BSDs +if test x"$SKIP_PO" = x; then + find_tool SHA1SUM sha1sum gsha1sum shasum sha1 +fi + +use_libtool=0 +# We'd like to use grep -E, to see if any of LT_INIT, +# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac, +# but that's not portable enough (e.g., for Solaris). +grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \ + && use_libtool=1 +grep '^[ ]*LT_INIT' configure.ac >/dev/null \ + && use_libtool=1 +if test $use_libtool = 1; then + find_tool LIBTOOLIZE glibtoolize libtoolize +fi + +# gnulib-tool requires at least automake and autoconf. +# If either is not listed, add it (with minimum version) as a prerequisite. +case $buildreq in + *automake*) ;; + *) buildreq="automake 1.9 +$buildreq" ;; +esac +case $buildreq in + *autoconf*) ;; + *) buildreq="autoconf 2.59 +$buildreq" ;; +esac + +# When we can deduce that gnulib-tool will require patch, +# and when patch is not already listed as a prerequisite, add it, too. +if test -d "$local_gl_dir" \ + && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then + case $buildreq in + *patch*) ;; + *) buildreq="patch - +$buildreq" ;; + esac +fi + +if ! printf "$buildreq" | check_versions; then + echo >&2 + if test -f README-prereq; then + die "See README-prereq for how to get the prerequisite programs" + else + die "Please install the prerequisite programs" + fi +fi + +# Warn the user if autom4te appears to be broken; this causes known +# issues with at least gettext 0.18.3. +probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -) +if test "x$probe" != xhi; then + warn_ "WARNING: your autom4te wrapper eats stdin;" + warn_ "if bootstrap fails, consider upgrading your autotools" +fi + +echo "$0: Bootstrapping from checked-out $package sources..." + +# See if we can use gnulib's git-merge-changelog merge driver. +if $use_git && test -d .git && check_exists git; then + if git config merge.merge-changelog.driver >/dev/null ; then + : + elif check_exists git-merge-changelog; then + echo "$0: initializing git-merge-changelog driver" + git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' + git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' + else + echo "$0: consider installing git-merge-changelog from gnulib" + fi +fi + + +cleanup_gnulib() { + status=$? + rm -fr "$gnulib_path" + exit $status +} + +git_modules_config () { + test -f .gitmodules && git config --file .gitmodules "$@" +} + +if $use_gnulib; then + if $use_git; then + gnulib_path=$(git_modules_config submodule.gnulib.path) + test -z "$gnulib_path" && gnulib_path=gnulib + fi + + # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a + # submodule, for use in the rest of the script. + + case ${GNULIB_SRCDIR--} in + -) + # Note that $use_git is necessarily true in this case. + if git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + git submodule init -- "$gnulib_path" || exit $? + git submodule update -- "$gnulib_path" || exit $? + + elif [ ! -d "$gnulib_path" ]; then + echo "$0: getting gnulib files..." + + trap cleanup_gnulib 1 2 13 15 + + shallow= + if test -z "$GNULIB_REVISION"; then + git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' + fi + git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ + || cleanup_gnulib + + trap - 1 2 13 15 + fi + GNULIB_SRCDIR=$gnulib_path + ;; + *) + # Use GNULIB_SRCDIR directly or as a reference. + if $use_git && test -d "$GNULIB_SRCDIR"/.git && \ + git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + if git submodule -h|grep -- --reference > /dev/null; then + # Prefer the one-liner available in git 1.6.4 or newer. + git submodule update --init --reference "$GNULIB_SRCDIR" \ + "$gnulib_path" || exit $? + else + # This fallback allows at least git 1.5.5. + if test -f "$gnulib_path"/gnulib-tool; then + # Since file already exists, assume submodule init already complete. + git submodule update -- "$gnulib_path" || exit $? + else + # Older git can't clone into an empty directory. + rmdir "$gnulib_path" 2>/dev/null + git clone --reference "$GNULIB_SRCDIR" \ + "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ + && git submodule init -- "$gnulib_path" \ + && git submodule update -- "$gnulib_path" \ + || exit $? + fi + fi + GNULIB_SRCDIR=$gnulib_path + fi + ;; + esac + + if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \ + && ! git_modules_config submodule.gnulib.url >/dev/null; then + (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib + fi + + # $GNULIB_SRCDIR now points to the version of gnulib to use, and + # we no longer need to use git or $gnulib_path below here. + + if $bootstrap_sync; then + cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { + echo "$0: updating bootstrap and restarting..." + case $(sh -c 'echo "$1"' -- a) in + a) ignored=--;; + *) ignored=ignored;; + esac + exec sh -c \ + 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ + $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \ + "$0" "$@" --no-bootstrap-sync + } + fi + + gnulib_tool=$GNULIB_SRCDIR/gnulib-tool + <$gnulib_tool || exit $? +fi + +# Get translations. + +download_po_files() { + subdir=$1 + domain=$2 + echo "$me: getting translations into $subdir for $domain..." + cmd=$(printf "$po_download_command_format" "$subdir" "$domain") + eval "$cmd" +} + +# Mirror .po files to $po_dir/.reference and copy only the new +# or modified ones into $po_dir. Also update $po_dir/LINGUAS. +# Note po files that exist locally only are left in $po_dir but will +# not be included in LINGUAS and hence will not be distributed. +update_po_files() { + # Directory containing primary .po files. + # Overwrite them only when we're sure a .po file is new. + po_dir=$1 + domain=$2 + + # Mirror *.po files into this dir. + # Usually contains *.s1 checksum files. + ref_po_dir="$po_dir/.reference" + + test -d $ref_po_dir || mkdir $ref_po_dir || return + download_po_files $ref_po_dir $domain \ + && ls "$ref_po_dir"/*.po 2>/dev/null | + sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return + + langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g') + test "$langs" = '*' && langs=x + for po in $langs; do + case $po in x) continue;; esac + new_po="$ref_po_dir/$po.po" + cksum_file="$ref_po_dir/$po.s1" + if ! test -f "$cksum_file" || + ! test -f "$po_dir/$po.po" || + ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then + echo "$me: updated $po_dir/$po.po..." + cp "$new_po" "$po_dir/$po.po" \ + && $SHA1SUM < "$new_po" > "$cksum_file" || return + fi + done +} + +case $SKIP_PO in +'') + if test -d po; then + update_po_files po $package || exit + fi + + if test -d runtime-po; then + update_po_files runtime-po $package-runtime || exit + fi;; +esac + +symlink_to_dir() +{ + src=$1/$2 + dst=${3-$2} + + test -f "$src" && { + + # If the destination directory doesn't exist, create it. + # This is required at least for "lib/uniwidth/cjk.h". + dst_dir=$(dirname "$dst") + if ! test -d "$dst_dir"; then + mkdir -p "$dst_dir" + + # If we've just created a directory like lib/uniwidth, + # tell version control system(s) it's ignorable. + # FIXME: for now, this does only one level + parent=$(dirname "$dst_dir") + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_vc_ignore $ig "${dst_dir##*/}" + done + fi + + if $copy; then + { + test ! -h "$dst" || { + echo "$me: rm -f $dst" && + rm -f "$dst" + } + } && + test -f "$dst" && + cmp -s "$src" "$dst" || { + echo "$me: cp -fp $src $dst" && + cp -fp "$src" "$dst" + } + else + # Leave any existing symlink alone, if it already points to the source, + # so that broken build tools that care about symlink times + # aren't confused into doing unnecessary builds. Conversely, if the + # existing symlink's timestamp is older than the source, make it afresh, + # so that broken tools aren't confused into skipping needed builds. See + # . + test -h "$dst" && + src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && + dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && + test "$src_i" = "$dst_i" && + both_ls=$(ls -dt "$src" "$dst") && + test "X$both_ls" = "X$dst$nl$src" || { + dot_dots= + case $src in + /*) ;; + *) + case /$dst/ in + *//* | */../* | */./* | /*/*/*/*/*/) + die "invalid symlink calculation: $src -> $dst";; + /*/*/*/*/) dot_dots=../../../;; + /*/*/*/) dot_dots=../../;; + /*/*/) dot_dots=../;; + esac;; + esac + + echo "$me: ln -fs $dot_dots$src $dst" && + ln -fs "$dot_dots$src" "$dst" + } + fi + } +} + +version_controlled_file() { + parent=$1 + file=$2 + if test -d .git; then + git rm -n "$file" > /dev/null 2>&1 + elif test -d .svn; then + svn log -r HEAD "$file" > /dev/null 2>&1 + elif test -d CVS; then + grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null | + grep '^/[^/]*/[0-9]' > /dev/null + else + warn_ "no version control for $file?" + false + fi +} + +# NOTE: we have to be careful to run both autopoint and libtoolize +# before gnulib-tool, since gnulib-tool is likely to provide newer +# versions of files "installed" by these two programs. +# Then, *after* gnulib-tool (see below), we have to be careful to +# run autoreconf in such a way that it does not run either of these +# two just-pre-run programs. + +# Import from gettext. +with_gettext=yes +grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ + with_gettext=no + +if test $with_gettext = yes || test $use_libtool = 1; then + + tempbase=.bootstrap$$ + trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15 + + > $tempbase.0 > $tempbase.1 && + find . ! -type d -print | sort > $tempbase.0 || exit + + if test $with_gettext = yes; then + # Released autopoint has the tendency to install macros that have been + # obsoleted in current gnulib, so run this before gnulib-tool. + echo "$0: $AUTOPOINT --force" + $AUTOPOINT --force || exit + fi + + # Autoreconf runs aclocal before libtoolize, which causes spurious + # warnings if the initial aclocal is confused by the libtoolized + # (or worse out-of-date) macro directory. + # libtoolize 1.9b added the --install option; but we support back + # to libtoolize 1.5.22, where the install action was default. + if test $use_libtool = 1; then + install= + case $($LIBTOOLIZE --help) in + *--install*) install=--install ;; + esac + echo "running: $LIBTOOLIZE $install --copy" + $LIBTOOLIZE $install --copy + fi + + find . ! -type d -print | sort >$tempbase.1 + old_IFS=$IFS + IFS=$nl + for file in $(comm -13 $tempbase.0 $tempbase.1); do + IFS=$old_IFS + parent=${file%/*} + version_controlled_file "$parent" "$file" || { + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_vc_ignore "$ig" "${file##*/}" + done + } + done + IFS=$old_IFS + + rm -f $tempbase.0 $tempbase.1 + trap - 1 2 13 15 +fi + +# Import from gnulib. + +if $use_gnulib; then + gnulib_tool_options="\ + --no-changelog\ + --aux-dir=$build_aux\ + --doc-base=$doc_base\ + --lib=$gnulib_name\ + --m4-base=$m4_base/\ + --source-base=$source_base/\ + --tests-base=$tests_base\ + --local-dir=$local_gl_dir\ + $gnulib_tool_option_extras\ + " + if test $use_libtool = 1; then + case "$gnulib_tool_options " in + *' --libtool '*) ;; + *) gnulib_tool_options="$gnulib_tool_options --libtool" ;; + esac + fi + echo "$0: $gnulib_tool $gnulib_tool_options --import ..." + $gnulib_tool $gnulib_tool_options --import $gnulib_modules \ + || die "gnulib-tool failed" + + for file in $gnulib_files; do + symlink_to_dir "$GNULIB_SRCDIR" $file \ + || die "failed to symlink $file" + done +fi + +bootstrap_post_import_hook \ + || die "bootstrap_post_import_hook failed" + +# Don't proceed if there are uninitialized submodules. In particular, +# the next step will remove dangling links, which might be links into +# uninitialized submodules. +# +# Uninitialized submodules are listed with an initial dash. +if $use_git && git submodule | grep '^-' >/dev/null; then + die "some git submodules are not initialized. " \ + "Run 'git submodule init' and bootstrap again." +fi + +# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some +# gnulib-populated directories. Such .m4 files would cause aclocal to fail. +# The following requires GNU find 4.2.3 or newer. Considering the usual +# portability constraints of this script, that may seem a very demanding +# requirement, but it should be ok. Ignore any failure, which is fine, +# since this is only a convenience to help developers avoid the relatively +# unusual case in which a symlinked-to .m4 file is git-removed from gnulib +# between successive runs of this script. +find "$m4_base" "$source_base" \ + -depth \( -name '*.m4' -o -name '*.[ch]' \) \ + -type l -xtype l -delete > /dev/null 2>&1 + +# Invoke autoreconf with --force --install to ensure upgrades of tools +# such as ylwrap. +AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS" + +# Some systems (RHEL 5) are using ancient autotools, for which the +# --no-recursive option had not been invented. Detect that lack and +# omit the option when it's not supported. FIXME in 2017: remove this +# hack when RHEL 5 autotools are updated, or when they become irrelevant. +case $($AUTORECONF --help) in + *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";; +esac + +# Tell autoreconf not to invoke autopoint or libtoolize; they were run above. +echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS" +AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \ + || die "autoreconf failed" + +# Get some extra files from gnulib, overriding existing files. +for file in $gnulib_extra_files; do + case $file in + */INSTALL) dst=INSTALL;; + build-aux/*) dst=$build_aux/${file#build-aux/};; + *) dst=$file;; + esac + symlink_to_dir "$GNULIB_SRCDIR" $file $dst \ + || die "failed to symlink $file" +done + +if test $with_gettext = yes; then + # Create gettext configuration. + echo "$0: Creating po/Makevars from po/Makevars.template ..." + rm -f po/Makevars + sed ' + /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ + /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/ + /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'| + /^XGETTEXT_OPTIONS *=/{ + s/$/ \\/ + a\ + '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} + } + ' po/Makevars.template >po/Makevars \ + || die 'cannot generate po/Makevars' + + # If the 'gettext' module is in use, grab the latest Makefile.in.in. + # If only the 'gettext-h' module is in use, assume autopoint already + # put the correct version of this file into place. + case $gnulib_modules in + *gettext-h*) ;; + *gettext*) + cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \ + || die "cannot create po/Makefile.in.in" + ;; + esac + + if test -d runtime-po; then + # Similarly for runtime-po/Makevars, but not quite the same. + rm -f runtime-po/Makevars + sed ' + /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/ + /^subdir *=.*/s/=.*/= runtime-po/ + /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ + /^XGETTEXT_OPTIONS *=/{ + s/$/ \\/ + a\ + '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} + } + ' po/Makevars.template >runtime-po/Makevars \ + || die 'cannot generate runtime-po/Makevars' + + # Copy identical files from po to runtime-po. + (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) + fi +fi + +bootstrap_epilogue + +echo "$0: done. Now you can run './configure'." + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/bootstrap.conf b/bootstrap.conf new file mode 100644 index 000000000..6781d25a7 --- /dev/null +++ b/bootstrap.conf @@ -0,0 +1,90 @@ +# Bootstrap configuration. + +# Copyright (C) 2006-2019 Free Software Foundation, Inc. + +# This program 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. + +# 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263 + +# gnulib modules used by this package. +# mbswidth is used by gnulib-fix-width.diff's changes to argp rather than +# directly. +gnulib_modules=" + argp + error + fnmatch + getdelim + getline + gettext-h + gitlog-to-changelog + mbswidth + progname + realloc-gnu + regex +" + +gnulib_tool_option_extras="\ + --no-conditional-dependencies \ + --no-vc-files \ +" + +gnulib_name=libgnu +source_base=grub-core/lib/gnulib +gnulib_extra_files=" + build-aux/install-sh + build-aux/mdate-sh + build-aux/texinfo.tex + build-aux/depcomp + build-aux/config.guess + build-aux/config.sub +" + +# Additional xgettext options to use. Use "\\\newline" to break lines. +XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ + --from-code=UTF-8\\\ +' + +checkout_only_file= +copy=true +vc_ignore= + +SKIP_PO=t + +# Build prerequisites +buildreq="\ +autoconf 2.63 +automake 1.11 +gettext 0.18.3 +git 1.5.5 +tar - +" + +# bootstrap doesn't give us a reasonable way to stop Automake from +# overwriting this, so we just copy our version aside and put it back later. +cp -a INSTALL INSTALL.grub + +bootstrap_post_import_hook () { + set -e + for patchname in fix-null-deref fix-width no-abort; do + patch -d grub-core/lib/gnulib -p2 \ + < "grub-core/lib/gnulib-patches/$patchname.patch" + done + FROM_BOOTSTRAP=1 ./autogen.sh + set +e # bootstrap expects this +} + +bootstrap_epilogue () { + mv INSTALL.grub INSTALL +} diff --git a/build-aux/config.rpath b/build-aux/config.rpath deleted file mode 100755 index c38b914d6..000000000 --- a/build-aux/config.rpath +++ /dev/null @@ -1,690 +0,0 @@ -#! /bin/sh -# Output a system dependent set of variables, describing how to set the -# run time search path of shared libraries in an executable. -# -# Copyright 1996-2013 Free Software Foundation, Inc. -# Taken from GNU libtool, 2001 -# Originally by Gordon Matzigkeit , 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld -# should be set by the caller. -# -# The set of defined variables is at the end of this script. - -# Known limitations: -# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer -# than 256 bytes, otherwise the compiler driver will dump core. The only -# known workaround is to choose shorter directory names for the build -# directory and/or the installation directory. - -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -shrext=.so - -host="$1" -host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -# Code taken from libtool.m4's _LT_CC_BASENAME. - -for cc_temp in $CC""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` - -# Code taken from libtool.m4's _LT_COMPILER_PIC. - -wl= -if test "$GCC" = yes; then - wl='-Wl,' -else - case "$host_os" in - aix*) - wl='-Wl,' - ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) - ;; - hpux9* | hpux10* | hpux11*) - wl='-Wl,' - ;; - irix5* | irix6* | nonstopux*) - wl='-Wl,' - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - ecc*) - wl='-Wl,' - ;; - icc* | ifort*) - wl='-Wl,' - ;; - lf95*) - wl='-Wl,' - ;; - nagfor*) - wl='-Wl,-Wl,,' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - wl='-Wl,' - ;; - ccc*) - wl='-Wl,' - ;; - xl* | bgxl* | bgf* | mpixl*) - wl='-Wl,' - ;; - como) - wl='-lopt=' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) - wl= - ;; - *Sun\ C*) - wl='-Wl,' - ;; - esac - ;; - esac - ;; - newsos6) - ;; - *nto* | *qnx*) - ;; - osf3* | osf4* | osf5*) - wl='-Wl,' - ;; - rdos*) - ;; - solaris*) - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - wl='-Qoption ld ' - ;; - *) - wl='-Wl,' - ;; - esac - ;; - sunos4*) - wl='-Qoption ld ' - ;; - sysv4 | sysv4.2uw2* | sysv4.3*) - wl='-Wl,' - ;; - sysv4*MP*) - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - wl='-Wl,' - ;; - unicos*) - wl='-Wl,' - ;; - uts4*) - ;; - esac -fi - -# Code taken from libtool.m4's _LT_LINKER_SHLIBS. - -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no - -case "$host_os" in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - # Unlike libtool, we use -rpath here, not --rpath, since the documented - # option of GNU ld is called -rpath, not --rpath. - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - case "$host_os" in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - fi - ;; - amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - cygwin* | mingw* | pw32* | cegcc*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - haiku*) - ;; - interix[3-9]*) - hardcode_direct=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - netbsd*) - ;; - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - else - ld_shlibs=no - fi - ;; - esac - ;; - sunos4*) - hardcode_direct=yes - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - esac - if test "$ld_shlibs" = no; then - hardcode_libdir_flag_spec= - fi -else - case "$host_os" in - aix3*) - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - else - aix_use_runtimelinking=no - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - fi - hardcode_direct=yes - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - fi - # Begin _LT_AC_SYS_LIBPATH_AIX. - echo 'int main () { return 0; }' > conftest.c - ${CC} ${LDFLAGS} conftest.c -o conftest - aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - fi - if test -z "$aix_libpath"; then - aix_libpath="/usr/lib:/lib" - fi - rm -f conftest.c conftest - # End _LT_AC_SYS_LIBPATH_AIX. - if test "$aix_use_runtimelinking" = yes; then - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - else - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - fi - fi - ;; - amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - bsdi[45]*) - ;; - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - libext=lib - ;; - darwin* | rhapsody*) - hardcode_direct=no - if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then - : - else - ld_shlibs=no - fi - ;; - dgux*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - freebsd2.2*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - freebsd2*) - hardcode_direct=yes - hardcode_minus_L=yes - ;; - freebsd* | dragonfly*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - hpux9*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - hpux10*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - hpux11*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - ;; - *) - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - irix5* | irix6* | nonstopux*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - netbsd*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - newsos6) - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - *nto* | *qnx*) - ;; - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - osf3*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - osf4* | osf5*) - if test "$GCC" = yes; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - # Both cc and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - solaris*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - sunos4*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - sysv4) - case $host_vendor in - sni) - hardcode_direct=yes # is this really true??? - ;; - siemens) - hardcode_direct=no - ;; - motorola) - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - ;; - sysv4.3*) - ;; - sysv4*MP*) - if test -d /usr/nec; then - ld_shlibs=yes - fi - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - ;; - sysv5* | sco3.2v5* | sco5v6*) - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator=':' - ;; - uts4*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - *) - ld_shlibs=no - ;; - esac -fi - -# Check dynamic linker characteristics -# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. -# Unlike libtool.m4, here we don't care about _all_ names of the library, but -# only about the one the linker finds when passed -lNAME. This is the last -# element of library_names_spec in libtool.m4, or possibly two of them if the -# linker has special search rules. -library_names_spec= # the last element of library_names_spec in libtool.m4 -libname_spec='lib$name' -case "$host_os" in - aix3*) - library_names_spec='$libname.a' - ;; - aix[4-9]*) - library_names_spec='$libname$shrext' - ;; - amigaos*) - case "$host_cpu" in - powerpc*) - library_names_spec='$libname$shrext' ;; - m68k) - library_names_spec='$libname.a' ;; - esac - ;; - beos*) - library_names_spec='$libname$shrext' - ;; - bsdi[45]*) - library_names_spec='$libname$shrext' - ;; - cygwin* | mingw* | pw32* | cegcc*) - shrext=.dll - library_names_spec='$libname.dll.a $libname.lib' - ;; - darwin* | rhapsody*) - shrext=.dylib - library_names_spec='$libname$shrext' - ;; - dgux*) - library_names_spec='$libname$shrext' - ;; - freebsd* | dragonfly*) - case "$host_os" in - freebsd[123]*) - library_names_spec='$libname$shrext$versuffix' ;; - *) - library_names_spec='$libname$shrext' ;; - esac - ;; - gnu*) - library_names_spec='$libname$shrext' - ;; - haiku*) - library_names_spec='$libname$shrext' - ;; - hpux9* | hpux10* | hpux11*) - case $host_cpu in - ia64*) - shrext=.so - ;; - hppa*64*) - shrext=.sl - ;; - *) - shrext=.sl - ;; - esac - library_names_spec='$libname$shrext' - ;; - interix[3-9]*) - library_names_spec='$libname$shrext' - ;; - irix5* | irix6* | nonstopux*) - library_names_spec='$libname$shrext' - case "$host_os" in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; - *) libsuff= shlibsuff= ;; - esac - ;; - esac - ;; - linux*oldld* | linux*aout* | linux*coff*) - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - library_names_spec='$libname$shrext' - ;; - knetbsd*-gnu) - library_names_spec='$libname$shrext' - ;; - netbsd*) - library_names_spec='$libname$shrext' - ;; - newsos6) - library_names_spec='$libname$shrext' - ;; - *nto* | *qnx*) - library_names_spec='$libname$shrext' - ;; - openbsd*) - library_names_spec='$libname$shrext$versuffix' - ;; - os2*) - libname_spec='$name' - shrext=.dll - library_names_spec='$libname.a' - ;; - osf3* | osf4* | osf5*) - library_names_spec='$libname$shrext' - ;; - rdos*) - ;; - solaris*) - library_names_spec='$libname$shrext' - ;; - sunos4*) - library_names_spec='$libname$shrext$versuffix' - ;; - sysv4 | sysv4.3*) - library_names_spec='$libname$shrext' - ;; - sysv4*MP*) - library_names_spec='$libname$shrext' - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - library_names_spec='$libname$shrext' - ;; - tpf*) - library_names_spec='$libname$shrext' - ;; - uts4*) - library_names_spec='$libname$shrext' - ;; -esac - -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' -escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` -shlibext=`echo "$shrext" | sed -e 's,^\.,,'` -escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` -escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` -escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` - -LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. - -# Written by Jim Meyering - -use strict; -use warnings; -use Getopt::Long; -use POSIX qw(strftime); - -(my $ME = $0) =~ s|.*/||; - -# use File::Coda; # http://meyering.net/code/Coda/ -END { - defined fileno STDOUT or return; - close STDOUT and return; - warn "$ME: failed to close standard output: $!\n"; - $? ||= 1; -} - -sub usage ($) -{ - my ($exit_code) = @_; - my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); - if ($exit_code != 0) - { - print $STREAM "Try '$ME --help' for more information.\n"; - } - else - { - print $STREAM < ChangeLog - $ME -- -n 5 foo > last-5-commits-to-branch-foo - -SPECIAL SYNTAX: - -The following types of strings are interpreted specially when they appear -at the beginning of a log message line. They are not copied to the output. - - Copyright-paperwork-exempt: Yes - Append the "(tiny change)" notation to the usual "date name email" - ChangeLog header to mark a change that does not require a copyright - assignment. - Co-authored-by: Joe User - List the specified name and email address on a second - ChangeLog header, denoting a co-author. - Signed-off-by: Joe User - These lines are simply elided. - -In a FILE specified via --amend, comment lines (starting with "#") are ignored. -FILE must consist of pairs where SHA is a 40-byte SHA1 (alone on -a line) referring to a commit in the current project, and CODE refers to one -or more consecutive lines of Perl code. Pairs must be separated by one or -more blank line. - -Here is sample input for use with --amend=FILE, from coreutils: - -3a169f4c5d9159283548178668d2fae6fced3030 -# fix typo in title: -s/all tile types/all file types/ - -1379ed974f1fa39b12e2ffab18b3f7a607082202 -# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. -# Change the author to be Paul. Note the escaped "@": -s,Jim .*>,Paul Eggert , - -EOF - } - exit $exit_code; -} - -# If the string $S is a well-behaved file name, simply return it. -# If it contains white space, quotes, etc., quote it, and return the new string. -sub shell_quote($) -{ - my ($s) = @_; - if ($s =~ m![^\w+/.,-]!) - { - # Convert each single quote to '\'' - $s =~ s/\'/\'\\\'\'/g; - # Then single quote the string. - $s = "'$s'"; - } - return $s; -} - -sub quoted_cmd(@) -{ - return join (' ', map {shell_quote $_} @_); -} - -# Parse file F. -# Comment lines (starting with "#") are ignored. -# F must consist of pairs where SHA is a 40-byte SHA1 -# (alone on a line) referring to a commit in the current project, and -# CODE refers to one or more consecutive lines of Perl code. -# Pairs must be separated by one or more blank line. -sub parse_amend_file($) -{ - my ($f) = @_; - - open F, '<', $f - or die "$ME: $f: failed to open for reading: $!\n"; - - my $fail; - my $h = {}; - my $in_code = 0; - my $sha; - while (defined (my $line = )) - { - $line =~ /^\#/ - and next; - chomp $line; - $line eq '' - and $in_code = 0, next; - - if (!$in_code) - { - $line =~ /^([0-9a-fA-F]{40})$/ - or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), - $fail = 1, next; - $sha = lc $1; - $in_code = 1; - exists $h->{$sha} - and (warn "$ME: $f:$.: duplicate SHA1\n"), - $fail = 1, next; - } - else - { - $h->{$sha} ||= ''; - $h->{$sha} .= "$line\n"; - } - } - close F; - - $fail - and exit 1; - - return $h; -} - -# git_dir_option $SRCDIR -# -# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR -# is undef). Return as a list (0 or 1 element). -sub git_dir_option($) -{ - my ($srcdir) = @_; - my @res = (); - if (defined $srcdir) - { - my $qdir = shell_quote $srcdir; - my $cmd = "cd $qdir && git rev-parse --show-toplevel"; - my $qcmd = shell_quote $cmd; - my $git_dir = qx($cmd); - defined $git_dir - or die "$ME: cannot run $qcmd: $!\n"; - $? == 0 - or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; - chomp $git_dir; - push @res, "--git-dir=$git_dir/.git"; - } - @res; -} - -{ - my $since_date; - my $format_string = '%s%n%b%n'; - my $amend_file; - my $append_dot = 0; - my $cluster = 1; - my $strip_tab = 0; - my $strip_cherry_pick = 0; - my $srcdir; - GetOptions - ( - help => sub { usage 0 }, - version => sub { print "$ME version $VERSION\n"; exit }, - 'since=s' => \$since_date, - 'format=s' => \$format_string, - 'amend=s' => \$amend_file, - 'append-dot' => \$append_dot, - 'cluster!' => \$cluster, - 'strip-tab' => \$strip_tab, - 'strip-cherry-pick' => \$strip_cherry_pick, - 'srcdir=s' => \$srcdir, - ) or usage 1; - - defined $since_date - and unshift @ARGV, "--since=$since_date"; - - # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) - # that makes a correction in the log or attribution of that commit. - my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; - - my @cmd = ('git', - git_dir_option $srcdir, - qw(log --log-size), - '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); - open PIPE, '-|', @cmd - or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" - . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); - - my $prev_multi_paragraph; - my $prev_date_line = ''; - my @prev_coauthors = (); - while (1) - { - defined (my $in = ) - or last; - $in =~ /^log size (\d+)$/ - or die "$ME:$.: Invalid line (expected log size):\n$in"; - my $log_nbytes = $1; - - my $log; - my $n_read = read PIPE, $log, $log_nbytes; - $n_read == $log_nbytes - or die "$ME:$.: unexpected EOF\n"; - - # Extract leading hash. - my ($sha, $rest) = split ':', $log, 2; - defined $sha - or die "$ME:$.: malformed log entry\n"; - $sha =~ /^[0-9a-fA-F]{40}$/ - or die "$ME:$.: invalid SHA1: $sha\n"; - - # If this commit's log requires any transformation, do it now. - my $code = $amend_code->{$sha}; - if (defined $code) - { - eval 'use Safe'; - my $s = new Safe; - # Put the unpreprocessed entry into "$_". - $_ = $rest; - - # Let $code operate on it, safely. - my $r = $s->reval("$code") - or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; - - # Note that we've used this entry. - delete $amend_code->{$sha}; - - # Update $rest upon success. - $rest = $_; - } - - # Remove lines inserted by "git cherry-pick". - if ($strip_cherry_pick) - { - $rest =~ s/^\s*Conflicts:\n.*//sm; - $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; - } - - my @line = split "\n", $rest; - my $author_line = shift @line; - defined $author_line - or die "$ME:$.: unexpected EOF\n"; - $author_line =~ /^(\d+) (.*>)$/ - or die "$ME:$.: Invalid line " - . "(expected date/author/email):\n$author_line\n"; - - # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog - # `(tiny change)' annotation. - my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line) - ? ' (tiny change)' : ''); - - my $date_line = sprintf "%s %s$tiny\n", - strftime ("%F", localtime ($1)), $2; - - my @coauthors = grep /^Co-authored-by:.*$/, @line; - # Omit meta-data lines we've already interpreted. - @line = grep !/^(?:Signed-off-by:[ ].*>$ - |Co-authored-by:[ ] - |Copyright-paperwork-exempt:[ ] - )/x, @line; - - # Remove leading and trailing blank lines. - if (@line) - { - while ($line[0] =~ /^\s*$/) { shift @line; } - while ($line[$#line] =~ /^\s*$/) { pop @line; } - } - - # Record whether there are two or more paragraphs. - my $multi_paragraph = grep /^\s*$/, @line; - - # Format 'Co-authored-by: A U Thor ' lines in - # standard multi-author ChangeLog format. - for (@coauthors) - { - s/^Co-authored-by:\s*/\t /; - s/\s*/ - or warn "$ME: warning: missing email address for " - . substr ($_, 5) . "\n"; - } - - # If clustering of commit messages has been disabled, if this header - # would be different from the previous date/name/email/coauthors header, - # or if this or the previous entry consists of two or more paragraphs, - # then print the header. - if ( ! $cluster - || $date_line ne $prev_date_line - || "@coauthors" ne "@prev_coauthors" - || $multi_paragraph - || $prev_multi_paragraph) - { - $prev_date_line eq '' - or print "\n"; - print $date_line; - @coauthors - and print join ("\n", @coauthors), "\n"; - } - $prev_date_line = $date_line; - @prev_coauthors = @coauthors; - $prev_multi_paragraph = $multi_paragraph; - - # If there were any lines - if (@line == 0) - { - warn "$ME: warning: empty commit message:\n $date_line\n"; - } - else - { - if ($append_dot) - { - # If the first line of the message has enough room, then - if (length $line[0] < 72) - { - # append a dot if there is no other punctuation or blank - # at the end. - $line[0] =~ /[[:punct:]\s]$/ - or $line[0] .= '.'; - } - } - - # Remove one additional leading TAB from each line. - $strip_tab - and map { s/^\t// } @line; - - # Prefix each non-empty line with a TAB. - @line = map { length $_ ? "\t$_" : '' } @line; - - print "\n", join ("\n", @line), "\n"; - } - - defined ($in = ) - or last; - $in ne "\n" - and die "$ME:$.: unexpected line:\n$in"; - } - - close PIPE - or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; - # FIXME-someday: include $PROCESS_STATUS in the diagnostic - - # Complain about any unused entry in the --amend=F specified file. - my $fail = 0; - foreach my $sha (keys %$amend_code) - { - warn "$ME:$amend_file: unused entry: $sha\n"; - $fail = 1; - } - - exit $fail; -} - -# Local Variables: -# mode: perl -# indent-tabs-mode: nil -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "my $VERSION = '" -# time-stamp-format: "%:y-%02m-%02d %02H:%02M" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "'; # UTC" -# End: diff --git a/build-aux/snippet/_Noreturn.h b/build-aux/snippet/_Noreturn.h deleted file mode 100644 index c44ad89b7..000000000 --- a/build-aux/snippet/_Noreturn.h +++ /dev/null @@ -1,10 +0,0 @@ -#if !defined _Noreturn && __STDC_VERSION__ < 201112 -# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ - || 0x5110 <= __SUNPRO_C) -# define _Noreturn __attribute__ ((__noreturn__)) -# elif 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn -# endif -#endif diff --git a/build-aux/snippet/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h deleted file mode 100644 index 8ea2a4747..000000000 --- a/build-aux/snippet/arg-nonnull.h +++ /dev/null @@ -1,26 +0,0 @@ -/* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools - that the values passed as arguments n, ..., m must be non-NULL pointers. - n = 1 stands for the first argument, n = 2 for the second argument etc. */ -#ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -# else -# define _GL_ARG_NONNULL(params) -# endif -#endif diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h deleted file mode 100644 index b35b933cd..000000000 --- a/build-aux/snippet/c++defs.h +++ /dev/null @@ -1,271 +0,0 @@ -/* C++ compatible function declaration macros. - Copyright (C) 2010-2013 Free Software Foundation, Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GL_CXXDEFS_H -#define _GL_CXXDEFS_H - -/* The three most frequent use cases of these macros are: - - * For providing a substitute for a function that is missing on some - platforms, but is declared and works fine on the platforms on which - it exists: - - #if @GNULIB_FOO@ - # if !@HAVE_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on all platforms, - but is broken/insufficient and needs to be replaced on some platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on some platforms - but is broken/insufficient and needs to be replaced on some of them and - is additionally either missing or undeclared on some other platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif -*/ - -/* _GL_EXTERN_C declaration; - performs the declaration with C linkage. */ -#if defined __cplusplus -# define _GL_EXTERN_C extern "C" -#else -# define _GL_EXTERN_C extern -#endif - -/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); - declares a replacement function, named rpl_func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ - _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype rpl_func parameters_and_attributes - -/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); - declares the system function, named func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype func parameters_and_attributes - -/* _GL_CXXALIAS_RPL (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to rpl_func, if GNULIB_NAMESPACE is defined. - Example: - _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); - */ -#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ - _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - rettype (*const func) parameters = ::rpl_func; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); - is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); - except that the C function rpl_func may have a slightly different - declaration. A cast is used to silence the "invalid conversion" error - that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - rettype (*const func) parameters = \ - reinterpret_cast(::rpl_func); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to the system provided function func, if GNULIB_NAMESPACE - is defined. - Example: - _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); - */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* If we were to write - rettype (*const func) parameters = ::func; - like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls - better (remove an indirection through a 'static' pointer variable), - but then the _GL_CXXALIASWARN macro below would cause a warning not only - for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = ::func; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function func may have a slightly different declaration. - A cast is used to silence the "invalid conversion" error that would - otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = \ - reinterpret_cast(::func); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function is picked among a set of overloaded functions, - namely the one with rettype2 and parameters2. Two consecutive casts - are used to silence the "cannot find a match" and "invalid conversion" - errors that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* The outer cast must be a reinterpret_cast. - The inner cast: When the function is defined as a set of overloaded - functions, it works as a static_cast<>, choosing the designated variant. - When the function is defined as a single variant, it works as a - reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = \ - reinterpret_cast( \ - (rettype2(*)parameters2)(::func)); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN (func); - causes a warning to be emitted when ::func is used but not when - GNULIB_NAMESPACE::func is used. func must be defined without overloaded - variants. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN(func) \ - _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN_1(func,namespace) \ - _GL_CXXALIASWARN_2 (func, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_WARN_ON_USE (func, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN_2(func,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN(func) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); - causes a warning to be emitted when the given overloaded variant of ::func - is used but not when GNULIB_NAMESPACE::func is used. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ - GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ - _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -#endif /* _GL_CXXDEFS_H */ diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h deleted file mode 100644 index 1736a1bd7..000000000 --- a/build-aux/snippet/warn-on-use.h +++ /dev/null @@ -1,109 +0,0 @@ -/* A C macro for emitting warnings if a function is used. - Copyright (C) 2010-2013 Free Software Foundation, Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* _GL_WARN_ON_USE (function, "literal string") issues a declaration - for FUNCTION which will then trigger a compiler warning containing - the text of "literal string" anywhere that function is called, if - supported by the compiler. If the compiler does not support this - feature, the macro expands to an unused extern declaration. - - This macro is useful for marking a function as a potential - portability trap, with the intent that "literal string" include - instructions on the replacement function that should be used - instead. However, one of the reasons that a function is a - portability trap is if it has the wrong signature. Declaring - FUNCTION with a different signature in C is a compilation error, so - this macro must use the same type as any existing declaration so - that programs that avoid the problematic FUNCTION do not fail to - compile merely because they included a header that poisoned the - function. But this implies that _GL_WARN_ON_USE is only safe to - use if FUNCTION is known to already have a declaration. Use of - this macro implies that there must not be any other macro hiding - the declaration of FUNCTION; but undefining FUNCTION first is part - of the poisoning process anyway (although for symbols that are - provided only via a macro, the result is a compilation error rather - than a warning containing "literal string"). Also note that in - C++, it is only safe to use if FUNCTION has no overloads. - - For an example, it is possible to poison 'getline' by: - - adding a call to gl_WARN_ON_USE_PREPARE([[#include ]], - [getline]) in configure.ac, which potentially defines - HAVE_RAW_DECL_GETLINE - - adding this code to a header that wraps the system : - #undef getline - #if HAVE_RAW_DECL_GETLINE - _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" - "not universally present; use the gnulib module getline"); - #endif - - It is not possible to directly poison global variables. But it is - possible to write a wrapper accessor function, and poison that - (less common usage, like &environ, will cause a compilation error - rather than issue the nice warning, but the end result of informing - the developer about their portability problem is still achieved): - #if HAVE_RAW_DECL_ENVIRON - static char ***rpl_environ (void) { return &environ; } - _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); - # undef environ - # define environ (*rpl_environ ()) - #endif - */ -#ifndef _GL_WARN_ON_USE - -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function -# else /* Unsupported. */ -# define _GL_WARN_ON_USE(function, message) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") - is like _GL_WARN_ON_USE (function, "string"), except that the function is - declared with the given prototype, consisting of return type, parameters, - and attributes. - This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does - not work in this case. */ -#ifndef _GL_WARN_ON_USE_CXX -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes \ - __attribute__ ((__warning__ (msg))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes -# else /* Unsupported. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_EXTERN_C declaration; - performs the declaration with C linkage. */ -#ifndef _GL_WARN_EXTERN_C -# if defined __cplusplus -# define _GL_WARN_EXTERN_C extern "C" -# else -# define _GL_WARN_EXTERN_C extern -# endif -#endif diff --git a/conf/Makefile.common b/conf/Makefile.common index f761f7224..6cd71cbb2 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -66,7 +66,7 @@ platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib +CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib CFLAGS_POSIX = -fno-builtin CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap @@ -133,6 +133,6 @@ $(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.u .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am $(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def - if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi + if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./bootstrap manually." >&2; exit 1; fi $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1) mv $@.new $@ diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index b16bd9253..46c4e95e2 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -28,10 +28,9 @@ EXTRA_DIST += grub-core/gensymlist.sh EXTRA_DIST += grub-core/genemuinit.sh EXTRA_DIST += grub-core/genemuinitheader.sh -EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff -EXTRA_DIST += grub-core/gnulib-fix-width.diff -EXTRA_DIST += grub-core/gnulib-no-abort.diff -EXTRA_DIST += grub-core/gnulib-no-gets.diff +EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch +EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch +EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch EXTRA_DIST += grub-core/lib/libgcrypt EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic diff --git a/configure.ac b/configure.ac index e36195266..05d040cd6 100644 --- a/configure.ac +++ b/configure.ac @@ -45,8 +45,8 @@ save_program_prefix="${program_prefix}" AC_CANONICAL_TARGET program_prefix="${save_program_prefix}" -AM_INIT_AUTOMAKE([1.10.1]) -AC_PREREQ(2.60) +AM_INIT_AUTOMAKE([1.11]) +AC_PREREQ(2.63) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config-util.h]) @@ -362,6 +362,7 @@ AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no) AC_GNU_SOURCE AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.18.3]) AC_SYS_LARGEFILE # Identify characteristics of the host architecture. @@ -2014,7 +2015,7 @@ fi AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([grub-core/Makefile]) -AC_CONFIG_FILES([grub-core/gnulib/Makefile]) +AC_CONFIG_FILES([grub-core/lib/gnulib/Makefile]) AC_CONFIG_FILES([po/Makefile.in]) AC_CONFIG_FILES([docs/Makefile]) AC_CONFIG_FILES([util/bash-completion.d/Makefile]) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index ca40874e5..53eb52c42 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -77,6 +77,7 @@ This edition documents version @value{VERSION}. * Coding style:: * Finding your way around:: * Contributing Changes:: +* Updating External Code:: * Porting:: * Error Handling:: * Stack and heap size:: @@ -466,6 +467,35 @@ If your intention is to just get started, please do not submit a inclusion request. Instead, please subscribe to the mailing list, and communicate first (e.g. sending a patch, asking a question, commenting on another message...). +@node Updating External Code +@chapter Updating external code + +GRUB includes some code from other projects, and it is sometimes necessary +to update it. + +@menu +* Gnulib:: +@end menu + +@node Gnulib +@section Gnulib + +Gnulib is a source code library that provides basic functionality to +programs and libraries. Many software packages make use of Gnulib +to avoid reinventing the portability wheel. + +GRUB imports Gnulib using its @command{bootstrap} utility, identifying a +particular Git commit in @file{bootstrap.conf}. To upgrade to a new Gnulib +commit, set @code{GNULIB_REVISION} in @file{bootstrap.conf} to the new commit +ID, then run @kbd{./bootstrap} and whatever else you need to make sure it +works. Check for changes to Gnulib's @file{NEWS} file between the old and new +commits; in some cases it will be necessary to adjust GRUB to match. You may +also need to update the patches in @file{grub-core/lib/gnulib-patches/}. + +To add a new Gnulib module or remove one that is no longer needed, change +@code{gnulib_modules} in @file{bootstrap.conf}. Again, run @kbd{./bootstrap} +and whatever else you need to make sure it works. + @node Porting @chapter Porting @@ -672,7 +702,7 @@ is already present and you'll need to make it follow the existant code paths for your platform adding adjustments if necessary. When done compile: @example -./autogen.sh +./bootstrap ./configure --target=$cpu --with-platform=$platform TARGET_CC=.. OBJCOPY=... STRIP=... make > /dev/null @end example diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2346bd291..58df4ab07 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -394,7 +394,7 @@ program = { ldadd = 'kernel.exec$(EXEEXT)'; ldadd = '$(MODULE_FILES)'; - ldadd = 'gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; enable = emu; }; @@ -406,7 +406,7 @@ program = { emu_nodist = symlist.c; ldadd = 'kernel.exec$(EXEEXT)'; - ldadd = 'gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; enable = emu; }; @@ -730,7 +730,7 @@ module = { name = regexp; common = commands/regexp.c; common = commands/wildcard.c; - common = gnulib/regex.c; + common = lib/gnulib/regex.c; cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; }; diff --git a/grub-core/gnulib-fix-gcc7-fallthrough.diff b/grub-core/gnulib-fix-gcc7-fallthrough.diff deleted file mode 100644 index 9802e2d24..000000000 --- a/grub-core/gnulib-fix-gcc7-fallthrough.diff +++ /dev/null @@ -1,14 +0,0 @@ -diff --git grub-core/gnulib/regexec.c grub-core/gnulib/regexec.c -index f632cd4..a7776f0 100644 ---- grub-core/gnulib/regexec.c -+++ grub-core/gnulib/regexec.c -@@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, - case OP_UTF8_PERIOD: - if (ch >= ASCII_CHARS) - return false; -+#if defined __GNUC__ && __GNUC__ >= 7 -+ __attribute__ ((fallthrough)); -+#endif - /* FALLTHROUGH */ - #endif - case OP_PERIOD: diff --git a/grub-core/gnulib-no-abort.diff b/grub-core/gnulib-no-abort.diff deleted file mode 100644 index 8377338f7..000000000 --- a/grub-core/gnulib-no-abort.diff +++ /dev/null @@ -1,30 +0,0 @@ -=== modified file 'grub-core/gnulib/regcomp.c' ---- grub-core/gnulib/regcomp.c 2010-09-20 10:35:33 +0000 -+++ grub-core/gnulib/regcomp.c 2012-03-10 11:31:42 +0000 -@@ -549,13 +549,9 @@ regerror (int errcode, const regex_t *_R - if (BE (errcode < 0 - || errcode >= (int) (sizeof (__re_error_msgid_idx) - / sizeof (__re_error_msgid_idx[0])), 0)) -- /* Only error codes returned by the rest of the code should be passed -- to this routine. If we are given anything else, or if other regex -- code generates an invalid error code, then the program has a bug. -- Dump core so we can fix it. */ -- abort (); -- -- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); -+ msg = gettext ("unknown regexp error"); -+ else -+ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); - - msg_size = strlen (msg) + 1; /* Includes the null. */ - -@@ -1119,7 +1119,7 @@ - } - break; - default: -- abort (); -+ break; - } - - if (mb_chars || has_period) - diff --git a/grub-core/gnulib-no-gets.diff b/grub-core/gnulib-no-gets.diff deleted file mode 100644 index 1a9487e84..000000000 --- a/grub-core/gnulib-no-gets.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- /tmp/x.diff 2013-04-11 16:51:42.777873536 +0200 -+++ grub-core/gnulib/stdio.in.h 2013-04-11 16:51:49.917873298 +0200 -@@ -700,7 +700,6 @@ - removed it. */ - #undef gets - #if HAVE_RAW_DECL_GETS --_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); - #endif - - diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am deleted file mode 100644 index 3444397fe..000000000 --- a/grub-core/gnulib/Makefile.am +++ /dev/null @@ -1,1747 +0,0 @@ -## DO NOT EDIT! GENERATED AUTOMATICALLY! -## Process this file with automake to produce Makefile.in. -# Copyright (C) 2002-2013 Free Software Foundation, Inc. -# -# This file 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. -# -# This file 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 this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex - -AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects - -SUBDIRS = -noinst_HEADERS = -noinst_LIBRARIES = -noinst_LTLIBRARIES = -EXTRA_DIST = -BUILT_SOURCES = -SUFFIXES = -MOSTLYCLEANFILES = core *.stackdump -MOSTLYCLEANDIRS = -CLEANFILES = -DISTCLEANFILES = -MAINTAINERCLEANFILES = - -AM_CPPFLAGS = -AM_CFLAGS = - -noinst_LIBRARIES += libgnu.a - -libgnu_a_SOURCES = -libgnu_a_LIBADD = $(gl_LIBOBJS) -libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) -EXTRA_libgnu_a_SOURCES = - -## begin gnulib module alloca - - -libgnu_a_LIBADD += @ALLOCA@ -libgnu_a_DEPENDENCIES += @ALLOCA@ -EXTRA_DIST += alloca.c - -EXTRA_libgnu_a_SOURCES += alloca.c - -## end gnulib module alloca - -## begin gnulib module alloca-opt - -BUILT_SOURCES += $(ALLOCA_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_ALLOCA_H -alloca.h: alloca.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/alloca.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -else -alloca.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += alloca.h alloca.h-t - -EXTRA_DIST += alloca.in.h - -## end gnulib module alloca-opt - -## begin gnulib module argp - -libgnu_a_SOURCES += argp.h argp-ba.c argp-eexst.c \ - argp-fmtstream.c argp-fmtstream.h argp-fs-xinl.c argp-help.c \ - argp-namefrob.h argp-parse.c argp-pin.c argp-pv.c argp-pvh.c \ - argp-xinl.c - -## end gnulib module argp - -## begin gnulib module btowc - - -EXTRA_DIST += btowc.c - -EXTRA_libgnu_a_SOURCES += btowc.c - -## end gnulib module btowc - -## begin gnulib module configmake - -# Listed in the same order as the GNU makefile conventions, and -# provided by autoconf 2.59c+. -# The Automake-defined pkg* macros are appended, in the order -# listed in the Automake 1.10a+ documentation. -configmake.h: Makefile - $(AM_V_GEN)rm -f $@-t && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - echo '#define PREFIX "$(prefix)"'; \ - echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ - echo '#define BINDIR "$(bindir)"'; \ - echo '#define SBINDIR "$(sbindir)"'; \ - echo '#define LIBEXECDIR "$(libexecdir)"'; \ - echo '#define DATAROOTDIR "$(datarootdir)"'; \ - echo '#define DATADIR "$(datadir)"'; \ - echo '#define SYSCONFDIR "$(sysconfdir)"'; \ - echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ - echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ - echo '#define INCLUDEDIR "$(includedir)"'; \ - echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ - echo '#define DOCDIR "$(docdir)"'; \ - echo '#define INFODIR "$(infodir)"'; \ - echo '#define HTMLDIR "$(htmldir)"'; \ - echo '#define DVIDIR "$(dvidir)"'; \ - echo '#define PDFDIR "$(pdfdir)"'; \ - echo '#define PSDIR "$(psdir)"'; \ - echo '#define LIBDIR "$(libdir)"'; \ - echo '#define LISPDIR "$(lispdir)"'; \ - echo '#define LOCALEDIR "$(localedir)"'; \ - echo '#define MANDIR "$(mandir)"'; \ - echo '#define MANEXT "$(manext)"'; \ - echo '#define PKGDATADIR "$(pkgdatadir)"'; \ - echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ - echo '#define PKGLIBDIR "$(pkglibdir)"'; \ - echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ - } | sed '/""/d' > $@-t && \ - mv -f $@-t $@ - -BUILT_SOURCES += configmake.h -CLEANFILES += configmake.h configmake.h-t - -## end gnulib module configmake - -## begin gnulib module dirname-lgpl - -libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c - -EXTRA_DIST += dirname.h - -## end gnulib module dirname-lgpl - -## begin gnulib module dosname - - -EXTRA_DIST += dosname.h - -## end gnulib module dosname - -## begin gnulib module errno - -BUILT_SOURCES += $(ERRNO_H) - -# We need the following in order to create when the system -# doesn't have one that is POSIX compliant. -if GL_GENERATE_ERRNO_H -errno.h: errno.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ - -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ - -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ - -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \ - -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ - -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ - -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ - < $(srcdir)/errno.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -errno.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += errno.h errno.h-t - -EXTRA_DIST += errno.in.h - -## end gnulib module errno - -## begin gnulib module error - - -EXTRA_DIST += error.c error.h - -EXTRA_libgnu_a_SOURCES += error.c - -## end gnulib module error - -## begin gnulib module float - -BUILT_SOURCES += $(FLOAT_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_FLOAT_H -float.h: float.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ - -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ - < $(srcdir)/float.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -float.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += float.h float.h-t - -EXTRA_DIST += float.c float.in.h itold.c - -EXTRA_libgnu_a_SOURCES += float.c itold.c - -## end gnulib module float - -## begin gnulib module fnmatch - -BUILT_SOURCES += $(FNMATCH_H) - -# We need the following in order to create when the system -# doesn't have one that supports the required API. -if GL_GENERATE_FNMATCH_H -fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - < $(srcdir)/fnmatch.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -else -fnmatch.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t - -EXTRA_DIST += fnmatch.c fnmatch.in.h fnmatch_loop.c - -EXTRA_libgnu_a_SOURCES += fnmatch.c fnmatch_loop.c - -## end gnulib module fnmatch - -## begin gnulib module getdelim - - -EXTRA_DIST += getdelim.c - -EXTRA_libgnu_a_SOURCES += getdelim.c - -## end gnulib module getdelim - -## begin gnulib module getline - - -EXTRA_DIST += getline.c - -EXTRA_libgnu_a_SOURCES += getline.c - -## end gnulib module getline - -## begin gnulib module getopt-posix - -BUILT_SOURCES += $(GETOPT_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - < $(srcdir)/getopt.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -MOSTLYCLEANFILES += getopt.h getopt.h-t - -EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h - -EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c - -## end gnulib module getopt-posix - -## begin gnulib module gettext - -# This is for those projects which use "gettextize --intl" to put a source-code -# copy of libintl into their package. In such projects, every Makefile.am needs -# -I$(top_builddir)/intl, so that can be found in this directory. -# For the Makefile.ams in other directories it is the maintainer's -# responsibility; for the one from gnulib we do it here. -# This option has no effect when the user disables NLS (because then the intl -# directory contains no libintl.h file) or when the project does not use -# "gettextize --intl". -AM_CPPFLAGS += -I$(top_builddir)/intl - -EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath - -## end gnulib module gettext - -## begin gnulib module gettext-h - -libgnu_a_SOURCES += gettext.h - -## end gnulib module gettext-h - -## begin gnulib module havelib - - -EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath - -## end gnulib module havelib - -## begin gnulib module intprops - - -EXTRA_DIST += intprops.h - -## end gnulib module intprops - -## begin gnulib module langinfo - -BUILT_SOURCES += langinfo.h - -# We need the following in order to create an empty placeholder for -# when the system doesn't have one. -langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ - -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \ - -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ - -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ - -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ - -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ - -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ - -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/langinfo.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += langinfo.h langinfo.h-t - -EXTRA_DIST += langinfo.in.h - -## end gnulib module langinfo - -## begin gnulib module localcharset - -libgnu_a_SOURCES += localcharset.h localcharset.c - -# We need the following in order to install a simple file in $(libdir) -# which is shared with other installed packages. We use a list of referencing -# packages so that "make uninstall" will remove the file if and only if it -# is not used by another installed package. -# On systems with glibc-2.1 or newer, the file is redundant, therefore we -# avoid installing it. - -all-local: charset.alias ref-add.sed ref-del.sed - -charset_alias = $(DESTDIR)$(libdir)/charset.alias -charset_tmp = $(DESTDIR)$(libdir)/charset.tmp -install-exec-local: install-exec-localcharset -install-exec-localcharset: all-local - if test $(GLIBC21) = no; then \ - case '$(host_os)' in \ - darwin[56]*) \ - need_charset_alias=true ;; \ - darwin* | cygwin* | mingw* | pw32* | cegcc*) \ - need_charset_alias=false ;; \ - *) \ - need_charset_alias=true ;; \ - esac ; \ - else \ - need_charset_alias=false ; \ - fi ; \ - if $$need_charset_alias; then \ - $(mkinstalldirs) $(DESTDIR)$(libdir) ; \ - fi ; \ - if test -f $(charset_alias); then \ - sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \ - $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ - rm -f $(charset_tmp) ; \ - else \ - if $$need_charset_alias; then \ - sed -f ref-add.sed charset.alias > $(charset_tmp) ; \ - $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ - rm -f $(charset_tmp) ; \ - fi ; \ - fi - -uninstall-local: uninstall-localcharset -uninstall-localcharset: all-local - if test -f $(charset_alias); then \ - sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \ - if grep '^# Packages using this file: $$' $(charset_tmp) \ - > /dev/null; then \ - rm -f $(charset_alias); \ - else \ - $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \ - fi; \ - rm -f $(charset_tmp); \ - fi - -charset.alias: config.charset - $(AM_V_GEN)rm -f t-$@ $@ && \ - $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \ - mv t-$@ $@ - -SUFFIXES += .sed .sin -.sin.sed: - $(AM_V_GEN)rm -f t-$@ $@ && \ - sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ - mv t-$@ $@ - -CLEANFILES += charset.alias ref-add.sed ref-del.sed - -EXTRA_DIST += config.charset ref-add.sin ref-del.sin - -## end gnulib module localcharset - -## begin gnulib module locale - -BUILT_SOURCES += locale.h - -# We need the following in order to create when the system -# doesn't have one that provides all definitions. -locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ - -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \ - -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \ - -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \ - -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ - -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ - -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ - -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ - -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ - -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/locale.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += locale.h locale.h-t - -EXTRA_DIST += locale.in.h - -## end gnulib module locale - -## begin gnulib module localeconv - - -EXTRA_DIST += localeconv.c - -EXTRA_libgnu_a_SOURCES += localeconv.c - -## end gnulib module localeconv - -## begin gnulib module malloc-gnu - - -EXTRA_DIST += malloc.c - -EXTRA_libgnu_a_SOURCES += malloc.c - -## end gnulib module malloc-gnu - -## begin gnulib module malloc-posix - - -EXTRA_DIST += malloc.c - -EXTRA_libgnu_a_SOURCES += malloc.c - -## end gnulib module malloc-posix - -## begin gnulib module mbrtowc - - -EXTRA_DIST += mbrtowc.c - -EXTRA_libgnu_a_SOURCES += mbrtowc.c - -## end gnulib module mbrtowc - -## begin gnulib module mbsinit - - -EXTRA_DIST += mbsinit.c - -EXTRA_libgnu_a_SOURCES += mbsinit.c - -## end gnulib module mbsinit - -## begin gnulib module mbsrtowcs - - -EXTRA_DIST += mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c - -EXTRA_libgnu_a_SOURCES += mbsrtowcs-state.c mbsrtowcs.c - -## end gnulib module mbsrtowcs - -## begin gnulib module mbswidth - -libgnu_a_SOURCES += mbswidth.h mbswidth.c - -## end gnulib module mbswidth - -## begin gnulib module mbtowc - - -EXTRA_DIST += mbtowc-impl.h mbtowc.c - -EXTRA_libgnu_a_SOURCES += mbtowc.c - -## end gnulib module mbtowc - -## begin gnulib module memchr - - -EXTRA_DIST += memchr.c memchr.valgrind - -EXTRA_libgnu_a_SOURCES += memchr.c - -## end gnulib module memchr - -## begin gnulib module mempcpy - - -EXTRA_DIST += mempcpy.c - -EXTRA_libgnu_a_SOURCES += mempcpy.c - -## end gnulib module mempcpy - -## begin gnulib module msvc-inval - - -EXTRA_DIST += msvc-inval.c msvc-inval.h - -EXTRA_libgnu_a_SOURCES += msvc-inval.c - -## end gnulib module msvc-inval - -## begin gnulib module msvc-nothrow - - -EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h - -EXTRA_libgnu_a_SOURCES += msvc-nothrow.c - -## end gnulib module msvc-nothrow - -## begin gnulib module nl_langinfo - - -EXTRA_DIST += nl_langinfo.c - -EXTRA_libgnu_a_SOURCES += nl_langinfo.c - -## end gnulib module nl_langinfo - -## begin gnulib module progname - -libgnu_a_SOURCES += progname.h progname.c - -## end gnulib module progname - -## begin gnulib module rawmemchr - - -EXTRA_DIST += rawmemchr.c rawmemchr.valgrind - -EXTRA_libgnu_a_SOURCES += rawmemchr.c - -## end gnulib module rawmemchr - -## begin gnulib module realloc-posix - - -EXTRA_DIST += realloc.c - -EXTRA_libgnu_a_SOURCES += realloc.c - -## end gnulib module realloc-posix - -## begin gnulib module regex - - -EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c - -EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c - -## end gnulib module regex - -## begin gnulib module size_max - -libgnu_a_SOURCES += size_max.h - -## end gnulib module size_max - -## begin gnulib module sleep - - -EXTRA_DIST += sleep.c - -EXTRA_libgnu_a_SOURCES += sleep.c - -## end gnulib module sleep - -## begin gnulib module snippet/_Noreturn - -# Because this Makefile snippet defines a variable used by other -# gnulib Makefile snippets, it must be present in all Makefile.am that -# need it. This is ensured by the applicability 'all' defined above. - -_NORETURN_H=$(top_srcdir)/build-aux/snippet/_Noreturn.h - -EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h - -## end gnulib module snippet/_Noreturn - -## begin gnulib module snippet/arg-nonnull - -# The BUILT_SOURCES created by this Makefile snippet are not used via #include -# statements but through direct file reference. Therefore this snippet must be -# present in all Makefile.am that need it. This is ensured by the applicability -# 'all' defined above. - -BUILT_SOURCES += arg-nonnull.h -# The arg-nonnull.h that gets inserted into generated .h files is the same as -# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut -# off. -arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h - $(AM_V_GEN)rm -f $@-t $@ && \ - sed -n -e '/GL_ARG_NONNULL/,$$p' \ - < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \ - > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t - -ARG_NONNULL_H=arg-nonnull.h - -EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h - -## end gnulib module snippet/arg-nonnull - -## begin gnulib module snippet/c++defs - -# The BUILT_SOURCES created by this Makefile snippet are not used via #include -# statements but through direct file reference. Therefore this snippet must be -# present in all Makefile.am that need it. This is ensured by the applicability -# 'all' defined above. - -BUILT_SOURCES += c++defs.h -# The c++defs.h that gets inserted into generated .h files is the same as -# build-aux/snippet/c++defs.h, except that it has the copyright header cut off. -c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h - $(AM_V_GEN)rm -f $@-t $@ && \ - sed -n -e '/_GL_CXXDEFS/,$$p' \ - < $(top_srcdir)/build-aux/snippet/c++defs.h \ - > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += c++defs.h c++defs.h-t - -CXXDEFS_H=c++defs.h - -EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h - -## end gnulib module snippet/c++defs - -## begin gnulib module snippet/warn-on-use - -BUILT_SOURCES += warn-on-use.h -# The warn-on-use.h that gets inserted into generated .h files is the same as -# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut -# off. -warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h - $(AM_V_GEN)rm -f $@-t $@ && \ - sed -n -e '/^.ifndef/,$$p' \ - < $(top_srcdir)/build-aux/snippet/warn-on-use.h \ - > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t - -WARN_ON_USE_H=warn-on-use.h - -EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h - -## end gnulib module snippet/warn-on-use - -## begin gnulib module stdalign - -BUILT_SOURCES += $(STDALIGN_H) - -# We need the following in order to create when the system -# doesn't have one that works. -if GL_GENERATE_STDALIGN_H -stdalign.h: stdalign.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/stdalign.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdalign.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdalign.h stdalign.h-t - -EXTRA_DIST += stdalign.in.h - -## end gnulib module stdalign - -## begin gnulib module stdbool - -BUILT_SOURCES += $(STDBOOL_H) - -# We need the following in order to create when the system -# doesn't have one that works. -if GL_GENERATE_STDBOOL_H -stdbool.h: stdbool.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdbool.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdbool.h stdbool.h-t - -EXTRA_DIST += stdbool.in.h - -## end gnulib module stdbool - -## begin gnulib module stddef - -BUILT_SOURCES += $(STDDEF_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_STDDEF_H -stddef.h: stddef.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ - -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ - -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ - < $(srcdir)/stddef.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stddef.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stddef.h stddef.h-t - -EXTRA_DIST += stddef.in.h - -## end gnulib module stddef - -## begin gnulib module stdint - -BUILT_SOURCES += $(STDINT_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_STDINT_H -stdint.h: stdint.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ - -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ - -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ - -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ - -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ - -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ - -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ - -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ - -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ - -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ - -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ - -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ - -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ - -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ - -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ - -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ - -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ - -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ - -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ - -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ - -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ - -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ - < $(srcdir)/stdint.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdint.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdint.h stdint.h-t - -EXTRA_DIST += stdint.in.h - -## end gnulib module stdint - -## begin gnulib module stdio - -BUILT_SOURCES += stdio.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ - -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ - -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ - -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ - -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ - -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ - -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ - -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ - -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ - -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ - -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ - -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ - -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ - -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ - -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ - -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ - -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ - -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ - -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ - -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ - -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ - -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ - -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ - -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ - -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ - -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ - -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ - -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ - -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ - -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ - -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ - -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ - -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ - -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ - -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ - -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ - -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ - -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ - -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ - -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ - -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ - -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ - -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ - -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ - -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ - -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ - -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ - -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ - -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ - -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ - -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ - -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ - -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ - -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ - < $(srcdir)/stdio.in.h | \ - sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ - -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ - -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ - -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ - -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ - -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ - -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ - -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ - -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ - -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ - -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ - -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \ - -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \ - -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ - -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ - -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ - -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ - -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ - -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ - -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ - -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ - -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ - -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ - -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ - -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ - -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ - -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ - -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ - -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \ - -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ - -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ - -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ - -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ - -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ - -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ - -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ - -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ - -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ - -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ - -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \ - -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ - -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ - -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ - -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ - -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ - -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ - -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ - -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ - -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += stdio.h stdio.h-t - -EXTRA_DIST += stdio.in.h - -## end gnulib module stdio - -## begin gnulib module stdlib - -BUILT_SOURCES += stdlib.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ - $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ - -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ - -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ - -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ - -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ - -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ - -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ - -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ - -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ - -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \ - -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \ - -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \ - -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ - -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ - -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ - -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ - -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ - -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \ - -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ - -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \ - -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ - -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ - -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ - -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ - -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \ - -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ - -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ - -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ - -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ - -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ - -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ - -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ - -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ - < $(srcdir)/stdlib.in.h | \ - sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ - -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ - -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ - -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ - -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ - -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ - -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ - -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ - -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ - -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ - -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ - -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ - -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ - -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ - -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ - -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ - -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ - -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ - -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ - -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ - -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ - -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ - -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ - -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ - -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ - -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ - -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ - -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ - -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ - -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ - -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ - -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ - -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ - -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ - -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ - -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ - -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ - -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ - -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ - -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ - -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ - -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ - -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _Noreturn/r $(_NORETURN_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += stdlib.h stdlib.h-t - -EXTRA_DIST += stdlib.in.h - -## end gnulib module stdlib - -## begin gnulib module strcase - - -EXTRA_DIST += strcasecmp.c strncasecmp.c - -EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c - -## end gnulib module strcase - -## begin gnulib module strchrnul - - -EXTRA_DIST += strchrnul.c strchrnul.valgrind - -EXTRA_libgnu_a_SOURCES += strchrnul.c - -## end gnulib module strchrnul - -## begin gnulib module streq - - -EXTRA_DIST += streq.h - -## end gnulib module streq - -## begin gnulib module strerror - - -EXTRA_DIST += strerror.c - -EXTRA_libgnu_a_SOURCES += strerror.c - -## end gnulib module strerror - -## begin gnulib module strerror-override - - -EXTRA_DIST += strerror-override.c strerror-override.h - -EXTRA_libgnu_a_SOURCES += strerror-override.c - -## end gnulib module strerror-override - -## begin gnulib module string - -BUILT_SOURCES += string.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ - -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ - -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ - -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ - -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ - -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ - -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ - -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ - -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ - -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ - -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ - -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ - -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ - -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ - -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ - -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ - -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ - -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ - -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ - -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ - -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ - -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ - -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ - -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ - -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ - -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ - -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ - -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ - -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ - -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ - -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ - -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ - -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ - -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ - -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ - -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ - -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ - -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ - < $(srcdir)/string.in.h | \ - sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ - -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ - -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ - -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ - -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ - -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ - -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ - -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ - -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ - -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ - -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ - -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ - -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ - -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ - -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ - -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ - -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ - -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ - -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ - -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ - -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ - -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ - -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ - -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ - -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ - -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ - -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ - -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ - -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ - -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ - -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ - -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ - -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ - -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ - -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ - -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ - < $(srcdir)/string.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += string.h string.h-t - -EXTRA_DIST += string.in.h - -## end gnulib module string - -## begin gnulib module strings - -BUILT_SOURCES += strings.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ - -e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \ - -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ - -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ - -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/strings.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += strings.h strings.h-t - -EXTRA_DIST += strings.in.h - -## end gnulib module strings - -## begin gnulib module strndup - - -EXTRA_DIST += strndup.c - -EXTRA_libgnu_a_SOURCES += strndup.c - -## end gnulib module strndup - -## begin gnulib module strnlen - - -EXTRA_DIST += strnlen.c - -EXTRA_libgnu_a_SOURCES += strnlen.c - -## end gnulib module strnlen - -## begin gnulib module strnlen1 - -libgnu_a_SOURCES += strnlen1.h strnlen1.c - -## end gnulib module strnlen1 - -## begin gnulib module sys_types - -BUILT_SOURCES += sys/types.h - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -sys/types.h: sys_types.in.h $(top_builddir)/config.status - $(AM_V_at)$(MKDIR_P) sys - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ - -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ - < $(srcdir)/sys_types.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += sys/types.h sys/types.h-t - -EXTRA_DIST += sys_types.in.h - -## end gnulib module sys_types - -## begin gnulib module sysexits - -BUILT_SOURCES += $(SYSEXITS_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_SYSEXITS_H -sysexits.h: sysexits.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_SYSEXITS_H''@|$(HAVE_SYSEXITS_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_SYSEXITS_H''@|$(NEXT_SYSEXITS_H)|g' \ - < $(srcdir)/sysexits.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -else -sysexits.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += sysexits.h sysexits.h-t - -EXTRA_DIST += sysexits.in.h - -## end gnulib module sysexits - -## begin gnulib module unistd - -BUILT_SOURCES += unistd.h -libgnu_a_SOURCES += unistd.c - -# We need the following in order to create an empty placeholder for -# when the system doesn't have one. -unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ - -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ - -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ - -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ - -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ - -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ - -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ - -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ - -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ - -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ - -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ - -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ - -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ - -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ - -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ - -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ - -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ - -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ - -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ - -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ - -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ - -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ - -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ - -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ - -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ - -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ - -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ - -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ - -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ - -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ - -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ - -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ - -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ - -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ - -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ - -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ - -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ - -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ - -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ - -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ - -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ - -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ - -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ - -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ - -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ - -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ - -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ - -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ - -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ - -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ - -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ - < $(srcdir)/unistd.in.h | \ - sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ - -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ - -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ - -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ - -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ - -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ - -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ - -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \ - -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ - -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ - -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ - -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ - -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ - -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ - -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ - -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ - -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ - -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ - -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ - -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ - -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ - -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ - -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ - -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ - -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ - -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ - -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ - -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ - -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ - -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ - -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ - -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ - -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ - -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ - -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ - -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ - -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ - -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ - -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ - -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ - -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ - -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ - | \ - sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ - -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ - -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ - -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ - -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ - -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ - -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ - -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ - -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ - -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ - -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ - -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ - -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ - -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ - -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ - -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ - -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ - -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ - -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ - -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ - -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ - -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ - -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ - -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ - -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ - -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ - -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ - -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ - -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ - -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += unistd.h unistd.h-t - -EXTRA_DIST += unistd.in.h - -## end gnulib module unistd - -## begin gnulib module unitypes - -BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H) - -unitypes.h: unitypes.in.h - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/unitypes.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -MOSTLYCLEANFILES += unitypes.h unitypes.h-t - -EXTRA_DIST += unitypes.in.h - -## end gnulib module unitypes - -## begin gnulib module uniwidth/base - -BUILT_SOURCES += $(LIBUNISTRING_UNIWIDTH_H) - -uniwidth.h: uniwidth.in.h - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/uniwidth.in.h; \ - } > $@-t && \ - mv -f $@-t $@ -MOSTLYCLEANFILES += uniwidth.h uniwidth.h-t - -EXTRA_DIST += localcharset.h uniwidth.in.h - -## end gnulib module uniwidth/base - -## begin gnulib module uniwidth/width - -if LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH -libgnu_a_SOURCES += uniwidth/width.c -endif - -EXTRA_DIST += uniwidth/cjk.h - -## end gnulib module uniwidth/width - -## begin gnulib module vasnprintf - - -EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h - -EXTRA_libgnu_a_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c - -## end gnulib module vasnprintf - -## begin gnulib module verify - - -EXTRA_DIST += verify.h - -## end gnulib module verify - -## begin gnulib module vsnprintf - - -EXTRA_DIST += vsnprintf.c - -EXTRA_libgnu_a_SOURCES += vsnprintf.c - -## end gnulib module vsnprintf - -## begin gnulib module wchar - -BUILT_SOURCES += wchar.h - -# We need the following in order to create when the system -# version does not work standalone. -wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ - -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ - -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ - -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \ - -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \ - -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \ - -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \ - -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \ - -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \ - -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \ - -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \ - -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \ - -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \ - -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \ - -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \ - -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \ - -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \ - -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \ - -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \ - -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \ - -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \ - -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \ - -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \ - -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \ - -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \ - -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \ - -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \ - -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \ - -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \ - -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \ - -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \ - -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \ - -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \ - -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \ - -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \ - -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \ - -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \ - -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \ - -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \ - -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \ - -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \ - -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \ - < $(srcdir)/wchar.in.h | \ - sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ - -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ - -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ - -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ - -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \ - -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \ - -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \ - -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \ - -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \ - -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ - -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \ - -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ - -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ - -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ - -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ - -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ - -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ - -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \ - -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \ - -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \ - -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \ - -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \ - -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \ - -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \ - -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \ - -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \ - -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \ - -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \ - -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \ - -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \ - -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \ - -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \ - -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \ - -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \ - -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \ - -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ - -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ - -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ - -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ - -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ - | \ - sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ - -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ - -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ - -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ - -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ - -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ - -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \ - -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \ - -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \ - -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \ - -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ - -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ - -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += wchar.h wchar.h-t - -EXTRA_DIST += wchar.in.h - -## end gnulib module wchar - -## begin gnulib module wcrtomb - - -EXTRA_DIST += wcrtomb.c - -EXTRA_libgnu_a_SOURCES += wcrtomb.c - -## end gnulib module wcrtomb - -## begin gnulib module wctype-h - -BUILT_SOURCES += wctype.h -libgnu_a_SOURCES += wctype-h.c - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ - -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ - -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ - -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ - -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ - -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \ - -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ - -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ - -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ - -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ - -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ - -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ - -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ - -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/wctype.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += wctype.h wctype.h-t - -EXTRA_DIST += wctype.in.h - -## end gnulib module wctype-h - -## begin gnulib module wcwidth - - -EXTRA_DIST += wcwidth.c - -EXTRA_libgnu_a_SOURCES += wcwidth.c - -## end gnulib module wcwidth - -## begin gnulib module xsize - -libgnu_a_SOURCES += xsize.h xsize.c - -## end gnulib module xsize - - -mostlyclean-local: mostlyclean-generic - @for dir in '' $(MOSTLYCLEANDIRS); do \ - if test -n "$$dir" && test -d $$dir; then \ - echo "rmdir $$dir"; rmdir $$dir; \ - fi; \ - done; \ - : diff --git a/grub-core/gnulib/alloca.c b/grub-core/gnulib/alloca.c deleted file mode 100644 index ee0f01886..000000000 --- a/grub-core/gnulib/alloca.c +++ /dev/null @@ -1,478 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#include - -#include - -#include -#include - -#ifdef emacs -# include "lisp.h" -# include "blockinput.h" -# ifdef EMACS_FREE -# undef free -# define free EMACS_FREE -# endif -#else -# define memory_full() abort () -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -# ifndef alloca - -# ifdef emacs -# ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -# ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -/* Using #error here is not wise since this file should work for - old and obscure compilers. */ -# endif /* STACK_DIRECTION undefined */ -# endif /* static */ -# endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -# else -# define ADDRESS_FUNCTION(arg) &(arg) -# endif - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -# ifndef STACK_DIRECTION -# define STACK_DIRECTION 0 /* Direction unknown. */ -# endif - -# if STACK_DIRECTION != 0 - -# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -# else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -# define STACK_DIR stack_dir - -static int -find_stack_direction (int *addr, int depth) -{ - int dir, dummy = 0; - if (! addr) - addr = &dummy; - *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; - dir = depth ? find_stack_direction (addr, depth - 1) : 0; - return dir + dummy; -} - -# endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -# ifndef ALIGN_SIZE -# define ALIGN_SIZE sizeof(double) -# endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -void * -alloca (size_t size) -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -# if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - STACK_DIR = find_stack_direction (NULL, (size & 1) + 20); -# endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -# ifdef emacs - BLOCK_INPUT; -# endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free (hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -# ifdef emacs - UNBLOCK_INPUT; -# endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - /* Address of header. */ - register header *new; - - size_t combined_size = sizeof (header) + size; - if (combined_size < sizeof (header)) - memory_full (); - - new = malloc (combined_size); - - if (! new) - memory_full (); - - new->h.next = last_alloca_header; - new->h.deep = depth; - - last_alloca_header = new; - - /* User storage begins just after header. */ - - return (void *) (new + 1); - } -} - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) - -# ifdef DEBUG_I00AFUNC -# include -# endif - -# ifndef CRAY_STACK -# define CRAY_STACK -# ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -# else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -# endif /* CRAY2 */ -# endif /* not CRAY_STACK */ - -# ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -# else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -# endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -# endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -# endif /* not CRAY2 */ -# endif /* CRAY */ - -# endif /* no alloca */ -#endif /* not GCC 2 */ diff --git a/grub-core/gnulib/alloca.in.h b/grub-core/gnulib/alloca.in.h deleted file mode 100644 index 72d28ee30..000000000 --- a/grub-core/gnulib/alloca.in.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Memory allocation on the stack. - - Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation, - Inc. - - This program 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, 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 - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, see - . - */ - -/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H - means there is a real alloca function. */ -#ifndef _GL_ALLOCA_H -#define _GL_ALLOCA_H - -/* alloca (N) returns a pointer to N bytes of memory - allocated on the stack, which will last until the function returns. - Use of alloca should be avoided: - - inside arguments of function calls - undefined behaviour, - - in inline functions - the allocation may actually last until the - calling function returns, - - for huge N (say, N >= 65536) - you never know how large (or small) - the stack is, and when the stack cannot fulfill the memory allocation - request, the program just crashes. - */ - -#ifndef alloca -# ifdef __GNUC__ -# define alloca __builtin_alloca -# elif defined _AIX -# define alloca __alloca -# elif defined _MSC_VER -# include -# define alloca _alloca -# elif defined __DECC && defined __VMS -# define alloca __ALLOCA -# elif defined __TANDEM && defined _TNS_E_TARGET -# ifdef __cplusplus -extern "C" -# endif -void *_alloca (unsigned short); -# pragma intrinsic (_alloca) -# define alloca _alloca -# else -# include -# ifdef __cplusplus -extern "C" -# endif -void *alloca (size_t); -# endif -#endif - -#endif /* _GL_ALLOCA_H */ diff --git a/grub-core/gnulib/argp-ba.c b/grub-core/gnulib/argp-ba.c deleted file mode 100644 index 5abc9d00a..000000000 --- a/grub-core/gnulib/argp-ba.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Default definition for ARGP_PROGRAM_BUG_ADDRESS. - Copyright (C) 1996-1997, 1999, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* If set by the user program, it should point to string that is the - bug-reporting address for the program. It will be printed by argp_help if - the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help - messages), embedded in a sentence that says something like "Report bugs to - ADDR." */ -const char *argp_program_bug_address -/* This variable should be zero-initialized. On most systems, putting it into - BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see - - . */ -#if defined __ELF__ - /* On ELF systems, variables in BSS behave well. */ -#else - = (const char *) 0 -#endif - ; diff --git a/grub-core/gnulib/argp-eexst.c b/grub-core/gnulib/argp-eexst.c deleted file mode 100644 index a8bb77fcf..000000000 --- a/grub-core/gnulib/argp-eexst.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Default definition for ARGP_ERR_EXIT_STATUS - Copyright (C) 1997, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "argp.h" - -/* The exit status that argp will use when exiting due to a parsing error. - If not defined or set by the user program, this defaults to EX_USAGE from - . */ -error_t argp_err_exit_status = EX_USAGE; diff --git a/grub-core/gnulib/argp-fmtstream.c b/grub-core/gnulib/argp-fmtstream.c deleted file mode 100644 index 02406ff2a..000000000 --- a/grub-core/gnulib/argp-fmtstream.c +++ /dev/null @@ -1,488 +0,0 @@ -/* Word-wrapping and line-truncating streams - Copyright (C) 1997-1999, 2001-2003, 2005, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* This package emulates glibc 'line_wrap_stream' semantics for systems that - don't have that. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include - -#include "argp-fmtstream.h" -#include "argp-namefrob.h" -#include "mbswidth.h" - -#ifndef ARGP_FMTSTREAM_USE_LINEWRAP - -#ifndef isblank -#define isblank(ch) ((ch)==' ' || (ch)=='\t') -#endif - -#if defined _LIBC && defined USE_IN_LIBIO -# include -# include -# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a) -#endif - -#define INIT_BUF_SIZE 200 -#define PRINTF_SIZE_GUESS 150 - -/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines - written on it with LMARGIN spaces and limits them to RMARGIN columns - total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by - replacing the whitespace before them with a newline and WMARGIN spaces. - Otherwise, chars beyond RMARGIN are simply dropped until a newline. - Returns NULL if there was an error. */ -argp_fmtstream_t -__argp_make_fmtstream (FILE *stream, - size_t lmargin, size_t rmargin, ssize_t wmargin) -{ - argp_fmtstream_t fs; - - fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream)); - if (fs != NULL) - { - fs->stream = stream; - - fs->lmargin = lmargin; - fs->rmargin = rmargin; - fs->wmargin = wmargin; - fs->point_col = 0; - fs->point_offs = 0; - - fs->buf = (char *) malloc (INIT_BUF_SIZE); - if (! fs->buf) - { - free (fs); - fs = 0; - } - else - { - fs->p = fs->buf; - fs->end = fs->buf + INIT_BUF_SIZE; - } - } - - return fs; -} -#if 0 -/* Not exported. */ -#ifdef weak_alias -weak_alias (__argp_make_fmtstream, argp_make_fmtstream) -#endif -#endif - -/* Flush FS to its stream, and free it (but don't close the stream). */ -void -__argp_fmtstream_free (argp_fmtstream_t fs) -{ - __argp_fmtstream_update (fs); - if (fs->p > fs->buf) - { -#ifdef USE_IN_LIBIO - __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf); -#else - fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream); -#endif - } - free (fs->buf); - free (fs); -} -#if 0 -/* Not exported. */ -#ifdef weak_alias -weak_alias (__argp_fmtstream_free, argp_fmtstream_free) -#endif -#endif - - -/* Return the pointer to the first character that doesn't fit in l columns. */ -static inline const ptrdiff_t -add_width (const char *ptr, const char *end, size_t l) -{ - mbstate_t ps; - const char *ptr0 = ptr; - - memset (&ps, 0, sizeof (ps)); - - while (ptr < end) - { - wchar_t wc; - size_t s, k; - - s = mbrtowc (&wc, ptr, end - ptr, &ps); - if (s == (size_t) -1) - break; - if (s == (size_t) -2) - { - if (1 >= l) - break; - l--; - ptr++; - continue; - } - - if (wc == '\e' && ptr + 3 < end - && ptr[1] == '[' && (ptr[2] == '0' || ptr[2] == '1') - && ptr[3] == 'm') - { - ptr += 4; - continue; - } - - k = wcwidth (wc); - - if (k >= l) - break; - l -= k; - ptr += s; - } - return ptr - ptr0; -} - -/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the - end of its buffer. This code is mostly from glibc stdio/linewrap.c. */ -void -__argp_fmtstream_update (argp_fmtstream_t fs) -{ - char *buf, *nl; - size_t len; - - /* Scan the buffer for newlines. */ - buf = fs->buf + fs->point_offs; - while (buf < fs->p) - { - size_t r; - - if (fs->point_col == 0 && fs->lmargin != 0) - { - /* We are starting a new line. Print spaces to the left margin. */ - const size_t pad = fs->lmargin; - if (fs->p + pad < fs->end) - { - /* We can fit in them in the buffer by moving the - buffer text up and filling in the beginning. */ - memmove (buf + pad, buf, fs->p - buf); - fs->p += pad; /* Compensate for bigger buffer. */ - memset (buf, ' ', pad); /* Fill in the spaces. */ - buf += pad; /* Don't bother searching them. */ - } - else - { - /* No buffer space for spaces. Must flush. */ - size_t i; - for (i = 0; i < pad; i++) - { -#ifdef USE_IN_LIBIO - if (_IO_fwide (fs->stream, 0) > 0) - putwc_unlocked (L' ', fs->stream); - else -#endif - putc_unlocked (' ', fs->stream); - } - } - fs->point_col = pad; - } - - len = fs->p - buf; - nl = memchr (buf, '\n', len); - - if (fs->point_col < 0) - fs->point_col = 0; - - if (!nl) - { - size_t display_width = mbsnwidth (buf, fs->p - buf, MBSW_STOP_AT_NUL); - /* The buffer ends in a partial line. */ - - if (fs->point_col + display_width < fs->rmargin) - { - /* The remaining buffer text is a partial line and fits - within the maximum line width. Advance point for the - characters to be written and stop scanning. */ - fs->point_col += display_width; - break; - } - else - /* Set the end-of-line pointer for the code below to - the end of the buffer. */ - nl = fs->p; - } - else - { - size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL); - if (display_width < (ssize_t) fs->rmargin) - { - /* The buffer contains a full line that fits within the maximum - line width. Reset point and scan the next line. */ - fs->point_col = 0; - buf = nl + 1; - continue; - } - } - - /* This line is too long. */ - r = fs->rmargin - 1; - - if (fs->wmargin < 0) - { - /* Truncate the line by overwriting the excess with the - newline and anything after it in the buffer. */ - if (nl < fs->p) - { - memmove (buf + (r - fs->point_col), nl, fs->p - nl); - fs->p -= buf + (r - fs->point_col) - nl; - /* Reset point for the next line and start scanning it. */ - fs->point_col = 0; - buf += r + 1; /* Skip full line plus \n. */ - } - else - { - /* The buffer ends with a partial line that is beyond the - maximum line width. Advance point for the characters - written, and discard those past the max from the buffer. */ - fs->point_col += len; - fs->p -= fs->point_col - r; - break; - } - } - else - { - /* Do word wrap. Go to the column just past the maximum line - width and scan back for the beginning of the word there. - Then insert a line break. */ - - char *p, *nextline; - int i; - - p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col)); - while (p >= buf && !isblank ((unsigned char) *p)) - --p; - nextline = p + 1; /* This will begin the next line. */ - - if (nextline > buf) - { - /* Swallow separating blanks. */ - if (p >= buf) - do - --p; - while (p >= buf && isblank ((unsigned char) *p)); - nl = p + 1; /* The newline will replace the first blank. */ - } - else - { - /* A single word that is greater than the maximum line width. - Oh well. Put it on an overlong line by itself. */ - p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col)); - /* Find the end of the long word. */ - if (p < nl) - do - ++p; - while (p < nl && !isblank ((unsigned char) *p)); - if (p == nl) - { - /* It already ends a line. No fussing required. */ - fs->point_col = 0; - buf = nl + 1; - continue; - } - /* We will move the newline to replace the first blank. */ - nl = p; - /* Swallow separating blanks. */ - do - ++p; - while (isblank ((unsigned char) *p)); - /* The next line will start here. */ - nextline = p; - } - - /* Note: There are a bunch of tests below for - NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall - at the end of the buffer, and NEXTLINE is in fact empty (and so - we need not be careful to maintain its contents). */ - - if ((nextline == buf + len + 1 - ? fs->end - nl < fs->wmargin + 1 - : nextline - (nl + 1) < fs->wmargin) - && fs->p > nextline) - { - /* The margin needs more blanks than we removed. */ - if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL) - > fs->wmargin + 1) - /* Make some space for them. */ - { - size_t mv = fs->p - nextline; - memmove (nl + 1 + fs->wmargin, nextline, mv); - nextline = nl + 1 + fs->wmargin; - len = nextline + mv - buf; - *nl++ = '\n'; - } - else - /* Output the first line so we can use the space. */ - { -#ifdef _LIBC - __fxprintf (fs->stream, "%.*s\n", - (int) (nl - fs->buf), fs->buf); -#else - if (nl > fs->buf) - fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream); - putc_unlocked ('\n', fs->stream); -#endif - - len += buf - fs->buf; - nl = buf = fs->buf; - } - } - else - /* We can fit the newline and blanks in before - the next word. */ - *nl++ = '\n'; - - if (nextline - nl >= fs->wmargin - || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin)) - /* Add blanks up to the wrap margin column. */ - for (i = 0; i < fs->wmargin; ++i) - *nl++ = ' '; - else - for (i = 0; i < fs->wmargin; ++i) -#ifdef USE_IN_LIBIO - if (_IO_fwide (fs->stream, 0) > 0) - putwc_unlocked (L' ', fs->stream); - else -#endif - putc_unlocked (' ', fs->stream); - - /* Copy the tail of the original buffer into the current buffer - position. */ - if (nl < nextline) - memmove (nl, nextline, buf + len - nextline); - len -= nextline - buf; - - /* Continue the scan on the remaining lines in the buffer. */ - buf = nl; - - /* Restore bufp to include all the remaining text. */ - fs->p = nl + len; - - /* Reset the counter of what has been output this line. If wmargin - is 0, we want to avoid the lmargin getting added, so we set - point_col to a magic value of -1 in that case. */ - fs->point_col = fs->wmargin ? fs->wmargin : -1; - } - } - - /* Remember that we've scanned as far as the end of the buffer. */ - fs->point_offs = fs->p - fs->buf; -} - -/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by - growing the buffer, or by flushing it. True is returned iff we succeed. */ -int -__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount) -{ - if ((size_t) (fs->end - fs->p) < amount) - { - ssize_t wrote; - - /* Flush FS's buffer. */ - __argp_fmtstream_update (fs); - -#ifdef _LIBC - __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf); - wrote = fs->p - fs->buf; -#else - wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream); -#endif - if (wrote == fs->p - fs->buf) - { - fs->p = fs->buf; - fs->point_offs = 0; - } - else - { - fs->p -= wrote; - fs->point_offs -= wrote; - memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf); - return 0; - } - - if ((size_t) (fs->end - fs->buf) < amount) - /* Gotta grow the buffer. */ - { - size_t old_size = fs->end - fs->buf; - size_t new_size = old_size + amount; - char *new_buf; - - if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size))) - { - __set_errno (ENOMEM); - return 0; - } - - fs->buf = new_buf; - fs->end = new_buf + new_size; - fs->p = fs->buf; - } - } - - return 1; -} - -ssize_t -__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...) -{ - int out; - size_t avail; - size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */ - - do - { - va_list args; - - if (! __argp_fmtstream_ensure (fs, size_guess)) - return -1; - - va_start (args, fmt); - avail = fs->end - fs->p; - out = __vsnprintf (fs->p, avail, fmt, args); - va_end (args); - if ((size_t) out >= avail) - size_guess = out + 1; - } - while ((size_t) out >= avail); - - fs->p += out; - - return out; -} -#if 0 -/* Not exported. */ -#ifdef weak_alias -weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf) -#endif -#endif - -#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */ diff --git a/grub-core/gnulib/argp-fmtstream.h b/grub-core/gnulib/argp-fmtstream.h deleted file mode 100644 index 000090ea6..000000000 --- a/grub-core/gnulib/argp-fmtstream.h +++ /dev/null @@ -1,359 +0,0 @@ -/* Word-wrapping and line-truncating streams. - Copyright (C) 1997, 2006-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* This package emulates glibc 'line_wrap_stream' semantics for systems that - don't have that. If the system does have it, it is just a wrapper for - that. This header file is only used internally while compiling argp, and - shouldn't be installed. */ - -#ifndef _ARGP_FMTSTREAM_H -#define _ARGP_FMTSTREAM_H - -#include -#include -#include - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ - || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) -/* line_wrap_stream is available, so use that. */ -#define ARGP_FMTSTREAM_USE_LINEWRAP -#endif - -#ifdef ARGP_FMTSTREAM_USE_LINEWRAP -/* Just be a simple wrapper for line_wrap_stream; the semantics are - *slightly* different, as line_wrap_stream doesn't actually make a new - object, it just modifies the given stream (reversibly) to do - line-wrapping. Since we control who uses this code, it doesn't matter. */ - -#include - -typedef FILE *argp_fmtstream_t; - -#define argp_make_fmtstream line_wrap_stream -#define __argp_make_fmtstream line_wrap_stream -#define argp_fmtstream_free line_unwrap_stream -#define __argp_fmtstream_free line_unwrap_stream - -#define __argp_fmtstream_putc(fs,ch) putc(ch,fs) -#define argp_fmtstream_putc(fs,ch) putc(ch,fs) -#define __argp_fmtstream_puts(fs,str) fputs(str,fs) -#define argp_fmtstream_puts(fs,str) fputs(str,fs) -#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs) -#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs) -#define __argp_fmtstream_printf fprintf -#define argp_fmtstream_printf fprintf - -#define __argp_fmtstream_lmargin line_wrap_lmargin -#define argp_fmtstream_lmargin line_wrap_lmargin -#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin -#define argp_fmtstream_set_lmargin line_wrap_set_lmargin -#define __argp_fmtstream_rmargin line_wrap_rmargin -#define argp_fmtstream_rmargin line_wrap_rmargin -#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin -#define argp_fmtstream_set_rmargin line_wrap_set_rmargin -#define __argp_fmtstream_wmargin line_wrap_wmargin -#define argp_fmtstream_wmargin line_wrap_wmargin -#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin -#define argp_fmtstream_set_wmargin line_wrap_set_wmargin -#define __argp_fmtstream_point line_wrap_point -#define argp_fmtstream_point line_wrap_point - -#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */ -/* Guess we have to define our own version. */ - -struct argp_fmtstream -{ - FILE *stream; /* The stream we're outputting to. */ - - size_t lmargin, rmargin; /* Left and right margins. */ - ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */ - - /* Point in buffer to which we've processed for wrapping, but not output. */ - size_t point_offs; - /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */ - ssize_t point_col; - - char *buf; /* Output buffer. */ - char *p; /* Current end of text in BUF. */ - char *end; /* Absolute end of BUF. */ -}; - -typedef struct argp_fmtstream *argp_fmtstream_t; - -/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines - written on it with LMARGIN spaces and limits them to RMARGIN columns - total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by - replacing the whitespace before them with a newline and WMARGIN spaces. - Otherwise, chars beyond RMARGIN are simply dropped until a newline. - Returns NULL if there was an error. */ -extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream, - size_t __lmargin, - size_t __rmargin, - ssize_t __wmargin); -extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream, - size_t __lmargin, - size_t __rmargin, - ssize_t __wmargin); - -/* Flush __FS to its stream, and free it (but don't close the stream). */ -extern void __argp_fmtstream_free (argp_fmtstream_t __fs); -extern void argp_fmtstream_free (argp_fmtstream_t __fs); - -extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs, - const char *__fmt, ...) - _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); -extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs, - const char *__fmt, ...) - _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); - -#if _LIBC -extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch); -extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch); - -extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); -extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); - -extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs, - const char *__str, size_t __len); -extern size_t argp_fmtstream_write (argp_fmtstream_t __fs, - const char *__str, size_t __len); -#endif - -/* Access macros for various bits of state. */ -#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin) -#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin) -#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin) -#define __argp_fmtstream_lmargin argp_fmtstream_lmargin -#define __argp_fmtstream_rmargin argp_fmtstream_rmargin -#define __argp_fmtstream_wmargin argp_fmtstream_wmargin - -#if _LIBC -/* Set __FS's left margin to LMARGIN and return the old value. */ -extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, - size_t __lmargin); -extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, - size_t __lmargin); - -/* Set __FS's right margin to __RMARGIN and return the old value. */ -extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, - size_t __rmargin); -extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, - size_t __rmargin); - -/* Set __FS's wrap margin to __WMARGIN and return the old value. */ -extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, - size_t __wmargin); -extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, - size_t __wmargin); - -/* Return the column number of the current output point in __FS. */ -extern size_t argp_fmtstream_point (argp_fmtstream_t __fs); -extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs); -#endif - -/* Internal routines. */ -extern void _argp_fmtstream_update (argp_fmtstream_t __fs); -extern void __argp_fmtstream_update (argp_fmtstream_t __fs); -extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); -extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); - -#if !_LIBC || defined __OPTIMIZE__ -/* Inline versions of above routines. */ - -#if !_LIBC -#define __argp_fmtstream_putc argp_fmtstream_putc -#define __argp_fmtstream_puts argp_fmtstream_puts -#define __argp_fmtstream_write argp_fmtstream_write -#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin -#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin -#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin -#define __argp_fmtstream_point argp_fmtstream_point -#define __argp_fmtstream_update _argp_fmtstream_update -#define __argp_fmtstream_ensure _argp_fmtstream_ensure -_GL_INLINE_HEADER_BEGIN -#ifndef ARGP_FS_EI -# define ARGP_FS_EI _GL_INLINE -#endif -#endif - -#ifndef ARGP_FS_EI -# ifdef __GNUC__ - /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 - inline semantics, unless -fgnu89-inline is used. It defines a macro - __GNUC_STDC_INLINE__ to indicate this situation or a macro - __GNUC_GNU_INLINE__ to indicate the opposite situation. - - GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline - semantics but warns, unless -fgnu89-inline is used: - warning: C99 inline functions are not supported; using GNU89 - warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute - It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. - - Whereas Apple GCC 4.0.1 build 5479 without -std=c99 or -std=gnu99 - implements the GNU C inline semantics and defines the macro - __GNUC_GNU_INLINE__, but it does not warn and does not support - __attribute__ ((__gnu_inline__)). - - All in all, these are the possible combinations. For every compiler, - we need to choose ARGP_FS_EI so that the corresponding table cell - contains an "ok". - - \ ARGP_FS_EI inline extern extern - \ inline inline - CC \ __attribute__ - ((gnu_inline)) - - gcc 4.3.0 error ok ok - gcc 4.3.0 -std=gnu99 -fgnu89-inline error ok ok - gcc 4.3.0 -std=gnu99 ok error ok - - gcc 4.2.2 error ok ok - gcc 4.2.2 -std=gnu99 -fgnu89-inline error ok ok - gcc 4.2.2 -std=gnu99 error warning ok - - gcc 4.1.2 error ok warning - gcc 4.1.2 -std=gnu99 error ok warning - - Apple gcc 4.0.1 error ok warning - Apple gcc 4.0.1 -std=gnu99 ok error warning - */ -# if defined __GNUC_STDC_INLINE__ -# define ARGP_FS_EI inline -# elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) -# define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__)) -# else -# define ARGP_FS_EI extern inline -# endif -# else - /* With other compilers, assume the ISO C99 meaning of 'inline', if - the compiler supports 'inline' at all. */ -# define ARGP_FS_EI inline -# endif -#endif - -ARGP_FS_EI size_t -__argp_fmtstream_write (argp_fmtstream_t __fs, - const char *__str, size_t __len) -{ - if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len)) - { - memcpy (__fs->p, __str, __len); - __fs->p += __len; - return __len; - } - else - return 0; -} - -ARGP_FS_EI int -__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str) -{ - size_t __len = strlen (__str); - if (__len) - { - size_t __wrote = __argp_fmtstream_write (__fs, __str, __len); - return __wrote == __len ? 0 : -1; - } - else - return 0; -} - -ARGP_FS_EI int -__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch) -{ - if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1)) - return *__fs->p++ = __ch; - else - return EOF; -} - -/* Set __FS's left margin to __LMARGIN and return the old value. */ -ARGP_FS_EI size_t -__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin) -{ - size_t __old; - if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) - __argp_fmtstream_update (__fs); - __old = __fs->lmargin; - __fs->lmargin = __lmargin; - return __old; -} - -/* Set __FS's right margin to __RMARGIN and return the old value. */ -ARGP_FS_EI size_t -__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin) -{ - size_t __old; - if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) - __argp_fmtstream_update (__fs); - __old = __fs->rmargin; - __fs->rmargin = __rmargin; - return __old; -} - -/* Set FS's wrap margin to __WMARGIN and return the old value. */ -ARGP_FS_EI size_t -__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin) -{ - size_t __old; - if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) - __argp_fmtstream_update (__fs); - __old = __fs->wmargin; - __fs->wmargin = __wmargin; - return __old; -} - -/* Return the column number of the current output point in __FS. */ -ARGP_FS_EI size_t -__argp_fmtstream_point (argp_fmtstream_t __fs) -{ - if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) - __argp_fmtstream_update (__fs); - return __fs->point_col >= 0 ? __fs->point_col : 0; -} - -#if !_LIBC -#undef __argp_fmtstream_putc -#undef __argp_fmtstream_puts -#undef __argp_fmtstream_write -#undef __argp_fmtstream_set_lmargin -#undef __argp_fmtstream_set_rmargin -#undef __argp_fmtstream_set_wmargin -#undef __argp_fmtstream_point -#undef __argp_fmtstream_update -#undef __argp_fmtstream_ensure -_GL_INLINE_HEADER_END -#endif - -#endif /* !_LIBC || __OPTIMIZE__ */ - -#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */ - -#endif /* argp-fmtstream.h */ diff --git a/grub-core/gnulib/argp-fs-xinl.c b/grub-core/gnulib/argp-fs-xinl.c deleted file mode 100644 index 35547d93d..000000000 --- a/grub-core/gnulib/argp-fs-xinl.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Real definitions for extern inline functions in argp-fmtstream.h - Copyright (C) 1997, 2003-2004, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef _LIBC -# define ARGP_FS_EI -#else -# define ARGP_FS_EI _GL_EXTERN_INLINE -#endif -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 -#include "argp-fmtstream.h" - -#if 0 -/* Not exported. */ -/* Add weak aliases. */ -#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias) - -weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc) -weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts) -weak_alias (__argp_fmtstream_write, argp_fmtstream_write) -weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin) -weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin) -weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin) -weak_alias (__argp_fmtstream_point, argp_fmtstream_point) - -#endif -#endif diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c deleted file mode 100644 index b9be63f40..000000000 --- a/grub-core/gnulib/argp-help.c +++ /dev/null @@ -1,1960 +0,0 @@ -/* Hierarchical argument parsing help output - Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_IN_LIBIO -# include -#endif - -#ifdef _LIBC -# include -# undef dgettext -# define dgettext(domain, msgid) \ - INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES) -#else -# include "gettext.h" -#endif - -#include "argp.h" -#include "argp-fmtstream.h" -#include "argp-namefrob.h" -#include "mbswidth.h" - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -/* User-selectable (using an environment variable) formatting parameters. - - These may be specified in an environment variable called 'ARGP_HELP_FMT', - with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2 - Where VALn must be a positive integer. The list of variables is in the - UPARAM_NAMES vector, below. */ - -/* Default parameters. */ -#define DUP_ARGS 0 /* True if option argument can be duplicated. */ -#define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */ -#define SHORT_OPT_COL 2 /* column in which short options start */ -#define LONG_OPT_COL 6 /* column in which long options start */ -#define DOC_OPT_COL 2 /* column in which doc options start */ -#define OPT_DOC_COL 29 /* column in which option text starts */ -#define HEADER_COL 1 /* column in which group headers are printed */ -#define USAGE_INDENT 12 /* indentation of wrapped usage lines */ -#define RMARGIN 79 /* right margin used for wrapping */ - -/* User-selectable (using an environment variable) formatting parameters. - They must all be of type 'int' for the parsing code to work. */ -struct uparams -{ - /* If true, arguments for an option are shown with both short and long - options, even when a given option has both, e.g. '-x ARG, --longx=ARG'. - If false, then if an option has both, the argument is only shown with - the long one, e.g., '-x, --longx=ARG', and a message indicating that - this really means both is printed below the options. */ - int dup_args; - - /* This is true if when DUP_ARGS is false, and some duplicate arguments have - been suppressed, an explanatory message should be printed. */ - int dup_args_note; - - /* Various output columns. */ - int short_opt_col; /* column in which short options start */ - int long_opt_col; /* column in which long options start */ - int doc_opt_col; /* column in which doc options start */ - int opt_doc_col; /* column in which option text starts */ - int header_col; /* column in which group headers are printed */ - int usage_indent; /* indentation of wrapped usage lines */ - int rmargin; /* right margin used for wrapping */ - - int valid; /* True when the values in here are valid. */ -}; - -/* This is a global variable, as user options are only ever read once. */ -static struct uparams uparams = { - DUP_ARGS, DUP_ARGS_NOTE, - SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL, - USAGE_INDENT, RMARGIN, - 0 -}; - -/* A particular uparam, and what the user name is. */ -struct uparam_name -{ - const char *name; /* User name. */ - int is_bool; /* Whether it's 'boolean'. */ - size_t uparams_offs; /* Location of the (int) field in UPARAMS. */ -}; - -/* The name-field mappings we know about. */ -static const struct uparam_name uparam_names[] = -{ - { "dup-args", 1, offsetof (struct uparams, dup_args) }, - { "dup-args-note", 1, offsetof (struct uparams, dup_args_note) }, - { "short-opt-col", 0, offsetof (struct uparams, short_opt_col) }, - { "long-opt-col", 0, offsetof (struct uparams, long_opt_col) }, - { "doc-opt-col", 0, offsetof (struct uparams, doc_opt_col) }, - { "opt-doc-col", 0, offsetof (struct uparams, opt_doc_col) }, - { "header-col", 0, offsetof (struct uparams, header_col) }, - { "usage-indent", 0, offsetof (struct uparams, usage_indent) }, - { "rmargin", 0, offsetof (struct uparams, rmargin) }, - { 0 } -}; - -static void -validate_uparams (const struct argp_state *state, struct uparams *upptr) -{ - const struct uparam_name *up; - - for (up = uparam_names; up->name; up++) - { - if (up->is_bool - || up->uparams_offs == offsetof (struct uparams, rmargin)) - continue; - if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin) - { - __argp_failure (state, 0, 0, - dgettext (state->root_argp->argp_domain, - "\ -ARGP_HELP_FMT: %s value is less than or equal to %s"), - "rmargin", up->name); - return; - } - } - uparams = *upptr; - uparams.valid = 1; -} - -/* Read user options from the environment, and fill in UPARAMS appropriately. */ -static void -fill_in_uparams (const struct argp_state *state) -{ - const char *var = getenv ("ARGP_HELP_FMT"); - struct uparams new_params = uparams; - -#define SKIPWS(p) do { while (isspace ((unsigned char) *p)) p++; } while (0); - - if (var) - { - /* Parse var. */ - while (*var) - { - SKIPWS (var); - - if (isalpha ((unsigned char) *var)) - { - size_t var_len; - const struct uparam_name *un; - int unspec = 0, val = 0; - const char *arg = var; - - while (isalnum ((unsigned char) *arg) || *arg == '-' || *arg == '_') - arg++; - var_len = arg - var; - - SKIPWS (arg); - - if (*arg == '\0' || *arg == ',') - unspec = 1; - else if (*arg == '=') - { - arg++; - SKIPWS (arg); - } - - if (unspec) - { - if (var[0] == 'n' && var[1] == 'o' && var[2] == '-') - { - val = 0; - var += 3; - var_len -= 3; - } - else - val = 1; - } - else if (isdigit ((unsigned char) *arg)) - { - val = atoi (arg); - while (isdigit ((unsigned char) *arg)) - arg++; - SKIPWS (arg); - } - - for (un = uparam_names; un->name; un++) - if (strlen (un->name) == var_len - && strncmp (var, un->name, var_len) == 0) - { - if (unspec && !un->is_bool) - __argp_failure (state, 0, 0, - dgettext (state->root_argp->argp_domain, - "\ -%.*s: ARGP_HELP_FMT parameter requires a value"), - (int) var_len, var); - else if (val < 0) - __argp_failure (state, 0, 0, - dgettext (state->root_argp->argp_domain, - "\ -%.*s: ARGP_HELP_FMT parameter must be positive"), - (int) var_len, var); - else - *(int *)((char *)&new_params + un->uparams_offs) = val; - break; - } - if (! un->name) - __argp_failure (state, 0, 0, - dgettext (state->root_argp->argp_domain, "\ -%.*s: Unknown ARGP_HELP_FMT parameter"), - (int) var_len, var); - - var = arg; - if (*var == ',') - var++; - } - else if (*var) - { - __argp_failure (state, 0, 0, - dgettext (state->root_argp->argp_domain, - "Garbage in ARGP_HELP_FMT: %s"), var); - break; - } - } - validate_uparams (state, &new_params); - } -} - -/* Returns true if OPT hasn't been marked invisible. Visibility only affects - whether OPT is displayed or used in sorting, not option shadowing. */ -#define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN)) - -/* Returns true if OPT is an alias for an earlier option. */ -#define oalias(opt) ((opt)->flags & OPTION_ALIAS) - -/* Returns true if OPT is a documentation-only entry. */ -#define odoc(opt) ((opt)->flags & OPTION_DOC) - -/* Returns true if OPT should not be translated */ -#define onotrans(opt) ((opt)->flags & OPTION_NO_TRANS) - -/* Returns true if OPT is the end-of-list marker for a list of options. */ -#define oend(opt) __option_is_end (opt) - -/* Returns true if OPT has a short option. */ -#define oshort(opt) __option_is_short (opt) - -/* - The help format for a particular option is like: - - -xARG, -yARG, --long1=ARG, --long2=ARG Documentation... - - Where ARG will be omitted if there's no argument, for this option, or - will be surrounded by "[" and "]" appropriately if the argument is - optional. The documentation string is word-wrapped appropriately, and if - the list of options is long enough, it will be started on a separate line. - If there are no short options for a given option, the first long option is - indented slightly in a way that's supposed to make most long options appear - to be in a separate column. - - For example, the following output (from ps): - - -p PID, --pid=PID List the process PID - --pgrp=PGRP List processes in the process group PGRP - -P, -x, --no-parent Include processes without parents - -Q, --all-fields Don't elide unusable fields (normally if there's - some reason ps can't print a field for any - process, it's removed from the output entirely) - -r, --reverse, --gratuitously-long-reverse-option - Reverse the order of any sort - --session[=SID] Add the processes from the session SID (which - defaults to the sid of the current process) - - Here are some more options: - -f ZOT, --foonly=ZOT Glork a foonly - -z, --zaza Snit a zar - - -?, --help Give this help list - --usage Give a short usage message - -V, --version Print program version - - The struct argp_option array for the above could look like: - - { - {"pid", 'p', "PID", 0, "List the process PID"}, - {"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"}, - {"no-parent", 'P', 0, 0, "Include processes without parents"}, - {0, 'x', 0, OPTION_ALIAS}, - {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally" - " if there's some reason ps can't" - " print a field for any process, it's" - " removed from the output entirely)" }, - {"reverse", 'r', 0, 0, "Reverse the order of any sort"}, - {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS}, - {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL, - "Add the processes from the session" - " SID (which defaults to the sid of" - " the current process)" }, - - {0,0,0,0, "Here are some more options:"}, - {"foonly", 'f', "ZOT", 0, "Glork a foonly"}, - {"zaza", 'z', 0, 0, "Snit a zar"}, - - {0} - } - - Note that the last three options are automatically supplied by argp_parse, - unless you tell it not to with ARGP_NO_HELP. - -*/ - -/* Returns true if CH occurs between BEG and END. */ -static int -find_char (char ch, char *beg, char *end) -{ - while (beg < end) - if (*beg == ch) - return 1; - else - beg++; - return 0; -} - -struct hol_cluster; /* fwd decl */ - -struct hol_entry -{ - /* First option. */ - const struct argp_option *opt; - /* Number of options (including aliases). */ - unsigned num; - - /* A pointers into the HOL's short_options field, to the first short option - letter for this entry. The order of the characters following this point - corresponds to the order of options pointed to by OPT, and there are at - most NUM. A short option recorded in an option following OPT is only - valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's - probably been shadowed by some other entry). */ - char *short_options; - - /* Entries are sorted by their group first, in the order: - 1, 2, ..., n, 0, -m, ..., -2, -1 - and then alphabetically within each group. The default is 0. */ - int group; - - /* The cluster of options this entry belongs to, or 0 if none. */ - struct hol_cluster *cluster; - - /* The argp from which this option came. */ - const struct argp *argp; - - /* Position in the array */ - unsigned ord; -}; - -/* A cluster of entries to reflect the argp tree structure. */ -struct hol_cluster -{ - /* A descriptive header printed before options in this cluster. */ - const char *header; - - /* Used to order clusters within the same group with the same parent, - according to the order in which they occurred in the parent argp's child - list. */ - int index; - - /* How to sort this cluster with respect to options and other clusters at the - same depth (clusters always follow options in the same group). */ - int group; - - /* The cluster to which this cluster belongs, or 0 if it's at the base - level. */ - struct hol_cluster *parent; - - /* The argp from which this cluster is (eventually) derived. */ - const struct argp *argp; - - /* The distance this cluster is from the root. */ - int depth; - - /* Clusters in a given hol are kept in a linked list, to make freeing them - possible. */ - struct hol_cluster *next; -}; - -/* A list of options for help. */ -struct hol -{ - /* An array of hol_entry's. */ - struct hol_entry *entries; - /* The number of entries in this hol. If this field is zero, the others - are undefined. */ - unsigned num_entries; - - /* A string containing all short options in this HOL. Each entry contains - pointers into this string, so the order can't be messed with blindly. */ - char *short_options; - - /* Clusters of entries in this hol. */ - struct hol_cluster *clusters; -}; - -/* Create a struct hol from the options in ARGP. CLUSTER is the - hol_cluster in which these entries occur, or 0, if at the root. */ -static struct hol * -make_hol (const struct argp *argp, struct hol_cluster *cluster) -{ - char *so; - const struct argp_option *o; - const struct argp_option *opts = argp->options; - struct hol_entry *entry; - unsigned num_short_options = 0; - struct hol *hol = malloc (sizeof (struct hol)); - - assert (hol); - - hol->num_entries = 0; - hol->clusters = 0; - - if (opts) - { - int cur_group = 0; - - /* The first option must not be an alias. */ - assert (! oalias (opts)); - - /* Calculate the space needed. */ - for (o = opts; ! oend (o); o++) - { - if (! oalias (o)) - hol->num_entries++; - if (oshort (o)) - num_short_options++; /* This is an upper bound. */ - } - - hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries); - hol->short_options = malloc (num_short_options + 1); - - assert (hol->entries && hol->short_options); - if (SIZE_MAX <= UINT_MAX) - assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry)); - - /* Fill in the entries. */ - so = hol->short_options; - for (o = opts, entry = hol->entries; ! oend (o); entry++) - { - entry->opt = o; - entry->num = 0; - entry->short_options = so; - entry->group = cur_group = - o->group - ? o->group - : ((!o->name && !o->key) - ? cur_group + 1 - : cur_group); - entry->cluster = cluster; - entry->argp = argp; - - do - { - entry->num++; - if (oshort (o) && ! find_char (o->key, hol->short_options, so)) - /* O has a valid short option which hasn't already been used.*/ - *so++ = o->key; - o++; - } - while (! oend (o) && oalias (o)); - } - *so = '\0'; /* null terminated so we can find the length */ - } - - return hol; -} - -/* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the - associated argp child list entry), INDEX, and PARENT, and return a pointer - to it. ARGP is the argp that this cluster results from. */ -static struct hol_cluster * -hol_add_cluster (struct hol *hol, int group, const char *header, int index, - struct hol_cluster *parent, const struct argp *argp) -{ - struct hol_cluster *cl = malloc (sizeof (struct hol_cluster)); - if (cl) - { - cl->group = group; - cl->header = header; - - cl->index = index; - cl->parent = parent; - cl->argp = argp; - cl->depth = parent ? parent->depth + 1 : 0; - - cl->next = hol->clusters; - hol->clusters = cl; - } - return cl; -} - -/* Free HOL and any resources it uses. */ -static void -hol_free (struct hol *hol) -{ - struct hol_cluster *cl = hol->clusters; - - while (cl) - { - struct hol_cluster *next = cl->next; - free (cl); - cl = next; - } - - if (hol->num_entries > 0) - { - free (hol->entries); - free (hol->short_options); - } - - free (hol); -} - -static int -hol_entry_short_iterate (const struct hol_entry *entry, - int (*func)(const struct argp_option *opt, - const struct argp_option *real, - const char *domain, void *cookie), - const char *domain, void *cookie) -{ - unsigned nopts; - int val = 0; - const struct argp_option *opt, *real = entry->opt; - char *so = entry->short_options; - - for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--) - if (oshort (opt) && *so == opt->key) - { - if (!oalias (opt)) - real = opt; - if (ovisible (opt)) - val = (*func)(opt, real, domain, cookie); - so++; - } - - return val; -} - -static inline int -#if __GNUC__ >= 3 -__attribute__ ((always_inline)) -#endif -hol_entry_long_iterate (const struct hol_entry *entry, - int (*func)(const struct argp_option *opt, - const struct argp_option *real, - const char *domain, void *cookie), - const char *domain, void *cookie) -{ - unsigned nopts; - int val = 0; - const struct argp_option *opt, *real = entry->opt; - - for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--) - if (opt->name) - { - if (!oalias (opt)) - real = opt; - if (ovisible (opt)) - val = (*func)(opt, real, domain, cookie); - } - - return val; -} - -/* Iterator that returns true for the first short option. */ -static int -until_short (const struct argp_option *opt, const struct argp_option *real, - const char *domain, void *cookie) -{ - return oshort (opt) ? opt->key : 0; -} - -/* Returns the first valid short option in ENTRY, or 0 if there is none. */ -static char -hol_entry_first_short (const struct hol_entry *entry) -{ - return hol_entry_short_iterate (entry, until_short, - entry->argp->argp_domain, 0); -} - -/* Returns the first valid long option in ENTRY, or 0 if there is none. */ -static const char * -hol_entry_first_long (const struct hol_entry *entry) -{ - const struct argp_option *opt; - unsigned num; - for (opt = entry->opt, num = entry->num; num > 0; opt++, num--) - if (opt->name && ovisible (opt)) - return opt->name; - return 0; -} - -/* Returns the entry in HOL with the long option name NAME, or 0 if there is - none. */ -static struct hol_entry * -hol_find_entry (struct hol *hol, const char *name) -{ - struct hol_entry *entry = hol->entries; - unsigned num_entries = hol->num_entries; - - while (num_entries-- > 0) - { - const struct argp_option *opt = entry->opt; - unsigned num_opts = entry->num; - - while (num_opts-- > 0) - if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0) - return entry; - else - opt++; - - entry++; - } - - return 0; -} - -/* If an entry with the long option NAME occurs in HOL, set its special - sort position to GROUP. */ -static void -hol_set_group (struct hol *hol, const char *name, int group) -{ - struct hol_entry *entry = hol_find_entry (hol, name); - if (entry) - entry->group = group; -} - -/* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1. - EQ is what to return if GROUP1 and GROUP2 are the same. */ -static int -group_cmp (int group1, int group2, int eq) -{ - if (group1 == group2) - return eq; - else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0)) - return group1 - group2; - else - return group2 - group1; -} - -/* Compare clusters CL1 & CL2 by the order that they should appear in - output. */ -static int -hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2) -{ - /* If one cluster is deeper than the other, use its ancestor at the same - level, so that finding the common ancestor is straightforward. - - clN->depth > 0 means that clN->parent != NULL (see hol_add_cluster) */ - while (cl1->depth > cl2->depth) - cl1 = cl1->parent; - while (cl2->depth > cl1->depth) - cl2 = cl2->parent; - - /* Now reduce both clusters to their ancestors at the point where both have - a common parent; these can be directly compared. */ - while (cl1->parent != cl2->parent) - cl1 = cl1->parent, cl2 = cl2->parent; - - return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index); -} - -/* Return the ancestor of CL that's just below the root (i.e., has a parent - of 0). */ -static struct hol_cluster * -hol_cluster_base (struct hol_cluster *cl) -{ - while (cl->parent) - cl = cl->parent; - return cl; -} - -/* Return true if CL1 is a child of CL2. */ -static int -hol_cluster_is_child (const struct hol_cluster *cl1, - const struct hol_cluster *cl2) -{ - while (cl1 && cl1 != cl2) - cl1 = cl1->parent; - return cl1 == cl2; -} - -/* Given the name of an OPTION_DOC option, modifies NAME to start at the tail - that should be used for comparisons, and returns true iff it should be - treated as a non-option. */ -static int -canon_doc_option (const char **name) -{ - int non_opt; - - if (!*name) - non_opt = 1; - else - { - /* Skip initial whitespace. */ - while (isspace ((unsigned char) **name)) - (*name)++; - /* Decide whether this looks like an option (leading '-') or not. */ - non_opt = (**name != '-'); - /* Skip until part of name used for sorting. */ - while (**name && !isalnum ((unsigned char) **name)) - (*name)++; - } - return non_opt; -} - -#define HOL_ENTRY_PTRCMP(a,b) ((a)->ord < (b)->ord ? -1 : 1) - -/* Order ENTRY1 & ENTRY2 by the order which they should appear in a help - listing. */ -static int -hol_entry_cmp (const struct hol_entry *entry1, - const struct hol_entry *entry2) -{ - /* The group numbers by which the entries should be ordered; if either is - in a cluster, then this is just the group within the cluster. */ - int group1 = entry1->group, group2 = entry2->group; - int rc; - - if (entry1->cluster != entry2->cluster) - { - /* The entries are not within the same cluster, so we can't compare them - directly, we have to use the appropriate clustering level too. */ - if (! entry1->cluster) - /* ENTRY1 is at the "base level", not in a cluster, so we have to - compare it's group number with that of the base cluster in which - ENTRY2 resides. Note that if they're in the same group, the - clustered option always comes laster. */ - return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1); - else if (! entry2->cluster) - /* Likewise, but ENTRY2's not in a cluster. */ - return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1); - else - /* Both entries are in clusters, we can just compare the clusters. */ - return (rc = hol_cluster_cmp (entry1->cluster, entry2->cluster)) ? - rc : HOL_ENTRY_PTRCMP (entry1, entry2); - } - else if (group1 == group2) - /* The entries are both in the same cluster and group, so compare them - alphabetically. */ - { - int short1 = hol_entry_first_short (entry1); - int short2 = hol_entry_first_short (entry2); - int doc1 = odoc (entry1->opt); - int doc2 = odoc (entry2->opt); - const char *long1 = hol_entry_first_long (entry1); - const char *long2 = hol_entry_first_long (entry2); - - if (doc1) - doc1 = canon_doc_option (&long1); - if (doc2) - doc2 = canon_doc_option (&long2); - - if (doc1 != doc2) - /* "documentation" options always follow normal options (or - documentation options that *look* like normal options). */ - return doc1 - doc2; - else if (!short1 && !short2 && long1 && long2) - /* Only long options. */ - return (rc = __strcasecmp (long1, long2)) ? - rc : HOL_ENTRY_PTRCMP (entry1, entry2); - else - /* Compare short/short, long/short, short/long, using the first - character of long options. Entries without *any* valid - options (such as options with OPTION_HIDDEN set) will be put - first, but as they're not displayed, it doesn't matter where - they are. */ - { - unsigned char first1 = short1 ? short1 : long1 ? *long1 : 0; - unsigned char first2 = short2 ? short2 : long2 ? *long2 : 0; - /* Use tolower, not _tolower, since only the former is - guaranteed to work on something already lower case. */ - int lower_cmp = tolower (first1) - tolower (first2); - /* Compare ignoring case, except when the options are both the - same letter, in which case lower-case always comes first. */ - return lower_cmp ? lower_cmp : - (rc = first2 - first1) ? - rc : HOL_ENTRY_PTRCMP (entry1, entry2); - } - } - else - /* Within the same cluster, but not the same group, so just compare - groups. */ - return group_cmp (group1, group2, HOL_ENTRY_PTRCMP (entry1, entry2)); -} - -/* Version of hol_entry_cmp with correct signature for qsort. */ -static int -hol_entry_qcmp (const void *entry1_v, const void *entry2_v) -{ - return hol_entry_cmp (entry1_v, entry2_v); -} - -/* Sort HOL by group and alphabetically by option name (with short options - taking precedence over long). Since the sorting is for display purposes - only, the shadowing of options isn't effected. */ -static void -hol_sort (struct hol *hol) -{ - if (hol->num_entries > 0) - { - unsigned i; - struct hol_entry *e; - for (i = 0, e = hol->entries; i < hol->num_entries; i++, e++) - e->ord = i; - qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry), - hol_entry_qcmp); - } -} - -/* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow - any in MORE with the same name. */ -static void -hol_append (struct hol *hol, struct hol *more) -{ - struct hol_cluster **cl_end = &hol->clusters; - - /* Steal MORE's cluster list, and add it to the end of HOL's. */ - while (*cl_end) - cl_end = &(*cl_end)->next; - *cl_end = more->clusters; - more->clusters = 0; - - /* Merge entries. */ - if (more->num_entries > 0) - { - if (hol->num_entries == 0) - { - hol->num_entries = more->num_entries; - hol->entries = more->entries; - hol->short_options = more->short_options; - more->num_entries = 0; /* Mark MORE's fields as invalid. */ - } - else - /* Append the entries in MORE to those in HOL, taking care to only add - non-shadowed SHORT_OPTIONS values. */ - { - unsigned left; - char *so, *more_so; - struct hol_entry *e; - unsigned num_entries = hol->num_entries + more->num_entries; - struct hol_entry *entries = - malloc (num_entries * sizeof (struct hol_entry)); - unsigned hol_so_len = strlen (hol->short_options); - char *short_options = - malloc (hol_so_len + strlen (more->short_options) + 1); - - assert (entries && short_options); - if (SIZE_MAX <= UINT_MAX) - assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry)); - - __mempcpy (__mempcpy (entries, hol->entries, - hol->num_entries * sizeof (struct hol_entry)), - more->entries, - more->num_entries * sizeof (struct hol_entry)); - - __mempcpy (short_options, hol->short_options, hol_so_len); - - /* Fix up the short options pointers from HOL. */ - for (e = entries, left = hol->num_entries; left > 0; e++, left--) - e->short_options = - short_options + (e->short_options - hol->short_options); - - /* Now add the short options from MORE, fixing up its entries - too. */ - so = short_options + hol_so_len; - more_so = more->short_options; - for (left = more->num_entries; left > 0; e++, left--) - { - int opts_left; - const struct argp_option *opt; - - e->short_options = so; - - for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--) - { - int ch = *more_so; - if (oshort (opt) && ch == opt->key) - /* The next short option in MORE_SO, CH, is from OPT. */ - { - if (! find_char (ch, short_options, - short_options + hol_so_len)) - /* The short option CH isn't shadowed by HOL's options, - so add it to the sum. */ - *so++ = ch; - more_so++; - } - } - } - - *so = '\0'; - - free (hol->entries); - free (hol->short_options); - - hol->entries = entries; - hol->num_entries = num_entries; - hol->short_options = short_options; - } - } - - hol_free (more); -} - -/* Inserts enough spaces to make sure STREAM is at column COL. */ -static void -indent_to (argp_fmtstream_t stream, unsigned col) -{ - int needed = col - __argp_fmtstream_point (stream); - while (needed-- > 0) - __argp_fmtstream_putc (stream, ' '); -} - -/* Output to STREAM either a space, or a newline if there isn't room for at - least ENSURE characters before the right margin. */ -static void -space (argp_fmtstream_t stream, size_t ensure) -{ - if (__argp_fmtstream_point (stream) + ensure - >= __argp_fmtstream_rmargin (stream)) - __argp_fmtstream_putc (stream, '\n'); - else - __argp_fmtstream_putc (stream, ' '); -} - -/* If the option REAL has an argument, we print it in using the printf - format REQ_FMT or OPT_FMT depending on whether it's a required or - optional argument. */ -static void -arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt, - const char *domain, argp_fmtstream_t stream) -{ - if (real->arg) - { - if (real->flags & OPTION_ARG_OPTIONAL) - __argp_fmtstream_printf (stream, opt_fmt, - dgettext (domain, real->arg)); - else - __argp_fmtstream_printf (stream, req_fmt, - dgettext (domain, real->arg)); - } -} - -/* Helper functions for hol_entry_help. */ - -/* State used during the execution of hol_help. */ -struct hol_help_state -{ - /* PREV_ENTRY should contain the previous entry printed, or 0. */ - struct hol_entry *prev_entry; - - /* If an entry is in a different group from the previous one, and SEP_GROUPS - is true, then a blank line will be printed before any output. */ - int sep_groups; - - /* True if a duplicate option argument was suppressed (only ever set if - UPARAMS.dup_args is false). */ - int suppressed_dup_arg; -}; - -/* Some state used while printing a help entry (used to communicate with - helper functions). See the doc for hol_entry_help for more info, as most - of the fields are copied from its arguments. */ -struct pentry_state -{ - const struct hol_entry *entry; - argp_fmtstream_t stream; - struct hol_help_state *hhstate; - - /* True if nothing's been printed so far. */ - int first; - - /* If non-zero, the state that was used to print this help. */ - const struct argp_state *state; -}; - -/* If a user doc filter should be applied to DOC, do so. */ -static const char * -filter_doc (const char *doc, int key, const struct argp *argp, - const struct argp_state *state) -{ - if (argp->help_filter) - /* We must apply a user filter to this output. */ - { - void *input = __argp_input (argp, state); - return (*argp->help_filter) (key, doc, input); - } - else - /* No filter. */ - return doc; -} - -/* Prints STR as a header line, with the margin lines set appropriately, and - notes the fact that groups should be separated with a blank line. ARGP is - the argp that should dictate any user doc filtering to take place. Note - that the previous wrap margin isn't restored, but the left margin is reset - to 0. */ -static void -print_header (const char *str, const struct argp *argp, - struct pentry_state *pest) -{ - const char *tstr = dgettext (argp->argp_domain, str); - const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state); - - if (fstr) - { - if (*fstr) - { - if (pest->hhstate->prev_entry) - /* Precede with a blank line. */ - __argp_fmtstream_putc (pest->stream, '\n'); - indent_to (pest->stream, uparams.header_col); - __argp_fmtstream_set_lmargin (pest->stream, uparams.header_col); - __argp_fmtstream_set_wmargin (pest->stream, uparams.header_col); - __argp_fmtstream_puts (pest->stream, fstr); - __argp_fmtstream_set_lmargin (pest->stream, 0); - __argp_fmtstream_putc (pest->stream, '\n'); - } - - pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */ - } - - if (fstr != tstr) - free ((char *) fstr); -} - -/* Inserts a comma if this isn't the first item on the line, and then makes - sure we're at least to column COL. If this *is* the first item on a line, - prints any pending whitespace/headers that should precede this line. Also - clears FIRST. */ -static void -comma (unsigned col, struct pentry_state *pest) -{ - if (pest->first) - { - const struct hol_entry *pe = pest->hhstate->prev_entry; - const struct hol_cluster *cl = pest->entry->cluster; - - if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group) - __argp_fmtstream_putc (pest->stream, '\n'); - - if (cl && cl->header && *cl->header - && (!pe - || (pe->cluster != cl - && !hol_cluster_is_child (pe->cluster, cl)))) - /* If we're changing clusters, then this must be the start of the - ENTRY's cluster unless that is an ancestor of the previous one - (in which case we had just popped into a sub-cluster for a bit). - If so, then print the cluster's header line. */ - { - int old_wm = __argp_fmtstream_wmargin (pest->stream); - print_header (cl->header, cl->argp, pest); - __argp_fmtstream_set_wmargin (pest->stream, old_wm); - } - - pest->first = 0; - } - else - __argp_fmtstream_puts (pest->stream, ", "); - - indent_to (pest->stream, col); -} - -/* Print help for ENTRY to STREAM. */ -static void -hol_entry_help (struct hol_entry *entry, const struct argp_state *state, - argp_fmtstream_t stream, struct hol_help_state *hhstate) -{ - unsigned num; - const struct argp_option *real = entry->opt, *opt; - char *so = entry->short_options; - int have_long_opt = 0; /* We have any long options. */ - /* Saved margins. */ - int old_lm = __argp_fmtstream_set_lmargin (stream, 0); - int old_wm = __argp_fmtstream_wmargin (stream); - /* PEST is a state block holding some of our variables that we'd like to - share with helper functions. */ - struct pentry_state pest; - - pest.entry = entry; - pest.stream = stream; - pest.hhstate = hhstate; - pest.first = 1; - pest.state = state; - - if (! odoc (real)) - for (opt = real, num = entry->num; num > 0; opt++, num--) - if (opt->name && ovisible (opt)) - { - have_long_opt = 1; - break; - } - - /* First emit short options. */ - __argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */ - for (opt = real, num = entry->num; num > 0; opt++, num--) - if (oshort (opt) && opt->key == *so) - /* OPT has a valid (non shadowed) short option. */ - { - if (ovisible (opt)) - { - comma (uparams.short_opt_col, &pest); - __argp_fmtstream_putc (stream, '-'); - __argp_fmtstream_putc (stream, *so); - if (!have_long_opt || uparams.dup_args) - arg (real, " %s", "[%s]", state->root_argp->argp_domain, stream); - else if (real->arg) - hhstate->suppressed_dup_arg = 1; - } - so++; - } - - /* Now, long options. */ - if (odoc (real)) - /* A "documentation" option. */ - { - __argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col); - for (opt = real, num = entry->num; num > 0; opt++, num--) - if (opt->name && *opt->name && ovisible (opt)) - { - comma (uparams.doc_opt_col, &pest); - /* Calling dgettext here isn't quite right, since sorting will - have been done on the original; but documentation options - should be pretty rare anyway... */ - __argp_fmtstream_puts (stream, - onotrans (opt) ? - opt->name : - dgettext (state->root_argp->argp_domain, - opt->name)); - } - } - else - /* A real long option. */ - { - int first_long_opt = 1; - - __argp_fmtstream_set_wmargin (stream, uparams.long_opt_col); - for (opt = real, num = entry->num; num > 0; opt++, num--) - if (opt->name && ovisible (opt)) - { - comma (uparams.long_opt_col, &pest); - __argp_fmtstream_printf (stream, "--%s", opt->name); - if (first_long_opt || uparams.dup_args) - arg (real, "=%s", "[=%s]", state->root_argp->argp_domain, - stream); - else if (real->arg) - hhstate->suppressed_dup_arg = 1; - } - } - - /* Next, documentation strings. */ - __argp_fmtstream_set_lmargin (stream, 0); - - if (pest.first) - { - /* Didn't print any switches, what's up? */ - if (!oshort (real) && !real->name) - /* This is a group header, print it nicely. */ - print_header (real->doc, entry->argp, &pest); - else - /* Just a totally shadowed option or null header; print nothing. */ - goto cleanup; /* Just return, after cleaning up. */ - } - else - { - const char *tstr = real->doc ? dgettext (state->root_argp->argp_domain, - real->doc) : 0; - const char *fstr = filter_doc (tstr, real->key, entry->argp, state); - if (fstr && *fstr) - { - unsigned int col = __argp_fmtstream_point (stream); - - __argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col); - __argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col); - - if (col > (unsigned int) (uparams.opt_doc_col + 3)) - __argp_fmtstream_putc (stream, '\n'); - else if (col >= (unsigned int) uparams.opt_doc_col) - __argp_fmtstream_puts (stream, " "); - else - indent_to (stream, uparams.opt_doc_col); - - __argp_fmtstream_puts (stream, fstr); - } - if (fstr && fstr != tstr) - free ((char *) fstr); - - /* Reset the left margin. */ - __argp_fmtstream_set_lmargin (stream, 0); - __argp_fmtstream_putc (stream, '\n'); - } - - hhstate->prev_entry = entry; - -cleanup: - __argp_fmtstream_set_lmargin (stream, old_lm); - __argp_fmtstream_set_wmargin (stream, old_wm); -} - -/* Output a long help message about the options in HOL to STREAM. */ -static void -hol_help (struct hol *hol, const struct argp_state *state, - argp_fmtstream_t stream) -{ - unsigned num; - struct hol_entry *entry; - struct hol_help_state hhstate = { 0, 0, 0 }; - - for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--) - hol_entry_help (entry, state, stream, &hhstate); - - if (hhstate.suppressed_dup_arg && uparams.dup_args_note) - { - const char *tstr = dgettext (state->root_argp->argp_domain, "\ -Mandatory or optional arguments to long options are also mandatory or \ -optional for any corresponding short options."); - const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE, - state ? state->root_argp : 0, state); - if (fstr && *fstr) - { - __argp_fmtstream_putc (stream, '\n'); - __argp_fmtstream_puts (stream, fstr); - __argp_fmtstream_putc (stream, '\n'); - } - if (fstr && fstr != tstr) - free ((char *) fstr); - } -} - -/* Helper functions for hol_usage. */ - -/* If OPT is a short option without an arg, append its key to the string - pointer pointer to by COOKIE, and advance the pointer. */ -static int -add_argless_short_opt (const struct argp_option *opt, - const struct argp_option *real, - const char *domain, void *cookie) -{ - char **snao_end = cookie; - if (!(opt->arg || real->arg) - && !((opt->flags | real->flags) & OPTION_NO_USAGE)) - *(*snao_end)++ = opt->key; - return 0; -} - -/* If OPT is a short option with an arg, output a usage entry for it to the - stream pointed at by COOKIE. */ -static int -usage_argful_short_opt (const struct argp_option *opt, - const struct argp_option *real, - const char *domain, void *cookie) -{ - argp_fmtstream_t stream = cookie; - const char *arg = opt->arg; - int flags = opt->flags | real->flags; - - if (! arg) - arg = real->arg; - - if (arg && !(flags & OPTION_NO_USAGE)) - { - arg = dgettext (domain, arg); - - if (flags & OPTION_ARG_OPTIONAL) - __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg); - else - { - /* Manually do line wrapping so that it (probably) won't - get wrapped at the embedded space. */ - space (stream, 6 + strlen (arg)); - __argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg); - } - } - - return 0; -} - -/* Output a usage entry for the long option opt to the stream pointed at by - COOKIE. */ -static int -usage_long_opt (const struct argp_option *opt, - const struct argp_option *real, - const char *domain, void *cookie) -{ - argp_fmtstream_t stream = cookie; - const char *arg = opt->arg; - int flags = opt->flags | real->flags; - - if (! arg) - arg = real->arg; - - if (! (flags & OPTION_NO_USAGE) && !odoc (opt)) - { - if (arg) - { - arg = dgettext (domain, arg); - if (flags & OPTION_ARG_OPTIONAL) - __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg); - else - __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg); - } - else - __argp_fmtstream_printf (stream, " [--%s]", opt->name); - } - - return 0; -} - -/* Print a short usage description for the arguments in HOL to STREAM. */ -static void -hol_usage (struct hol *hol, argp_fmtstream_t stream) -{ - if (hol->num_entries > 0) - { - unsigned nentries; - struct hol_entry *entry; - char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1); - char *snao_end = short_no_arg_opts; - - /* First we put a list of short options without arguments. */ - for (entry = hol->entries, nentries = hol->num_entries - ; nentries > 0 - ; entry++, nentries--) - hol_entry_short_iterate (entry, add_argless_short_opt, - entry->argp->argp_domain, &snao_end); - if (snao_end > short_no_arg_opts) - { - *snao_end++ = 0; - __argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts); - } - - /* Now a list of short options *with* arguments. */ - for (entry = hol->entries, nentries = hol->num_entries - ; nentries > 0 - ; entry++, nentries--) - hol_entry_short_iterate (entry, usage_argful_short_opt, - entry->argp->argp_domain, stream); - - /* Finally, a list of long options (whew!). */ - for (entry = hol->entries, nentries = hol->num_entries - ; nentries > 0 - ; entry++, nentries--) - hol_entry_long_iterate (entry, usage_long_opt, - entry->argp->argp_domain, stream); - } -} - -/* Make a HOL containing all levels of options in ARGP. CLUSTER is the - cluster in which ARGP's entries should be clustered, or 0. */ -static struct hol * -argp_hol (const struct argp *argp, struct hol_cluster *cluster) -{ - const struct argp_child *child = argp->children; - struct hol *hol = make_hol (argp, cluster); - if (child) - while (child->argp) - { - struct hol_cluster *child_cluster = - ((child->group || child->header) - /* Put CHILD->argp within its own cluster. */ - ? hol_add_cluster (hol, child->group, child->header, - child - argp->children, cluster, argp) - /* Just merge it into the parent's cluster. */ - : cluster); - hol_append (hol, argp_hol (child->argp, child_cluster)) ; - child++; - } - return hol; -} - -/* Calculate how many different levels with alternative args strings exist in - ARGP. */ -static size_t -argp_args_levels (const struct argp *argp) -{ - size_t levels = 0; - const struct argp_child *child = argp->children; - - if (argp->args_doc && strchr (argp->args_doc, '\n')) - levels++; - - if (child) - while (child->argp) - levels += argp_args_levels ((child++)->argp); - - return levels; -} - -/* Print all the non-option args documented in ARGP to STREAM. Any output is - preceded by a space. LEVELS is a pointer to a byte vector the length - returned by argp_args_levels; it should be initialized to zero, and - updated by this routine for the next call if ADVANCE is true. True is - returned as long as there are more patterns to output. */ -static int -argp_args_usage (const struct argp *argp, const struct argp_state *state, - char **levels, int advance, argp_fmtstream_t stream) -{ - char *our_level = *levels; - int multiple = 0; - const struct argp_child *child = argp->children; - const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0; - const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state); - - if (fdoc) - { - const char *cp = fdoc; - nl = __strchrnul (cp, '\n'); - if (*nl != '\0') - /* This is a "multi-level" args doc; advance to the correct position - as determined by our state in LEVELS, and update LEVELS. */ - { - int i; - multiple = 1; - for (i = 0; i < *our_level; i++) - cp = nl + 1, nl = __strchrnul (cp, '\n'); - (*levels)++; - } - - /* Manually do line wrapping so that it (probably) won't get wrapped at - any embedded spaces. */ - space (stream, 1 + mbsnwidth (cp, nl - cp, MBSW_STOP_AT_NUL)); - - __argp_fmtstream_write (stream, cp, nl - cp); - } - if (fdoc && fdoc != tdoc) - free ((char *)fdoc); /* Free user's modified doc string. */ - - if (child) - while (child->argp) - advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream); - - if (advance && multiple) - { - /* Need to increment our level. */ - if (*nl) - /* There's more we can do here. */ - { - (*our_level)++; - advance = 0; /* Our parent shouldn't advance also. */ - } - else if (*our_level > 0) - /* We had multiple levels, but used them up; reset to zero. */ - *our_level = 0; - } - - return !advance; -} - -/* Print the documentation for ARGP to STREAM; if POST is false, then - everything preceding a '\v' character in the documentation strings (or - the whole string, for those with none) is printed, otherwise, everything - following the '\v' character (nothing for strings without). Each separate - bit of documentation is separated a blank line, and if PRE_BLANK is true, - then the first is as well. If FIRST_ONLY is true, only the first - occurrence is output. Returns true if anything was output. */ -static int -argp_doc (const struct argp *argp, const struct argp_state *state, - int post, int pre_blank, int first_only, - argp_fmtstream_t stream) -{ - const char *text; - const char *inp_text; - size_t inp_text_len = 0; - const char *trans_text; - void *input = 0; - int anything = 0; - const struct argp_child *child = argp->children; - - if (argp->doc) - { - char *vt = strchr (argp->doc, '\v'); - if (vt) - { - if (post) - { - inp_text = vt + 1; - if (! *inp_text) - inp_text = 0; - } - else - { - inp_text_len = vt - argp->doc; - inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0; - } - } - else - inp_text = post ? 0 : argp->doc; - trans_text = inp_text ? dgettext (argp->argp_domain, inp_text) : NULL; - } - else - trans_text = inp_text = 0; - - if (argp->help_filter) - /* We have to filter the doc strings. */ - { - input = __argp_input (argp, state); - text = - (*argp->help_filter) (post - ? ARGP_KEY_HELP_POST_DOC - : ARGP_KEY_HELP_PRE_DOC, - trans_text, input); - } - else - text = (const char *) trans_text; - - if (text) - { - if (pre_blank) - __argp_fmtstream_putc (stream, '\n'); - - __argp_fmtstream_puts (stream, text); - - if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) - __argp_fmtstream_putc (stream, '\n'); - - anything = 1; - } - - if (text && text != trans_text) - free ((char *) text); /* Free TEXT returned from the help filter. */ - - if (inp_text && inp_text_len) - free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */ - - if (post && argp->help_filter) - /* Now see if we have to output an ARGP_KEY_HELP_EXTRA text. */ - { - text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input); - if (text) - { - if (anything || pre_blank) - __argp_fmtstream_putc (stream, '\n'); - __argp_fmtstream_puts (stream, text); - free ((char *) text); - if (__argp_fmtstream_point (stream) - > __argp_fmtstream_lmargin (stream)) - __argp_fmtstream_putc (stream, '\n'); - anything = 1; - } - } - - if (child) - while (child->argp && !(first_only && anything)) - anything |= - argp_doc ((child++)->argp, state, - post, anything || pre_blank, first_only, - stream); - - return anything; -} - -/* Output a usage message for ARGP to STREAM. If called from - argp_state_help, STATE is the relevant parsing state. FLAGS are from the - set ARGP_HELP_*. NAME is what to use wherever a "program name" is - needed. */ -static void -_help (const struct argp *argp, const struct argp_state *state, FILE *stream, - unsigned flags, char *name) -{ - int anything = 0; /* Whether we've output anything. */ - struct hol *hol = 0; - argp_fmtstream_t fs; - - if (! stream) - return; - -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __flockfile (stream); -#endif - - if (! uparams.valid) - fill_in_uparams (state); - - fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0); - if (! fs) - { -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __funlockfile (stream); -#endif - return; - } - - if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG)) - { - hol = argp_hol (argp, 0); - - /* If present, these options always come last. */ - hol_set_group (hol, "help", -1); - hol_set_group (hol, "version", -1); - - hol_sort (hol); - } - - if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE)) - /* Print a short "Usage:" message. */ - { - int first_pattern = 1, more_patterns; - size_t num_pattern_levels = argp_args_levels (argp); - char *pattern_levels = alloca (num_pattern_levels); - - memset (pattern_levels, 0, num_pattern_levels); - - do - { - int old_lm; - int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent); - char *levels = pattern_levels; - - if (first_pattern) - __argp_fmtstream_printf (fs, "%s %s", - dgettext (argp->argp_domain, "Usage:"), - name); - else - __argp_fmtstream_printf (fs, "%s %s", - dgettext (argp->argp_domain, " or: "), - name); - - /* We set the lmargin as well as the wmargin, because hol_usage - manually wraps options with newline to avoid annoying breaks. */ - old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent); - - if (flags & ARGP_HELP_SHORT_USAGE) - /* Just show where the options go. */ - { - if (hol->num_entries > 0) - __argp_fmtstream_puts (fs, dgettext (argp->argp_domain, - " [OPTION...]")); - } - else - /* Actually print the options. */ - { - hol_usage (hol, fs); - flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */ - } - - more_patterns = argp_args_usage (argp, state, &levels, 1, fs); - - __argp_fmtstream_set_wmargin (fs, old_wm); - __argp_fmtstream_set_lmargin (fs, old_lm); - - __argp_fmtstream_putc (fs, '\n'); - anything = 1; - - first_pattern = 0; - } - while (more_patterns); - } - - if (flags & ARGP_HELP_PRE_DOC) - anything |= argp_doc (argp, state, 0, 0, 1, fs); - - if (flags & ARGP_HELP_SEE) - { - __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\ -Try '%s --help' or '%s --usage' for more information.\n"), - name, name); - anything = 1; - } - - if (flags & ARGP_HELP_LONG) - /* Print a long, detailed help message. */ - { - /* Print info about all the options. */ - if (hol->num_entries > 0) - { - if (anything) - __argp_fmtstream_putc (fs, '\n'); - hol_help (hol, state, fs); - anything = 1; - } - } - - if (flags & ARGP_HELP_POST_DOC) - /* Print any documentation strings at the end. */ - anything |= argp_doc (argp, state, 1, anything, 0, fs); - - if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address) - { - if (anything) - __argp_fmtstream_putc (fs, '\n'); - __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, - "Report bugs to %s.\n"), - argp_program_bug_address); - anything = 1; - } - -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __funlockfile (stream); -#endif - - if (hol) - hol_free (hol); - - __argp_fmtstream_free (fs); -} - -/* Output a usage message for ARGP to STREAM. FLAGS are from the set - ARGP_HELP_*. NAME is what to use wherever a "program name" is needed. */ -void __argp_help (const struct argp *argp, FILE *stream, - unsigned flags, char *name) -{ - struct argp_state state; - memset (&state, 0, sizeof state); - state.root_argp = argp; - _help (argp, &state, stream, flags, name); -} -#ifdef weak_alias -weak_alias (__argp_help, argp_help) -#endif - -#if ! (defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME) -char * -__argp_short_program_name (void) -{ -# if HAVE_DECL_PROGRAM_INVOCATION_NAME - return __argp_base_name (program_invocation_name); -# else - /* FIXME: What now? Miles suggests that it is better to use NULL, - but currently the value is passed on directly to fputs_unlocked, - so that requires more changes. */ -# if __GNUC__ -# warning No reasonable value to return -# endif /* __GNUC__ */ - return ""; -# endif -} -#endif - -/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are - from the set ARGP_HELP_*. */ -void -__argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags) -{ - if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream) - { - if (state && (state->flags & ARGP_LONG_ONLY)) - flags |= ARGP_HELP_LONG_ONLY; - - _help (state ? state->root_argp : 0, state, stream, flags, - state ? state->name : __argp_short_program_name ()); - - if (!state || ! (state->flags & ARGP_NO_EXIT)) - { - if (flags & ARGP_HELP_EXIT_ERR) - exit (argp_err_exit_status); - if (flags & ARGP_HELP_EXIT_OK) - exit (0); - } - } -} -#ifdef weak_alias -weak_alias (__argp_state_help, argp_state_help) -#endif - -/* If appropriate, print the printf string FMT and following args, preceded - by the program name and ':', to stderr, and followed by a "Try ... --help" - message, then exit (1). */ -void -__argp_error (const struct argp_state *state, const char *fmt, ...) -{ - if (!state || !(state->flags & ARGP_NO_ERRS)) - { - FILE *stream = state ? state->err_stream : stderr; - - if (stream) - { - va_list ap; - -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __flockfile (stream); -#endif - - va_start (ap, fmt); - -#ifdef USE_IN_LIBIO - if (_IO_fwide (stream, 0) > 0) - { - char *buf; - - if (__asprintf (&buf, fmt, ap) < 0) - buf = NULL; - - __fwprintf (stream, L"%s: %s\n", - state ? state->name : __argp_short_program_name (), - buf); - - free (buf); - } - else -#endif - { - fputs_unlocked (state - ? state->name : __argp_short_program_name (), - stream); - putc_unlocked (':', stream); - putc_unlocked (' ', stream); - - vfprintf (stream, fmt, ap); - - putc_unlocked ('\n', stream); - } - - __argp_state_help (state, stream, ARGP_HELP_STD_ERR); - - va_end (ap); - -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __funlockfile (stream); -#endif - } - } -} -#ifdef weak_alias -weak_alias (__argp_error, argp_error) -#endif - -/* Similar to the standard gnu error-reporting function error(), but will - respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print - to STATE->err_stream. This is useful for argument parsing code that is - shared between program startup (when exiting is desired) and runtime - option parsing (when typically an error code is returned instead). The - difference between this function and argp_error is that the latter is for - *parsing errors*, and the former is for other problems that occur during - parsing but don't reflect a (syntactic) problem with the input. */ -void -__argp_failure (const struct argp_state *state, int status, int errnum, - const char *fmt, ...) -{ - if (!state || !(state->flags & ARGP_NO_ERRS)) - { - FILE *stream = state ? state->err_stream : stderr; - - if (stream) - { -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __flockfile (stream); -#endif - -#ifdef USE_IN_LIBIO - if (_IO_fwide (stream, 0) > 0) - __fwprintf (stream, L"%s", - state ? state->name : __argp_short_program_name ()); - else -#endif - fputs_unlocked (state - ? state->name : __argp_short_program_name (), - stream); - - if (fmt) - { - va_list ap; - - va_start (ap, fmt); -#ifdef USE_IN_LIBIO - if (_IO_fwide (stream, 0) > 0) - { - char *buf; - - if (__asprintf (&buf, fmt, ap) < 0) - buf = NULL; - - __fwprintf (stream, L": %s", buf); - - free (buf); - } - else -#endif - { - putc_unlocked (':', stream); - putc_unlocked (' ', stream); - - vfprintf (stream, fmt, ap); - } - - va_end (ap); - } - - if (errnum) - { - char buf[200]; - -#ifdef USE_IN_LIBIO - if (_IO_fwide (stream, 0) > 0) - __fwprintf (stream, L": %s", - __strerror_r (errnum, buf, sizeof (buf))); - else -#endif - { - char const *s = NULL; - putc_unlocked (':', stream); - putc_unlocked (' ', stream); -#if _LIBC || (HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P && !defined strerror_r) - s = __strerror_r (errnum, buf, sizeof buf); -#elif HAVE_DECL_STRERROR_R - if (__strerror_r (errnum, buf, sizeof buf) == 0) - s = buf; -#endif -#if !_LIBC - if (! s && ! (s = strerror (errnum))) - s = dgettext (state->root_argp->argp_domain, - "Unknown system error"); -#endif - fputs (s, stream); - } - } - -#ifdef USE_IN_LIBIO - if (_IO_fwide (stream, 0) > 0) - putwc_unlocked (L'\n', stream); - else -#endif - putc_unlocked ('\n', stream); - -#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE) - __funlockfile (stream); -#endif - - if (status && (!state || !(state->flags & ARGP_NO_EXIT))) - exit (status); - } - } -} -#ifdef weak_alias -weak_alias (__argp_failure, argp_failure) -#endif diff --git a/grub-core/gnulib/argp-namefrob.h b/grub-core/gnulib/argp-namefrob.h deleted file mode 100644 index 6333958c6..000000000 --- a/grub-core/gnulib/argp-namefrob.h +++ /dev/null @@ -1,157 +0,0 @@ -/* Name frobnication for compiling argp outside of glibc - Copyright (C) 1997, 2003, 2007, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#if !_LIBC -/* This code is written for inclusion in gnu-libc, and uses names in the - namespace reserved for libc. If we're not compiling in libc, define those - names to be the normal ones instead. */ - -/* argp-parse functions */ -#undef __argp_parse -#define __argp_parse argp_parse -#undef __option_is_end -#define __option_is_end _option_is_end -#undef __option_is_short -#define __option_is_short _option_is_short -#undef __argp_input -#define __argp_input _argp_input - -/* argp-help functions */ -#undef __argp_help -#define __argp_help argp_help -#undef __argp_error -#define __argp_error argp_error -#undef __argp_failure -#define __argp_failure argp_failure -#undef __argp_state_help -#define __argp_state_help argp_state_help -#undef __argp_usage -#define __argp_usage argp_usage - -/* argp-fmtstream functions */ -#undef __argp_make_fmtstream -#define __argp_make_fmtstream argp_make_fmtstream -#undef __argp_fmtstream_free -#define __argp_fmtstream_free argp_fmtstream_free -#undef __argp_fmtstream_putc -#define __argp_fmtstream_putc argp_fmtstream_putc -#undef __argp_fmtstream_puts -#define __argp_fmtstream_puts argp_fmtstream_puts -#undef __argp_fmtstream_write -#define __argp_fmtstream_write argp_fmtstream_write -#undef __argp_fmtstream_printf -#define __argp_fmtstream_printf argp_fmtstream_printf -#undef __argp_fmtstream_set_lmargin -#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin -#undef __argp_fmtstream_set_rmargin -#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin -#undef __argp_fmtstream_set_wmargin -#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin -#undef __argp_fmtstream_point -#define __argp_fmtstream_point argp_fmtstream_point -#undef __argp_fmtstream_update -#define __argp_fmtstream_update _argp_fmtstream_update -#undef __argp_fmtstream_ensure -#define __argp_fmtstream_ensure _argp_fmtstream_ensure -#undef __argp_fmtstream_lmargin -#define __argp_fmtstream_lmargin argp_fmtstream_lmargin -#undef __argp_fmtstream_rmargin -#define __argp_fmtstream_rmargin argp_fmtstream_rmargin -#undef __argp_fmtstream_wmargin -#define __argp_fmtstream_wmargin argp_fmtstream_wmargin - -/* normal libc functions we call */ -#undef __flockfile -#define __flockfile flockfile -#undef __funlockfile -#define __funlockfile funlockfile -#undef __mempcpy -#define __mempcpy mempcpy -#undef __sleep -#define __sleep sleep -#undef __strcasecmp -#define __strcasecmp strcasecmp -#undef __strchrnul -#define __strchrnul strchrnul -#undef __strerror_r -#define __strerror_r strerror_r -#undef __strndup -#define __strndup strndup -#undef __vsnprintf -#define __vsnprintf vsnprintf - -#if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED -# define clearerr_unlocked(x) clearerr (x) -#endif -#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED -# define feof_unlocked(x) feof (x) -#endif -#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED -# define ferror_unlocked(x) ferror (x) -#endif -#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED -# define fflush_unlocked(x) fflush (x) -#endif -#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED -# define fgets_unlocked(x,y,z) fgets (x,y,z) -#endif -#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED -# define fputc_unlocked(x,y) fputc (x,y) -#endif -#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED -# define fputs_unlocked(x,y) fputs (x,y) -#endif -#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED -# define fread_unlocked(w,x,y,z) fread (w,x,y,z) -#endif -#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED -# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) -#endif -#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED -# define getc_unlocked(x) getc (x) -#endif -#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED -# define getchar_unlocked() getchar () -#endif -#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED -# define putc_unlocked(x,y) putc (x,y) -#endif -#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED -# define putchar_unlocked(x) putchar (x) -#endif - -#endif /* !_LIBC */ - -#ifndef __set_errno -# define __set_errno(e) (errno = (e)) -#endif - -#if defined GNULIB_ARGP_DISABLE_DIRNAME -# define __argp_base_name(arg) arg -#elif defined GNULIB_ARGP_EXTERN_BASENAME -extern char *__argp_base_name (const char *arg); -#else -# include "dirname.h" -# define __argp_base_name last_component -#endif - -#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME -# define __argp_short_program_name() (program_invocation_short_name) -#else -extern char *__argp_short_program_name (void); -#endif diff --git a/grub-core/gnulib/argp-parse.c b/grub-core/gnulib/argp-parse.c deleted file mode 100644 index 67ea32c54..000000000 --- a/grub-core/gnulib/argp-parse.c +++ /dev/null @@ -1,953 +0,0 @@ -/* Hierarchical argument parsing, layered over getopt - Copyright (C) 1995-2000, 2002-2004, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _LIBC -# include -# undef dgettext -# define dgettext(domain, msgid) \ - INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES) -#else -# include "gettext.h" -#endif -#define N_(msgid) msgid - -#include "argp.h" -#include "argp-namefrob.h" - -#define alignto(n, d) ((((n) + (d) - 1) / (d)) * (d)) - -/* Getopt return values. */ -#define KEY_END (-1) /* The end of the options. */ -#define KEY_ARG 1 /* A non-option argument. */ -#define KEY_ERR '?' /* An error parsing the options. */ - -/* The meta-argument used to prevent any further arguments being interpreted - as options. */ -#define QUOTE "--" - -/* The number of bits we steal in a long-option value for our own use. */ -#define GROUP_BITS CHAR_BIT - -/* The number of bits available for the user value. */ -#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS) -#define USER_MASK ((1 << USER_BITS) - 1) - -/* EZ alias for ARGP_ERR_UNKNOWN. */ -#define EBADKEY ARGP_ERR_UNKNOWN - -/* Default options. */ - -/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep - for one second intervals, decrementing _ARGP_HANG until it's zero. Thus - you can force the program to continue by attaching a debugger and setting - it to 0 yourself. */ -static volatile int _argp_hang; - -#define OPT_PROGNAME -2 -#define OPT_USAGE -3 -#define OPT_HANG -4 - -static const struct argp_option argp_default_options[] = -{ - {"help", '?', 0, 0, N_("give this help list"), -1}, - {"usage", OPT_USAGE, 0, 0, N_("give a short usage message"), 0}, - {"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("set the program name"), 0}, - {"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN, - N_("hang for SECS seconds (default 3600)"), 0}, - {NULL, 0, 0, 0, NULL, 0} -}; - -static error_t -argp_default_parser (int key, char *arg, struct argp_state *state) -{ - switch (key) - { - case '?': - __argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP); - break; - case OPT_USAGE: - __argp_state_help (state, state->out_stream, - ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK); - break; - - case OPT_PROGNAME: /* Set the program name. */ -#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME - program_invocation_name = arg; -#endif - /* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka - __PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined - to be that, so we have to be a bit careful here.] */ - - /* Update what we use for messages. */ - state->name = __argp_base_name (arg); - -#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME - program_invocation_short_name = state->name; -#endif - - if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS)) - == ARGP_PARSE_ARGV0) - /* Update what getopt uses too. */ - state->argv[0] = arg; - - break; - - case OPT_HANG: - _argp_hang = atoi (arg ? arg : "3600"); - while (_argp_hang-- > 0) - __sleep (1); - break; - - default: - return EBADKEY; - } - return 0; -} - -static const struct argp argp_default_argp = - {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"}; - - -static const struct argp_option argp_version_options[] = -{ - {"version", 'V', 0, 0, N_("print program version"), -1}, - {NULL, 0, 0, 0, NULL, 0} -}; - -static error_t -argp_version_parser (int key, char *arg, struct argp_state *state) -{ - switch (key) - { - case 'V': - if (argp_program_version_hook) - (*argp_program_version_hook) (state->out_stream, state); - else if (argp_program_version) - fprintf (state->out_stream, "%s\n", argp_program_version); - else - __argp_error (state, "%s", - dgettext (state->root_argp->argp_domain, - "(PROGRAM ERROR) No version known!?")); - if (! (state->flags & ARGP_NO_EXIT)) - exit (0); - break; - default: - return EBADKEY; - } - return 0; -} - -static const struct argp argp_version_argp = - {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"}; - -/* Returns the offset into the getopt long options array LONG_OPTIONS of a - long option with called NAME, or -1 if none is found. Passing NULL as - NAME will return the number of options. */ -static int -find_long_option (struct option *long_options, const char *name) -{ - struct option *l = long_options; - while (l->name != NULL) - if (name != NULL && strcmp (l->name, name) == 0) - return l - long_options; - else - l++; - if (name == NULL) - return l - long_options; - else - return -1; -} - - -/* The state of a "group" during parsing. Each group corresponds to a - particular argp structure from the tree of such descending from the top - level argp passed to argp_parse. */ -struct group -{ - /* This group's parsing function. */ - argp_parser_t parser; - - /* Which argp this group is from. */ - const struct argp *argp; - - /* Points to the point in SHORT_OPTS corresponding to the end of the short - options for this group. We use it to determine from which group a - particular short options is from. */ - char *short_end; - - /* The number of non-option args successfully handled by this parser. */ - unsigned args_processed; - - /* This group's parser's parent's group. */ - struct group *parent; - unsigned parent_index; /* And the our position in the parent. */ - - /* These fields are swapped into and out of the state structure when - calling this group's parser. */ - void *input, **child_inputs; - void *hook; -}; - -/* Call GROUP's parser with KEY and ARG, swapping any group-specific info - from STATE before calling, and back into state afterwards. If GROUP has - no parser, EBADKEY is returned. */ -static error_t -group_parse (struct group *group, struct argp_state *state, int key, char *arg) -{ - if (group->parser) - { - error_t err; - state->hook = group->hook; - state->input = group->input; - state->child_inputs = group->child_inputs; - state->arg_num = group->args_processed; - err = (*group->parser)(key, arg, state); - group->hook = state->hook; - return err; - } - else - return EBADKEY; -} - -struct parser -{ - const struct argp *argp; - - /* SHORT_OPTS is the getopt short options string for the union of all the - groups of options. */ - char *short_opts; - /* LONG_OPTS is the array of getop long option structures for the union of - all the groups of options. */ - struct option *long_opts; - /* OPT_DATA is the getopt data used for the re-entrant getopt. */ - struct _getopt_data opt_data; - - /* States of the various parsing groups. */ - struct group *groups; - /* The end of the GROUPS array. */ - struct group *egroup; - /* A vector containing storage for the CHILD_INPUTS field in all groups. */ - void **child_inputs; - - /* True if we think using getopt is still useful; if false, then - remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is - cleared whenever getopt returns KEY_END, but may be set again if the user - moves the next argument pointer backwards. */ - int try_getopt; - - /* State block supplied to parsing routines. */ - struct argp_state state; - - /* Memory used by this parser. */ - void *storage; -}; - -/* The next usable entries in the various parser tables being filled in by - convert_options. */ -struct parser_convert_state -{ - struct parser *parser; - char *short_end; - struct option *long_end; - void **child_inputs_end; -}; - -/* Converts all options in ARGP (which is put in GROUP) and ancestors - into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and - CVT->LONG_END are the points at which new options are added. Returns the - next unused group entry. CVT holds state used during the conversion. */ -static struct group * -convert_options (const struct argp *argp, - struct group *parent, unsigned parent_index, - struct group *group, struct parser_convert_state *cvt) -{ - /* REAL is the most recent non-alias value of OPT. */ - const struct argp_option *real = argp->options; - const struct argp_child *children = argp->children; - - if (real || argp->parser) - { - const struct argp_option *opt; - - if (real) - for (opt = real; !__option_is_end (opt); opt++) - { - if (! (opt->flags & OPTION_ALIAS)) - /* OPT isn't an alias, so we can use values from it. */ - real = opt; - - if (! (real->flags & OPTION_DOC)) - /* A real option (not just documentation). */ - { - if (__option_is_short (opt)) - /* OPT can be used as a short option. */ - { - *cvt->short_end++ = opt->key; - if (real->arg) - { - *cvt->short_end++ = ':'; - if (real->flags & OPTION_ARG_OPTIONAL) - *cvt->short_end++ = ':'; - } - *cvt->short_end = '\0'; /* keep 0 terminated */ - } - - if (opt->name - && find_long_option (cvt->parser->long_opts, opt->name) < 0) - /* OPT can be used as a long option. */ - { - cvt->long_end->name = opt->name; - cvt->long_end->has_arg = - (real->arg - ? (real->flags & OPTION_ARG_OPTIONAL - ? optional_argument - : required_argument) - : no_argument); - cvt->long_end->flag = 0; - /* we add a disambiguating code to all the user's - values (which is removed before we actually call - the function to parse the value); this means that - the user loses use of the high 8 bits in all his - values (the sign of the lower bits is preserved - however)... */ - cvt->long_end->val = - ((opt->key ? opt->key : real->key) & USER_MASK) - + (((group - cvt->parser->groups) + 1) << USER_BITS); - - /* Keep the LONG_OPTS list terminated. */ - (++cvt->long_end)->name = NULL; - } - } - } - - group->parser = argp->parser; - group->argp = argp; - group->short_end = cvt->short_end; - group->args_processed = 0; - group->parent = parent; - group->parent_index = parent_index; - group->input = 0; - group->hook = 0; - group->child_inputs = 0; - - if (children) - /* Assign GROUP's CHILD_INPUTS field some space from - CVT->child_inputs_end.*/ - { - unsigned num_children = 0; - while (children[num_children].argp) - num_children++; - group->child_inputs = cvt->child_inputs_end; - cvt->child_inputs_end += num_children; - } - - parent = group++; - } - else - parent = 0; - - if (children) - { - unsigned index = 0; - while (children->argp) - group = - convert_options (children++->argp, parent, index++, group, cvt); - } - - return group; -} - -/* Find the merged set of getopt options, with keys appropriately prefixed. */ -static void -parser_convert (struct parser *parser, const struct argp *argp, int flags) -{ - struct parser_convert_state cvt; - - cvt.parser = parser; - cvt.short_end = parser->short_opts; - cvt.long_end = parser->long_opts; - cvt.child_inputs_end = parser->child_inputs; - - if (flags & ARGP_IN_ORDER) - *cvt.short_end++ = '-'; - else if (flags & ARGP_NO_ARGS) - *cvt.short_end++ = '+'; - *cvt.short_end = '\0'; - - cvt.long_end->name = NULL; - - parser->argp = argp; - - if (argp) - parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt); - else - parser->egroup = parser->groups; /* No parsers at all! */ -} - -/* Lengths of various parser fields which we will allocated. */ -struct parser_sizes -{ - size_t short_len; /* Getopt short options string. */ - size_t long_len; /* Getopt long options vector. */ - size_t num_groups; /* Group structures we allocate. */ - size_t num_child_inputs; /* Child input slots. */ -}; - -/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of - argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by - the maximum lengths of the resulting merged getopt short options string and - long-options array, respectively. */ -static void -calc_sizes (const struct argp *argp, struct parser_sizes *szs) -{ - const struct argp_child *child = argp->children; - const struct argp_option *opt = argp->options; - - if (opt || argp->parser) - { - szs->num_groups++; - if (opt) - { - int num_opts = 0; - while (!__option_is_end (opt++)) - num_opts++; - szs->short_len += num_opts * 3; /* opt + up to 2 ':'s */ - szs->long_len += num_opts; - } - } - - if (child) - while (child->argp) - { - calc_sizes ((child++)->argp, szs); - szs->num_child_inputs++; - } -} - -/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */ -static error_t -parser_init (struct parser *parser, const struct argp *argp, - int argc, char **argv, int flags, void *input) -{ - error_t err = 0; - struct group *group; - struct parser_sizes szs; - struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER; - char *storage; - size_t glen, gsum; - size_t clen, csum; - size_t llen, lsum; - size_t slen, ssum; - - szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1; - szs.long_len = 0; - szs.num_groups = 0; - szs.num_child_inputs = 0; - - if (argp) - calc_sizes (argp, &szs); - - /* Lengths of the various bits of storage used by PARSER. */ - glen = (szs.num_groups + 1) * sizeof (struct group); - clen = szs.num_child_inputs * sizeof (void *); - llen = (szs.long_len + 1) * sizeof (struct option); - slen = szs.short_len + 1; - - /* Sums of previous lengths, properly aligned. There's no need to - align gsum, since struct group is aligned at least as strictly as - void * (since it contains a void * member). And there's no need - to align lsum, since struct option is aligned at least as - strictly as char. */ - gsum = glen; - csum = alignto (gsum + clen, alignof (struct option)); - lsum = csum + llen; - ssum = lsum + slen; - - parser->storage = malloc (ssum); - if (! parser->storage) - return ENOMEM; - - storage = parser->storage; - parser->groups = parser->storage; - parser->child_inputs = (void **) (storage + gsum); - parser->long_opts = (struct option *) (storage + csum); - parser->short_opts = storage + lsum; - parser->opt_data = opt_data; - - memset (parser->child_inputs, 0, clen); - parser_convert (parser, argp, flags); - - memset (&parser->state, 0, sizeof (struct argp_state)); - parser->state.root_argp = parser->argp; - parser->state.argc = argc; - parser->state.argv = argv; - parser->state.flags = flags; - parser->state.err_stream = stderr; - parser->state.out_stream = stdout; - parser->state.next = 0; /* Tell getopt to initialize. */ - parser->state.pstate = parser; - - parser->try_getopt = 1; - - /* Call each parser for the first time, giving it a chance to propagate - values to child parsers. */ - if (parser->groups < parser->egroup) - parser->groups->input = input; - for (group = parser->groups; - group < parser->egroup && (!err || err == EBADKEY); - group++) - { - if (group->parent) - /* If a child parser, get the initial input value from the parent. */ - group->input = group->parent->child_inputs[group->parent_index]; - - if (!group->parser - && group->argp->children && group->argp->children->argp) - /* For the special case where no parsing function is supplied for an - argp, propagate its input to its first child, if any (this just - makes very simple wrapper argps more convenient). */ - group->child_inputs[0] = group->input; - - err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0); - } - if (err == EBADKEY) - err = 0; /* Some parser didn't understand. */ - - if (err) - return err; - - if (parser->state.flags & ARGP_NO_ERRS) - { - parser->opt_data.opterr = 0; - if (parser->state.flags & ARGP_PARSE_ARGV0) - /* getopt always skips ARGV[0], so we have to fake it out. As long - as OPTERR is 0, then it shouldn't actually try to access it. */ - parser->state.argv--, parser->state.argc++; - } - else - parser->opt_data.opterr = 1; /* Print error messages. */ - - if (parser->state.argv == argv && argv[0]) - /* There's an argv[0]; use it for messages. */ - parser->state.name = __argp_base_name (argv[0]); - else - parser->state.name = __argp_short_program_name (); - - return 0; -} - -/* Free any storage consumed by PARSER (but not PARSER itself). */ -static error_t -parser_finalize (struct parser *parser, - error_t err, int arg_ebadkey, int *end_index) -{ - struct group *group; - - if (err == EBADKEY && arg_ebadkey) - /* Suppress errors generated by unparsed arguments. */ - err = 0; - - if (! err) - { - if (parser->state.next == parser->state.argc) - /* We successfully parsed all arguments! Call all the parsers again, - just a few more times... */ - { - for (group = parser->groups; - group < parser->egroup && (!err || err==EBADKEY); - group++) - if (group->args_processed == 0) - err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0); - for (group = parser->egroup - 1; - group >= parser->groups && (!err || err==EBADKEY); - group--) - err = group_parse (group, &parser->state, ARGP_KEY_END, 0); - - if (err == EBADKEY) - err = 0; /* Some parser didn't understand. */ - - /* Tell the user that all arguments are parsed. */ - if (end_index) - *end_index = parser->state.next; - } - else if (end_index) - /* Return any remaining arguments to the user. */ - *end_index = parser->state.next; - else - /* No way to return the remaining arguments, they must be bogus. */ - { - if (!(parser->state.flags & ARGP_NO_ERRS) - && parser->state.err_stream) - fprintf (parser->state.err_stream, - dgettext (parser->argp->argp_domain, - "%s: Too many arguments\n"), - parser->state.name); - err = EBADKEY; - } - } - - /* Okay, we're all done, with either an error or success; call the parsers - to indicate which one. */ - - if (err) - { - /* Maybe print an error message. */ - if (err == EBADKEY) - /* An appropriate message describing what the error was should have - been printed earlier. */ - __argp_state_help (&parser->state, parser->state.err_stream, - ARGP_HELP_STD_ERR); - - /* Since we didn't exit, give each parser an error indication. */ - for (group = parser->groups; group < parser->egroup; group++) - group_parse (group, &parser->state, ARGP_KEY_ERROR, 0); - } - else - /* Notify parsers of success, and propagate back values from parsers. */ - { - /* We pass over the groups in reverse order so that child groups are - given a chance to do there processing before passing back a value to - the parent. */ - for (group = parser->egroup - 1 - ; group >= parser->groups && (!err || err == EBADKEY) - ; group--) - err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0); - if (err == EBADKEY) - err = 0; /* Some parser didn't understand. */ - } - - /* Call parsers once more, to do any final cleanup. Errors are ignored. */ - for (group = parser->egroup - 1; group >= parser->groups; group--) - group_parse (group, &parser->state, ARGP_KEY_FINI, 0); - - if (err == EBADKEY) - err = EINVAL; - - free (parser->storage); - - return err; -} - -/* Call the user parsers to parse the non-option argument VAL, at the current - position, returning any error. The state NEXT pointer is assumed to have - been adjusted (by getopt) to point after this argument; this function will - adjust it correctly to reflect however many args actually end up being - consumed. */ -static error_t -parser_parse_arg (struct parser *parser, char *val) -{ - /* Save the starting value of NEXT, first adjusting it so that the arg - we're parsing is again the front of the arg vector. */ - int index = --parser->state.next; - error_t err = EBADKEY; - struct group *group; - int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */ - - /* Try to parse the argument in each parser. */ - for (group = parser->groups - ; group < parser->egroup && err == EBADKEY - ; group++) - { - parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */ - key = ARGP_KEY_ARG; - err = group_parse (group, &parser->state, key, val); - - if (err == EBADKEY) - /* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */ - { - parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */ - key = ARGP_KEY_ARGS; - err = group_parse (group, &parser->state, key, 0); - } - } - - if (! err) - { - if (key == ARGP_KEY_ARGS) - /* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't - changed by the user, *all* arguments should be considered - consumed. */ - parser->state.next = parser->state.argc; - - if (parser->state.next > index) - /* Remember that we successfully processed a non-option - argument -- but only if the user hasn't gotten tricky and set - the clock back. */ - (--group)->args_processed += (parser->state.next - index); - else - /* The user wants to reparse some args, give getopt another try. */ - parser->try_getopt = 1; - } - - return err; -} - -/* Call the user parsers to parse the option OPT, with argument VAL, at the - current position, returning any error. */ -static error_t -parser_parse_opt (struct parser *parser, int opt, char *val) -{ - /* The group key encoded in the high bits; 0 for short opts or - group_number + 1 for long opts. */ - int group_key = opt >> USER_BITS; - error_t err = EBADKEY; - - if (group_key == 0) - /* A short option. By comparing OPT's position in SHORT_OPTS to the - various starting positions in each group's SHORT_END field, we can - determine which group OPT came from. */ - { - struct group *group; - char *short_index = strchr (parser->short_opts, opt); - - if (short_index) - for (group = parser->groups; group < parser->egroup; group++) - if (group->short_end > short_index) - { - err = group_parse (group, &parser->state, opt, - parser->opt_data.optarg); - break; - } - } - else - /* A long option. We use shifts instead of masking for extracting - the user value in order to preserve the sign. */ - err = - group_parse (&parser->groups[group_key - 1], &parser->state, - (opt << GROUP_BITS) >> GROUP_BITS, - parser->opt_data.optarg); - - if (err == EBADKEY) - /* At least currently, an option not recognized is an error in the - parser, because we pre-compute which parser is supposed to deal - with each option. */ - { - static const char bad_key_err[] = - N_("(PROGRAM ERROR) Option should have been recognized!?"); - if (group_key == 0) - __argp_error (&parser->state, "-%c: %s", opt, - dgettext (parser->argp->argp_domain, bad_key_err)); - else - { - struct option *long_opt = parser->long_opts; - while (long_opt->val != opt && long_opt->name) - long_opt++; - __argp_error (&parser->state, "--%s: %s", - long_opt->name ? long_opt->name : "???", - dgettext (parser->argp->argp_domain, bad_key_err)); - } - } - - return err; -} - -/* Parse the next argument in PARSER (as indicated by PARSER->state.next). - Any error from the parsers is returned, and *ARGP_EBADKEY indicates - whether a value of EBADKEY is due to an unrecognized argument (which is - generally not fatal). */ -static error_t -parser_parse_next (struct parser *parser, int *arg_ebadkey) -{ - int opt; - error_t err = 0; - - if (parser->state.quoted && parser->state.next < parser->state.quoted) - /* The next argument pointer has been moved to before the quoted - region, so pretend we never saw the quoting "--", and give getopt - another chance. If the user hasn't removed it, getopt will just - process it again. */ - parser->state.quoted = 0; - - if (parser->try_getopt && !parser->state.quoted) - /* Give getopt a chance to parse this. */ - { - /* Put it back in OPTIND for getopt. */ - parser->opt_data.optind = parser->state.next; - /* Distinguish KEY_ERR from a real option. */ - parser->opt_data.optopt = KEY_END; - if (parser->state.flags & ARGP_LONG_ONLY) - opt = _getopt_long_only_r (parser->state.argc, parser->state.argv, - parser->short_opts, parser->long_opts, 0, - &parser->opt_data); - else - opt = _getopt_long_r (parser->state.argc, parser->state.argv, - parser->short_opts, parser->long_opts, 0, - &parser->opt_data); - /* And see what getopt did. */ - parser->state.next = parser->opt_data.optind; - - if (opt == KEY_END) - /* Getopt says there are no more options, so stop using - getopt; we'll continue if necessary on our own. */ - { - parser->try_getopt = 0; - if (parser->state.next > 1 - && strcmp (parser->state.argv[parser->state.next - 1], QUOTE) - == 0) - /* Not only is this the end of the options, but it's a - "quoted" region, which may have args that *look* like - options, so we definitely shouldn't try to use getopt past - here, whatever happens. */ - parser->state.quoted = parser->state.next; - } - else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END) - /* KEY_ERR can have the same value as a valid user short - option, but in the case of a real error, getopt sets OPTOPT - to the offending character, which can never be KEY_END. */ - { - *arg_ebadkey = 0; - return EBADKEY; - } - } - else - opt = KEY_END; - - if (opt == KEY_END) - { - /* We're past what getopt considers the options. */ - if (parser->state.next >= parser->state.argc - || (parser->state.flags & ARGP_NO_ARGS)) - /* Indicate that we're done. */ - { - *arg_ebadkey = 1; - return EBADKEY; - } - else - /* A non-option arg; simulate what getopt might have done. */ - { - opt = KEY_ARG; - parser->opt_data.optarg = parser->state.argv[parser->state.next++]; - } - } - - if (opt == KEY_ARG) - /* A non-option argument; try each parser in turn. */ - err = parser_parse_arg (parser, parser->opt_data.optarg); - else - err = parser_parse_opt (parser, opt, parser->opt_data.optarg); - - if (err == EBADKEY) - *arg_ebadkey = (opt == KEY_END || opt == KEY_ARG); - - return err; -} - -/* Parse the options strings in ARGC & ARGV according to the argp in ARGP. - FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the - index in ARGV of the first unparsed option is returned in it. If an - unknown option is present, EINVAL is returned; if some parser routine - returned a non-zero value, it is returned; otherwise 0 is returned. */ -error_t -__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, - int *end_index, void *input) -{ - error_t err; - struct parser parser; - - /* If true, then err == EBADKEY is a result of a non-option argument failing - to be parsed (which in some cases isn't actually an error). */ - int arg_ebadkey = 0; - -#ifndef _LIBC - if (!(flags & ARGP_PARSE_ARGV0)) - { -#if HAVE_DECL_PROGRAM_INVOCATION_NAME - if (!program_invocation_name) - program_invocation_name = argv[0]; -#endif -#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME - if (!program_invocation_short_name) - program_invocation_short_name = __argp_base_name (argv[0]); -#endif - } -#endif - - if (! (flags & ARGP_NO_HELP)) - /* Add our own options. */ - { - struct argp_child *child = alloca (4 * sizeof (struct argp_child)); - struct argp *top_argp = alloca (sizeof (struct argp)); - - /* TOP_ARGP has no options, it just serves to group the user & default - argps. */ - memset (top_argp, 0, sizeof (*top_argp)); - top_argp->children = child; - - memset (child, 0, 4 * sizeof (struct argp_child)); - - if (argp) - (child++)->argp = argp; - (child++)->argp = &argp_default_argp; - if (argp_program_version || argp_program_version_hook) - (child++)->argp = &argp_version_argp; - child->argp = 0; - - argp = top_argp; - } - - /* Construct a parser for these arguments. */ - err = parser_init (&parser, argp, argc, argv, flags, input); - - if (! err) - /* Parse! */ - { - while (! err) - err = parser_parse_next (&parser, &arg_ebadkey); - err = parser_finalize (&parser, err, arg_ebadkey, end_index); - } - - return err; -} -#ifdef weak_alias -weak_alias (__argp_parse, argp_parse) -#endif - -/* Return the input field for ARGP in the parser corresponding to STATE; used - by the help routines. */ -void * -__argp_input (const struct argp *argp, const struct argp_state *state) -{ - if (state && state->pstate) - { - struct group *group; - struct parser *parser = state->pstate; - - for (group = parser->groups; group < parser->egroup; group++) - if (group->argp == argp) - return group->input; - } - - return 0; -} -#ifdef weak_alias -weak_alias (__argp_input, _argp_input) -#endif diff --git a/grub-core/gnulib/argp-pin.c b/grub-core/gnulib/argp-pin.c deleted file mode 100644 index 78cbb355b..000000000 --- a/grub-core/gnulib/argp-pin.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Full and short program names for argp module - Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME -char *program_invocation_short_name = 0; -#endif -#ifndef HAVE_PROGRAM_INVOCATION_NAME -char *program_invocation_name = 0; -#endif diff --git a/grub-core/gnulib/argp-pv.c b/grub-core/gnulib/argp-pv.c deleted file mode 100644 index c74070d12..000000000 --- a/grub-core/gnulib/argp-pv.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Default definition for ARGP_PROGRAM_VERSION. - Copyright (C) 1996-1997, 1999, 2006, 2009-2013 Free Software Foundation, - Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* If set by the user program to a non-zero value, then a default option - --version is added (unless the ARGP_NO_HELP flag is used), which will - print this string followed by a newline and exit (unless the - ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ -const char *argp_program_version -/* This variable should be zero-initialized. On most systems, putting it into - BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see - - . */ -#if defined __ELF__ - /* On ELF systems, variables in BSS behave well. */ -#else - = (const char *) 0 -#endif - ; diff --git a/grub-core/gnulib/argp-pvh.c b/grub-core/gnulib/argp-pvh.c deleted file mode 100644 index 885ff4b75..000000000 --- a/grub-core/gnulib/argp-pvh.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Default definition for ARGP_PROGRAM_VERSION_HOOK. - Copyright (C) 1996-1997, 1999, 2004, 2009-2013 Free Software Foundation, - Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "argp.h" - -/* If set by the user program to a non-zero value, then a default option - --version is added (unless the ARGP_NO_HELP flag is used), which calls - this function with a stream to print the version to and a pointer to the - current parsing state, and then exits (unless the ARGP_NO_EXIT flag is - used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ -void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = NULL; diff --git a/grub-core/gnulib/argp-xinl.c b/grub-core/gnulib/argp-xinl.c deleted file mode 100644 index 04d8cf703..000000000 --- a/grub-core/gnulib/argp-xinl.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Real definitions for extern inline functions in argp.h - Copyright (C) 1997-1998, 2004, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if defined _LIBC || defined HAVE_FEATURES_H -# include -#endif - -#ifndef __USE_EXTERN_INLINES -# define __USE_EXTERN_INLINES 1 -#endif -#ifdef _LIBC -# define ARGP_EI -#else -# define ARGP_EI _GL_EXTERN_INLINE -#endif -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 -#include "argp.h" - -/* Add weak aliases. */ -#if _LIBC - 0 && defined (weak_alias) - -weak_alias (__argp_usage, argp_usage) -weak_alias (__option_is_short, _option_is_short) -weak_alias (__option_is_end, _option_is_end) - -#endif diff --git a/grub-core/gnulib/argp.h b/grub-core/gnulib/argp.h deleted file mode 100644 index c4094a40c..000000000 --- a/grub-core/gnulib/argp.h +++ /dev/null @@ -1,650 +0,0 @@ -/* Hierarchical argument parsing, layered over getopt. - Copyright (C) 1995-1999, 2003-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Miles Bader . - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _ARGP_H -#define _ARGP_H - -#include -#include -#include -#include - -#define __need_error_t -#include - -#ifndef __THROW -# define __THROW -#endif -#ifndef __NTH -# define __NTH(fct) fct __THROW -#endif - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -/* GCC 2.95 and later have "__restrict"; C99 compilers have - "restrict", and "configure" may have defined "restrict". - Other compilers use __restrict, __restrict__, and _Restrict, and - 'configure' might #define 'restrict' to those words. */ -#ifndef __restrict -# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) -# if 199901L <= __STDC_VERSION__ -# define __restrict restrict -# else -# define __restrict -# endif -# endif -#endif - -#ifndef __error_t_defined -typedef int error_t; -# define __error_t_defined -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* A description of a particular option. A pointer to an array of - these is passed in the OPTIONS field of an argp structure. Each option - entry can correspond to one long option and/or one short option; more - names for the same option can be added by following an entry in an option - array with options having the OPTION_ALIAS flag set. */ -struct argp_option -{ - /* The long option name. For more than one name for the same option, you - can use following options with the OPTION_ALIAS flag set. */ - const char *name; - - /* What key is returned for this option. If > 0 and printable, then it's - also accepted as a short option. */ - int key; - - /* If non-NULL, this is the name of the argument associated with this - option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */ - const char *arg; - - /* OPTION_ flags. */ - int flags; - - /* The doc string for this option. If both NAME and KEY are 0, This string - will be printed outdented from the normal option column, making it - useful as a group header (it will be the first thing printed in its - group); in this usage, it's conventional to end the string with a ':'. - - Write the initial value as N_("TEXT") if you want xgettext to collect - it into a POT file. */ - const char *doc; - - /* The group this option is in. In a long help message, options are sorted - alphabetically within each group, and the groups presented in the order - 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with - if this field 0 will inherit the group number of the previous entry, or - zero if it's the first one, unless its a group header (NAME and KEY both - 0), in which case, the previous entry + 1 is the default. Automagic - options such as --help are put into group -1. */ - int group; -}; - -/* The argument associated with this option is optional. */ -#define OPTION_ARG_OPTIONAL 0x1 - -/* This option isn't displayed in any help messages. */ -#define OPTION_HIDDEN 0x2 - -/* This option is an alias for the closest previous non-alias option. This - means that it will be displayed in the same help entry, and will inherit - fields other than NAME and KEY from the aliased option. */ -#define OPTION_ALIAS 0x4 - -/* This option isn't actually an option (and so should be ignored by the - actual option parser), but rather an arbitrary piece of documentation that - should be displayed in much the same manner as the options. If this flag - is set, then the option NAME field is displayed unmodified (e.g., no '--' - prefix is added) at the left-margin (where a *short* option would normally - be displayed), and the documentation string in the normal place. The NAME - field will be translated using gettext, unless OPTION_NO_TRANS is set (see - below). For purposes of sorting, any leading whitespace and punctuation is - ignored, except that if the first non-whitespace character is not '-', this - entry is displayed after all options (and OPTION_DOC entries with a leading - '-') in the same group. */ -#define OPTION_DOC 0x8 - -/* This option shouldn't be included in "long" usage messages (but is still - included in help messages). This is mainly intended for options that are - completely documented in an argp's ARGS_DOC field, in which case including - the option in the generic usage list would be redundant. For instance, - if ARGS_DOC is "FOO BAR\n-x BLAH", and the '-x' option's purpose is to - distinguish these two cases, -x should probably be marked - OPTION_NO_USAGE. */ -#define OPTION_NO_USAGE 0x10 - -/* Valid only in conjunction with OPTION_DOC. This option disables translation - of option name. */ -#define OPTION_NO_TRANS 0x20 - - -struct argp; /* fwd declare this type */ -struct argp_state; /* " */ -struct argp_child; /* " */ - -/* The type of a pointer to an argp parsing function. */ -typedef error_t (*argp_parser_t) (int key, char *arg, - struct argp_state *state); - -/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such - returns will simply be ignored. For user keys, this error will be turned - into EINVAL (if the call to argp_parse is such that errors are propagated - back to the user instead of exiting); returning EINVAL itself would result - in an immediate stop to parsing in *all* cases. */ -#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */ - -/* Special values for the KEY argument to an argument parsing function. - ARGP_ERR_UNKNOWN should be returned if they aren't understood. - - The sequence of keys to a parsing function is either (where each - uppercased word should be prefixed by 'ARGP_KEY_' and opt is a user key): - - INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all - or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed - or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized - - The third case is where every parser returned ARGP_KEY_UNKNOWN for an - argument, in which case parsing stops at that argument (returning the - unparsed arguments to the caller of argp_parse if requested, or stopping - with an error message if not). - - If an error occurs (either detected by argp, or because the parsing - function returned an error value), then the parser is called with - ARGP_KEY_ERROR, and no further calls are made. */ - -/* This is not an option at all, but rather a command line argument. If a - parser receiving this key returns success, the fact is recorded, and the - ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the - argument, a parser function decrements the NEXT field of the state it's - passed, the option won't be considered processed; this is to allow you to - actually modify the argument (perhaps into an option), and have it - processed again. */ -#define ARGP_KEY_ARG 0 -/* There are remaining arguments not parsed by any parser, which may be found - starting at (STATE->argv + STATE->next). If success is returned, but - STATE->next left untouched, it's assumed that all arguments were consume, - otherwise, the parser should adjust STATE->next to reflect any arguments - consumed. */ -#define ARGP_KEY_ARGS 0x1000006 -/* There are no more command line arguments at all. */ -#define ARGP_KEY_END 0x1000001 -/* Because it's common to want to do some special processing if there aren't - any non-option args, user parsers are called with this key if they didn't - successfully process any non-option arguments. Called just before - ARGP_KEY_END (where more general validity checks on previously parsed - arguments can take place). */ -#define ARGP_KEY_NO_ARGS 0x1000002 -/* Passed in before any parsing is done. Afterwards, the values of each - element of the CHILD_INPUT field, if any, in the state structure is - copied to each child's state to be the initial value of the INPUT field. */ -#define ARGP_KEY_INIT 0x1000003 -/* Use after all other keys, including SUCCESS & END. */ -#define ARGP_KEY_FINI 0x1000007 -/* Passed in when parsing has successfully been completed (even if there are - still arguments remaining). */ -#define ARGP_KEY_SUCCESS 0x1000004 -/* Passed in if an error occurs. */ -#define ARGP_KEY_ERROR 0x1000005 - -/* An argp structure contains a set of options declarations, a function to - deal with parsing one, documentation string, a possible vector of child - argp's, and perhaps a function to filter help output. When actually - parsing options, getopt is called with the union of all the argp - structures chained together through their CHILD pointers, with conflicts - being resolved in favor of the first occurrence in the chain. */ -struct argp -{ - /* An array of argp_option structures, terminated by an entry with both - NAME and KEY having a value of 0. */ - const struct argp_option *options; - - /* What to do with an option from this structure. KEY is the key - associated with the option, and ARG is any associated argument (NULL if - none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be - returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then - parsing is stopped immediately, and that value is returned from - argp_parse(). For special (non-user-supplied) values of KEY, see the - ARGP_KEY_ definitions below. */ - argp_parser_t parser; - - /* A string describing what other arguments are wanted by this program. It - is only used by argp_usage to print the "Usage:" message. If it - contains newlines, the strings separated by them are considered - alternative usage patterns, and printed on separate lines (lines after - the first are prefix by " or: " instead of "Usage:"). */ - const char *args_doc; - - /* If non-NULL, a string containing extra text to be printed before and - after the options in a long help message (separated by a vertical tab - '\v' character). - Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if - you want xgettext to collect the two pieces of text into a POT file. */ - const char *doc; - - /* A vector of argp_children structures, terminated by a member with a 0 - argp field, pointing to child argps should be parsed with this one. Any - conflicts are resolved in favor of this argp, or early argps in the - CHILDREN list. This field is useful if you use libraries that supply - their own argp structure, which you want to use in conjunction with your - own. */ - const struct argp_child *children; - - /* If non-zero, this should be a function to filter the output of help - messages. KEY is either a key from an option, in which case TEXT is - that option's help text, or a special key from the ARGP_KEY_HELP_ - defines, below, describing which other help text TEXT is. The function - should return either TEXT, if it should be used as-is, a replacement - string, which should be malloced, and will be freed by argp, or NULL, - meaning "print nothing". The value for TEXT is *after* any translation - has been done, so if any of the replacement text also needs translation, - that should be done by the filter function. INPUT is either the input - supplied to argp_parse, or NULL, if argp_help was called directly. */ - char *(*help_filter) (int __key, const char *__text, void *__input); - - /* If non-zero the strings used in the argp library are translated using - the domain described by this string. Otherwise the currently installed - default domain is used. */ - const char *argp_domain; -}; - -/* Possible KEY arguments to a help filter function. */ -#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceding options. */ -#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */ -#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */ -#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation; - TEXT is NULL for this key. */ -/* Explanatory note emitted when duplicate option arguments have been - suppressed. */ -#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005 -#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */ - -/* When an argp has a non-zero CHILDREN field, it should point to a vector of - argp_child structures, each of which describes a subsidiary argp. */ -struct argp_child -{ - /* The child parser. */ - const struct argp *argp; - - /* Flags for this child. */ - int flags; - - /* If non-zero, an optional header to be printed in help output before the - child options. As a side-effect, a non-zero value forces the child - options to be grouped together; to achieve this effect without actually - printing a header string, use a value of "". */ - const char *header; - - /* Where to group the child options relative to the other ("consolidated") - options in the parent argp; the values are the same as the GROUP field - in argp_option structs, but all child-groupings follow parent options at - a particular group level. If both this field and HEADER are zero, then - they aren't grouped at all, but rather merged with the parent options - (merging the child's grouping levels with the parents). */ - int group; -}; - -/* Parsing state. This is provided to parsing functions called by argp, - which may examine and, as noted, modify fields. */ -struct argp_state -{ - /* The top level ARGP being parsed. */ - const struct argp *root_argp; - - /* The argument vector being parsed. May be modified. */ - int argc; - char **argv; - - /* The index in ARGV of the next arg that to be parsed. May be modified. */ - int next; - - /* The flags supplied to argp_parse. May be modified. */ - unsigned flags; - - /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the - number of the current arg, starting at zero, and incremented after each - such call returns. At all other times, this is the number of such - arguments that have been processed. */ - unsigned arg_num; - - /* If non-zero, the index in ARGV of the first argument following a special - '--' argument (which prevents anything following being interpreted as an - option). Only set once argument parsing has proceeded past this point. */ - int quoted; - - /* An arbitrary pointer passed in from the user. */ - void *input; - /* Values to pass to child parsers. This vector will be the same length as - the number of children for the current parser. */ - void **child_inputs; - - /* For the parser's use. Initialized to 0. */ - void *hook; - - /* The name used when printing messages. This is initialized to ARGV[0], - or PROGRAM_INVOCATION_NAME if that is unavailable. */ - char *name; - - /* Streams used when argp prints something. */ - FILE *err_stream; /* For errors; initialized to stderr. */ - FILE *out_stream; /* For information; initialized to stdout. */ - - void *pstate; /* Private, for use by argp. */ -}; - -/* Flags for argp_parse (note that the defaults are those that are - convenient for program command line parsing): */ - -/* Don't ignore the first element of ARGV. Normally (and always unless - ARGP_NO_ERRS is set) the first element of the argument vector is - skipped for option parsing purposes, as it corresponds to the program name - in a command line. */ -#define ARGP_PARSE_ARGV0 0x01 - -/* Don't print error messages for unknown options to stderr; unless this flag - is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program - name in the error messages. This flag implies ARGP_NO_EXIT (on the - assumption that silent exiting upon errors is bad behaviour). */ -#define ARGP_NO_ERRS 0x02 - -/* Don't parse any non-option args. Normally non-option args are parsed by - calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg - as the value. Since it's impossible to know which parse function wants to - handle it, each one is called in turn, until one returns 0 or an error - other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the - argp_parse returns prematurely (but with a return value of 0). If all - args have been parsed without error, all parsing functions are called one - last time with a key of ARGP_KEY_END. This flag needn't normally be set, - as the normal behavior is to stop parsing as soon as some argument can't - be handled. */ -#define ARGP_NO_ARGS 0x04 - -/* Parse options and arguments in the same order they occur on the command - line -- normally they're rearranged so that all options come first. */ -#define ARGP_IN_ORDER 0x08 - -/* Don't provide the standard long option --help, which causes usage and - option help information to be output to stdout, and exit (0) called. */ -#define ARGP_NO_HELP 0x10 - -/* Don't exit on errors (they may still result in error messages). */ -#define ARGP_NO_EXIT 0x20 - -/* Use the gnu getopt "long-only" rules for parsing arguments. */ -#define ARGP_LONG_ONLY 0x40 - -/* Turns off any message-printing/exiting options. */ -#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP) - -/* Parse the options strings in ARGC & ARGV according to the options in ARGP. - FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the - index in ARGV of the first unparsed option is returned in it. If an - unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser - routine returned a non-zero value, it is returned; otherwise 0 is - returned. This function may also call exit unless the ARGP_NO_HELP flag - is set. INPUT is a pointer to a value to be passed in to the parser. */ -extern error_t argp_parse (const struct argp *__restrict __argp, - int /*argc*/, char **__restrict /*argv*/, - unsigned __flags, int *__restrict __arg_index, - void *__restrict __input); -extern error_t __argp_parse (const struct argp *__restrict __argp, - int /*argc*/, char **__restrict /*argv*/, - unsigned __flags, int *__restrict __arg_index, - void *__restrict __input); - -/* Global variables. */ - -/* GNULIB makes sure both program_invocation_name and - program_invocation_short_name are available */ -#ifdef GNULIB_PROGRAM_INVOCATION_NAME -extern char *program_invocation_name; -# undef HAVE_DECL_PROGRAM_INVOCATION_NAME -# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1 -#endif - -#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME -extern char *program_invocation_short_name; -# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME -# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1 -#endif - -/* If defined or set by the user program to a non-zero value, then a default - option --version is added (unless the ARGP_NO_HELP flag is used), which - will print this string followed by a newline and exit (unless the - ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ -extern const char *argp_program_version; - -/* If defined or set by the user program to a non-zero value, then a default - option --version is added (unless the ARGP_NO_HELP flag is used), which - calls this function with a stream to print the version to and a pointer to - the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is - used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ -extern void (*argp_program_version_hook) (FILE *__restrict __stream, - struct argp_state *__restrict - __state); - -/* If defined or set by the user program, it should point to string that is - the bug-reporting address for the program. It will be printed by - argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various - standard help messages), embedded in a sentence that says something like - "Report bugs to ADDR." */ -extern const char *argp_program_bug_address; - -/* The exit status that argp will use when exiting due to a parsing error. - If not defined or set by the user program, this defaults to EX_USAGE from - . */ -extern error_t argp_err_exit_status; - -/* Flags for argp_help. */ -#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */ -#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */ -#define ARGP_HELP_SEE 0x04 /* a "Try ... for more help" message. */ -#define ARGP_HELP_LONG 0x08 /* a long help message. */ -#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */ -#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */ -#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC) -#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */ -#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to - reflect ARGP_LONG_ONLY mode. */ - -/* These ARGP_HELP flags are only understood by argp_state_help. */ -#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */ -#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */ - -/* The standard thing to do after a program command line parsing error, if an - error message has already been printed. */ -#define ARGP_HELP_STD_ERR \ - (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR) -/* The standard thing to do after a program command line parsing error, if no - more specific error message has been printed. */ -#define ARGP_HELP_STD_USAGE \ - (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR) -/* The standard thing to do in response to a --help option. */ -#define ARGP_HELP_STD_HELP \ - (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \ - | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR) - -/* Output a usage message for ARGP to STREAM. FLAGS are from the set - ARGP_HELP_*. */ -extern void argp_help (const struct argp *__restrict __argp, - FILE *__restrict __stream, - unsigned __flags, char *__restrict __name); -extern void __argp_help (const struct argp *__restrict __argp, - FILE *__restrict __stream, unsigned __flags, - char *__name); - -/* The following routines are intended to be called from within an argp - parsing routine (thus taking an argp_state structure as the first - argument). They may or may not print an error message and exit, depending - on the flags in STATE -- in any case, the caller should be prepared for - them *not* to exit, and should return an appropriate error after calling - them. [argp_usage & argp_error should probably be called argp_state_..., - but they're used often enough that they should be short] */ - -/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are - from the set ARGP_HELP_*. */ -extern void argp_state_help (const struct argp_state *__restrict __state, - FILE *__restrict __stream, - unsigned int __flags); -extern void __argp_state_help (const struct argp_state *__restrict __state, - FILE *__restrict __stream, - unsigned int __flags); - -#if _LIBC -/* Possibly output the standard usage message for ARGP to stderr and exit. */ -extern void argp_usage (const struct argp_state *__state); -extern void __argp_usage (const struct argp_state *__state); -#endif - -/* If appropriate, print the printf string FMT and following args, preceded - by the program name and ':', to stderr, and followed by a "Try ... --help" - message, then exit (1). */ -extern void argp_error (const struct argp_state *__restrict __state, - const char *__restrict __fmt, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)); -extern void __argp_error (const struct argp_state *__restrict __state, - const char *__restrict __fmt, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)); - -/* Similar to the standard gnu error-reporting function error(), but will - respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print - to STATE->err_stream. This is useful for argument parsing code that is - shared between program startup (when exiting is desired) and runtime - option parsing (when typically an error code is returned instead). The - difference between this function and argp_error is that the latter is for - *parsing errors*, and the former is for other problems that occur during - parsing but don't reflect a (syntactic) problem with the input. */ -extern void argp_failure (const struct argp_state *__restrict __state, - int __status, int __errnum, - const char *__restrict __fmt, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5)); -extern void __argp_failure (const struct argp_state *__restrict __state, - int __status, int __errnum, - const char *__restrict __fmt, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5)); - -#if _LIBC -/* Returns true if the option OPT is a valid short option. */ -extern int _option_is_short (const struct argp_option *__opt) __THROW; -extern int __option_is_short (const struct argp_option *__opt) __THROW; - -/* Returns true if the option OPT is in fact the last (unused) entry in an - options array. */ -extern int _option_is_end (const struct argp_option *__opt) __THROW; -extern int __option_is_end (const struct argp_option *__opt) __THROW; -#endif - -/* Return the input field for ARGP in the parser corresponding to STATE; used - by the help routines. */ -extern void *_argp_input (const struct argp *__restrict __argp, - const struct argp_state *__restrict __state) - __THROW; -extern void *__argp_input (const struct argp *__restrict __argp, - const struct argp_state *__restrict __state) - __THROW; - -#if !_LIBC || defined __USE_EXTERN_INLINES - -# if !_LIBC -# define __argp_usage argp_usage -# define __argp_state_help argp_state_help -# define __option_is_short _option_is_short -# define __option_is_end _option_is_end -_GL_INLINE_HEADER_BEGIN -# ifndef ARGP_EI -# define ARGP_EI _GL_INLINE -# endif -# endif - -# ifndef ARGP_EI -# ifdef __GNUC__ - /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 - inline semantics, unless -fgnu89-inline is used. It defines a macro - __GNUC_STDC_INLINE__ to indicate this situation or a macro - __GNUC_GNU_INLINE__ to indicate the opposite situation. - GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline - semantics but warns, unless -fgnu89-inline is used: - warning: C99 inline functions are not supported; using GNU89 - warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute - It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. */ -# if defined __GNUC_STDC_INLINE__ -# define ARGP_EI __inline__ -# elif defined __GNUC_GNU_INLINE__ -# define ARGP_EI extern __inline__ __attribute__ ((__gnu_inline__)) -# else -# define ARGP_EI extern __inline__ -# endif -# else - /* With other compilers, assume the ISO C99 meaning of 'inline', if - the compiler supports 'inline' at all. */ -# define ARGP_EI inline -# endif -# endif - -ARGP_EI void -__argp_usage (const struct argp_state *__state) -{ - __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); -} - -ARGP_EI int -__NTH (__option_is_short (const struct argp_option *__opt)) -{ - if (__opt->flags & OPTION_DOC) - return 0; - else - { - int __key = __opt->key; - return __key > 0 && __key <= UCHAR_MAX && isprint (__key); - } -} - -ARGP_EI int -__NTH (__option_is_end (const struct argp_option *__opt)) -{ - return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; -} - -# if !_LIBC -# undef __argp_usage -# undef __argp_state_help -# undef __option_is_short -# undef __option_is_end -_GL_INLINE_HEADER_END -# endif -#endif /* Use extern inlines. */ - -#ifdef __cplusplus -} -#endif - -#endif /* argp.h */ diff --git a/grub-core/gnulib/asnprintf.c b/grub-core/gnulib/asnprintf.c deleted file mode 100644 index 76e228d86..000000000 --- a/grub-core/gnulib/asnprintf.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#include - -/* Specification. */ -#include "vasnprintf.h" - -#include - -char * -asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) -{ - va_list args; - char *result; - - va_start (args, format); - result = vasnprintf (resultbuf, lengthp, format, args); - va_end (args); - return result; -} diff --git a/grub-core/gnulib/basename-lgpl.c b/grub-core/gnulib/basename-lgpl.c deleted file mode 100644 index 9307e8314..000000000 --- a/grub-core/gnulib/basename-lgpl.c +++ /dev/null @@ -1,75 +0,0 @@ -/* basename.c -- return the last element in a file name - - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software - Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include "dirname.h" - -#include - -/* Return the address of the last file name component of NAME. If - NAME has no relative file name components because it is a file - system root, return the empty string. */ - -char * -last_component (char const *name) -{ - char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); - char const *p; - bool saw_slash = false; - - while (ISSLASH (*base)) - base++; - - for (p = base; *p; p++) - { - if (ISSLASH (*p)) - saw_slash = true; - else if (saw_slash) - { - base = p; - saw_slash = false; - } - } - - return (char *) base; -} - -/* Return the length of the basename NAME. Typically NAME is the - value returned by base_name or last_component. Act like strlen - (NAME), except omit all trailing slashes. */ - -size_t -base_len (char const *name) -{ - size_t len; - size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); - - for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) - continue; - - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1 - && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2]) - return 2; - - if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len - && len == prefix_len && ISSLASH (name[prefix_len])) - return prefix_len + 1; - - return len; -} diff --git a/grub-core/gnulib/btowc.c b/grub-core/gnulib/btowc.c deleted file mode 100644 index 6c7cbec9d..000000000 --- a/grub-core/gnulib/btowc.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Convert unibyte character to wide character. - Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - -wint_t -btowc (int c) -{ - if (c != EOF) - { - char buf[1]; - wchar_t wc; - - buf[0] = c; - if (mbtowc (&wc, buf, 1) >= 0) - return wc; - } - return WEOF; -} diff --git a/grub-core/gnulib/config.charset b/grub-core/gnulib/config.charset deleted file mode 100644 index a991419cd..000000000 --- a/grub-core/gnulib/config.charset +++ /dev/null @@ -1,684 +0,0 @@ -#! /bin/sh -# Output a system dependent table of character encoding aliases. -# -# Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc. -# -# This program 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, 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, see . -# -# The table consists of lines of the form -# ALIAS CANONICAL -# -# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)". -# ALIAS is compared in a case sensitive way. -# -# CANONICAL is the GNU canonical name for this character encoding. -# It must be an encoding supported by libiconv. Support by GNU libc is -# also desirable. CANONICAL is case insensitive. Usually an upper case -# MIME charset name is preferred. -# The current list of GNU canonical charset names is as follows. -# -# name MIME? used by which systems -# (darwin = Mac OS X, woe32 = native Windows) -# -# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin -# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin -# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin -# ISO-8859-3 Y glibc solaris cygwin -# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin -# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin -# ISO-8859-6 Y glibc aix hpux solaris cygwin -# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin -# ISO-8859-8 Y glibc aix hpux osf solaris cygwin -# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin -# ISO-8859-13 glibc netbsd openbsd darwin cygwin -# ISO-8859-14 glibc cygwin -# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin -# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin -# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin -# KOI8-T glibc -# CP437 dos -# CP775 dos -# CP850 aix osf dos -# CP852 dos -# CP855 dos -# CP856 aix -# CP857 dos -# CP861 dos -# CP862 dos -# CP864 dos -# CP865 dos -# CP866 freebsd netbsd openbsd darwin dos -# CP869 dos -# CP874 woe32 dos -# CP922 aix -# CP932 aix cygwin woe32 dos -# CP943 aix -# CP949 osf darwin woe32 dos -# CP950 woe32 dos -# CP1046 aix -# CP1124 aix -# CP1125 dos -# CP1129 aix -# CP1131 darwin -# CP1250 woe32 -# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32 -# CP1252 aix woe32 -# CP1253 woe32 -# CP1254 woe32 -# CP1255 glibc woe32 -# CP1256 woe32 -# CP1257 woe32 -# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin -# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin -# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin -# EUC-TW glibc aix hpux irix osf solaris netbsd -# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin -# BIG5-HKSCS glibc solaris darwin -# GBK glibc aix osf solaris darwin cygwin woe32 dos -# GB18030 glibc solaris netbsd darwin -# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin -# JOHAB glibc solaris woe32 -# TIS-620 glibc aix hpux osf solaris cygwin -# VISCII Y glibc -# TCVN5712-1 glibc -# ARMSCII-8 glibc darwin -# GEORGIAN-PS glibc cygwin -# PT154 glibc -# HP-ROMAN8 hpux -# HP-ARABIC8 hpux -# HP-GREEK8 hpux -# HP-HEBREW8 hpux -# HP-TURKISH8 hpux -# HP-KANA8 hpux -# DEC-KANJI osf -# DEC-HANYU osf -# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin -# -# Note: Names which are not marked as being a MIME name should not be used in -# Internet protocols for information interchange (mail, news, etc.). -# -# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications -# must understand both names and treat them as equivalent. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM - -host="$1" -os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'` -echo "# This file contains a table of character encoding aliases," -echo "# suitable for operating system '${os}'." -echo "# It was automatically generated from config.charset." -# List of references, updated during installation: -echo "# Packages using this file: " -case "$os" in - linux-gnulibc1*) - # Linux libc5 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "C ASCII" - echo "POSIX ASCII" - for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ - en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ - en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ - es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ - et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ - fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ - it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ - sv_FI sv_SE; do - echo "$l ISO-8859-1" - echo "$l.iso-8859-1 ISO-8859-1" - echo "$l.iso-8859-15 ISO-8859-15" - echo "$l.iso-8859-15@euro ISO-8859-15" - echo "$l@euro ISO-8859-15" - echo "$l.cp-437 CP437" - echo "$l.cp-850 CP850" - echo "$l.cp-1252 CP1252" - echo "$l.cp-1252@euro CP1252" - #echo "$l.atari-st ATARI-ST" # not a commonly used encoding - echo "$l.utf-8 UTF-8" - echo "$l.utf-8@euro UTF-8" - done - for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ - sl_SI sr sr_CS sr_YU; do - echo "$l ISO-8859-2" - echo "$l.iso-8859-2 ISO-8859-2" - echo "$l.cp-852 CP852" - echo "$l.cp-1250 CP1250" - echo "$l.utf-8 UTF-8" - done - for l in mk mk_MK ru ru_RU; do - echo "$l ISO-8859-5" - echo "$l.iso-8859-5 ISO-8859-5" - echo "$l.koi8-r KOI8-R" - echo "$l.cp-866 CP866" - echo "$l.cp-1251 CP1251" - echo "$l.utf-8 UTF-8" - done - for l in ar ar_SA; do - echo "$l ISO-8859-6" - echo "$l.iso-8859-6 ISO-8859-6" - echo "$l.cp-864 CP864" - #echo "$l.cp-868 CP868" # not a commonly used encoding - echo "$l.cp-1256 CP1256" - echo "$l.utf-8 UTF-8" - done - for l in el el_GR gr gr_GR; do - echo "$l ISO-8859-7" - echo "$l.iso-8859-7 ISO-8859-7" - echo "$l.cp-869 CP869" - echo "$l.cp-1253 CP1253" - echo "$l.cp-1253@euro CP1253" - echo "$l.utf-8 UTF-8" - echo "$l.utf-8@euro UTF-8" - done - for l in he he_IL iw iw_IL; do - echo "$l ISO-8859-8" - echo "$l.iso-8859-8 ISO-8859-8" - echo "$l.cp-862 CP862" - echo "$l.cp-1255 CP1255" - echo "$l.utf-8 UTF-8" - done - for l in tr tr_TR; do - echo "$l ISO-8859-9" - echo "$l.iso-8859-9 ISO-8859-9" - echo "$l.cp-857 CP857" - echo "$l.cp-1254 CP1254" - echo "$l.utf-8 UTF-8" - done - for l in lt lt_LT lv lv_LV; do - #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name - echo "$l ISO-8859-13" - done - for l in ru_UA uk uk_UA; do - echo "$l KOI8-U" - done - for l in zh zh_CN; do - #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name - echo "$l GB2312" - done - for l in ja ja_JP ja_JP.EUC; do - echo "$l EUC-JP" - done - for l in ko ko_KR; do - echo "$l EUC-KR" - done - for l in th th_TH; do - echo "$l TIS-620" - done - for l in fa fa_IR; do - #echo "$l ISIRI-3342" # a broken encoding - echo "$l.utf-8 UTF-8" - done - ;; - linux* | *-gnu*) - # With glibc-2.1 or newer, we don't need any canonicalization, - # because glibc has iconv and both glibc and libiconv support all - # GNU canonical names directly. Therefore, the Makefile does not - # need to install the alias file at all. - # The following applies only to glibc-2.0.x and older libcs. - echo "ISO_646.IRV:1983 ASCII" - ;; - aix*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-6 ISO-8859-6" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "IBM-850 CP850" - echo "IBM-856 CP856" - echo "IBM-921 ISO-8859-13" - echo "IBM-922 CP922" - echo "IBM-932 CP932" - echo "IBM-943 CP943" - echo "IBM-1046 CP1046" - echo "IBM-1124 CP1124" - echo "IBM-1129 CP1129" - echo "IBM-1252 CP1252" - echo "IBM-eucCN GB2312" - echo "IBM-eucJP EUC-JP" - echo "IBM-eucKR EUC-KR" - echo "IBM-eucTW EUC-TW" - echo "big5 BIG5" - echo "GBK GBK" - echo "TIS-620 TIS-620" - echo "UTF-8 UTF-8" - ;; - hpux*) - echo "iso88591 ISO-8859-1" - echo "iso88592 ISO-8859-2" - echo "iso88595 ISO-8859-5" - echo "iso88596 ISO-8859-6" - echo "iso88597 ISO-8859-7" - echo "iso88598 ISO-8859-8" - echo "iso88599 ISO-8859-9" - echo "iso885915 ISO-8859-15" - echo "roman8 HP-ROMAN8" - echo "arabic8 HP-ARABIC8" - echo "greek8 HP-GREEK8" - echo "hebrew8 HP-HEBREW8" - echo "turkish8 HP-TURKISH8" - echo "kana8 HP-KANA8" - echo "tis620 TIS-620" - echo "big5 BIG5" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "hp15CN GB2312" - #echo "ccdc ?" # what is this? - echo "SJIS SHIFT_JIS" - echo "utf8 UTF-8" - ;; - irix*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-9 ISO-8859-9" - echo "eucCN GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - ;; - osf*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "cp850 CP850" - echo "big5 BIG5" - echo "dechanyu DEC-HANYU" - echo "dechanzi GB2312" - echo "deckanji DEC-KANJI" - echo "deckorean EUC-KR" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "GBK GBK" - echo "KSC5601 CP949" - echo "sdeckanji EUC-JP" - echo "SJIS SHIFT_JIS" - echo "TACTIS TIS-620" - echo "UTF-8 UTF-8" - ;; - solaris*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-3 ISO-8859-3" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-6 ISO-8859-6" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "koi8-r KOI8-R" - echo "ansi-1251 CP1251" - echo "BIG5 BIG5" - echo "Big5-HKSCS BIG5-HKSCS" - echo "gb2312 GB2312" - echo "GBK GBK" - echo "GB18030 GB18030" - echo "cns11643 EUC-TW" - echo "5601 EUC-KR" - echo "ko_KR.johap92 JOHAB" - echo "eucJP EUC-JP" - echo "PCK SHIFT_JIS" - echo "TIS620.2533 TIS-620" - #echo "sun_eu_greek ?" # what is this? - echo "UTF-8 UTF-8" - ;; - freebsd* | os2*) - # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just - # reuse FreeBSD's locale data for OS/2. - echo "C ASCII" - echo "US-ASCII ASCII" - for l in la_LN lt_LN; do - echo "$l.ASCII ASCII" - done - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ - lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do - echo "$l.ISO_8859-1 ISO-8859-1" - echo "$l.DIS_8859-15 ISO-8859-15" - done - for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do - echo "$l.ISO_8859-2 ISO-8859-2" - done - for l in la_LN lt_LT; do - echo "$l.ISO_8859-4 ISO-8859-4" - done - for l in ru_RU ru_SU; do - echo "$l.KOI8-R KOI8-R" - echo "$l.ISO_8859-5 ISO-8859-5" - echo "$l.CP866 CP866" - done - echo "uk_UA.KOI8-U KOI8-U" - echo "zh_TW.BIG5 BIG5" - echo "zh_TW.Big5 BIG5" - echo "zh_CN.EUC GB2312" - echo "ja_JP.EUC EUC-JP" - echo "ja_JP.SJIS SHIFT_JIS" - echo "ja_JP.Shift_JIS SHIFT_JIS" - echo "ko_KR.EUC EUC-KR" - ;; - netbsd*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - echo "eucCN GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "BIG5 BIG5" - echo "SJIS SHIFT_JIS" - ;; - openbsd*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - ;; - darwin[56]*) - # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "C ASCII" - for l in en_AU en_CA en_GB en_US la_LN; do - echo "$l.US-ASCII ASCII" - done - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ - nl_NL no_NO pt_PT sv_SE; do - echo "$l ISO-8859-1" - echo "$l.ISO8859-1 ISO-8859-1" - echo "$l.ISO8859-15 ISO-8859-15" - done - for l in la_LN; do - echo "$l.ISO8859-1 ISO-8859-1" - echo "$l.ISO8859-15 ISO-8859-15" - done - for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do - echo "$l.ISO8859-2 ISO-8859-2" - done - for l in la_LN lt_LT; do - echo "$l.ISO8859-4 ISO-8859-4" - done - for l in ru_RU; do - echo "$l.KOI8-R KOI8-R" - echo "$l.ISO8859-5 ISO-8859-5" - echo "$l.CP866 CP866" - done - for l in bg_BG; do - echo "$l.CP1251 CP1251" - done - echo "uk_UA.KOI8-U KOI8-U" - echo "zh_TW.BIG5 BIG5" - echo "zh_TW.Big5 BIG5" - echo "zh_CN.EUC GB2312" - echo "ja_JP.EUC EUC-JP" - echo "ja_JP.SJIS SHIFT_JIS" - echo "ko_KR.EUC EUC-KR" - ;; - darwin*) - # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is - # useless: - # - It returns the empty string when LANG is set to a locale of the - # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 - # LC_CTYPE file. - # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by - # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. - # - The documentation says: - # "... all code that calls BSD system routines should ensure - # that the const *char parameters of these routines are in UTF-8 - # encoding. All BSD system functions expect their string - # parameters to be in UTF-8 encoding and nothing else." - # It also says - # "An additional caveat is that string parameters for files, - # paths, and other file-system entities must be in canonical - # UTF-8. In a canonical UTF-8 Unicode string, all decomposable - # characters are decomposed ..." - # but this is not true: You can pass non-decomposed UTF-8 strings - # to file system functions, and it is the OS which will convert - # them to decomposed UTF-8 before accessing the file system. - # - The Apple Terminal application displays UTF-8 by default. - # - However, other applications are free to use different encodings: - # - xterm uses ISO-8859-1 by default. - # - TextEdit uses MacRoman by default. - # We prefer UTF-8 over decomposed UTF-8-MAC because one should - # minimize the use of decomposed Unicode. Unfortunately, through the - # Darwin file system, decomposed UTF-8 strings are leaked into user - # space nevertheless. - # Then there are also the locales with encodings other than US-ASCII - # and UTF-8. These locales can be occasionally useful to users (e.g. - # when grepping through ISO-8859-1 encoded text files), when all their - # file names are in US-ASCII. - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - echo "KOI8-R KOI8-R" - echo "KOI8-U KOI8-U" - echo "CP866 CP866" - echo "CP949 CP949" - echo "CP1131 CP1131" - echo "CP1251 CP1251" - echo "eucCN GB2312" - echo "GB2312 GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "Big5 BIG5" - echo "Big5HKSCS BIG5-HKSCS" - echo "GBK GBK" - echo "GB18030 GB18030" - echo "SJIS SHIFT_JIS" - echo "ARMSCII-8 ARMSCII-8" - echo "PT154 PT154" - #echo "ISCII-DEV ?" - echo "* UTF-8" - ;; - beos* | haiku*) - # BeOS and Haiku have a single locale, and it has UTF-8 encoding. - echo "* UTF-8" - ;; - msdosdjgpp*) - # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "#" - echo "# The encodings given here may not all be correct." - echo "# If you find that the encoding given for your language and" - echo "# country is not the one your DOS machine actually uses, just" - echo "# correct it in this file, and send a mail to" - echo "# Juan Manuel Guerrero " - echo "# and Bruno Haible ." - echo "#" - echo "C ASCII" - # ISO-8859-1 languages - echo "ca CP850" - echo "ca_ES CP850" - echo "da CP865" # not CP850 ?? - echo "da_DK CP865" # not CP850 ?? - echo "de CP850" - echo "de_AT CP850" - echo "de_CH CP850" - echo "de_DE CP850" - echo "en CP850" - echo "en_AU CP850" # not CP437 ?? - echo "en_CA CP850" - echo "en_GB CP850" - echo "en_NZ CP437" - echo "en_US CP437" - echo "en_ZA CP850" # not CP437 ?? - echo "es CP850" - echo "es_AR CP850" - echo "es_BO CP850" - echo "es_CL CP850" - echo "es_CO CP850" - echo "es_CR CP850" - echo "es_CU CP850" - echo "es_DO CP850" - echo "es_EC CP850" - echo "es_ES CP850" - echo "es_GT CP850" - echo "es_HN CP850" - echo "es_MX CP850" - echo "es_NI CP850" - echo "es_PA CP850" - echo "es_PY CP850" - echo "es_PE CP850" - echo "es_SV CP850" - echo "es_UY CP850" - echo "es_VE CP850" - echo "et CP850" - echo "et_EE CP850" - echo "eu CP850" - echo "eu_ES CP850" - echo "fi CP850" - echo "fi_FI CP850" - echo "fr CP850" - echo "fr_BE CP850" - echo "fr_CA CP850" - echo "fr_CH CP850" - echo "fr_FR CP850" - echo "ga CP850" - echo "ga_IE CP850" - echo "gd CP850" - echo "gd_GB CP850" - echo "gl CP850" - echo "gl_ES CP850" - echo "id CP850" # not CP437 ?? - echo "id_ID CP850" # not CP437 ?? - echo "is CP861" # not CP850 ?? - echo "is_IS CP861" # not CP850 ?? - echo "it CP850" - echo "it_CH CP850" - echo "it_IT CP850" - echo "lt CP775" - echo "lt_LT CP775" - echo "lv CP775" - echo "lv_LV CP775" - echo "nb CP865" # not CP850 ?? - echo "nb_NO CP865" # not CP850 ?? - echo "nl CP850" - echo "nl_BE CP850" - echo "nl_NL CP850" - echo "nn CP865" # not CP850 ?? - echo "nn_NO CP865" # not CP850 ?? - echo "no CP865" # not CP850 ?? - echo "no_NO CP865" # not CP850 ?? - echo "pt CP850" - echo "pt_BR CP850" - echo "pt_PT CP850" - echo "sv CP850" - echo "sv_SE CP850" - # ISO-8859-2 languages - echo "cs CP852" - echo "cs_CZ CP852" - echo "hr CP852" - echo "hr_HR CP852" - echo "hu CP852" - echo "hu_HU CP852" - echo "pl CP852" - echo "pl_PL CP852" - echo "ro CP852" - echo "ro_RO CP852" - echo "sk CP852" - echo "sk_SK CP852" - echo "sl CP852" - echo "sl_SI CP852" - echo "sq CP852" - echo "sq_AL CP852" - echo "sr CP852" # CP852 or CP866 or CP855 ?? - echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? - echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? - # ISO-8859-3 languages - echo "mt CP850" - echo "mt_MT CP850" - # ISO-8859-5 languages - echo "be CP866" - echo "be_BE CP866" - echo "bg CP866" # not CP855 ?? - echo "bg_BG CP866" # not CP855 ?? - echo "mk CP866" # not CP855 ?? - echo "mk_MK CP866" # not CP855 ?? - echo "ru CP866" - echo "ru_RU CP866" - echo "uk CP1125" - echo "uk_UA CP1125" - # ISO-8859-6 languages - echo "ar CP864" - echo "ar_AE CP864" - echo "ar_DZ CP864" - echo "ar_EG CP864" - echo "ar_IQ CP864" - echo "ar_IR CP864" - echo "ar_JO CP864" - echo "ar_KW CP864" - echo "ar_MA CP864" - echo "ar_OM CP864" - echo "ar_QA CP864" - echo "ar_SA CP864" - echo "ar_SY CP864" - # ISO-8859-7 languages - echo "el CP869" - echo "el_GR CP869" - # ISO-8859-8 languages - echo "he CP862" - echo "he_IL CP862" - # ISO-8859-9 languages - echo "tr CP857" - echo "tr_TR CP857" - # Japanese - echo "ja CP932" - echo "ja_JP CP932" - # Chinese - echo "zh_CN GBK" - echo "zh_TW CP950" # not CP938 ?? - # Korean - echo "kr CP949" # not CP934 ?? - echo "kr_KR CP949" # not CP934 ?? - # Thai - echo "th CP874" - echo "th_TH CP874" - # Other - echo "eo CP850" - echo "eo_EO CP850" - ;; -esac diff --git a/grub-core/gnulib/dirname-lgpl.c b/grub-core/gnulib/dirname-lgpl.c deleted file mode 100644 index 82f66301f..000000000 --- a/grub-core/gnulib/dirname-lgpl.c +++ /dev/null @@ -1,86 +0,0 @@ -/* dirname.c -- return all but the last element in a file name - - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software - Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include "dirname.h" - -#include -#include - -/* Return the length of the prefix of FILE that will be used by - dir_name. If FILE is in the working directory, this returns zero - even though 'dir_name (FILE)' will return ".". Works properly even - if there are trailing slashes (by effectively ignoring them). */ - -size_t -dir_len (char const *file) -{ - size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); - size_t length; - - /* Advance prefix_length beyond important leading slashes. */ - prefix_length += (prefix_length != 0 - ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE - && ISSLASH (file[prefix_length])) - : (ISSLASH (file[0]) - ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT - && ISSLASH (file[1]) && ! ISSLASH (file[2]) - ? 2 : 1)) - : 0)); - - /* Strip the basename and any redundant slashes before it. */ - for (length = last_component (file) - file; - prefix_length < length; length--) - if (! ISSLASH (file[length - 1])) - break; - return length; -} - - -/* In general, we can't use the builtin 'dirname' function if available, - since it has different meanings in different environments. - In some environments the builtin 'dirname' modifies its argument. - - Return the leading directories part of FILE, allocated with malloc. - Works properly even if there are trailing slashes (by effectively - ignoring them). Return NULL on failure. - - If lstat (FILE) would succeed, then { chdir (dir_name (FILE)); - lstat (base_name (FILE)); } will access the same file. Likewise, - if the sequence { chdir (dir_name (FILE)); - rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE - to "foo" in the same directory FILE was in. */ - -char * -mdir_name (char const *file) -{ - size_t length = dir_len (file); - bool append_dot = (length == 0 - || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE - && length == FILE_SYSTEM_PREFIX_LEN (file) - && file[2] != '\0' && ! ISSLASH (file[2]))); - char *dir = malloc (length + append_dot + 1); - if (!dir) - return NULL; - memcpy (dir, file, length); - if (append_dot) - dir[length++] = '.'; - dir[length] = '\0'; - return dir; -} diff --git a/grub-core/gnulib/dirname.h b/grub-core/gnulib/dirname.h deleted file mode 100644 index 4ad031200..000000000 --- a/grub-core/gnulib/dirname.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Take file names apart into directory and base names. - - Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation, - Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef DIRNAME_H_ -# define DIRNAME_H_ 1 - -# include -# include -# include "dosname.h" - -# ifndef DIRECTORY_SEPARATOR -# define DIRECTORY_SEPARATOR '/' -# endif - -# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT -# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 -# endif - -# if GNULIB_DIRNAME -char *base_name (char const *file); -char *dir_name (char const *file); -# endif - -char *mdir_name (char const *file); -size_t base_len (char const *file) _GL_ATTRIBUTE_PURE; -size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE; -char *last_component (char const *file) _GL_ATTRIBUTE_PURE; - -bool strip_trailing_slashes (char *file); - -#endif /* not DIRNAME_H_ */ diff --git a/grub-core/gnulib/dosname.h b/grub-core/gnulib/dosname.h deleted file mode 100644 index ba63ce4bd..000000000 --- a/grub-core/gnulib/dosname.h +++ /dev/null @@ -1,53 +0,0 @@ -/* File names on MS-DOS/Windows systems. - - Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - From Paul Eggert and Jim Meyering. */ - -#ifndef _DOSNAME_H -#define _DOSNAME_H - -#if (defined _WIN32 || defined __WIN32__ || \ - defined __MSDOS__ || defined __CYGWIN__ || \ - defined __EMX__ || defined __DJGPP__) - /* This internal macro assumes ASCII, but all hosts that support drive - letters use ASCII. */ -# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ - <= 'z' - 'a') -# define FILE_SYSTEM_PREFIX_LEN(Filename) \ - (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) -# ifndef __CYGWIN__ -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 -# endif -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -#else -# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 -# define ISSLASH(C) ((C) == '/') -#endif - -#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 -#endif - -#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) -# else -# define IS_ABSOLUTE_FILE_NAME(F) \ - (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0) -#endif -#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) - -#endif /* DOSNAME_H_ */ diff --git a/grub-core/gnulib/errno.in.h b/grub-core/gnulib/errno.in.h deleted file mode 100644 index 49b35464b..000000000 --- a/grub-core/gnulib/errno.in.h +++ /dev/null @@ -1,279 +0,0 @@ -/* A POSIX-like . - - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _@GUARD_PREFIX@_ERRNO_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_ERRNO_H@ - -#ifndef _@GUARD_PREFIX@_ERRNO_H -#define _@GUARD_PREFIX@_ERRNO_H - - -/* On native Windows platforms, many macros are not defined. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -/* These are the same values as defined by MSVC 10, for interoperability. */ - -# ifndef ENOMSG -# define ENOMSG 122 -# define GNULIB_defined_ENOMSG 1 -# endif - -# ifndef EIDRM -# define EIDRM 111 -# define GNULIB_defined_EIDRM 1 -# endif - -# ifndef ENOLINK -# define ENOLINK 121 -# define GNULIB_defined_ENOLINK 1 -# endif - -# ifndef EPROTO -# define EPROTO 134 -# define GNULIB_defined_EPROTO 1 -# endif - -# ifndef EBADMSG -# define EBADMSG 104 -# define GNULIB_defined_EBADMSG 1 -# endif - -# ifndef EOVERFLOW -# define EOVERFLOW 132 -# define GNULIB_defined_EOVERFLOW 1 -# endif - -# ifndef ENOTSUP -# define ENOTSUP 129 -# define GNULIB_defined_ENOTSUP 1 -# endif - -# ifndef ENETRESET -# define ENETRESET 117 -# define GNULIB_defined_ENETRESET 1 -# endif - -# ifndef ECONNABORTED -# define ECONNABORTED 106 -# define GNULIB_defined_ECONNABORTED 1 -# endif - -# ifndef ECANCELED -# define ECANCELED 105 -# define GNULIB_defined_ECANCELED 1 -# endif - -# ifndef EOWNERDEAD -# define EOWNERDEAD 133 -# define GNULIB_defined_EOWNERDEAD 1 -# endif - -# ifndef ENOTRECOVERABLE -# define ENOTRECOVERABLE 127 -# define GNULIB_defined_ENOTRECOVERABLE 1 -# endif - -# ifndef EINPROGRESS -# define EINPROGRESS 112 -# define EALREADY 103 -# define ENOTSOCK 128 -# define EDESTADDRREQ 109 -# define EMSGSIZE 115 -# define EPROTOTYPE 136 -# define ENOPROTOOPT 123 -# define EPROTONOSUPPORT 135 -# define EOPNOTSUPP 130 -# define EAFNOSUPPORT 102 -# define EADDRINUSE 100 -# define EADDRNOTAVAIL 101 -# define ENETDOWN 116 -# define ENETUNREACH 118 -# define ECONNRESET 108 -# define ENOBUFS 119 -# define EISCONN 113 -# define ENOTCONN 126 -# define ETIMEDOUT 138 -# define ECONNREFUSED 107 -# define ELOOP 114 -# define EHOSTUNREACH 110 -# define EWOULDBLOCK 140 -# define GNULIB_defined_ESOCK 1 -# endif - -# ifndef ETXTBSY -# define ETXTBSY 139 -# define ENODATA 120 /* not required by POSIX */ -# define ENOSR 124 /* not required by POSIX */ -# define ENOSTR 125 /* not required by POSIX */ -# define ETIME 137 /* not required by POSIX */ -# define EOTHER 131 /* not required by POSIX */ -# define GNULIB_defined_ESTREAMS 1 -# endif - -/* These are intentionally the same values as the WSA* error numbers, defined - in . */ -# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */ -# define EPFNOSUPPORT 10046 /* not required by POSIX */ -# define ESHUTDOWN 10058 /* not required by POSIX */ -# define ETOOMANYREFS 10059 /* not required by POSIX */ -# define EHOSTDOWN 10064 /* not required by POSIX */ -# define EPROCLIM 10067 /* not required by POSIX */ -# define EUSERS 10068 /* not required by POSIX */ -# define EDQUOT 10069 -# define ESTALE 10070 -# define EREMOTE 10071 /* not required by POSIX */ -# define GNULIB_defined_EWINSOCK 1 - -# endif - - -/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros - EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */ -# if @EMULTIHOP_HIDDEN@ -# define EMULTIHOP @EMULTIHOP_VALUE@ -# define GNULIB_defined_EMULTIHOP 1 -# endif -# if @ENOLINK_HIDDEN@ -# define ENOLINK @ENOLINK_VALUE@ -# define GNULIB_defined_ENOLINK 1 -# endif -# if @EOVERFLOW_HIDDEN@ -# define EOVERFLOW @EOVERFLOW_VALUE@ -# define GNULIB_defined_EOVERFLOW 1 -# endif - - -/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, - EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. - Likewise, on NonStop Kernel, EDQUOT is not defined. - Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, - HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. - - Note: When one of these systems defines some of these macros some day, - binaries will have to be recompiled so that they recognizes the new - errno values from the system. */ - -# ifndef ENOMSG -# define ENOMSG 2000 -# define GNULIB_defined_ENOMSG 1 -# endif - -# ifndef EIDRM -# define EIDRM 2001 -# define GNULIB_defined_EIDRM 1 -# endif - -# ifndef ENOLINK -# define ENOLINK 2002 -# define GNULIB_defined_ENOLINK 1 -# endif - -# ifndef EPROTO -# define EPROTO 2003 -# define GNULIB_defined_EPROTO 1 -# endif - -# ifndef EMULTIHOP -# define EMULTIHOP 2004 -# define GNULIB_defined_EMULTIHOP 1 -# endif - -# ifndef EBADMSG -# define EBADMSG 2005 -# define GNULIB_defined_EBADMSG 1 -# endif - -# ifndef EOVERFLOW -# define EOVERFLOW 2006 -# define GNULIB_defined_EOVERFLOW 1 -# endif - -# ifndef ENOTSUP -# define ENOTSUP 2007 -# define GNULIB_defined_ENOTSUP 1 -# endif - -# ifndef ENETRESET -# define ENETRESET 2011 -# define GNULIB_defined_ENETRESET 1 -# endif - -# ifndef ECONNABORTED -# define ECONNABORTED 2012 -# define GNULIB_defined_ECONNABORTED 1 -# endif - -# ifndef ESTALE -# define ESTALE 2009 -# define GNULIB_defined_ESTALE 1 -# endif - -# ifndef EDQUOT -# define EDQUOT 2010 -# define GNULIB_defined_EDQUOT 1 -# endif - -# ifndef ECANCELED -# define ECANCELED 2008 -# define GNULIB_defined_ECANCELED 1 -# endif - -/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not - defined. */ - -# ifndef EOWNERDEAD -# if defined __sun - /* Use the same values as defined for Solaris >= 8, for - interoperability. */ -# define EOWNERDEAD 58 -# define ENOTRECOVERABLE 59 -# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* We have a conflict here: pthreads-win32 defines these values - differently than MSVC 10. It's hairy to decide which one to use. */ -# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS - /* Use the same values as defined by pthreads-win32, for - interoperability. */ -# define EOWNERDEAD 43 -# define ENOTRECOVERABLE 44 -# else - /* Use the same values as defined by MSVC 10, for - interoperability. */ -# define EOWNERDEAD 133 -# define ENOTRECOVERABLE 127 -# endif -# else -# define EOWNERDEAD 2013 -# define ENOTRECOVERABLE 2014 -# endif -# define GNULIB_defined_EOWNERDEAD 1 -# define GNULIB_defined_ENOTRECOVERABLE 1 -# endif - -# ifndef EILSEQ -# define EILSEQ 2015 -# define GNULIB_defined_EILSEQ 1 -# endif - -#endif /* _@GUARD_PREFIX@_ERRNO_H */ -#endif /* _@GUARD_PREFIX@_ERRNO_H */ diff --git a/grub-core/gnulib/error.c b/grub-core/gnulib/error.c deleted file mode 100644 index 865b29340..000000000 --- a/grub-core/gnulib/error.c +++ /dev/null @@ -1,401 +0,0 @@ -/* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by David MacKenzie . */ - -#if !_LIBC -# include -#endif - -#include "error.h" - -#include -#include -#include -#include - -#if !_LIBC && ENABLE_NLS -# include "gettext.h" -# define _(msgid) gettext (msgid) -#endif - -#ifdef _LIBC -# include -# include -# include -# include -# define mbsrtowcs __mbsrtowcs -#endif - -#if USE_UNLOCKED_IO -# include "unlocked-io.h" -#endif - -#ifndef _ -# define _(String) String -#endif - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -void (*error_print_progname) (void); - -/* This variable is incremented each time 'error' is called. */ -unsigned int error_message_count; - -#ifdef _LIBC -/* In the GNU C library, there is a predefined variable for this. */ - -# define program_name program_invocation_name -# include -# include -# include - -/* In GNU libc we want do not want to use the common name 'error' directly. - Instead make it a weak alias. */ -extern void __error (int status, int errnum, const char *message, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); -extern void __error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, - ...) - __attribute__ ((__format__ (__printf__, 5, 6)));; -# define error __error -# define error_at_line __error_at_line - -# include -# define fflush(s) INTUSE(_IO_fflush) (s) -# undef putc -# define putc(c, fp) INTUSE(_IO_putc) (c, fp) - -# include - -#else /* not _LIBC */ - -# include -# include - -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* Get declarations of the native Windows API functions. */ -# define WIN32_LEAN_AND_MEAN -# include -/* Get _get_osfhandle. */ -# include "msvc-nothrow.h" -# endif - -/* The gnulib override of fcntl is not needed in this file. */ -# undef fcntl - -# if !HAVE_DECL_STRERROR_R -# ifndef HAVE_DECL_STRERROR_R -"this configure-time declaration test was not run" -# endif -# if STRERROR_R_CHAR_P -char *strerror_r (); -# else -int strerror_r (); -# endif -# endif - -/* The calling program should define program_name and set it to the - name of the executing program. */ -extern char *program_name; - -# if HAVE_STRERROR_R || defined strerror_r -# define __strerror_r strerror_r -# endif /* HAVE_STRERROR_R || defined strerror_r */ -#endif /* not _LIBC */ - -#if !_LIBC -/* Return non-zero if FD is open. */ -static int -is_open (int fd) -{ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* On native Windows: The initial state of unassigned standard file - descriptors is that they are open but point to an INVALID_HANDLE_VALUE. - There is no fcntl, and the gnulib replacement fcntl does not support - F_GETFL. */ - return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; -# else -# ifndef F_GETFL -# error Please port fcntl to your platform -# endif - return 0 <= fcntl (fd, F_GETFL); -# endif -} -#endif - -static void -flush_stdout (void) -{ -#if !_LIBC - int stdout_fd; - -# if GNULIB_FREOPEN_SAFER - /* Use of gnulib's freopen-safer module normally ensures that - fileno (stdout) == 1 - whenever stdout is open. */ - stdout_fd = STDOUT_FILENO; -# else - /* POSIX states that fileno (stdout) after fclose is unspecified. But in - practice it is not a problem, because stdout is statically allocated and - the fd of a FILE stream is stored as a field in its allocated memory. */ - stdout_fd = fileno (stdout); -# endif - /* POSIX states that fflush (stdout) after fclose is unspecified; it - is safe in glibc, but not on all other platforms. fflush (NULL) - is always defined, but too draconian. */ - if (0 <= stdout_fd && is_open (stdout_fd)) -#endif - fflush (stdout); -} - -static void -print_errno_message (int errnum) -{ - char const *s; - -#if defined HAVE_STRERROR_R || _LIBC - char errbuf[1024]; -# if STRERROR_R_CHAR_P || _LIBC - s = __strerror_r (errnum, errbuf, sizeof errbuf); -# else - if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) - s = errbuf; - else - s = 0; -# endif -#else - s = strerror (errnum); -#endif - -#if !_LIBC - if (! s) - s = _("Unknown system error"); -#endif - -#if _LIBC - __fxprintf (NULL, ": %s", s); -#else - fprintf (stderr, ": %s", s); -#endif -} - -static void -error_tail (int status, int errnum, const char *message, va_list args) -{ -#if _LIBC - if (_IO_fwide (stderr, 0) > 0) - { -# define ALLOCA_LIMIT 2000 - size_t len = strlen (message) + 1; - wchar_t *wmessage = NULL; - mbstate_t st; - size_t res; - const char *tmp; - bool use_malloc = false; - - while (1) - { - if (__libc_use_alloca (len * sizeof (wchar_t))) - wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); - else - { - if (!use_malloc) - wmessage = NULL; - - wchar_t *p = (wchar_t *) realloc (wmessage, - len * sizeof (wchar_t)); - if (p == NULL) - { - free (wmessage); - fputws_unlocked (L"out of memory\n", stderr); - return; - } - wmessage = p; - use_malloc = true; - } - - memset (&st, '\0', sizeof (st)); - tmp = message; - - res = mbsrtowcs (wmessage, &tmp, len, &st); - if (res != len) - break; - - if (__builtin_expect (len >= SIZE_MAX / 2, 0)) - { - /* This really should not happen if everything is fine. */ - res = (size_t) -1; - break; - } - - len *= 2; - } - - if (res == (size_t) -1) - { - /* The string cannot be converted. */ - if (use_malloc) - { - free (wmessage); - use_malloc = false; - } - wmessage = (wchar_t *) L"???"; - } - - __vfwprintf (stderr, wmessage, args); - - if (use_malloc) - free (wmessage); - } - else -#endif - vfprintf (stderr, message, args); - va_end (args); - - ++error_message_count; - if (errnum) - print_errno_message (errnum); -#if _LIBC - __fxprintf (NULL, "\n"); -#else - putc ('\n', stderr); -#endif - fflush (stderr); - if (status) - exit (status); -} - - -/* Print the program name and error message MESSAGE, which is a printf-style - format string with optional args. - If ERRNUM is nonzero, print its corresponding system error message. - Exit with status STATUS if it is nonzero. */ -void -error (int status, int errnum, const char *message, ...) -{ - va_list args; - -#if defined _LIBC && defined __libc_ptf_call - /* We do not want this call to be cut short by a thread - cancellation. Therefore disable cancellation for now. */ - int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); -#endif - - flush_stdout (); -#ifdef _LIBC - _IO_flockfile (stderr); -#endif - if (error_print_progname) - (*error_print_progname) (); - else - { -#if _LIBC - __fxprintf (NULL, "%s: ", program_name); -#else - fprintf (stderr, "%s: ", program_name); -#endif - } - - va_start (args, message); - error_tail (status, errnum, message, args); - -#ifdef _LIBC - _IO_funlockfile (stderr); -# ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); -# endif -#endif -} - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -int error_one_per_line; - -void -error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) -{ - va_list args; - - if (error_one_per_line) - { - static const char *old_file_name; - static unsigned int old_line_number; - - if (old_line_number == line_number - && (file_name == old_file_name - || strcmp (old_file_name, file_name) == 0)) - /* Simply return and print nothing. */ - return; - - old_file_name = file_name; - old_line_number = line_number; - } - -#if defined _LIBC && defined __libc_ptf_call - /* We do not want this call to be cut short by a thread - cancellation. Therefore disable cancellation for now. */ - int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); -#endif - - flush_stdout (); -#ifdef _LIBC - _IO_flockfile (stderr); -#endif - if (error_print_progname) - (*error_print_progname) (); - else - { -#if _LIBC - __fxprintf (NULL, "%s:", program_name); -#else - fprintf (stderr, "%s:", program_name); -#endif - } - -#if _LIBC - __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); -#else - fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); -#endif - - va_start (args, message); - error_tail (status, errnum, message, args); - -#ifdef _LIBC - _IO_funlockfile (stderr); -# ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); -# endif -#endif -} - -#ifdef _LIBC -/* Make the weak alias. */ -# undef error -# undef error_at_line -weak_alias (__error, error) -weak_alias (__error_at_line, error_at_line) -#endif diff --git a/grub-core/gnulib/error.h b/grub-core/gnulib/error.h deleted file mode 100644 index afcb0e10c..000000000 --- a/grub-core/gnulib/error.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Declaration for error-reporting function - Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation, - Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _ERROR_H -#define _ERROR_H 1 - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Print a message with 'fprintf (stderr, FORMAT, ...)'; - if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). - If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ - -extern void error (int __status, int __errnum, const char *__format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); - -extern void error_at_line (int __status, int __errnum, const char *__fname, - unsigned int __lineno, const char *__format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -extern void (*error_print_progname) (void); - -/* This variable is incremented each time 'error' is called. */ -extern unsigned int error_message_count; - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -extern int error_one_per_line; - -#ifdef __cplusplus -} -#endif - -#endif /* error.h */ diff --git a/grub-core/gnulib/float+.h b/grub-core/gnulib/float+.h deleted file mode 100644 index 32fb790bb..000000000 --- a/grub-core/gnulib/float+.h +++ /dev/null @@ -1,147 +0,0 @@ -/* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2007. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _FLOATPLUS_H -#define _FLOATPLUS_H - -#include -#include - -/* Number of bits in the mantissa of a floating-point number, including the - "hidden bit". */ -#if FLT_RADIX == 2 -# define FLT_MANT_BIT FLT_MANT_DIG -# define DBL_MANT_BIT DBL_MANT_DIG -# define LDBL_MANT_BIT LDBL_MANT_DIG -#elif FLT_RADIX == 4 -# define FLT_MANT_BIT (FLT_MANT_DIG * 2) -# define DBL_MANT_BIT (DBL_MANT_DIG * 2) -# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) -#elif FLT_RADIX == 16 -# define FLT_MANT_BIT (FLT_MANT_DIG * 4) -# define DBL_MANT_BIT (DBL_MANT_DIG * 4) -# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) -#endif - -/* Bit mask that can be used to mask the exponent, as an unsigned number. */ -#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) -#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) -#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) - -/* Number of bits used for the exponent of a floating-point number, including - the exponent's sign. */ -#define FLT_EXP_BIT \ - (FLT_EXP_MASK < 0x100 ? 8 : \ - FLT_EXP_MASK < 0x200 ? 9 : \ - FLT_EXP_MASK < 0x400 ? 10 : \ - FLT_EXP_MASK < 0x800 ? 11 : \ - FLT_EXP_MASK < 0x1000 ? 12 : \ - FLT_EXP_MASK < 0x2000 ? 13 : \ - FLT_EXP_MASK < 0x4000 ? 14 : \ - FLT_EXP_MASK < 0x8000 ? 15 : \ - FLT_EXP_MASK < 0x10000 ? 16 : \ - FLT_EXP_MASK < 0x20000 ? 17 : \ - FLT_EXP_MASK < 0x40000 ? 18 : \ - FLT_EXP_MASK < 0x80000 ? 19 : \ - FLT_EXP_MASK < 0x100000 ? 20 : \ - FLT_EXP_MASK < 0x200000 ? 21 : \ - FLT_EXP_MASK < 0x400000 ? 22 : \ - FLT_EXP_MASK < 0x800000 ? 23 : \ - FLT_EXP_MASK < 0x1000000 ? 24 : \ - FLT_EXP_MASK < 0x2000000 ? 25 : \ - FLT_EXP_MASK < 0x4000000 ? 26 : \ - FLT_EXP_MASK < 0x8000000 ? 27 : \ - FLT_EXP_MASK < 0x10000000 ? 28 : \ - FLT_EXP_MASK < 0x20000000 ? 29 : \ - FLT_EXP_MASK < 0x40000000 ? 30 : \ - FLT_EXP_MASK <= 0x7fffffff ? 31 : \ - 32) -#define DBL_EXP_BIT \ - (DBL_EXP_MASK < 0x100 ? 8 : \ - DBL_EXP_MASK < 0x200 ? 9 : \ - DBL_EXP_MASK < 0x400 ? 10 : \ - DBL_EXP_MASK < 0x800 ? 11 : \ - DBL_EXP_MASK < 0x1000 ? 12 : \ - DBL_EXP_MASK < 0x2000 ? 13 : \ - DBL_EXP_MASK < 0x4000 ? 14 : \ - DBL_EXP_MASK < 0x8000 ? 15 : \ - DBL_EXP_MASK < 0x10000 ? 16 : \ - DBL_EXP_MASK < 0x20000 ? 17 : \ - DBL_EXP_MASK < 0x40000 ? 18 : \ - DBL_EXP_MASK < 0x80000 ? 19 : \ - DBL_EXP_MASK < 0x100000 ? 20 : \ - DBL_EXP_MASK < 0x200000 ? 21 : \ - DBL_EXP_MASK < 0x400000 ? 22 : \ - DBL_EXP_MASK < 0x800000 ? 23 : \ - DBL_EXP_MASK < 0x1000000 ? 24 : \ - DBL_EXP_MASK < 0x2000000 ? 25 : \ - DBL_EXP_MASK < 0x4000000 ? 26 : \ - DBL_EXP_MASK < 0x8000000 ? 27 : \ - DBL_EXP_MASK < 0x10000000 ? 28 : \ - DBL_EXP_MASK < 0x20000000 ? 29 : \ - DBL_EXP_MASK < 0x40000000 ? 30 : \ - DBL_EXP_MASK <= 0x7fffffff ? 31 : \ - 32) -#define LDBL_EXP_BIT \ - (LDBL_EXP_MASK < 0x100 ? 8 : \ - LDBL_EXP_MASK < 0x200 ? 9 : \ - LDBL_EXP_MASK < 0x400 ? 10 : \ - LDBL_EXP_MASK < 0x800 ? 11 : \ - LDBL_EXP_MASK < 0x1000 ? 12 : \ - LDBL_EXP_MASK < 0x2000 ? 13 : \ - LDBL_EXP_MASK < 0x4000 ? 14 : \ - LDBL_EXP_MASK < 0x8000 ? 15 : \ - LDBL_EXP_MASK < 0x10000 ? 16 : \ - LDBL_EXP_MASK < 0x20000 ? 17 : \ - LDBL_EXP_MASK < 0x40000 ? 18 : \ - LDBL_EXP_MASK < 0x80000 ? 19 : \ - LDBL_EXP_MASK < 0x100000 ? 20 : \ - LDBL_EXP_MASK < 0x200000 ? 21 : \ - LDBL_EXP_MASK < 0x400000 ? 22 : \ - LDBL_EXP_MASK < 0x800000 ? 23 : \ - LDBL_EXP_MASK < 0x1000000 ? 24 : \ - LDBL_EXP_MASK < 0x2000000 ? 25 : \ - LDBL_EXP_MASK < 0x4000000 ? 26 : \ - LDBL_EXP_MASK < 0x8000000 ? 27 : \ - LDBL_EXP_MASK < 0x10000000 ? 28 : \ - LDBL_EXP_MASK < 0x20000000 ? 29 : \ - LDBL_EXP_MASK < 0x40000000 ? 30 : \ - LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ - 32) - -/* Number of bits used for a floating-point number: the mantissa (not - counting the "hidden bit", since it may or may not be explicit), the - exponent, and the sign. */ -#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) -#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) -#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) - -/* Number of bytes used for a floating-point number. - This can be smaller than the 'sizeof'. For example, on i386 systems, - 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence - LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but - sizeof (long double) = 12 or = 16. */ -#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) -#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) -#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) - -/* Verify that SIZEOF_FLT <= sizeof (float) etc. */ -typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1]; -typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1]; -typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1]; - -#endif /* _FLOATPLUS_H */ diff --git a/grub-core/gnulib/float.c b/grub-core/gnulib/float.c deleted file mode 100644 index 366945fa3..000000000 --- a/grub-core/gnulib/float.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Auxiliary definitions for . - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2011. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ -const union gl_long_double_union gl_LDBL_MAX = - { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; -#elif defined __i386__ -const union gl_long_double_union gl_LDBL_MAX = - { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; -#else -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -typedef int dummy; -#endif diff --git a/grub-core/gnulib/float.in.h b/grub-core/gnulib/float.in.h deleted file mode 100644 index 84e1950f9..000000000 --- a/grub-core/gnulib/float.in.h +++ /dev/null @@ -1,188 +0,0 @@ -/* A correct . - - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _@GUARD_PREFIX@_FLOAT_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_FLOAT_H@ - -#ifndef _@GUARD_PREFIX@_FLOAT_H -#define _@GUARD_PREFIX@_FLOAT_H - -/* 'long double' properties. */ - -#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) -/* Number of mantissa units, in base FLT_RADIX. */ -# undef LDBL_MANT_DIG -# define LDBL_MANT_DIG 64 -/* Number of decimal digits that is sufficient for representing a number. */ -# undef LDBL_DIG -# define LDBL_DIG 18 -/* x-1 where x is the smallest representable number > 1. */ -# undef LDBL_EPSILON -# define LDBL_EPSILON 1.0842021724855044340E-19L -/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ -# undef LDBL_MIN_EXP -# define LDBL_MIN_EXP (-16381) -/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ -# undef LDBL_MAX_EXP -# define LDBL_MAX_EXP 16384 -/* Minimum positive normalized number. */ -# undef LDBL_MIN -# define LDBL_MIN 3.3621031431120935063E-4932L -/* Maximum representable finite number. */ -# undef LDBL_MAX -# define LDBL_MAX 1.1897314953572317650E+4932L -/* Minimum e such that 10^e is in the range of normalized numbers. */ -# undef LDBL_MIN_10_EXP -# define LDBL_MIN_10_EXP (-4931) -/* Maximum e such that 10^e is in the range of representable finite numbers. */ -# undef LDBL_MAX_10_EXP -# define LDBL_MAX_10_EXP 4932 -#endif - -/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of - precision in the compiler but 64 bits of precision at runtime. See - . */ -#if defined __i386__ && defined __FreeBSD__ -/* Number of mantissa units, in base FLT_RADIX. */ -# undef LDBL_MANT_DIG -# define LDBL_MANT_DIG 64 -/* Number of decimal digits that is sufficient for representing a number. */ -# undef LDBL_DIG -# define LDBL_DIG 18 -/* x-1 where x is the smallest representable number > 1. */ -# undef LDBL_EPSILON -# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */ -/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ -# undef LDBL_MIN_EXP -# define LDBL_MIN_EXP (-16381) -/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ -# undef LDBL_MAX_EXP -# define LDBL_MAX_EXP 16384 -/* Minimum positive normalized number. */ -# undef LDBL_MIN -# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */ -/* Maximum representable finite number. */ -# undef LDBL_MAX -/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }. - But the largest literal that GCC allows us to write is - 0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }. - So, define it like this through a reference to an external variable - - const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }; - extern const long double LDBL_MAX; - - Unfortunately, this is not a constant expression. */ -union gl_long_double_union - { - struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd; - long double ld; - }; -extern const union gl_long_double_union gl_LDBL_MAX; -# define LDBL_MAX (gl_LDBL_MAX.ld) -/* Minimum e such that 10^e is in the range of normalized numbers. */ -# undef LDBL_MIN_10_EXP -# define LDBL_MIN_10_EXP (-4931) -/* Maximum e such that 10^e is in the range of representable finite numbers. */ -# undef LDBL_MAX_10_EXP -# define LDBL_MAX_10_EXP 4932 -#endif - -/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are - wrong. - On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ -#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ -# undef LDBL_MIN_EXP -# define LDBL_MIN_EXP DBL_MIN_EXP -# undef LDBL_MIN_10_EXP -# define LDBL_MIN_10_EXP DBL_MIN_10_EXP -# undef LDBL_MIN -# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ -#endif -#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ -# undef LDBL_MAX -/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. - It is not easy to define: - #define LDBL_MAX 1.79769313486231580793728971405302307166e308L - is too small, whereas - #define LDBL_MAX 1.79769313486231580793728971405302307167e308L - is too large. Apparently a bug in GCC decimal-to-binary conversion. - Also, I can't get values larger than - #define LDBL63 ((long double) (1ULL << 63)) - #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) - #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) - #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) - #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL) - which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }. - So, define it like this through a reference to an external variable - - const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }; - extern const long double LDBL_MAX; - - or through a pointer cast - - #define LDBL_MAX \ - (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }) - - Unfortunately, this is not a constant expression, and the latter expression - does not work well when GCC is optimizing.. */ -union gl_long_double_union - { - struct { double hi; double lo; } dd; - long double ld; - }; -extern const union gl_long_double_union gl_LDBL_MAX; -# define LDBL_MAX (gl_LDBL_MAX.ld) -#endif - -/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong. - On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON - are wrong. */ -#if defined __sgi && (LDBL_MANT_DIG >= 106) -# undef LDBL_MANT_DIG -# define LDBL_MANT_DIG 106 -# if defined __GNUC__ -# undef LDBL_MIN_EXP -# define LDBL_MIN_EXP DBL_MIN_EXP -# undef LDBL_MIN_10_EXP -# define LDBL_MIN_10_EXP DBL_MIN_10_EXP -# undef LDBL_MIN -# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ -# undef LDBL_EPSILON -# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */ -# endif -#endif - -#if @REPLACE_ITOLD@ -/* Pull in a function that fixes the 'int' to 'long double' conversion - of glibc 2.7. */ -extern -# ifdef __cplusplus -"C" -# endif -void _Qp_itoq (long double *, int); -static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq; -#endif - -#endif /* _@GUARD_PREFIX@_FLOAT_H */ -#endif /* _@GUARD_PREFIX@_FLOAT_H */ diff --git a/grub-core/gnulib/fnmatch.c b/grub-core/gnulib/fnmatch.c deleted file mode 100644 index 6a09e1a9b..000000000 --- a/grub-core/gnulib/fnmatch.c +++ /dev/null @@ -1,350 +0,0 @@ -/* Copyright (C) 1991-1993, 1996-2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _LIBC -# include -#endif - -/* Enable GNU extensions in fnmatch.h. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -#if ! defined __builtin_expect && __GNUC__ < 3 -# define __builtin_expect(expr, expected) (expr) -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define WIDE_CHAR_SUPPORT \ - (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \ - && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY)) - -/* For platform which support the ISO C amendment 1 functionality we - support user defined character classes. */ -#if defined _LIBC || WIDE_CHAR_SUPPORT -# include -# include -#endif - -/* We need some of the locale data (the collation sequence information) - but there is no interface to get this information in general. Therefore - we support a correct implementation only in glibc. */ -#ifdef _LIBC -# include "../locale/localeinfo.h" -# include "../locale/elem-hash.h" -# include "../locale/coll-lookup.h" -# include - -# define CONCAT(a,b) __CONCAT(a,b) -# define mbsrtowcs __mbsrtowcs -# define fnmatch __fnmatch -extern int fnmatch (const char *pattern, const char *string, int flags); -#endif - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */ -#define NO_LEADING_PERIOD(flags) \ - ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD)) - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself, and have not detected a bug - in the library. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand 'configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU - - -# if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) -# define isblank(c) ((c) == ' ' || (c) == '\t') -# endif - -# define STREQ(s1, s2) (strcmp (s1, s2) == 0) - -# if defined _LIBC || WIDE_CHAR_SUPPORT -/* The GNU C library provides support for user-defined character classes - and the functions from ISO C amendment 1. */ -# ifdef CHARCLASS_NAME_MAX -# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX -# else -/* This shouldn't happen but some implementation might still have this - problem. Use a reasonable default value. */ -# define CHAR_CLASS_MAX_LENGTH 256 -# endif - -# ifdef _LIBC -# define IS_CHAR_CLASS(string) __wctype (string) -# else -# define IS_CHAR_CLASS(string) wctype (string) -# endif - -# ifdef _LIBC -# define ISWCTYPE(WC, WT) __iswctype (WC, WT) -# else -# define ISWCTYPE(WC, WT) iswctype (WC, WT) -# endif - -# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC -/* In this case we are implementing the multibyte character handling. */ -# define HANDLE_MULTIBYTE 1 -# endif - -# else -# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, 'xdigit'. */ - -# define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) -# endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -/* Global variable. */ -static int posixly_correct; - -# ifndef internal_function -/* Inside GNU libc we mark some function in a special way. In other - environments simply ignore the marking. */ -# define internal_function -# endif - -/* Note that this evaluates C many times. */ -# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) -# define CHAR char -# define UCHAR unsigned char -# define INT int -# define FCT internal_fnmatch -# define EXT ext_match -# define END end_pattern -# define L_(CS) CS -# ifdef _LIBC -# define BTOWC(C) __btowc (C) -# else -# define BTOWC(C) btowc (C) -# endif -# define STRLEN(S) strlen (S) -# define STRCAT(D, S) strcat (D, S) -# ifdef _LIBC -# define MEMPCPY(D, S, N) __mempcpy (D, S, N) -# else -# if HAVE_MEMPCPY -# define MEMPCPY(D, S, N) mempcpy (D, S, N) -# else -# define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) -# endif -# endif -# define MEMCHR(S, C, N) memchr (S, C, N) -# include "fnmatch_loop.c" - - -# if HANDLE_MULTIBYTE -# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c)) -# define CHAR wchar_t -# define UCHAR wint_t -# define INT wint_t -# define FCT internal_fnwmatch -# define EXT ext_wmatch -# define END end_wpattern -# define L_(CS) L##CS -# define BTOWC(C) (C) -# ifdef _LIBC -# define STRLEN(S) __wcslen (S) -# define STRCAT(D, S) __wcscat (D, S) -# define MEMPCPY(D, S, N) __wmempcpy (D, S, N) -# else -# define STRLEN(S) wcslen (S) -# define STRCAT(D, S) wcscat (D, S) -# if HAVE_WMEMPCPY -# define MEMPCPY(D, S, N) wmempcpy (D, S, N) -# else -# define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N)) -# endif -# endif -# define MEMCHR(S, C, N) wmemchr (S, C, N) -# define WIDE_CHAR_VERSION 1 - -# undef IS_CHAR_CLASS -/* We have to convert the wide character string in a multibyte string. But - we know that the character class names consist of alphanumeric characters - from the portable character set, and since the wide character encoding - for a member of the portable character set is the same code point as - its single-byte encoding, we can use a simplified method to convert the - string to a multibyte character string. */ -static wctype_t -is_char_class (const wchar_t *wcs) -{ - char s[CHAR_CLASS_MAX_LENGTH + 1]; - char *cp = s; - - do - { - /* Test for a printable character from the portable character set. */ -# ifdef _LIBC - if (*wcs < 0x20 || *wcs > 0x7e - || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60) - return (wctype_t) 0; -# else - switch (*wcs) - { - case L' ': case L'!': case L'"': case L'#': case L'%': - case L'&': case L'\'': case L'(': case L')': case L'*': - case L'+': case L',': case L'-': case L'.': case L'/': - case L'0': case L'1': case L'2': case L'3': case L'4': - case L'5': case L'6': case L'7': case L'8': case L'9': - case L':': case L';': case L'<': case L'=': case L'>': - case L'?': - case L'A': case L'B': case L'C': case L'D': case L'E': - case L'F': case L'G': case L'H': case L'I': case L'J': - case L'K': case L'L': case L'M': case L'N': case L'O': - case L'P': case L'Q': case L'R': case L'S': case L'T': - case L'U': case L'V': case L'W': case L'X': case L'Y': - case L'Z': - case L'[': case L'\\': case L']': case L'^': case L'_': - case L'a': case L'b': case L'c': case L'd': case L'e': - case L'f': case L'g': case L'h': case L'i': case L'j': - case L'k': case L'l': case L'm': case L'n': case L'o': - case L'p': case L'q': case L'r': case L's': case L't': - case L'u': case L'v': case L'w': case L'x': case L'y': - case L'z': case L'{': case L'|': case L'}': case L'~': - break; - default: - return (wctype_t) 0; - } -# endif - - /* Avoid overrunning the buffer. */ - if (cp == s + CHAR_CLASS_MAX_LENGTH) - return (wctype_t) 0; - - *cp++ = (char) *wcs++; - } - while (*wcs != L'\0'); - - *cp = '\0'; - -# ifdef _LIBC - return __wctype (s); -# else - return wctype (s); -# endif -} -# define IS_CHAR_CLASS(string) is_char_class (string) - -# include "fnmatch_loop.c" -# endif - - -int -fnmatch (const char *pattern, const char *string, int flags) -{ -# if HANDLE_MULTIBYTE -# define ALLOCA_LIMIT 2000 - if (__builtin_expect (MB_CUR_MAX, 1) != 1) - { - mbstate_t ps; - size_t patsize; - size_t strsize; - size_t totsize; - wchar_t *wpattern; - wchar_t *wstring; - int res; - - /* Calculate the size needed to convert the strings to - wide characters. */ - memset (&ps, '\0', sizeof (ps)); - patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1; - if (__builtin_expect (patsize != 0, 1)) - { - assert (mbsinit (&ps)); - strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1; - if (__builtin_expect (strsize != 0, 1)) - { - assert (mbsinit (&ps)); - totsize = patsize + strsize; - if (__builtin_expect (! (patsize <= totsize - && totsize <= SIZE_MAX / sizeof (wchar_t)), - 0)) - { - errno = ENOMEM; - return -1; - } - - /* Allocate room for the wide characters. */ - if (__builtin_expect (totsize < ALLOCA_LIMIT, 1)) - wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t)); - else - { - wpattern = malloc (totsize * sizeof (wchar_t)); - if (__builtin_expect (! wpattern, 0)) - { - errno = ENOMEM; - return -1; - } - } - wstring = wpattern + patsize; - - /* Convert the strings into wide characters. */ - mbsrtowcs (wpattern, &pattern, patsize, &ps); - assert (mbsinit (&ps)); - mbsrtowcs (wstring, &string, strsize, &ps); - - res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1, - flags & FNM_PERIOD, flags); - - if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0)) - free (wpattern); - return res; - } - } - } - -# endif /* HANDLE_MULTIBYTE */ - - return internal_fnmatch (pattern, string, string + strlen (string), - flags & FNM_PERIOD, flags); -} - -# ifdef _LIBC -# undef fnmatch -versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3); -# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3) -strong_alias (__fnmatch, __fnmatch_old) -compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0); -# endif -libc_hidden_ver (__fnmatch, fnmatch) -# endif - -#endif /* _LIBC or not __GNU_LIBRARY__. */ diff --git a/grub-core/gnulib/fnmatch.in.h b/grub-core/gnulib/fnmatch.in.h deleted file mode 100644 index d39ce2f1c..000000000 --- a/grub-core/gnulib/fnmatch.in.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2013 Free - Software Foundation, Inc. - - This file is part of the GNU C Library. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _FNMATCH_H -#define _FNMATCH_H 1 - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* We #undef these before defining them because some losing systems - (HP-UX A.08.07 for example) define these in . */ -#undef FNM_PATHNAME -#undef FNM_NOESCAPE -#undef FNM_PERIOD - -/* Bits set in the FLAGS argument to 'fnmatch'. */ -#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */ -#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */ - -#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE -# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -# define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */ -# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ -# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ -#endif - -/* Value returned by 'fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 - -/* This value is returned if the implementation does not support - 'fnmatch'. Since this is not the case here it will never be - returned but the conformance test suites still require the symbol - to be defined. */ -#ifdef _XOPEN_SOURCE -# define FNM_NOSYS (-1) -#endif - -/* Match NAME against the file name pattern PATTERN, - returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch (const char *__pattern, const char *__name, - int __flags) - _GL_ARG_NONNULL ((1, 2)); - -#ifdef __cplusplus -} -#endif - -#endif /* fnmatch.h */ diff --git a/grub-core/gnulib/fnmatch_loop.c b/grub-core/gnulib/fnmatch_loop.c deleted file mode 100644 index f57cd63f9..000000000 --- a/grub-core/gnulib/fnmatch_loop.c +++ /dev/null @@ -1,1219 +0,0 @@ -/* Copyright (C) 1991-1993, 1996-2006, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Match STRING against the file name pattern PATTERN, returning zero if - it matches, nonzero if not. */ -static int EXT (INT opt, const CHAR *pattern, const CHAR *string, - const CHAR *string_end, bool no_leading_period, int flags) - internal_function; -static const CHAR *END (const CHAR *patternp) internal_function; - -static int -internal_function -FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, - bool no_leading_period, int flags) -{ - register const CHAR *p = pattern, *n = string; - register UCHAR c; -#ifdef _LIBC -# if WIDE_CHAR_VERSION - const char *collseq = (const char *) - _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC); -# else - const UCHAR *collseq = (const UCHAR *) - _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB); -# endif -#endif - - while ((c = *p++) != L_('\0')) - { - bool new_no_leading_period = false; - c = FOLD (c); - - switch (c) - { - case L_('?'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; - - res = EXT (c, p, n, string_end, no_leading_period, - flags); - if (res != -1) - return res; - } - - if (n == string_end) - return FNM_NOMATCH; - else if (*n == L_('/') && (flags & FNM_FILE_NAME)) - return FNM_NOMATCH; - else if (*n == L_('.') && no_leading_period) - return FNM_NOMATCH; - break; - - case L_('\\'): - if (!(flags & FNM_NOESCAPE)) - { - c = *p++; - if (c == L_('\0')) - /* Trailing \ loses. */ - return FNM_NOMATCH; - c = FOLD (c); - } - if (n == string_end || FOLD ((UCHAR) *n) != c) - return FNM_NOMATCH; - break; - - case L_('*'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; - - res = EXT (c, p, n, string_end, no_leading_period, - flags); - if (res != -1) - return res; - } - - if (n != string_end && *n == L_('.') && no_leading_period) - return FNM_NOMATCH; - - for (c = *p++; c == L_('?') || c == L_('*'); c = *p++) - { - if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0) - { - const CHAR *endp = END (p); - if (endp != p) - { - /* This is a pattern. Skip over it. */ - p = endp; - continue; - } - } - - if (c == L_('?')) - { - /* A ? needs to match one character. */ - if (n == string_end) - /* There isn't another character; no match. */ - return FNM_NOMATCH; - else if (*n == L_('/') - && __builtin_expect (flags & FNM_FILE_NAME, 0)) - /* A slash does not match a wildcard under - FNM_FILE_NAME. */ - return FNM_NOMATCH; - else - /* One character of the string is consumed in matching - this ? wildcard, so *??? won't match if there are - less than three characters. */ - ++n; - } - } - - if (c == L_('\0')) - /* The wildcard(s) is/are the last element of the pattern. - If the name is a file name and contains another slash - this means it cannot match, unless the FNM_LEADING_DIR - flag is set. */ - { - int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; - - if (flags & FNM_FILE_NAME) - { - if (flags & FNM_LEADING_DIR) - result = 0; - else - { - if (MEMCHR (n, L_('/'), string_end - n) == NULL) - result = 0; - } - } - - return result; - } - else - { - const CHAR *endp; - - endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'), - string_end - n); - if (endp == NULL) - endp = string_end; - - if (c == L_('[') - || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0 - && (c == L_('@') || c == L_('+') || c == L_('!')) - && *p == L_('('))) - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - bool no_leading_period2 = no_leading_period; - - for (--p; n < endp; ++n, no_leading_period2 = false) - if (FCT (p, n, string_end, no_leading_period2, flags2) - == 0) - return 0; - } - else if (c == L_('/') && (flags & FNM_FILE_NAME)) - { - while (n < string_end && *n != L_('/')) - ++n; - if (n < string_end && *n == L_('/') - && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags) - == 0)) - return 0; - } - else - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - int no_leading_period2 = no_leading_period; - - if (c == L_('\\') && !(flags & FNM_NOESCAPE)) - c = *p; - c = FOLD (c); - for (--p; n < endp; ++n, no_leading_period2 = false) - if (FOLD ((UCHAR) *n) == c - && (FCT (p, n, string_end, no_leading_period2, flags2) - == 0)) - return 0; - } - } - - /* If we come here no match is possible with the wildcard. */ - return FNM_NOMATCH; - - case L_('['): - { - /* Nonzero if the sense of the character class is inverted. */ - const CHAR *p_init = p; - const CHAR *n_init = n; - register bool not; - CHAR cold; - UCHAR fn; - - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - - if (n == string_end) - return FNM_NOMATCH; - - if (*n == L_('.') && no_leading_period) - return FNM_NOMATCH; - - if (*n == L_('/') && (flags & FNM_FILE_NAME)) - /* '/' cannot be matched. */ - return FNM_NOMATCH; - - not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^'))); - if (not) - ++p; - - fn = FOLD ((UCHAR) *n); - - c = *p++; - for (;;) - { - if (!(flags & FNM_NOESCAPE) && c == L_('\\')) - { - if (*p == L_('\0')) - return FNM_NOMATCH; - c = FOLD ((UCHAR) *p); - ++p; - - goto normal_bracket; - } - else if (c == L_('[') && *p == L_(':')) - { - /* Leave room for the null. */ - CHAR str[CHAR_CLASS_MAX_LENGTH + 1]; - size_t c1 = 0; -#if defined _LIBC || WIDE_CHAR_SUPPORT - wctype_t wt; -#endif - const CHAR *startp = p; - - for (;;) - { - if (c1 == CHAR_CLASS_MAX_LENGTH) - /* The name is too long and therefore the pattern - is ill-formed. */ - return FNM_NOMATCH; - - c = *++p; - if (c == L_(':') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c < L_('a') || c >= L_('z')) - { - /* This cannot possibly be a character class name. - Match it as a normal range. */ - p = startp; - c = L_('['); - goto normal_bracket; - } - str[c1++] = c; - } - str[c1] = L_('\0'); - -#if defined _LIBC || WIDE_CHAR_SUPPORT - wt = IS_CHAR_CLASS (str); - if (wt == 0) - /* Invalid character class name. */ - return FNM_NOMATCH; - -# if defined _LIBC && ! WIDE_CHAR_VERSION - /* The following code is glibc specific but does - there a good job in speeding up the code since - we can avoid the btowc() call. */ - if (_ISCTYPE ((UCHAR) *n, wt)) - goto matched; -# else - if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) - goto matched; -# endif -#else - if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n)) - || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n)) - || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n)) - || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n)) - || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n)) - || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n)) - || (STREQ (str, L_("lower")) && islower ((UCHAR) *n)) - || (STREQ (str, L_("print")) && isprint ((UCHAR) *n)) - || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n)) - || (STREQ (str, L_("space")) && isspace ((UCHAR) *n)) - || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n)) - || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n))) - goto matched; -#endif - c = *p++; - } -#ifdef _LIBC - else if (c == L_('[') && *p == L_('=')) - { - UCHAR str[1]; - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - const CHAR *startp = p; - - c = *++p; - if (c == L_('\0')) - { - p = startp; - c = L_('['); - goto normal_bracket; - } - str[0] = c; - - c = *++p; - if (c != L_('=') || p[1] != L_(']')) - { - p = startp; - c = L_('['); - goto normal_bracket; - } - p += 2; - - if (nrules == 0) - { - if ((UCHAR) *n == str[0]) - goto matched; - } - else - { - const int32_t *table; -# if WIDE_CHAR_VERSION - const int32_t *weights; - const int32_t *extra; -# else - const unsigned char *weights; - const unsigned char *extra; -# endif - const int32_t *indirect; - int32_t idx; - const UCHAR *cp = (const UCHAR *) str; - - /* This #include defines a local function! */ -# if WIDE_CHAR_VERSION -# include -# else -# include -# endif - -# if WIDE_CHAR_VERSION - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC); - weights = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC); - extra = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC); -# else - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); -# endif - - idx = findidx (&cp); - if (idx != 0) - { - /* We found a table entry. Now see whether the - character we are currently at has the same - equivalence class value. */ - int len = weights[idx & 0xffffff]; - int32_t idx2; - const UCHAR *np = (const UCHAR *) n; - - idx2 = findidx (&np); - if (idx2 != 0 - && (idx >> 24) == (idx2 >> 24) - && len == weights[idx2 & 0xffffff]) - { - int cnt = 0; - - idx &= 0xffffff; - idx2 &= 0xffffff; - - while (cnt < len - && (weights[idx + 1 + cnt] - == weights[idx2 + 1 + cnt])) - ++cnt; - - if (cnt == len) - goto matched; - } - } - } - - c = *p++; - } -#endif - else if (c == L_('\0')) - { - /* [ unterminated, treat as normal character. */ - p = p_init; - n = n_init; - c = L_('['); - goto normal_match; - } - else - { - bool is_range = false; - -#ifdef _LIBC - bool is_seqval = false; - - if (c == L_('[') && *p == L_('.')) - { - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - const CHAR *startp = p; - size_t c1 = 0; - - while (1) - { - c = *++p; - if (c == L_('.') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c == '\0') - return FNM_NOMATCH; - ++c1; - } - - /* We have to handling the symbols differently in - ranges since then the collation sequence is - important. */ - is_range = *p == L_('-') && p[1] != L_('\0'); - - if (nrules == 0) - { - /* There are no names defined in the collation - data. Therefore we only accept the trivial - names consisting of the character itself. */ - if (c1 != 1) - return FNM_NOMATCH; - - if (!is_range && *n == startp[1]) - goto matched; - - cold = startp[1]; - c = *p++; - } - else - { - int32_t table_size; - const int32_t *symb_table; -# ifdef WIDE_CHAR_VERSION - char str[c1]; - size_t strcnt; -# else -# define str (startp + 1) -# endif - const unsigned char *extra; - int32_t idx; - int32_t elem; - int32_t second; - int32_t hash; - -# ifdef WIDE_CHAR_VERSION - /* We have to convert the name to a single-byte - string. This is possible since the names - consist of ASCII characters and the internal - representation is UCS4. */ - for (strcnt = 0; strcnt < c1; ++strcnt) - str[strcnt] = startp[1 + strcnt]; -# endif - - table_size = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); - - /* Locate the character in the hashing table. */ - hash = elem_hash (str, c1); - - idx = 0; - elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - second = hash % (table_size - 2) + 1; - - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - && (c1 - == extra[symb_table[2 * elem + 1]]) - && memcmp (str, - &extra[symb_table[2 * elem - + 1] - + 1], c1) == 0) - { - /* Yep, this is the entry. */ - idx = symb_table[2 * elem + 1]; - idx += 1 + extra[idx]; - break; - } - - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } - - if (symb_table[2 * elem] != 0) - { - /* Compare the byte sequence but only if - this is not part of a range. */ -# ifdef WIDE_CHAR_VERSION - int32_t *wextra; - - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; - - wextra = (int32_t *) &extra[idx + 4]; -# endif - - if (! is_range) - { -# ifdef WIDE_CHAR_VERSION - for (c1 = 0; - (int32_t) c1 < wextra[idx]; - ++c1) - if (n[c1] != wextra[1 + c1]) - break; - - if ((int32_t) c1 == wextra[idx]) - goto matched; -# else - for (c1 = 0; c1 < extra[idx]; ++c1) - if (n[c1] != extra[1 + c1]) - break; - - if (c1 == extra[idx]) - goto matched; -# endif - } - - /* Get the collation sequence value. */ - is_seqval = true; -# ifdef WIDE_CHAR_VERSION - cold = wextra[1 + wextra[idx]]; -# else - /* Adjust for the alignment. */ - idx += 1 + extra[idx]; - idx = (idx + 3) & ~4; - cold = *((int32_t *) &extra[idx]); -# endif - - c = *p++; - } - else if (c1 == 1) - { - /* No valid character. Match it as a - single byte. */ - if (!is_range && *n == str[0]) - goto matched; - - cold = str[0]; - c = *p++; - } - else - return FNM_NOMATCH; - } - } - else -# undef str -#endif - { - c = FOLD (c); - normal_bracket: - - /* We have to handling the symbols differently in - ranges since then the collation sequence is - important. */ - is_range = (*p == L_('-') && p[1] != L_('\0') - && p[1] != L_(']')); - - if (!is_range && c == fn) - goto matched; - -#if _LIBC - /* This is needed if we goto normal_bracket; from - outside of is_seqval's scope. */ - is_seqval = false; -#endif - - cold = c; - c = *p++; - } - - if (c == L_('-') && *p != L_(']')) - { -#if _LIBC - /* We have to find the collation sequence - value for C. Collation sequence is nothing - we can regularly access. The sequence - value is defined by the order in which the - definitions of the collation values for the - various characters appear in the source - file. A strange concept, nowhere - documented. */ - uint32_t fcollseq; - uint32_t lcollseq; - UCHAR cend = *p++; - -# ifdef WIDE_CHAR_VERSION - /* Search in the 'names' array for the characters. */ - fcollseq = __collseq_table_lookup (collseq, fn); - if (fcollseq == ~((uint32_t) 0)) - /* XXX We don't know anything about the character - we are supposed to match. This means we are - failing. */ - goto range_not_matched; - - if (is_seqval) - lcollseq = cold; - else - lcollseq = __collseq_table_lookup (collseq, cold); -# else - fcollseq = collseq[fn]; - lcollseq = is_seqval ? cold : collseq[(UCHAR) cold]; -# endif - - is_seqval = false; - if (cend == L_('[') && *p == L_('.')) - { - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_NRULES); - const CHAR *startp = p; - size_t c1 = 0; - - while (1) - { - c = *++p; - if (c == L_('.') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c == '\0') - return FNM_NOMATCH; - ++c1; - } - - if (nrules == 0) - { - /* There are no names defined in the - collation data. Therefore we only - accept the trivial names consisting - of the character itself. */ - if (c1 != 1) - return FNM_NOMATCH; - - cend = startp[1]; - } - else - { - int32_t table_size; - const int32_t *symb_table; -# ifdef WIDE_CHAR_VERSION - char str[c1]; - size_t strcnt; -# else -# define str (startp + 1) -# endif - const unsigned char *extra; - int32_t idx; - int32_t elem; - int32_t second; - int32_t hash; - -# ifdef WIDE_CHAR_VERSION - /* We have to convert the name to a single-byte - string. This is possible since the names - consist of ASCII characters and the internal - representation is UCS4. */ - for (strcnt = 0; strcnt < c1; ++strcnt) - str[strcnt] = startp[1 + strcnt]; -# endif - - table_size = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); - - /* Locate the character in the hashing - table. */ - hash = elem_hash (str, c1); - - idx = 0; - elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - second = hash % (table_size - 2) + 1; - - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - && (c1 - == extra[symb_table[2 * elem + 1]]) - && memcmp (str, - &extra[symb_table[2 * elem + 1] - + 1], c1) == 0) - { - /* Yep, this is the entry. */ - idx = symb_table[2 * elem + 1]; - idx += 1 + extra[idx]; - break; - } - - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } - - if (symb_table[2 * elem] != 0) - { - /* Compare the byte sequence but only if - this is not part of a range. */ -# ifdef WIDE_CHAR_VERSION - int32_t *wextra; - - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~4; - - wextra = (int32_t *) &extra[idx + 4]; -# endif - /* Get the collation sequence value. */ - is_seqval = true; -# ifdef WIDE_CHAR_VERSION - cend = wextra[1 + wextra[idx]]; -# else - /* Adjust for the alignment. */ - idx += 1 + extra[idx]; - idx = (idx + 3) & ~4; - cend = *((int32_t *) &extra[idx]); -# endif - } - else if (symb_table[2 * elem] != 0 && c1 == 1) - { - cend = str[0]; - c = *p++; - } - else - return FNM_NOMATCH; - } -# undef str - } - else - { - if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) - cend = *p++; - if (cend == L_('\0')) - return FNM_NOMATCH; - cend = FOLD (cend); - } - - /* XXX It is not entirely clear to me how to handle - characters which are not mentioned in the - collation specification. */ - if ( -# ifdef WIDE_CHAR_VERSION - lcollseq == 0xffffffff || -# endif - lcollseq <= fcollseq) - { - /* We have to look at the upper bound. */ - uint32_t hcollseq; - - if (is_seqval) - hcollseq = cend; - else - { -# ifdef WIDE_CHAR_VERSION - hcollseq = - __collseq_table_lookup (collseq, cend); - if (hcollseq == ~((uint32_t) 0)) - { - /* Hum, no information about the upper - bound. The matching succeeds if the - lower bound is matched exactly. */ - if (lcollseq != fcollseq) - goto range_not_matched; - - goto matched; - } -# else - hcollseq = collseq[cend]; -# endif - } - - if (lcollseq <= hcollseq && fcollseq <= hcollseq) - goto matched; - } -# ifdef WIDE_CHAR_VERSION - range_not_matched: -# endif -#else - /* We use a boring value comparison of the character - values. This is better than comparing using - 'strcoll' since the latter would have surprising - and sometimes fatal consequences. */ - UCHAR cend = *p++; - - if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) - cend = *p++; - if (cend == L_('\0')) - return FNM_NOMATCH; - - /* It is a range. */ - if (cold <= fn && fn <= cend) - goto matched; -#endif - - c = *p++; - } - } - - if (c == L_(']')) - break; - } - - if (!not) - return FNM_NOMATCH; - break; - - matched: - /* Skip the rest of the [...] that already matched. */ - do - { - ignore_next: - c = *p++; - - if (c == L_('\0')) - /* [... (unterminated) loses. */ - return FNM_NOMATCH; - - if (!(flags & FNM_NOESCAPE) && c == L_('\\')) - { - if (*p == L_('\0')) - return FNM_NOMATCH; - /* XXX 1003.2d11 is unclear if this is right. */ - ++p; - } - else if (c == L_('[') && *p == L_(':')) - { - int c1 = 0; - const CHAR *startp = p; - - while (1) - { - c = *++p; - if (++c1 == CHAR_CLASS_MAX_LENGTH) - return FNM_NOMATCH; - - if (*p == L_(':') && p[1] == L_(']')) - break; - - if (c < L_('a') || c >= L_('z')) - { - p = startp; - goto ignore_next; - } - } - p += 2; - c = *p++; - } - else if (c == L_('[') && *p == L_('=')) - { - c = *++p; - if (c == L_('\0')) - return FNM_NOMATCH; - c = *++p; - if (c != L_('=') || p[1] != L_(']')) - return FNM_NOMATCH; - p += 2; - c = *p++; - } - else if (c == L_('[') && *p == L_('.')) - { - ++p; - while (1) - { - c = *++p; - if (c == '\0') - return FNM_NOMATCH; - - if (*p == L_('.') && p[1] == L_(']')) - break; - } - p += 2; - c = *p++; - } - } - while (c != L_(']')); - if (not) - return FNM_NOMATCH; - } - break; - - case L_('+'): - case L_('@'): - case L_('!'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; - - res = EXT (c, p, n, string_end, no_leading_period, flags); - if (res != -1) - return res; - } - goto normal_match; - - case L_('/'): - if (NO_LEADING_PERIOD (flags)) - { - if (n == string_end || c != (UCHAR) *n) - return FNM_NOMATCH; - - new_no_leading_period = true; - break; - } - /* FALLTHROUGH */ - default: - normal_match: - if (n == string_end || c != FOLD ((UCHAR) *n)) - return FNM_NOMATCH; - } - - no_leading_period = new_no_leading_period; - ++n; - } - - if (n == string_end) - return 0; - - if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/')) - /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ - return 0; - - return FNM_NOMATCH; -} - - -static const CHAR * -internal_function -END (const CHAR *pattern) -{ - const CHAR *p = pattern; - - while (1) - if (*++p == L_('\0')) - /* This is an invalid pattern. */ - return pattern; - else if (*p == L_('[')) - { - /* Handle brackets special. */ - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - - /* Skip the not sign. We have to recognize it because of a possibly - following ']'. */ - if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) - ++p; - /* A leading ']' is recognized as such. */ - if (*p == L_(']')) - ++p; - /* Skip over all characters of the list. */ - while (*p != L_(']')) - if (*p++ == L_('\0')) - /* This is no valid pattern. */ - return pattern; - } - else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') - || *p == L_('!')) && p[1] == L_('(')) - p = END (p + 1); - else if (*p == L_(')')) - break; - - return p + 1; -} - - -static int -internal_function -EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, - bool no_leading_period, int flags) -{ - const CHAR *startp; - size_t level; - struct patternlist - { - struct patternlist *next; - CHAR str[1]; - } *list = NULL; - struct patternlist **lastp = &list; - size_t pattern_len = STRLEN (pattern); - const CHAR *p; - const CHAR *rs; - enum { ALLOCA_LIMIT = 8000 }; - - /* Parse the pattern. Store the individual parts in the list. */ - level = 0; - for (startp = p = pattern + 1; ; ++p) - if (*p == L_('\0')) - /* This is an invalid pattern. */ - return -1; - else if (*p == L_('[')) - { - /* Handle brackets special. */ - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - - /* Skip the not sign. We have to recognize it because of a possibly - following ']'. */ - if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) - ++p; - /* A leading ']' is recognized as such. */ - if (*p == L_(']')) - ++p; - /* Skip over all characters of the list. */ - while (*p != L_(']')) - if (*p++ == L_('\0')) - /* This is no valid pattern. */ - return -1; - } - else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') - || *p == L_('!')) && p[1] == L_('(')) - /* Remember the nesting level. */ - ++level; - else if (*p == L_(')')) - { - if (level-- == 0) - { - /* This means we found the end of the pattern. */ -#define NEW_PATTERN \ - struct patternlist *newp; \ - size_t plen; \ - size_t plensize; \ - size_t newpsize; \ - \ - plen = (opt == L_('?') || opt == L_('@') \ - ? pattern_len \ - : p - startp + 1UL); \ - plensize = plen * sizeof (CHAR); \ - newpsize = offsetof (struct patternlist, str) + plensize; \ - if ((size_t) -1 / sizeof (CHAR) < plen \ - || newpsize < offsetof (struct patternlist, str) \ - || ALLOCA_LIMIT <= newpsize) \ - return -1; \ - newp = (struct patternlist *) alloca (newpsize); \ - *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \ - newp->next = NULL; \ - *lastp = newp; \ - lastp = &newp->next - NEW_PATTERN; - break; - } - } - else if (*p == L_('|')) - { - if (level == 0) - { - NEW_PATTERN; - startp = p + 1; - } - } - assert (list != NULL); - assert (p[-1] == L_(')')); -#undef NEW_PATTERN - - switch (opt) - { - case L_('*'): - if (FCT (p, string, string_end, no_leading_period, flags) == 0) - return 0; - /* FALLTHROUGH */ - - case L_('+'): - do - { - for (rs = string; rs <= string_end; ++rs) - /* First match the prefix with the current pattern with the - current pattern. */ - if (FCT (list->str, string, rs, no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0 - /* This was successful. Now match the rest with the rest - of the pattern. */ - && (FCT (p, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME - ? flags : flags & ~FNM_PERIOD) == 0 - /* This didn't work. Try the whole pattern. */ - || (rs != string - && FCT (pattern - 1, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME - ? flags : flags & ~FNM_PERIOD) == 0))) - /* It worked. Signal success. */ - return 0; - } - while ((list = list->next) != NULL); - - /* None of the patterns lead to a match. */ - return FNM_NOMATCH; - - case L_('?'): - if (FCT (p, string, string_end, no_leading_period, flags) == 0) - return 0; - /* FALLTHROUGH */ - - case L_('@'): - do - /* I cannot believe it but 'strcat' is actually acceptable - here. Match the entire string with the prefix from the - pattern list and the rest of the pattern following the - pattern list. */ - if (FCT (STRCAT (list->str, p), string, string_end, - no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) - /* It worked. Signal success. */ - return 0; - while ((list = list->next) != NULL); - - /* None of the patterns lead to a match. */ - return FNM_NOMATCH; - - case L_('!'): - for (rs = string; rs <= string_end; ++rs) - { - struct patternlist *runp; - - for (runp = list; runp != NULL; runp = runp->next) - if (FCT (runp->str, string, rs, no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) - break; - - /* If none of the patterns matched see whether the rest does. */ - if (runp == NULL - && (FCT (p, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) - == 0)) - /* This is successful. */ - return 0; - } - - /* None of the patterns together with the rest of the pattern - lead to a match. */ - return FNM_NOMATCH; - - default: - assert (! "Invalid extended matching operator"); - break; - } - - return -1; -} - - -#undef FOLD -#undef CHAR -#undef UCHAR -#undef INT -#undef FCT -#undef EXT -#undef END -#undef MEMPCPY -#undef MEMCHR -#undef STRLEN -#undef STRCAT -#undef L_ -#undef BTOWC diff --git a/grub-core/gnulib/getdelim.c b/grub-core/gnulib/getdelim.c deleted file mode 100644 index fdbcde2a2..000000000 --- a/grub-core/gnulib/getdelim.c +++ /dev/null @@ -1,135 +0,0 @@ -/* getdelim.c --- Implementation of replacement getdelim function. - Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2013 Free Software - Foundation, Inc. - - This program 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, 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Ported from glibc by Simon Josefsson. */ - -/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc - optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */ -#define _GL_ARG_NONNULL(params) - -#include - -#include - -#include -#include -#include -#include - -#ifndef SSIZE_MAX -# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) -#endif - -#if USE_UNLOCKED_IO -# include "unlocked-io.h" -# define getc_maybe_unlocked(fp) getc(fp) -#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED -# undef flockfile -# undef funlockfile -# define flockfile(x) ((void) 0) -# define funlockfile(x) ((void) 0) -# define getc_maybe_unlocked(fp) getc(fp) -#else -# define getc_maybe_unlocked(fp) getc_unlocked(fp) -#endif - -/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and - NUL-terminate it). *LINEPTR is a pointer returned from malloc (or - NULL), pointing to *N characters of space. It is realloc'ed as - necessary. Returns the number of characters read (not including - the null terminator), or -1 on error or EOF. */ - -ssize_t -getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) -{ - ssize_t result; - size_t cur_len = 0; - - if (lineptr == NULL || n == NULL || fp == NULL) - { - errno = EINVAL; - return -1; - } - - flockfile (fp); - - if (*lineptr == NULL || *n == 0) - { - char *new_lineptr; - *n = 120; - new_lineptr = (char *) realloc (*lineptr, *n); - if (new_lineptr == NULL) - { - result = -1; - goto unlock_return; - } - *lineptr = new_lineptr; - } - - for (;;) - { - int i; - - i = getc_maybe_unlocked (fp); - if (i == EOF) - { - result = -1; - break; - } - - /* Make enough space for len+1 (for final NUL) bytes. */ - if (cur_len + 1 >= *n) - { - size_t needed_max = - SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; - size_t needed = 2 * *n + 1; /* Be generous. */ - char *new_lineptr; - - if (needed_max < needed) - needed = needed_max; - if (cur_len + 1 >= needed) - { - result = -1; - errno = EOVERFLOW; - goto unlock_return; - } - - new_lineptr = (char *) realloc (*lineptr, needed); - if (new_lineptr == NULL) - { - result = -1; - goto unlock_return; - } - - *lineptr = new_lineptr; - *n = needed; - } - - (*lineptr)[cur_len] = i; - cur_len++; - - if (i == delimiter) - break; - } - (*lineptr)[cur_len] = '\0'; - result = cur_len ? cur_len : result; - - unlock_return: - funlockfile (fp); /* doesn't set errno */ - - return result; -} diff --git a/grub-core/gnulib/getline.c b/grub-core/gnulib/getline.c deleted file mode 100644 index 1aa07b9c7..000000000 --- a/grub-core/gnulib/getline.c +++ /dev/null @@ -1,27 +0,0 @@ -/* getline.c --- Implementation of replacement getline function. - Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Written by Simon Josefsson. */ - -#include - -#include - -ssize_t -getline (char **lineptr, size_t *n, FILE *stream) -{ - return getdelim (lineptr, n, '\n', stream); -} diff --git a/grub-core/gnulib/getopt.c b/grub-core/gnulib/getopt.c deleted file mode 100644 index ef0f4ceec..000000000 --- a/grub-core/gnulib/getopt.c +++ /dev/null @@ -1,1245 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _LIBC -# include -#endif - -#include "getopt.h" - -#include -#include -#include -#include - -#ifdef _LIBC -# include -#else -# include "gettext.h" -# define _(msgid) gettext (msgid) -#endif - -#if defined _LIBC && defined USE_IN_LIBIO -# include -#endif - -/* This version of 'getopt' appears to the caller like standard Unix 'getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As 'getopt_long' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Using 'getopt' or setting the environment variable POSIXLY_CORRECT - disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt_int.h" - -/* For communication from 'getopt' to the caller. - When 'getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when 'ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to 'getopt'. - - On entry to 'getopt', zero means this is the first call; initialize. - - When 'getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, 'optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Keep a global copy of all internal members of getopt_data. */ - -static struct _getopt_data getopt_data; - - -#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV -extern char *getenv (); -#endif - -#ifdef _LIBC -/* Stored original parameters. - XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ -extern int __libc_argc; -extern char **__libc_argv; - -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -# ifdef USE_NONOPTION_FLAGS -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; -# endif - -# ifdef USE_NONOPTION_FLAGS -# define SWAP_FLAGS(ch1, ch2) \ - if (d->__nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -# else -# define SWAP_FLAGS(ch1, ch2) -# endif -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - 'first_nonopt' and 'last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -static void -exchange (char **argv, struct _getopt_data *d) -{ - int bottom = d->__first_nonopt; - int middle = d->__last_nonopt; - int top = d->optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - /* First make sure the handling of the '__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - d->__nonoption_flags_max_len), - '\0', top + 1 - d->__nonoption_flags_max_len); - d->__nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - d->__first_nonopt += (d->optind - d->__last_nonopt); - d->__last_nonopt = d->optind; -} - -/* Initialize the internal data when the first call is made. */ - -static const char * -_getopt_initialize (int argc _GL_UNUSED, - char **argv _GL_UNUSED, const char *optstring, - struct _getopt_data *d, int posixly_correct) -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - d->__first_nonopt = d->__last_nonopt = d->optind; - - d->__nextchar = NULL; - - d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - d->__ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - d->__ordering = REQUIRE_ORDER; - ++optstring; - } - else if (d->__posixly_correct) - d->__ordering = REQUIRE_ORDER; - else - d->__ordering = PERMUTE; - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - if (!d->__posixly_correct - && argc == __libc_argc && argv == __libc_argv) - { - if (d->__nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - d->__nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = d->__nonoption_flags_max_len = strlen (orig_str); - if (d->__nonoption_flags_max_len < argc) - d->__nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (d->__nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - d->__nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', d->__nonoption_flags_max_len - len); - } - } - d->__nonoption_flags_len = d->__nonoption_flags_max_len; - } - else - d->__nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If 'getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If 'getopt' finds another option character, it returns that character, - updating 'optind' and 'nextchar' so that the next call to 'getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, 'getopt' returns -1. - Then 'optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set 'opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in 'optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in 'optarg', otherwise 'optarg' is set to zero. - - If OPTSTRING starts with '-' or '+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with '--' instead of '-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a '=', or else the in next ARGV-element. - When 'getopt' finds a long-named option, it returns 0 if that option's - 'flag' field is nonzero, the value of the option's 'val' field - if the 'flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of 'struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal_r (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, - int long_only, struct _getopt_data *d, int posixly_correct) -{ - int print_errors = d->opterr; - - if (argc < 1) - return -1; - - d->optarg = NULL; - - if (d->optind == 0 || !d->__initialized) - { - if (d->optind == 0) - d->optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring, d, - posixly_correct); - d->__initialized = 1; - } - else if (optstring[0] == '-' || optstring[0] == '+') - optstring++; - if (optstring[0] == ':') - print_errors = 0; - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#if defined _LIBC && defined USE_NONOPTION_FLAGS -# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ - || (d->optind < d->__nonoption_flags_len \ - && __getopt_nonoption_flags[d->optind] == '1')) -#else -# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') -#endif - - if (d->__nextchar == NULL || *d->__nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (d->__last_nonopt > d->optind) - d->__last_nonopt = d->optind; - if (d->__first_nonopt > d->optind) - d->__first_nonopt = d->optind; - - if (d->__ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__last_nonopt != d->optind) - d->__first_nonopt = d->optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (d->optind < argc && NONOPTION_P) - d->optind++; - d->__last_nonopt = d->optind; - } - - /* The special ARGV-element '--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (d->optind != argc && !strcmp (argv[d->optind], "--")) - { - d->optind++; - - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__first_nonopt == d->__last_nonopt) - d->__first_nonopt = d->optind; - d->__last_nonopt = argc; - - d->optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (d->optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (d->__first_nonopt != d->__last_nonopt) - d->optind = d->__first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (d->__ordering == REQUIRE_ORDER) - return -1; - d->optarg = argv[d->optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - d->__nextchar = (argv[d->optind] + 1 - + (longopts != NULL && argv[d->optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[d->optind][1] == '-' - || (long_only && (argv[d->optind][2] - || !strchr (optstring, argv[d->optind][1]))))) - { - char *nameend; - unsigned int namelen; - const struct option *p; - const struct option *pfound = NULL; - struct option_list - { - const struct option *p; - struct option_list *next; - } *ambig_list = NULL; - int exact = 0; - int indfound = -1; - int option_index; - - for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - namelen = nameend - d->__nextchar; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, namelen)) - { - if (namelen == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - { - /* Second or later nonexact match found. */ - struct option_list *newp = malloc (sizeof (*newp)); - newp->p = p; - newp->next = ambig_list; - ambig_list = newp; - } - } - - if (ambig_list != NULL && !exact) - { - if (print_errors) - { - struct option_list first; - first.p = pfound; - first.next = ambig_list; - ambig_list = &first; - -#if defined _LIBC && defined USE_IN_LIBIO - char *buf = NULL; - size_t buflen = 0; - - FILE *fp = open_memstream (&buf, &buflen); - if (fp != NULL) - { - fprintf (fp, - _("%s: option '%s' is ambiguous; possibilities:"), - argv[0], argv[d->optind]); - - do - { - fprintf (fp, " '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - - fputc_unlocked ('\n', fp); - - if (__builtin_expect (fclose (fp) != EOF, 1)) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } - } -#else - fprintf (stderr, - _("%s: option '%s' is ambiguous; possibilities:"), - argv[0], argv[d->optind]); - do - { - fprintf (stderr, " '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - - fputc ('\n', stderr); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - d->optopt = 0; - return '?'; - } - - while (ambig_list != NULL) - { - struct option_list *pn = ambig_list->next; - free (ambig_list); - ambig_list = pn; - } - - if (pfound != NULL) - { - option_index = indfound; - d->optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[d->optind - 1][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option '--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#else - fprintf (stderr, _("\ -%s: option '--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option '%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); -#else - fprintf (stderr, _("\ -%s: option '%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - - d->__nextchar += strlen (d->__nextchar); - - d->optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '--%s' requires an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option '--%s' requires an argument\n"), - argv[0], pfound->name); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[d->optind][1] == '-' - || strchr (optstring, *d->__nextchar) == NULL) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[d->optind][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), - argv[0], d->__nextchar); -#else - fprintf (stderr, _("%s: unrecognized option '--%s'\n"), - argv[0], d->__nextchar); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); -#else - fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - d->__nextchar = (char *) ""; - d->optind++; - d->optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *d->__nextchar++; - const char *temp = strchr (optstring, c); - - /* Increment 'optind' when we start to process its last character. */ - if (*d->__nextchar == '\0') - ++d->optind; - - if (temp == NULL || c == ':' || c == ';') - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), - argv[0], c); -#else - fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); -#endif - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - d->optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - if (longopts == NULL) - goto no_longs; - - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c); -#endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented 'd->optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; - nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), - argv[0], d->optarg) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), - argv[0], d->optarg); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '-W %s' doesn't allow an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("\ -%s: option '-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - - d->__nextchar += strlen (d->__nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '-W %s' requires an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("\ -%s: option '-W %s' requires an argument\n"), - argv[0], pfound->name); -#endif - } - d->__nextchar += strlen (d->__nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - else - d->optarg = NULL; - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - no_longs: - d->__nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else - d->optarg = NULL; - d->__nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option requires an argument -- '%c'\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c); -#endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented 'optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; - d->__nextchar = NULL; - } - } - return c; - } -} - -int -_getopt_internal (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, int long_only, - int posixly_correct) -{ - int result; - - getopt_data.optind = optind; - getopt_data.opterr = opterr; - - result = _getopt_internal_r (argc, argv, optstring, longopts, - longind, long_only, &getopt_data, - posixly_correct); - - optind = getopt_data.optind; - optarg = getopt_data.optarg; - optopt = getopt_data.optopt; - - return result; -} - -/* glibc gets a LSB-compliant getopt. - Standalone applications get a POSIX-compliant getopt. */ -#if _LIBC -enum { POSIXLY_CORRECT = 0 }; -#else -enum { POSIXLY_CORRECT = 1 }; -#endif - -int -getopt (int argc, char *const *argv, const char *optstring) -{ - return _getopt_internal (argc, (char **) argv, optstring, - (const struct option *) 0, - (int *) 0, - 0, POSIXLY_CORRECT); -} - -#ifdef _LIBC -int -__posix_getopt (int argc, char *const *argv, const char *optstring) -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0, 1); -} -#endif - - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of 'getopt'. */ - -int -main (int argc, char **argv) -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value '%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/grub-core/gnulib/getopt.in.h b/grub-core/gnulib/getopt.in.h deleted file mode 100644 index d9c7d8144..000000000 --- a/grub-core/gnulib/getopt.in.h +++ /dev/null @@ -1,255 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _@GUARD_PREFIX@_GETOPT_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. We must - also inform the replacement unistd.h to not recursively use - ; our definitions will be present soon enough. */ -#if @HAVE_GETOPT_H@ -# define _GL_SYSTEM_GETOPT -# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ -# undef _GL_SYSTEM_GETOPT -#endif - -#ifndef _@GUARD_PREFIX@_GETOPT_H - -#ifndef __need_getopt -# define _@GUARD_PREFIX@_GETOPT_H 1 -#endif - -/* Standalone applications should #define __GETOPT_PREFIX to an - identifier that prefixes the external functions and variables - defined in this header. When this happens, include the - headers that might declare getopt so that they will not cause - confusion if included after this file (if the system had , - we have already included it). Then systematically rename - identifiers so that they do not collide with the system functions - and variables. Renaming avoids problems with some compilers and - linkers. */ -#if defined __GETOPT_PREFIX && !defined __need_getopt -# if !@HAVE_GETOPT_H@ -# define __need_system_stdlib_h -# include -# undef __need_system_stdlib_h -# include -# include -# endif -# undef __need_getopt -# undef getopt -# undef getopt_long -# undef getopt_long_only -# undef optarg -# undef opterr -# undef optind -# undef optopt -# undef option -# define __GETOPT_CONCAT(x, y) x ## y -# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) -# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) -# define getopt __GETOPT_ID (getopt) -# define getopt_long __GETOPT_ID (getopt_long) -# define getopt_long_only __GETOPT_ID (getopt_long_only) -# define optarg __GETOPT_ID (optarg) -# define opterr __GETOPT_ID (opterr) -# define optind __GETOPT_ID (optind) -# define optopt __GETOPT_ID (optopt) -# define option __GETOPT_ID (option) -# define _getopt_internal __GETOPT_ID (getopt_internal) -#endif - -/* Standalone applications get correct prototypes for getopt_long and - getopt_long_only; they declare "char **argv". libc uses prototypes - with "char *const *argv" that are incorrect because getopt_long and - getopt_long_only can permute argv; this is required for backward - compatibility (e.g., for LSB 2.0.1). - - This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', - but it caused redefinition warnings if both unistd.h and getopt.h were - included, since unistd.h includes getopt.h having previously defined - __need_getopt. - - The only place where __getopt_argv_const is used is in definitions - of getopt_long and getopt_long_only below, but these are visible - only if __need_getopt is not defined, so it is quite safe to rewrite - the conditional as follows: -*/ -#if !defined __need_getopt -# if defined __GETOPT_PREFIX -# define __getopt_argv_const /* empty */ -# else -# define __getopt_argv_const const -# endif -#endif - -/* If __GNU_LIBRARY__ is not already defined, either we are being used - standalone, or this is the first header included in the source file. - If we are being used with glibc, we need to include , but - that does not exist if we are standalone. So: if __GNU_LIBRARY__ is - not defined, include , which will pull in for us - if it's from glibc. (Why ctype.h? It's guaranteed to exist and it - doesn't flood the namespace with stuff the way some other headers do.) */ -#if !defined __GNU_LIBRARY__ -# include -#endif - -#ifndef __THROW -# ifndef __GNUC_PREREQ -# define __GNUC_PREREQ(maj, min) (0) -# endif -# if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW throw () -# else -# define __THROW -# endif -#endif - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from 'getopt' to the caller. - When 'getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when 'ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to 'getopt'. - - On entry to 'getopt', zero means this is the first call; initialize. - - When 'getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, 'optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message 'getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -#ifndef __need_getopt -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of 'struct option' terminated by an element containing a name which is - zero. - - The field 'has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field 'flag' is not NULL, it points to a variable that is set - to the value given in the field 'val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an 'int' to - a compiled-in constant, such as set a value from 'optarg', set the - option's 'flag' field to zero and its 'val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero 'flag' field, 'getopt' - returns the contents of the 'val' field. */ - -# if !GNULIB_defined_struct_option -struct option -{ - const char *name; - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; -# define GNULIB_defined_struct_option 1 -# endif - -/* Names for the values of the 'has_arg' field of 'struct option'. */ - -# define no_argument 0 -# define required_argument 1 -# define optional_argument 2 -#endif /* need getopt */ - - -/* Get definitions and prototypes for functions to process the - arguments in ARGV (ARGC of them, minus the program name) for - options given in OPTS. - - Return the option character from OPTS just read. Return -1 when - there are no more options. For unrecognized options, or options - missing arguments, 'optopt' is set to the option letter, and '?' is - returned. - - The OPTS string is a list of characters which are recognized option - letters, optionally followed by colons, specifying that that letter - takes an argument, to be placed in 'optarg'. - - If a letter in OPTS is followed by two colons, its argument is - optional. This behavior is specific to the GNU 'getopt'. - - The argument '--' causes premature termination of argument - scanning, explicitly telling 'getopt' that there are no more - options. - - If OPTS begins with '-', then non-option arguments are treated as - arguments to the option '\1'. This behavior is specific to the GNU - 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in - the environment, then do not permute arguments. */ - -extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) - __THROW _GL_ARG_NONNULL ((2, 3)); - -#ifndef __need_getopt -extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW _GL_ARG_NONNULL ((2, 3)); -extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW _GL_ARG_NONNULL ((2, 3)); - -#endif - -#ifdef __cplusplus -} -#endif - -/* Make sure we later can get all the definitions and declarations. */ -#undef __need_getopt - -#endif /* _@GUARD_PREFIX@_GETOPT_H */ -#endif /* _@GUARD_PREFIX@_GETOPT_H */ diff --git a/grub-core/gnulib/getopt1.c b/grub-core/gnulib/getopt1.c deleted file mode 100644 index 55a6b4eae..000000000 --- a/grub-core/gnulib/getopt1.c +++ /dev/null @@ -1,170 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef _LIBC -# include -#else -# include -# include "getopt.h" -#endif -#include "getopt_int.h" - -#include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, - const struct option *long_options, int *opt_index) -{ - return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 0, 0); -} - -int -_getopt_long_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) -{ - return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 0, d, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (int argc, char *__getopt_argv_const *argv, - const char *options, - const struct option *long_options, int *opt_index) -{ - return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 1, 0); -} - -int -_getopt_long_only_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) -{ - return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 1, d, 0); -} - - -#ifdef TEST - -#include - -int -main (int argc, char **argv) -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static const struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value '%s'\n", optarg); - break; - - case 'd': - printf ("option d with value '%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/grub-core/gnulib/getopt_int.h b/grub-core/gnulib/getopt_int.h deleted file mode 100644 index a6e4b9ea7..000000000 --- a/grub-core/gnulib/getopt_int.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Internal declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GETOPT_INT_H -#define _GETOPT_INT_H 1 - -#include - -extern int _getopt_internal (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, int __posixly_correct); - - -/* Reentrant versions which can handle parsing multiple argument - vectors at the same time. */ - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using '+' as the first character - of the list of option characters, or by calling getopt. - - PERMUTE is the default. We permute the contents of ARGV as we - scan, so that eventually all the non-options are at the end. - This allows options to be given in any order, even with programs - that were not written to expect this. - - RETURN_IN_ORDER is an option available to programs that were - written to expect options and other ARGV-elements in any order - and that care about the ordering of the two. We describe each - non-option ARGV-element as if it were the argument of an option - with character code 1. Using '-' as the first character of the - list of option characters selects this mode of operation. - - The special argument '--' forces an end of option-scanning regardless - of the value of 'ordering'. In the case of RETURN_IN_ORDER, only - '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */ - -enum __ord - { - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER - }; - -/* Data type for reentrant functions. */ -struct _getopt_data -{ - /* These have exactly the same meaning as the corresponding global - variables, except that they are used for the reentrant - versions of getopt. */ - int optind; - int opterr; - int optopt; - char *optarg; - - /* Internal members. */ - - /* True if the internal members have been initialized. */ - int __initialized; - - /* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - char *__nextchar; - - /* See __ord above. */ - enum __ord __ordering; - - /* If the POSIXLY_CORRECT environment variable is set - or getopt was called. */ - int __posixly_correct; - - - /* Handle permutation of arguments. */ - - /* Describe the part of ARGV that contains non-options that have - been skipped. 'first_nonopt' is the index in ARGV of the first - of them; 'last_nonopt' is the index after the last of them. */ - - int __first_nonopt; - int __last_nonopt; - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - int __nonoption_flags_max_len; - int __nonoption_flags_len; -#endif -}; - -/* The initializer is necessary to set OPTIND and OPTERR to their - default values and to clear the initialization flag. */ -#define _GETOPT_DATA_INITIALIZER { 1, 1 } - -extern int _getopt_internal_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, struct _getopt_data *__data, - int __posixly_correct); - -extern int _getopt_long_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - struct _getopt_data *__data); - -extern int _getopt_long_only_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, - int *__longind, - struct _getopt_data *__data); - -#endif /* getopt_int.h */ diff --git a/grub-core/gnulib/gettext.h b/grub-core/gnulib/gettext.h deleted file mode 100644 index d0215715a..000000000 --- a/grub-core/gnulib/gettext.h +++ /dev/null @@ -1,288 +0,0 @@ -/* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software - Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _LIBGETTEXT_H -#define _LIBGETTEXT_H 1 - -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS - -/* Get declarations of GNU message catalog functions. */ -# include - -/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by - the gettext() and ngettext() macros. This is an alternative to calling - textdomain(), and is useful for libraries. */ -# ifdef DEFAULT_TEXT_DOMAIN -# undef gettext -# define gettext(Msgid) \ - dgettext (DEFAULT_TEXT_DOMAIN, Msgid) -# undef ngettext -# define ngettext(Msgid1, Msgid2, N) \ - dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) -# endif - -#else - -/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which - chokes if dcgettext is defined as a macro. So include it now, to make - later inclusions of a NOP. We don't include - as well because people using "gettext.h" will not include , - and also including would fail on SunOS 4, whereas - is OK. */ -#if defined(__sun) -# include -#endif - -/* Many header files from the libstdc++ coming with g++ 3.3 or newer include - , which chokes if dcgettext is defined as a macro. So include - it now, to make later inclusions of a NOP. */ -#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) -# include -# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H -# include -# endif -#endif - -/* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# undef gettext -# define gettext(Msgid) ((const char *) (Msgid)) -# undef dgettext -# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) -# undef dcgettext -# define dcgettext(Domainname, Msgid, Category) \ - ((void) (Category), dgettext (Domainname, Msgid)) -# undef ngettext -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 \ - ? ((void) (Msgid2), (const char *) (Msgid1)) \ - : ((void) (Msgid1), (const char *) (Msgid2))) -# undef dngettext -# define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) -# undef dcngettext -# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) -# undef textdomain -# define textdomain(Domainname) ((const char *) (Domainname)) -# undef bindtextdomain -# define bindtextdomain(Domainname, Dirname) \ - ((void) (Domainname), (const char *) (Dirname)) -# undef bind_textdomain_codeset -# define bind_textdomain_codeset(Domainname, Codeset) \ - ((void) (Domainname), (const char *) (Codeset)) - -#endif - -/* Prefer gnulib's setlocale override over libintl's setlocale override. */ -#ifdef GNULIB_defined_setlocale -# undef setlocale -# define setlocale rpl_setlocale -#endif - -/* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ -#define gettext_noop(String) String - -/* The separator between msgctxt and msgid in a .mo file. */ -#define GETTEXT_CONTEXT_GLUE "\004" - -/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a - MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be - short and rarely need to change. - The letter 'p' stands for 'particular' or 'special'. */ -#ifdef DEFAULT_TEXT_DOMAIN -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#else -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#endif -#define dpgettext(Domainname, Msgctxt, Msgid) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) -#ifdef DEFAULT_TEXT_DOMAIN -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#else -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#endif -#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -pgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - int category) -{ - const char *translation = dcgettext (domain, msg_ctxt_id, category); - if (translation == msg_ctxt_id) - return msgid; - else - return translation; -} - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -npgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - const char *translation = - dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); - if (translation == msg_ctxt_id || translation == msgid_plural) - return (n == 1 ? msgid : msgid_plural); - else - return translation; -} - -/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID - can be arbitrary expressions. But for string literals these macros are - less efficient than those above. */ - -#include - -#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ >= 199901L */ ) -# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 -#else -# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 -#endif - -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS -#include -#endif - -#define pgettext_expr(Msgctxt, Msgid) \ - dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) -#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ - dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcgettext (domain, msg_ctxt_id, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (translation != msg_ctxt_id) - return translation; - } - return msgid; -} - -#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcnpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (!(translation == msg_ctxt_id || translation == msgid_plural)) - return translation; - } - return (n == 1 ? msgid : msgid_plural); -} - -#endif /* _LIBGETTEXT_H */ diff --git a/grub-core/gnulib/intprops.h b/grub-core/gnulib/intprops.h deleted file mode 100644 index b473052d1..000000000 --- a/grub-core/gnulib/intprops.h +++ /dev/null @@ -1,319 +0,0 @@ -/* intprops.h -- properties of integer types - - Copyright (C) 2001-2005, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Paul Eggert. */ - -#ifndef _GL_INTPROPS_H -#define _GL_INTPROPS_H - -#include - -/* Return an integer value, converted to the same type as the integer - expression E after integer type promotion. V is the unconverted value. */ -#define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) - -/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see - . */ -#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) - -/* The extra casts in the following macros work around compiler bugs, - e.g., in Cray C 5.0.3.0. */ - -/* True if the arithmetic type T is an integer type. bool counts as - an integer. */ -#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) - -/* True if negative values of the signed integer type T use two's - complement, ones' complement, or signed magnitude representation, - respectively. Much GNU code assumes two's complement, but some - people like to be portable to all possible C hosts. */ -#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) -#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) -#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) - -/* True if the signed integer expression E uses two's complement. */ -#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) - -/* True if the arithmetic type T is signed. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) - -/* Return 1 if the integer expression E, after integer promotion, has - a signed type. */ -#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) - - -/* Minimum and maximum values for integer types and expressions. These - macros have undefined behavior if T is signed and has padding bits. - If this is a problem for you, please let us know how to fix it for - your host. */ - -/* The maximum and minimum values for the integer type T. */ -#define TYPE_MINIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ TYPE_MAXIMUM (t))) -#define TYPE_MAXIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) - -/* The maximum and minimum values for the type of the expression E, - after integer promotion. E should not have side effects. */ -#define _GL_INT_MINIMUM(e) \ - (_GL_INT_SIGNED (e) \ - ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_CONVERT (e, 0)) -#define _GL_INT_MAXIMUM(e) \ - (_GL_INT_SIGNED (e) \ - ? _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_NEGATE_CONVERT (e, 1)) -#define _GL_SIGNED_INT_MAXIMUM(e) \ - (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1) - - -/* Return 1 if the __typeof__ keyword works. This could be done by - 'configure', but for now it's easier to do it by hand. */ -#if 2 <= __GNUC__ || 0x5110 <= __SUNPRO_C -# define _GL_HAVE___TYPEOF__ 1 -#else -# define _GL_HAVE___TYPEOF__ 0 -#endif - -/* Return 1 if the integer type or expression T might be signed. Return 0 - if it is definitely unsigned. This macro does not evaluate its argument, - and expands to an integer constant expression. */ -#if _GL_HAVE___TYPEOF__ -# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) -#else -# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 -#endif - -/* Bound on length of the string representing an unsigned integer - value representable in B bits. log10 (2.0) < 146/485. The - smallest value of B where this bound is not tight is 2621. */ -#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) - -/* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if T is signed, and then add 1 more for - a minus sign if needed. - - Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is - signed, this macro may overestimate the true bound by one byte when - applied to unsigned types of size 2, 4, 16, ... bytes. */ -#define INT_STRLEN_BOUND(t) \ - (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ - - _GL_SIGNED_TYPE_OR_EXPR (t)) \ - + _GL_SIGNED_TYPE_OR_EXPR (t)) - -/* Bound on buffer size needed to represent an integer type or expression T, - including the terminating null. */ -#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) - - -/* Range overflow checks. - - The INT__RANGE_OVERFLOW macros return 1 if the corresponding C - operators might not yield numerically correct answers due to - arithmetic overflow. They do not rely on undefined or - implementation-defined behavior. Their implementations are simple - and straightforward, but they are a bit harder to use than the - INT__OVERFLOW macros described below. - - Example usage: - - long int i = ...; - long int j = ...; - if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) - printf ("multiply would overflow"); - else - printf ("product is %ld", i * j); - - Restrictions on *_RANGE_OVERFLOW macros: - - These macros do not check for all possible numerical problems or - undefined or unspecified behavior: they do not check for division - by zero, for bad shift counts, or for shifting negative numbers. - - These macros may evaluate their arguments zero or multiple times, - so the arguments should not have side effects. The arithmetic - arguments (including the MIN and MAX arguments) must be of the same - integer type after the usual arithmetic conversions, and the type - must have minimum value MIN and maximum MAX. Unsigned types should - use a zero MIN of the proper type. - - These macros are tuned for constant MIN and MAX. For commutative - operations such as A + B, they are also tuned for constant B. */ - -/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? (a) < (min) - (b) \ - : (max) - (b) < (a)) - -/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? (max) + (b) < (a) \ - : (a) < (min) + (b)) - -/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ - ((min) < 0 \ - ? (a) < - (max) \ - : 0 < (a)) - -/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Avoid && and || as they tickle - bugs in Sun C 5.11 2010/08/13 and other compilers; see - . */ -#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? ((a) < 0 \ - ? (a) < (max) / (b) \ - : (b) == -1 \ - ? 0 \ - : (min) / (b) < (a)) \ - : (b) == 0 \ - ? 0 \ - : ((a) < 0 \ - ? (a) < (min) / (b) \ - : (max) / (b) < (a))) - -/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Do not check for division by zero. */ -#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ - ((min) < 0 && (b) == -1 && (a) < - (max)) - -/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Do not check for division by zero. - Mathematically, % should never overflow, but on x86-like hosts - INT_MIN % -1 traps, and the C standard permits this, so treat this - as an overflow too. */ -#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ - INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) - -/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Here, MIN and MAX are for A only, and B need - not be of the same type as the other arguments. The C standard says that - behavior is undefined for shifts unless 0 <= B < wordwidth, and that when - A is negative then A << B has undefined behavior and A >> B has - implementation-defined behavior, but do not check these other - restrictions. */ -#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ - ((a) < 0 \ - ? (a) < (min) >> (b) \ - : (max) >> (b) < (a)) - - -/* The _GL*_OVERFLOW macros have the same restrictions as the - *_RANGE_OVERFLOW macros, except that they do not assume that operands - (e.g., A and B) have the same type as MIN and MAX. Instead, they assume - that the result (e.g., A + B) has that type. */ -#define _GL_ADD_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ - : (a) < 0 ? (b) <= (a) + (b) \ - : (b) < 0 ? (a) <= (a) + (b) \ - : (a) + (b) < (b)) -#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ - : (a) < 0 ? 1 \ - : (b) < 0 ? (a) - (b) <= (a) \ - : (a) < (b)) -#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ - (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ - || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) -#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ - : (a) < 0 ? (b) <= (a) + (b) - 1 \ - : (b) < 0 && (a) + (b) <= (a)) -#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ - : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ - : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) - -/* Return a nonzero value if A is a mathematical multiple of B, where - A is unsigned, B is negative, and MAX is the maximum value of A's - type. A's type must be the same as (A % B)'s type. Normally (A % - -B == 0) suffices, but things get tricky if -B would overflow. */ -#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ - (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ - ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ - ? (a) \ - : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ - : (a) % - (b)) \ - == 0) - - -/* Integer overflow checks. - - The INT__OVERFLOW macros return 1 if the corresponding C operators - might not yield numerically correct answers due to arithmetic overflow. - They work correctly on all known practical hosts, and do not rely - on undefined behavior due to signed arithmetic overflow. - - Example usage: - - long int i = ...; - long int j = ...; - if (INT_MULTIPLY_OVERFLOW (i, j)) - printf ("multiply would overflow"); - else - printf ("product is %ld", i * j); - - These macros do not check for all possible numerical problems or - undefined or unspecified behavior: they do not check for division - by zero, for bad shift counts, or for shifting negative numbers. - - These macros may evaluate their arguments zero or multiple times, so the - arguments should not have side effects. - - These macros are tuned for their last argument being a constant. - - Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, - A % B, and A << B would overflow, respectively. */ - -#define INT_ADD_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) -#define INT_SUBTRACT_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) -#define INT_NEGATE_OVERFLOW(a) \ - INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) -#define INT_MULTIPLY_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) -#define INT_DIVIDE_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) -#define INT_REMAINDER_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) -#define INT_LEFT_SHIFT_OVERFLOW(a, b) \ - INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ - _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) - -/* Return 1 if the expression A B would overflow, - where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, - assuming MIN and MAX are the minimum and maximum for the result type. - Arguments should be free of side effects. */ -#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ - op_result_overflow (a, b, \ - _GL_INT_MINIMUM (0 * (b) + (a)), \ - _GL_INT_MAXIMUM (0 * (b) + (a))) - -#endif /* _GL_INTPROPS_H */ diff --git a/grub-core/gnulib/itold.c b/grub-core/gnulib/itold.c deleted file mode 100644 index 9aabc7e46..000000000 --- a/grub-core/gnulib/itold.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2011. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -void -_Qp_itoq (long double *result, int a) -{ - /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ - *result = (double) a; -} diff --git a/grub-core/gnulib/langinfo.in.h b/grub-core/gnulib/langinfo.in.h deleted file mode 100644 index 5388ce624..000000000 --- a/grub-core/gnulib/langinfo.in.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Substitute for and wrapper around . - Copyright (C) 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* - * POSIX for platforms that lack it or have an incomplete one. - * - */ - -#ifndef _@GUARD_PREFIX@_LANGINFO_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_LANGINFO_H@ -# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ -#endif - -#ifndef _@GUARD_PREFIX@_LANGINFO_H -#define _@GUARD_PREFIX@_LANGINFO_H - - -#if !@HAVE_LANGINFO_H@ - -/* A platform that lacks . */ - -/* Assume that it also lacks and the nl_item type. */ -# if !GNULIB_defined_nl_item -typedef int nl_item; -# define GNULIB_defined_nl_item 1 -# endif - -/* nl_langinfo items of the LC_CTYPE category */ -# define CODESET 10000 -/* nl_langinfo items of the LC_NUMERIC category */ -# define RADIXCHAR 10001 -# define THOUSEP 10002 -/* nl_langinfo items of the LC_TIME category */ -# define D_T_FMT 10003 -# define D_FMT 10004 -# define T_FMT 10005 -# define T_FMT_AMPM 10006 -# define AM_STR 10007 -# define PM_STR 10008 -# define DAY_1 10009 -# define DAY_2 (DAY_1 + 1) -# define DAY_3 (DAY_1 + 2) -# define DAY_4 (DAY_1 + 3) -# define DAY_5 (DAY_1 + 4) -# define DAY_6 (DAY_1 + 5) -# define DAY_7 (DAY_1 + 6) -# define ABDAY_1 10016 -# define ABDAY_2 (ABDAY_1 + 1) -# define ABDAY_3 (ABDAY_1 + 2) -# define ABDAY_4 (ABDAY_1 + 3) -# define ABDAY_5 (ABDAY_1 + 4) -# define ABDAY_6 (ABDAY_1 + 5) -# define ABDAY_7 (ABDAY_1 + 6) -# define MON_1 10023 -# define MON_2 (MON_1 + 1) -# define MON_3 (MON_1 + 2) -# define MON_4 (MON_1 + 3) -# define MON_5 (MON_1 + 4) -# define MON_6 (MON_1 + 5) -# define MON_7 (MON_1 + 6) -# define MON_8 (MON_1 + 7) -# define MON_9 (MON_1 + 8) -# define MON_10 (MON_1 + 9) -# define MON_11 (MON_1 + 10) -# define MON_12 (MON_1 + 11) -# define ABMON_1 10035 -# define ABMON_2 (ABMON_1 + 1) -# define ABMON_3 (ABMON_1 + 2) -# define ABMON_4 (ABMON_1 + 3) -# define ABMON_5 (ABMON_1 + 4) -# define ABMON_6 (ABMON_1 + 5) -# define ABMON_7 (ABMON_1 + 6) -# define ABMON_8 (ABMON_1 + 7) -# define ABMON_9 (ABMON_1 + 8) -# define ABMON_10 (ABMON_1 + 9) -# define ABMON_11 (ABMON_1 + 10) -# define ABMON_12 (ABMON_1 + 11) -# define ERA 10047 -# define ERA_D_FMT 10048 -# define ERA_D_T_FMT 10049 -# define ERA_T_FMT 10050 -# define ALT_DIGITS 10051 -/* nl_langinfo items of the LC_MONETARY category */ -# define CRNCYSTR 10052 -/* nl_langinfo items of the LC_MESSAGES category */ -# define YESEXPR 10053 -# define NOEXPR 10054 - -#else - -/* A platform that has . */ - -# if !@HAVE_LANGINFO_CODESET@ -# define CODESET 10000 -# define GNULIB_defined_CODESET 1 -# endif - -# if !@HAVE_LANGINFO_T_FMT_AMPM@ -# define T_FMT_AMPM 10006 -# define GNULIB_defined_T_FMT_AMPM 1 -# endif - -# if !@HAVE_LANGINFO_ERA@ -# define ERA 10047 -# define ERA_D_FMT 10048 -# define ERA_D_T_FMT 10049 -# define ERA_T_FMT 10050 -# define ALT_DIGITS 10051 -# define GNULIB_defined_ERA 1 -# endif - -# if !@HAVE_LANGINFO_YESEXPR@ -# define YESEXPR 10053 -# define NOEXPR 10054 -# define GNULIB_defined_YESEXPR 1 -# endif - -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -/* Declare overridden functions. */ - - -/* Return a piece of locale dependent information. - Note: The difference between nl_langinfo (CODESET) and locale_charset () - is that the latter normalizes the encoding names to GNU conventions. */ - -#if @GNULIB_NL_LANGINFO@ -# if @REPLACE_NL_LANGINFO@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef nl_langinfo -# define nl_langinfo rpl_nl_langinfo -# endif -_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); -_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); -# else -# if !@HAVE_NL_LANGINFO@ -_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); -# endif -_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); -# endif -_GL_CXXALIASWARN (nl_langinfo); -#elif defined GNULIB_POSIXCHECK -# undef nl_langinfo -# if HAVE_RAW_DECL_NL_LANGINFO -_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " - "use gnulib module nl_langinfo for portability"); -# endif -#endif - - -#endif /* _@GUARD_PREFIX@_LANGINFO_H */ -#endif /* _@GUARD_PREFIX@_LANGINFO_H */ diff --git a/grub-core/gnulib/localcharset.c b/grub-core/gnulib/localcharset.c deleted file mode 100644 index 953cc1e70..000000000 --- a/grub-core/gnulib/localcharset.c +++ /dev/null @@ -1,553 +0,0 @@ -/* Determine a canonical name for the current locale's character encoding. - - Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -/* Written by Bruno Haible . */ - -#include - -/* Specification. */ -#include "localcharset.h" - -#include -#include -#include -#include -#include - -#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET -# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ -#endif - -#if defined _WIN32 || defined __WIN32__ -# define WINDOWS_NATIVE -#endif - -#if defined __EMX__ -/* Assume EMX program runs on OS/2, even if compiled under DOS. */ -# ifndef OS2 -# define OS2 -# endif -#endif - -#if !defined WINDOWS_NATIVE -# include -# if HAVE_LANGINFO_CODESET -# include -# else -# if 0 /* see comment below */ -# include -# endif -# endif -# ifdef __CYGWIN__ -# define WIN32_LEAN_AND_MEAN -# include -# endif -#elif defined WINDOWS_NATIVE -# define WIN32_LEAN_AND_MEAN -# include -#endif -#if defined OS2 -# define INCL_DOS -# include -#endif - -#if ENABLE_RELOCATABLE -# include "relocatable.h" -#else -# define relocate(pathname) (pathname) -#endif - -/* Get LIBDIR. */ -#ifndef LIBDIR -# include "configmake.h" -#endif - -/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */ -#ifndef O_NOFOLLOW -# define O_NOFOLLOW 0 -#endif - -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Native Windows, Cygwin, OS/2, DOS */ -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -#endif - -#ifndef DIRECTORY_SEPARATOR -# define DIRECTORY_SEPARATOR '/' -#endif - -#ifndef ISSLASH -# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) -#endif - -#if HAVE_DECL_GETC_UNLOCKED -# undef getc -# define getc getc_unlocked -#endif - -/* The following static variable is declared 'volatile' to avoid a - possible multithread problem in the function get_charset_aliases. If we - are running in a threaded environment, and if two threads initialize - 'charset_aliases' simultaneously, both will produce the same value, - and everything will be ok if the two assignments to 'charset_aliases' - are atomic. But I don't know what will happen if the two assignments mix. */ -#if __STDC__ != 1 -# define volatile /* empty */ -#endif -/* Pointer to the contents of the charset.alias file, if it has already been - read, else NULL. Its format is: - ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ -static const char * volatile charset_aliases; - -/* Return a pointer to the contents of the charset.alias file. */ -static const char * -get_charset_aliases (void) -{ - const char *cp; - - cp = charset_aliases; - if (cp == NULL) - { -#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__) - const char *dir; - const char *base = "charset.alias"; - char *file_name; - - /* Make it possible to override the charset.alias location. This is - necessary for running the testsuite before "make install". */ - dir = getenv ("CHARSETALIASDIR"); - if (dir == NULL || dir[0] == '\0') - dir = relocate (LIBDIR); - - /* Concatenate dir and base into freshly allocated file_name. */ - { - size_t dir_len = strlen (dir); - size_t base_len = strlen (base); - int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); - file_name = (char *) malloc (dir_len + add_slash + base_len + 1); - if (file_name != NULL) - { - memcpy (file_name, dir, dir_len); - if (add_slash) - file_name[dir_len] = DIRECTORY_SEPARATOR; - memcpy (file_name + dir_len + add_slash, base, base_len + 1); - } - } - - if (file_name == NULL) - /* Out of memory. Treat the file as empty. */ - cp = ""; - else - { - int fd; - - /* Open the file. Reject symbolic links on platforms that support - O_NOFOLLOW. This is a security feature. Without it, an attacker - could retrieve parts of the contents (namely, the tail of the - first line that starts with "* ") of an arbitrary file by placing - a symbolic link to that file under the name "charset.alias" in - some writable directory and defining the environment variable - CHARSETALIASDIR to point to that directory. */ - fd = open (file_name, - O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); - if (fd < 0) - /* File not found. Treat it as empty. */ - cp = ""; - else - { - FILE *fp; - - fp = fdopen (fd, "r"); - if (fp == NULL) - { - /* Out of memory. Treat the file as empty. */ - close (fd); - cp = ""; - } - else - { - /* Parse the file's contents. */ - char *res_ptr = NULL; - size_t res_size = 0; - - for (;;) - { - int c; - char buf1[50+1]; - char buf2[50+1]; - size_t l1, l2; - char *old_res_ptr; - - c = getc (fp); - if (c == EOF) - break; - if (c == '\n' || c == ' ' || c == '\t') - continue; - if (c == '#') - { - /* Skip comment, to end of line. */ - do - c = getc (fp); - while (!(c == EOF || c == '\n')); - if (c == EOF) - break; - continue; - } - ungetc (c, fp); - if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) - break; - l1 = strlen (buf1); - l2 = strlen (buf2); - old_res_ptr = res_ptr; - if (res_size == 0) - { - res_size = l1 + 1 + l2 + 1; - res_ptr = (char *) malloc (res_size + 1); - } - else - { - res_size += l1 + 1 + l2 + 1; - res_ptr = (char *) realloc (res_ptr, res_size + 1); - } - if (res_ptr == NULL) - { - /* Out of memory. */ - res_size = 0; - free (old_res_ptr); - break; - } - strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); - strcpy (res_ptr + res_size - (l2 + 1), buf2); - } - fclose (fp); - if (res_size == 0) - cp = ""; - else - { - *(res_ptr + res_size) = '\0'; - cp = res_ptr; - } - } - } - - free (file_name); - } - -#else - -# if defined DARWIN7 - /* To avoid the trouble of installing a file that is shared by many - GNU packages -- many packaging systems have problems with this --, - simply inline the aliases here. */ - cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-4" "\0" "ISO-8859-4" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - "ISO8859-13" "\0" "ISO-8859-13" "\0" - "ISO8859-15" "\0" "ISO-8859-15" "\0" - "KOI8-R" "\0" "KOI8-R" "\0" - "KOI8-U" "\0" "KOI8-U" "\0" - "CP866" "\0" "CP866" "\0" - "CP949" "\0" "CP949" "\0" - "CP1131" "\0" "CP1131" "\0" - "CP1251" "\0" "CP1251" "\0" - "eucCN" "\0" "GB2312" "\0" - "GB2312" "\0" "GB2312" "\0" - "eucJP" "\0" "EUC-JP" "\0" - "eucKR" "\0" "EUC-KR" "\0" - "Big5" "\0" "BIG5" "\0" - "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" - "GBK" "\0" "GBK" "\0" - "GB18030" "\0" "GB18030" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "ARMSCII-8" "\0" "ARMSCII-8" "\0" - "PT154" "\0" "PT154" "\0" - /*"ISCII-DEV" "\0" "?" "\0"*/ - "*" "\0" "UTF-8" "\0"; -# endif - -# if defined VMS - /* To avoid the troubles of an extra file charset.alias_vms in the - sources of many GNU packages, simply inline the aliases here. */ - /* The list of encodings is taken from the OpenVMS 7.3-1 documentation - "Compaq C Run-Time Library Reference Manual for OpenVMS systems" - section 10.7 "Handling Different Character Sets". */ - cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-8" "\0" "ISO-8859-8" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - /* Japanese */ - "eucJP" "\0" "EUC-JP" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "DECKANJI" "\0" "DEC-KANJI" "\0" - "SDECKANJI" "\0" "EUC-JP" "\0" - /* Chinese */ - "eucTW" "\0" "EUC-TW" "\0" - "DECHANYU" "\0" "DEC-HANYU" "\0" - "DECHANZI" "\0" "GB2312" "\0" - /* Korean */ - "DECKOREAN" "\0" "EUC-KR" "\0"; -# endif - -# if defined WINDOWS_NATIVE || defined __CYGWIN__ - /* To avoid the troubles of installing a separate file in the same - directory as the DLL and of retrieving the DLL's directory at - runtime, simply inline the aliases here. */ - - cp = "CP936" "\0" "GBK" "\0" - "CP1361" "\0" "JOHAB" "\0" - "CP20127" "\0" "ASCII" "\0" - "CP20866" "\0" "KOI8-R" "\0" - "CP20936" "\0" "GB2312" "\0" - "CP21866" "\0" "KOI8-RU" "\0" - "CP28591" "\0" "ISO-8859-1" "\0" - "CP28592" "\0" "ISO-8859-2" "\0" - "CP28593" "\0" "ISO-8859-3" "\0" - "CP28594" "\0" "ISO-8859-4" "\0" - "CP28595" "\0" "ISO-8859-5" "\0" - "CP28596" "\0" "ISO-8859-6" "\0" - "CP28597" "\0" "ISO-8859-7" "\0" - "CP28598" "\0" "ISO-8859-8" "\0" - "CP28599" "\0" "ISO-8859-9" "\0" - "CP28605" "\0" "ISO-8859-15" "\0" - "CP38598" "\0" "ISO-8859-8" "\0" - "CP51932" "\0" "EUC-JP" "\0" - "CP51936" "\0" "GB2312" "\0" - "CP51949" "\0" "EUC-KR" "\0" - "CP51950" "\0" "EUC-TW" "\0" - "CP54936" "\0" "GB18030" "\0" - "CP65001" "\0" "UTF-8" "\0"; -# endif -#endif - - charset_aliases = cp; - } - - return cp; -} - -/* Determine the current locale's character encoding, and canonicalize it - into one of the canonical names listed in config.charset. - The result must not be freed; it is statically allocated. - If the canonical name cannot be determined, the result is a non-canonical - name. */ - -#ifdef STATIC -STATIC -#endif -const char * -locale_charset (void) -{ - const char *codeset; - const char *aliases; - -#if !(defined WINDOWS_NATIVE || defined OS2) - -# if HAVE_LANGINFO_CODESET - - /* Most systems support nl_langinfo (CODESET) nowadays. */ - codeset = nl_langinfo (CODESET); - -# ifdef __CYGWIN__ - /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always - returns "US-ASCII". Return the suffix of the locale name from the - environment variables (if present) or the codepage as a number. */ - if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) - { - const char *locale; - static char buf[2 + 10 + 1]; - - locale = getenv ("LC_ALL"); - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } - if (locale != NULL && locale[0] != '\0') - { - /* If the locale name contains an encoding after the dot, return - it. */ - const char *dot = strchr (locale, '.'); - - if (dot != NULL) - { - const char *modifier; - - dot++; - /* Look for the possible @... trailer and remove it, if any. */ - modifier = strchr (dot, '@'); - if (modifier == NULL) - return dot; - if (modifier - dot < sizeof (buf)) - { - memcpy (buf, dot, modifier - dot); - buf [modifier - dot] = '\0'; - return buf; - } - } - } - - /* The Windows API has a function returning the locale's codepage as a - number: GetACP(). This encoding is used by Cygwin, unless the user - has set the environment variable CYGWIN=codepage:oem (which very few - people do). - Output directed to console windows needs to be converted (to - GetOEMCP() if the console is using a raster font, or to - GetConsoleOutputCP() if it is using a TrueType font). Cygwin does - this conversion transparently (see winsup/cygwin/fhandler_console.cc), - converting to GetConsoleOutputCP(). This leads to correct results, - except when SetConsoleOutputCP has been called and a raster font is - in use. */ - sprintf (buf, "CP%u", GetACP ()); - codeset = buf; - } -# endif - -# else - - /* On old systems which lack it, use setlocale or getenv. */ - const char *locale = NULL; - - /* But most old systems don't have a complete set of locales. Some - (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't - use setlocale here; it would return "C" when it doesn't support the - locale name the user has set. */ -# if 0 - locale = setlocale (LC_CTYPE, NULL); -# endif - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_ALL"); - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } - } - - /* On some old systems, one used to set locale = "iso8859_1". On others, - you set it to "language_COUNTRY.charset". In any case, we resolve it - through the charset.alias file. */ - codeset = locale; - -# endif - -#elif defined WINDOWS_NATIVE - - static char buf[2 + 10 + 1]; - - /* The Windows API has a function returning the locale's codepage as a - number: GetACP(). - When the output goes to a console window, it needs to be provided in - GetOEMCP() encoding if the console is using a raster font, or in - GetConsoleOutputCP() encoding if it is using a TrueType font. - But in GUI programs and for output sent to files and pipes, GetACP() - encoding is the best bet. */ - sprintf (buf, "CP%u", GetACP ()); - codeset = buf; - -#elif defined OS2 - - const char *locale; - static char buf[2 + 10 + 1]; - ULONG cp[3]; - ULONG cplen; - - /* Allow user to override the codeset, as set in the operating system, - with standard language environment variables. */ - locale = getenv ("LC_ALL"); - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } - if (locale != NULL && locale[0] != '\0') - { - /* If the locale name contains an encoding after the dot, return it. */ - const char *dot = strchr (locale, '.'); - - if (dot != NULL) - { - const char *modifier; - - dot++; - /* Look for the possible @... trailer and remove it, if any. */ - modifier = strchr (dot, '@'); - if (modifier == NULL) - return dot; - if (modifier - dot < sizeof (buf)) - { - memcpy (buf, dot, modifier - dot); - buf [modifier - dot] = '\0'; - return buf; - } - } - - /* Resolve through the charset.alias file. */ - codeset = locale; - } - else - { - /* OS/2 has a function returning the locale's codepage as a number. */ - if (DosQueryCp (sizeof (cp), cp, &cplen)) - codeset = ""; - else - { - sprintf (buf, "CP%u", cp[0]); - codeset = buf; - } - } - -#endif - - if (codeset == NULL) - /* The canonical name cannot be determined. */ - codeset = ""; - - /* Resolve alias. */ - for (aliases = get_charset_aliases (); - *aliases != '\0'; - aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) - if (strcmp (codeset, aliases) == 0 - || (aliases[0] == '*' && aliases[1] == '\0')) - { - codeset = aliases + strlen (aliases) + 1; - break; - } - - /* Don't return an empty string. GNU libc and GNU libiconv interpret - the empty string as denoting "the locale's character encoding", - thus GNU libiconv would call this function a second time. */ - if (codeset[0] == '\0') - codeset = "ASCII"; - -#ifdef DARWIN7 - /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" - (the default codeset) does not work when MB_CUR_MAX is 1. */ - if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1) - codeset = "ASCII"; -#endif - - return codeset; -} diff --git a/grub-core/gnulib/localcharset.h b/grub-core/gnulib/localcharset.h deleted file mode 100644 index c20982986..000000000 --- a/grub-core/gnulib/localcharset.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU CHARSET Library. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _LOCALCHARSET_H -#define _LOCALCHARSET_H - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Determine the current locale's character encoding, and canonicalize it - into one of the canonical names listed in config.charset. - The result must not be freed; it is statically allocated. - If the canonical name cannot be determined, the result is a non-canonical - name. */ -extern const char * locale_charset (void); - - -#ifdef __cplusplus -} -#endif - - -#endif /* _LOCALCHARSET_H */ diff --git a/grub-core/gnulib/locale.in.h b/grub-core/gnulib/locale.in.h deleted file mode 100644 index 264161a6c..000000000 --- a/grub-core/gnulib/locale.in.h +++ /dev/null @@ -1,216 +0,0 @@ -/* A POSIX . - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#ifdef _GL_ALREADY_INCLUDING_LOCALE_H - -/* Special invocation conventions to handle Solaris header files - (through Solaris 10) when combined with gettext's libintl.h. */ - -#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ - -#else -/* Normal invocation convention. */ - -#ifndef _@GUARD_PREFIX@_LOCALE_H - -#define _GL_ALREADY_INCLUDING_LOCALE_H - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ - -#undef _GL_ALREADY_INCLUDING_LOCALE_H - -#ifndef _@GUARD_PREFIX@_LOCALE_H -#define _@GUARD_PREFIX@_LOCALE_H - -/* NetBSD 5.0 mis-defines NULL. */ -#include - -/* Mac OS X 10.5 defines the locale_t type in . */ -#if @HAVE_XLOCALE_H@ -# include -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. - On systems that don't define it, use the same value as GNU libintl. */ -#if !defined LC_MESSAGES -# define LC_MESSAGES 1729 -#endif - -/* Bionic libc's 'struct lconv' is just a dummy. */ -#if @REPLACE_STRUCT_LCONV@ -# define lconv rpl_lconv -struct lconv -{ - /* All 'char *' are actually 'const char *'. */ - - /* Members that depend on the LC_NUMERIC category of the locale. See - */ - - /* Symbol used as decimal point. */ - char *decimal_point; - /* Symbol used to separate groups of digits to the left of the decimal - point. */ - char *thousands_sep; - /* Definition of the size of groups of digits to the left of the decimal - point. */ - char *grouping; - - /* Members that depend on the LC_MONETARY category of the locale. See - */ - - /* Symbol used as decimal point. */ - char *mon_decimal_point; - /* Symbol used to separate groups of digits to the left of the decimal - point. */ - char *mon_thousands_sep; - /* Definition of the size of groups of digits to the left of the decimal - point. */ - char *mon_grouping; - /* Sign used to indicate a value >= 0. */ - char *positive_sign; - /* Sign used to indicate a value < 0. */ - char *negative_sign; - - /* For formatting local currency. */ - /* Currency symbol (3 characters) followed by separator (1 character). */ - char *currency_symbol; - /* Number of digits after the decimal point. */ - char frac_digits; - /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it - comes after the number. */ - char p_cs_precedes; - /* For values >= 0: Position of the sign. */ - char p_sign_posn; - /* For values >= 0: Placement of spaces between currency symbol, sign, and - number. */ - char p_sep_by_space; - /* For values < 0: 1 if the currency symbol precedes the number, 0 if it - comes after the number. */ - char n_cs_precedes; - /* For values < 0: Position of the sign. */ - char n_sign_posn; - /* For values < 0: Placement of spaces between currency symbol, sign, and - number. */ - char n_sep_by_space; - - /* For formatting international currency. */ - /* Currency symbol (3 characters) followed by separator (1 character). */ - char *int_curr_symbol; - /* Number of digits after the decimal point. */ - char int_frac_digits; - /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it - comes after the number. */ - char int_p_cs_precedes; - /* For values >= 0: Position of the sign. */ - char int_p_sign_posn; - /* For values >= 0: Placement of spaces between currency symbol, sign, and - number. */ - char int_p_sep_by_space; - /* For values < 0: 1 if the currency symbol precedes the number, 0 if it - comes after the number. */ - char int_n_cs_precedes; - /* For values < 0: Position of the sign. */ - char int_n_sign_posn; - /* For values < 0: Placement of spaces between currency symbol, sign, and - number. */ - char int_n_sep_by_space; -}; -#endif - -#if @GNULIB_LOCALECONV@ -# if @REPLACE_LOCALECONV@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef localeconv -# define localeconv rpl_localeconv -# endif -_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void)); -_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void)); -# else -_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); -# endif -_GL_CXXALIASWARN (localeconv); -#elif @REPLACE_STRUCT_LCONV@ -# undef localeconv -# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv -#elif defined GNULIB_POSIXCHECK -# undef localeconv -# if HAVE_RAW_DECL_LOCALECONV -_GL_WARN_ON_USE (localeconv, - "localeconv returns too few information on some platforms - " - "use gnulib module localeconv for portability"); -# endif -#endif - -#if @GNULIB_SETLOCALE@ -# if @REPLACE_SETLOCALE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef setlocale -# define setlocale rpl_setlocale -# define GNULIB_defined_setlocale 1 -# endif -_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale)); -_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale)); -# else -_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); -# endif -_GL_CXXALIASWARN (setlocale); -#elif defined GNULIB_POSIXCHECK -# undef setlocale -# if HAVE_RAW_DECL_SETLOCALE -_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " - "use gnulib module setlocale for portability"); -# endif -#endif - -#if @GNULIB_DUPLOCALE@ -# if @REPLACE_DUPLOCALE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef duplocale -# define duplocale rpl_duplocale -# endif -_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); -# else -# if @HAVE_DUPLOCALE@ -_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); -# endif -# endif -# if @HAVE_DUPLOCALE@ -_GL_CXXALIASWARN (duplocale); -# endif -#elif defined GNULIB_POSIXCHECK -# undef duplocale -# if HAVE_RAW_DECL_DUPLOCALE -_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " - "use gnulib module duplocale for portability"); -# endif -#endif - -#endif /* _@GUARD_PREFIX@_LOCALE_H */ -#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */ -#endif /* _@GUARD_PREFIX@_LOCALE_H */ diff --git a/grub-core/gnulib/localeconv.c b/grub-core/gnulib/localeconv.c deleted file mode 100644 index 7c7c77cfd..000000000 --- a/grub-core/gnulib/localeconv.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Query locale dependent information for formatting numbers. - Copyright (C) 2012-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#if HAVE_STRUCT_LCONV_DECIMAL_POINT - -/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* - members. */ - -struct lconv * -localeconv (void) -{ - static struct lconv result; -# undef lconv -# undef localeconv - struct lconv *sys_result = localeconv (); - - result.decimal_point = sys_result->decimal_point; - result.thousands_sep = sys_result->thousands_sep; - result.grouping = sys_result->grouping; - result.mon_decimal_point = sys_result->mon_decimal_point; - result.mon_thousands_sep = sys_result->mon_thousands_sep; - result.mon_grouping = sys_result->mon_grouping; - result.positive_sign = sys_result->positive_sign; - result.negative_sign = sys_result->negative_sign; - result.currency_symbol = sys_result->currency_symbol; - result.frac_digits = sys_result->frac_digits; - result.p_cs_precedes = sys_result->p_cs_precedes; - result.p_sign_posn = sys_result->p_sign_posn; - result.p_sep_by_space = sys_result->p_sep_by_space; - result.n_cs_precedes = sys_result->n_cs_precedes; - result.n_sign_posn = sys_result->n_sign_posn; - result.n_sep_by_space = sys_result->n_sep_by_space; - result.int_curr_symbol = sys_result->int_curr_symbol; - result.int_frac_digits = sys_result->int_frac_digits; - result.int_p_cs_precedes = sys_result->p_cs_precedes; - result.int_p_sign_posn = sys_result->p_sign_posn; - result.int_p_sep_by_space = sys_result->p_sep_by_space; - result.int_n_cs_precedes = sys_result->n_cs_precedes; - result.int_n_sign_posn = sys_result->n_sign_posn; - result.int_n_sep_by_space = sys_result->n_sep_by_space; - - return &result; -} - -#else - -/* Override for platforms where 'struct lconv' is a dummy. */ - -# include - -struct lconv * -localeconv (void) -{ - static /*const*/ struct lconv result = - { - /* decimal_point */ ".", - /* thousands_sep */ "", - /* grouping */ "", - /* mon_decimal_point */ "", - /* mon_thousands_sep */ "", - /* mon_grouping */ "", - /* positive_sign */ "", - /* negative_sign */ "", - /* currency_symbol */ "", - /* frac_digits */ CHAR_MAX, - /* p_cs_precedes */ CHAR_MAX, - /* p_sign_posn */ CHAR_MAX, - /* p_sep_by_space */ CHAR_MAX, - /* n_cs_precedes */ CHAR_MAX, - /* n_sign_posn */ CHAR_MAX, - /* n_sep_by_space */ CHAR_MAX, - /* int_curr_symbol */ "", - /* int_frac_digits */ CHAR_MAX, - /* int_p_cs_precedes */ CHAR_MAX, - /* int_p_sign_posn */ CHAR_MAX, - /* int_p_sep_by_space */ CHAR_MAX, - /* int_n_cs_precedes */ CHAR_MAX, - /* int_n_sign_posn */ CHAR_MAX, - /* int_n_sep_by_space */ CHAR_MAX - }; - - return &result; -} - -#endif diff --git a/grub-core/gnulib/malloc.c b/grub-core/gnulib/malloc.c deleted file mode 100644 index 908735d27..000000000 --- a/grub-core/gnulib/malloc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* malloc() function that is glibc compatible. - - Copyright (C) 1997-1998, 2006-2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* written by Jim Meyering and Bruno Haible */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include -/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ -#ifdef malloc -# define NEED_MALLOC_GNU 1 -# undef malloc -/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU -# define NEED_MALLOC_GNU 1 -#endif - -#include - -#include - -/* Allocate an N-byte block of memory from the heap. - If N is zero, allocate a 1-byte block. */ - -void * -rpl_malloc (size_t n) -{ - void *result; - -#if NEED_MALLOC_GNU - if (n == 0) - n = 1; -#endif - - result = malloc (n); - -#if !HAVE_MALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} diff --git a/grub-core/gnulib/mbrtowc.c b/grub-core/gnulib/mbrtowc.c deleted file mode 100644 index 5ee44aea4..000000000 --- a/grub-core/gnulib/mbrtowc.c +++ /dev/null @@ -1,402 +0,0 @@ -/* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#if GNULIB_defined_mbstate_t -/* Implement mbrtowc() on top of mbtowc(). */ - -# include -# include - -# include "localcharset.h" -# include "streq.h" -# include "verify.h" - - -verify (sizeof (mbstate_t) >= 4); - -static char internal_state[4]; - -size_t -mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) -{ - char *pstate = (char *)ps; - - if (s == NULL) - { - pwc = NULL; - s = ""; - n = 1; - } - - if (n == 0) - return (size_t)(-2); - - /* Here n > 0. */ - - if (pstate == NULL) - pstate = internal_state; - - { - size_t nstate = pstate[0]; - char buf[4]; - const char *p; - size_t m; - - switch (nstate) - { - case 0: - p = s; - m = n; - break; - case 3: - buf[2] = pstate[3]; - /*FALLTHROUGH*/ - case 2: - buf[1] = pstate[2]; - /*FALLTHROUGH*/ - case 1: - buf[0] = pstate[1]; - p = buf; - m = nstate; - buf[m++] = s[0]; - if (n >= 2 && m < 4) - { - buf[m++] = s[1]; - if (n >= 3 && m < 4) - buf[m++] = s[2]; - } - break; - default: - errno = EINVAL; - return (size_t)(-1); - } - - /* Here m > 0. */ - -# if __GLIBC__ || defined __UCLIBC__ - /* Work around bug */ - mbtowc (NULL, NULL, 0); -# endif - { - int res = mbtowc (pwc, p, m); - - if (res >= 0) - { - if (pwc != NULL && ((*pwc == 0) != (res == 0))) - abort (); - if (nstate >= (res > 0 ? res : 1)) - abort (); - res -= nstate; - pstate[0] = 0; - return res; - } - - /* mbtowc does not distinguish between invalid and incomplete multibyte - sequences. But mbrtowc needs to make this distinction. - There are two possible approaches: - - Use iconv() and its return value. - - Use built-in knowledge about the possible encodings. - Given the low quality of implementation of iconv() on the systems that - lack mbrtowc(), we use the second approach. - The possible encodings are: - - 8-bit encodings, - - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, - - UTF-8. - Use specialized code for each. */ - if (m >= 4 || m >= MB_CUR_MAX) - goto invalid; - /* Here MB_CUR_MAX > 1 and 0 < m < 4. */ - { - const char *encoding = locale_charset (); - - if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) - { - /* Cf. unistr/u8-mblen.c. */ - unsigned char c = (unsigned char) p[0]; - - if (c >= 0xc2) - { - if (c < 0xe0) - { - if (m == 1) - goto incomplete; - } - else if (c < 0xf0) - { - if (m == 1) - goto incomplete; - if (m == 2) - { - unsigned char c2 = (unsigned char) p[1]; - - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xe1 || c2 >= 0xa0) - && (c != 0xed || c2 < 0xa0)) - goto incomplete; - } - } - else if (c <= 0xf4) - { - if (m == 1) - goto incomplete; - else /* m == 2 || m == 3 */ - { - unsigned char c2 = (unsigned char) p[1]; - - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xf1 || c2 >= 0x90) - && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; - - if ((c3 ^ 0x80) < 0x40) - goto incomplete; - } - } - } - } - } - goto invalid; - } - - /* As a reference for this code, you can use the GNU libiconv - implementation. Look for uses of the RET_TOOFEW macro. */ - - if (STREQ_OPT (encoding, - "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) - goto incomplete; - } - if (m == 2) - { - unsigned char c = (unsigned char) p[0]; - - if (c == 0x8f) - { - unsigned char c2 = (unsigned char) p[1]; - - if (c2 >= 0xa1 && c2 < 0xff) - goto incomplete; - } - } - goto invalid; - } - if (STREQ_OPT (encoding, - "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - || STREQ_OPT (encoding, - "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) - || STREQ_OPT (encoding, - "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if (c >= 0xa1 && c < 0xff) - goto incomplete; - } - goto invalid; - } - if (STREQ_OPT (encoding, - "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0xa1 && c < 0xff) || c == 0x8e) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; - - if (c == 0x8e) - goto incomplete; - } - goto invalid; - } - if (STREQ_OPT (encoding, - "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; - - if (c >= 0x90 && c <= 0xe3) - { - unsigned char c2 = (unsigned char) p[1]; - - if (c2 >= 0x30 && c2 <= 0x39) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; - - if (c3 >= 0x81 && c3 <= 0xfe) - goto incomplete; - } - } - } - } - goto invalid; - } - if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) - || (c >= 0xf0 && c <= 0xf9)) - goto incomplete; - } - goto invalid; - } - - /* An unknown multibyte encoding. */ - goto incomplete; - } - - incomplete: - { - size_t k = nstate; - /* Here 0 <= k < m < 4. */ - pstate[++k] = s[0]; - if (k < m) - { - pstate[++k] = s[1]; - if (k < m) - pstate[++k] = s[2]; - } - if (k != m) - abort (); - } - pstate[0] = m; - return (size_t)(-2); - - invalid: - errno = EILSEQ; - /* The conversion state is undefined, says POSIX. */ - return (size_t)(-1); - } - } -} - -#else -/* Override the system's mbrtowc() function. */ - -# undef mbrtowc - -size_t -rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) -{ -# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG - if (s == NULL) - { - pwc = NULL; - s = ""; - n = 1; - } -# endif - -# if MBRTOWC_RETVAL_BUG - { - static mbstate_t internal_state; - - /* Override mbrtowc's internal state. We cannot call mbsinit() on the - hidden internal state, but we can call it on our variable. */ - if (ps == NULL) - ps = &internal_state; - - if (!mbsinit (ps)) - { - /* Parse the rest of the multibyte character byte for byte. */ - size_t count = 0; - for (; n > 0; s++, n--) - { - wchar_t wc; - size_t ret = mbrtowc (&wc, s, 1, ps); - - if (ret == (size_t)(-1)) - return (size_t)(-1); - count++; - if (ret != (size_t)(-2)) - { - /* The multibyte character has been completed. */ - if (pwc != NULL) - *pwc = wc; - return (wc == 0 ? 0 : count); - } - } - return (size_t)(-2); - } - } -# endif - -# if MBRTOWC_NUL_RETVAL_BUG - { - wchar_t wc; - size_t ret = mbrtowc (&wc, s, n, ps); - - if (ret != (size_t)(-1) && ret != (size_t)(-2)) - { - if (pwc != NULL) - *pwc = wc; - if (wc == 0) - ret = 0; - } - return ret; - } -# else - { -# if MBRTOWC_NULL_ARG1_BUG - wchar_t dummy; - - if (pwc == NULL) - pwc = &dummy; -# endif - - return mbrtowc (pwc, s, n, ps); - } -# endif -} - -#endif diff --git a/grub-core/gnulib/mbsinit.c b/grub-core/gnulib/mbsinit.c deleted file mode 100644 index 26fbb7fa2..000000000 --- a/grub-core/gnulib/mbsinit.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Test for initial conversion state. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include "verify.h" - -#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ - -/* On native Windows, 'mbstate_t' is defined as 'int'. */ - -int -mbsinit (const mbstate_t *ps) -{ - return ps == NULL || *ps == 0; -} - -#else - -/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() - and wcrtomb(), wcsrtombs(). - We assume that - - sizeof (mbstate_t) >= 4, - - only stateless encodings are supported (such as UTF-8 and EUC-JP, but - not ISO-2022 variants), - - for each encoding, the number of bytes for a wide character is <= 4. - (This maximum is attained for UTF-8, GB18030, EUC-TW.) - We define the meaning of mbstate_t as follows: - - In mb -> wc direction, mbstate_t's first byte contains the number of - buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. - - In wc -> mb direction, mbstate_t contains no information. In other - words, it is always in the initial state. */ - -verify (sizeof (mbstate_t) >= 4); - -int -mbsinit (const mbstate_t *ps) -{ - const char *pstate = (const char *)ps; - - return pstate == NULL || pstate[0] == 0; -} - -#endif diff --git a/grub-core/gnulib/mbsrtowcs-impl.h b/grub-core/gnulib/mbsrtowcs-impl.h deleted file mode 100644 index b50e9739b..000000000 --- a/grub-core/gnulib/mbsrtowcs-impl.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Convert string to wide string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -size_t -mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) -{ - if (ps == NULL) - ps = &_gl_mbsrtowcs_state; - { - const char *src = *srcp; - - if (dest != NULL) - { - wchar_t *destptr = dest; - - for (; len > 0; destptr++, len--) - { - size_t src_avail; - size_t ret; - - /* An optimized variant of - src_avail = strnlen1 (src, MB_LEN_MAX); */ - if (src[0] == '\0') - src_avail = 1; - else if (src[1] == '\0') - src_avail = 2; - else if (src[2] == '\0') - src_avail = 3; - else if (MB_LEN_MAX <= 4 || src[3] == '\0') - src_avail = 4; - else - src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); - - /* Parse the next multibyte character. */ - ret = mbrtowc (destptr, src, src_avail, ps); - - if (ret == (size_t)(-2)) - /* Encountered a multibyte character that extends past a '\0' byte - or that is longer than MB_LEN_MAX bytes. Cannot happen. */ - abort (); - - if (ret == (size_t)(-1)) - goto bad_input; - if (ret == 0) - { - src = NULL; - /* Here mbsinit (ps). */ - break; - } - src += ret; - } - - *srcp = src; - return destptr - dest; - } - else - { - /* Ignore dest and len, don't store *srcp at the end, and - don't clobber *ps. */ - mbstate_t state = *ps; - size_t totalcount = 0; - - for (;; totalcount++) - { - size_t src_avail; - size_t ret; - - /* An optimized variant of - src_avail = strnlen1 (src, MB_LEN_MAX); */ - if (src[0] == '\0') - src_avail = 1; - else if (src[1] == '\0') - src_avail = 2; - else if (src[2] == '\0') - src_avail = 3; - else if (MB_LEN_MAX <= 4 || src[3] == '\0') - src_avail = 4; - else - src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); - - /* Parse the next multibyte character. */ - ret = mbrtowc (NULL, src, src_avail, &state); - - if (ret == (size_t)(-2)) - /* Encountered a multibyte character that extends past a '\0' byte - or that is longer than MB_LEN_MAX bytes. Cannot happen. */ - abort (); - - if (ret == (size_t)(-1)) - goto bad_input2; - if (ret == 0) - { - /* Here mbsinit (&state). */ - break; - } - src += ret; - } - - return totalcount; - } - - bad_input: - *srcp = src; - bad_input2: - errno = EILSEQ; - return (size_t)(-1); - } -} diff --git a/grub-core/gnulib/mbsrtowcs-state.c b/grub-core/gnulib/mbsrtowcs-state.c deleted file mode 100644 index 5a0b8882b..000000000 --- a/grub-core/gnulib/mbsrtowcs-state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Convert string to wide string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include - -/* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */ -mbstate_t _gl_mbsrtowcs_state -/* The state must initially be in the "initial state"; so, zero-initialize it. - On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3, - see . - When it needs an initializer, use 0 or {0} as initializer? 0 only works - when mbstate_t is a scalar type (such as when gnulib defines it, or on - AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct - or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ -#if defined __ELF__ - /* On ELF systems, variables in BSS behave well. */ -#else - /* Use braces, to be on the safe side. */ - = { 0 } -#endif - ; diff --git a/grub-core/gnulib/mbsrtowcs.c b/grub-core/gnulib/mbsrtowcs.c deleted file mode 100644 index 116ff493b..000000000 --- a/grub-core/gnulib/mbsrtowcs.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Convert string to wide string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include -#include - -#include "strnlen1.h" - - -extern mbstate_t _gl_mbsrtowcs_state; - -#include "mbsrtowcs-impl.h" diff --git a/grub-core/gnulib/mbswidth.c b/grub-core/gnulib/mbswidth.c deleted file mode 100644 index baa4f2757..000000000 --- a/grub-core/gnulib/mbswidth.c +++ /dev/null @@ -1,199 +0,0 @@ -/* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Bruno Haible . */ - -#include - -/* Specification. */ -#include "mbswidth.h" - -/* Get MB_CUR_MAX. */ -#include - -#include - -/* Get isprint(). */ -#include - -/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ -#include - -/* Get iswcntrl(). */ -#include - -/* Get INT_MAX. */ -#include - -/* Returns the number of columns needed to represent the multibyte - character string pointed to by STRING. If a non-printable character - occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. - With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is - the multibyte analogue of the wcswidth function. */ -int -mbswidth (const char *string, int flags) -{ - return mbsnwidth (string, strlen (string), flags); -} - -/* Returns the number of columns needed to represent the multibyte - character string pointed to by STRING of length NBYTES. If a - non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is - specified, -1 is returned. */ -int -mbsnwidth (const char *string, size_t nbytes, int flags) -{ - const char *p = string; - const char *plimit = p + nbytes; - int width; - - width = 0; - if (MB_CUR_MAX > 1) - { - while (p < plimit) - switch (*p) - { - case ' ': case '!': case '"': case '#': case '%': - case '&': case '\'': case '(': case ')': case '*': - case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': - case '?': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '[': case '\\': case ']': case '^': case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': case '{': case '|': case '}': case '~': - /* These characters are printable ASCII characters. */ - p++; - width++; - break; - case '\0': - if (flags & MBSW_STOP_AT_NUL) - return width; - default: - /* If we have a multibyte sequence, scan it up to its end. */ - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); - do - { - wchar_t wc; - size_t bytes; - int w; - - bytes = mbrtowc (&wc, p, plimit - p, &mbstate); - - if (bytes == (size_t) -1) - /* An invalid multibyte sequence was encountered. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p++; - width++; - break; - } - else - return -1; - } - - if (bytes == (size_t) -2) - /* An incomplete multibyte character at the end. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p = plimit; - width++; - break; - } - else - return -1; - } - - if (bytes == 0) - /* A null wide character was encountered. */ - bytes = 1; - - w = wcwidth (wc); - if (w >= 0) - /* A printable multibyte character. */ - { - if (w > INT_MAX - width) - goto overflow; - width += w; - } - else - /* An unprintable multibyte character. */ - if (!(flags & MBSW_REJECT_UNPRINTABLE)) - { - if (!iswcntrl (wc)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - } - else - return -1; - - p += bytes; - } - while (! mbsinit (&mbstate)); - } - break; - } - return width; - } - - while (p < plimit) - { - unsigned char c = (unsigned char) *p++; - - if (c == 0 && (flags & MBSW_STOP_AT_NUL)) - return width; - - if (isprint (c)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - else if (!(flags & MBSW_REJECT_UNPRINTABLE)) - { - if (!iscntrl (c)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - } - else - return -1; - } - return width; - - overflow: - return INT_MAX; -} diff --git a/grub-core/gnulib/mbswidth.h b/grub-core/gnulib/mbswidth.h deleted file mode 100644 index d7207c58f..000000000 --- a/grub-core/gnulib/mbswidth.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2007, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Avoid a clash of our mbswidth() with a function of the same name defined - in UnixWare 7.1.1 . We need this #include before the #define - below. - However, we don't want to #include on all platforms because - - Tru64 with Desktop Toolkit C has a bug: must be included before - . - - BSD/OS 4.1 has a bug: and must be included before - . */ -#if HAVE_DECL_MBSWIDTH_IN_WCHAR_H -# include -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Optional flags to influence mbswidth/mbsnwidth behavior. */ - -/* If this bit is set, return -1 upon finding an invalid or incomplete - character. Otherwise, assume invalid characters have width 1. */ -#define MBSW_REJECT_INVALID 1 - -/* If this bit is set, return -1 upon finding a non-printable character. - Otherwise, assume unprintable characters have width 0 if they are - control characters and 1 otherwise. */ -#define MBSW_REJECT_UNPRINTABLE 2 - -/* If this bit is set \0 is treated as the end of string. - Otherwise it's treated as a normal one column width character. */ -#define MBSW_STOP_AT_NUL 4 - -/* Returns the number of screen columns needed for STRING. */ -#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ -extern int mbswidth (const char *string, int flags); - -/* Returns the number of screen columns needed for the NBYTES bytes - starting at BUF. */ -extern int mbsnwidth (const char *buf, size_t nbytes, int flags); - - -#ifdef __cplusplus -} -#endif diff --git a/grub-core/gnulib/mbtowc-impl.h b/grub-core/gnulib/mbtowc-impl.h deleted file mode 100644 index 767ab397c..000000000 --- a/grub-core/gnulib/mbtowc-impl.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Convert multibyte character to wide character. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2011. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* We don't need a static internal state, because the encoding is not state - dependent, and when mbrtowc returns (size_t)(-2). we throw the result - away. */ - -int -mbtowc (wchar_t *pwc, const char *s, size_t n) -{ - if (s == NULL) - return 0; - else - { - mbstate_t state; - wchar_t wc; - size_t result; - - memset (&state, 0, sizeof (mbstate_t)); - result = mbrtowc (&wc, s, n, &state); - if (result == (size_t)-1 || result == (size_t)-2) - { - errno = EILSEQ; - return -1; - } - if (pwc != NULL) - *pwc = wc; - return (wc == 0 ? 0 : result); - } -} diff --git a/grub-core/gnulib/mbtowc.c b/grub-core/gnulib/mbtowc.c deleted file mode 100644 index 632f2e1db..000000000 --- a/grub-core/gnulib/mbtowc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Convert multibyte character to wide character. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2011. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include - -#include -#include -#include - -#include "mbtowc-impl.h" diff --git a/grub-core/gnulib/memchr.c b/grub-core/gnulib/memchr.c deleted file mode 100644 index 3db38a94c..000000000 --- a/grub-core/gnulib/memchr.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2013 - Free Software Foundation, Inc. - - Based on strlen implementation by Torbjorn Granlund (tege@sics.se), - with help from Dan Sahlin (dan@sics.se) and - commentary by Jim Blandy (jimb@ai.mit.edu); - adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), - and implemented by Roland McGrath (roland@ai.mit.edu). - -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. - -This program 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 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . */ - -#ifndef _LIBC -# include -#endif - -#include - -#include - -#if defined _LIBC -# include -#else -# define reg_char char -#endif - -#include - -#if HAVE_BP_SYM_H || defined _LIBC -# include -#else -# define BP_SYM(sym) sym -#endif - -#undef __memchr -#ifdef _LIBC -# undef memchr -#endif - -#ifndef weak_alias -# define __memchr memchr -#endif - -/* Search no more than N bytes of S for C. */ -void * -__memchr (void const *s, int c_in, size_t n) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned reg_char c; - - c = (unsigned char) c_in; - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - n > 0 && (size_t) char_ptr % sizeof (longword) != 0; - --n, ++char_ptr) - if (*char_ptr == c) - return (void *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will test a - longword at a time. The tricky part is testing if *any of the four* - bytes in the longword in question are equal to c. We first use an xor - with repeated_c. This reduces the task to testing whether *any of the - four* bytes in longword1 is zero. - - We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - So, the test whether any byte in longword1 is zero is equivalent to - testing whether tmp is nonzero. */ - - while (n >= sizeof (longword)) - { - longword longword1 = *longword_ptr ^ repeated_c; - - if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - n -= sizeof (longword); - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that either n < sizeof (longword), or one of the - sizeof (longword) bytes starting at char_ptr is == c. On little-endian - machines, we could determine the first such byte without any further - memory accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. Choose code - that works in both cases. */ - - for (; n > 0; --n, ++char_ptr) - { - if (*char_ptr == c) - return (void *) char_ptr; - } - - return NULL; -} -#ifdef weak_alias -weak_alias (__memchr, BP_SYM (memchr)) -#endif diff --git a/grub-core/gnulib/memchr.valgrind b/grub-core/gnulib/memchr.valgrind deleted file mode 100644 index 60f247e10..000000000 --- a/grub-core/gnulib/memchr.valgrind +++ /dev/null @@ -1,14 +0,0 @@ -# Suppress a valgrind message about use of uninitialized memory in memchr(). -# POSIX states that when the character is found, memchr must not read extra -# bytes in an overestimated length (for example, where memchr is used to -# implement strnlen). However, we use a safe word read to provide a speedup. -{ - memchr-value4 - Memcheck:Value4 - fun:rpl_memchr -} -{ - memchr-value8 - Memcheck:Value8 - fun:rpl_memchr -} diff --git a/grub-core/gnulib/mempcpy.c b/grub-core/gnulib/mempcpy.c deleted file mode 100644 index 5582368ed..000000000 --- a/grub-core/gnulib/mempcpy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copy memory area and return pointer after last written byte. - Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#include - -/* Specification. */ -#include - -/* Copy N bytes of SRC to DEST, return pointer to bytes after the - last written byte. */ -void * -mempcpy (void *dest, const void *src, size_t n) -{ - return (char *) memcpy (dest, src, n) + n; -} diff --git a/grub-core/gnulib/msvc-inval.c b/grub-core/gnulib/msvc-inval.c deleted file mode 100644 index 7e57731eb..000000000 --- a/grub-core/gnulib/msvc-inval.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#include - -/* Specification. */ -#include "msvc-inval.h" - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ - && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) - -/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler - declaration. */ -# include - -# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING - -static void __cdecl -gl_msvc_invalid_parameter_handler (const wchar_t *expression, - const wchar_t *function, - const wchar_t *file, - unsigned int line, - uintptr_t dummy) -{ -} - -# else - -/* Get declarations of the native Windows API functions. */ -# define WIN32_LEAN_AND_MEAN -# include - -# if defined _MSC_VER - -static void cdecl -gl_msvc_invalid_parameter_handler (const wchar_t *expression, - const wchar_t *function, - const wchar_t *file, - unsigned int line, - uintptr_t dummy) -{ - RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); -} - -# else - -/* An index to thread-local storage. */ -static DWORD tls_index; -static int tls_initialized /* = 0 */; - -/* Used as a fallback only. */ -static struct gl_msvc_inval_per_thread not_per_thread; - -struct gl_msvc_inval_per_thread * -gl_msvc_inval_current (void) -{ - if (!tls_initialized) - { - tls_index = TlsAlloc (); - tls_initialized = 1; - } - if (tls_index == TLS_OUT_OF_INDEXES) - /* TlsAlloc had failed. */ - return ¬_per_thread; - else - { - struct gl_msvc_inval_per_thread *pointer = - (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index); - if (pointer == NULL) - { - /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */ - pointer = - (struct gl_msvc_inval_per_thread *) - malloc (sizeof (struct gl_msvc_inval_per_thread)); - if (pointer == NULL) - /* Could not allocate memory. Use the global storage. */ - pointer = ¬_per_thread; - TlsSetValue (tls_index, pointer); - } - return pointer; - } -} - -static void cdecl -gl_msvc_invalid_parameter_handler (const wchar_t *expression, - const wchar_t *function, - const wchar_t *file, - unsigned int line, - uintptr_t dummy) -{ - struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current (); - if (current->restart_valid) - longjmp (current->restart, 1); - else - /* An invalid parameter notification from outside the gnulib code. - Give the caller a chance to intervene. */ - RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); -} - -# endif - -# endif - -static int gl_msvc_inval_initialized /* = 0 */; - -void -gl_msvc_inval_ensure_handler (void) -{ - if (gl_msvc_inval_initialized == 0) - { - _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); - gl_msvc_inval_initialized = 1; - } -} - -#endif diff --git a/grub-core/gnulib/msvc-inval.h b/grub-core/gnulib/msvc-inval.h deleted file mode 100644 index dcb0353dc..000000000 --- a/grub-core/gnulib/msvc-inval.h +++ /dev/null @@ -1,222 +0,0 @@ -/* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _MSVC_INVAL_H -#define _MSVC_INVAL_H - -/* With MSVC runtime libraries with the "invalid parameter handler" concept, - functions like fprintf(), dup2(), or close() crash when the caller passes - an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) - instead. - This file defines macros that turn such an invalid parameter notification - into a non-local exit. An error code can then be produced at the target - of this exit. You can thus write code like - - TRY_MSVC_INVAL - { - - } - CATCH_MSVC_INVAL - { - - } - DONE_MSVC_INVAL; - - This entire block expands to a single statement. - - The handling of invalid parameters can be done in three ways: - - * The default way, which is reasonable for programs (not libraries): - AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING]) - - * The way for libraries that make "hairy" calls (like close(-1), or - fclose(fp) where fileno(fp) is closed, or simply getdtablesize()): - AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING]) - - * The way for libraries that make no "hairy" calls: - AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING]) - */ - -#define DEFAULT_HANDLING 0 -#define HAIRY_LIBRARY_HANDLING 1 -#define SANE_LIBRARY_HANDLING 2 - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ - && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) -/* A native Windows platform with the "invalid parameter handler" concept, - and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING. */ - -# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING -/* Default handling. */ - -# ifdef __cplusplus -extern "C" { -# endif - -/* Ensure that the invalid parameter handler in installed that just returns. - Because we assume no other part of the program installs a different - invalid parameter handler, this solution is multithread-safe. */ -extern void gl_msvc_inval_ensure_handler (void); - -# ifdef __cplusplus -} -# endif - -# define TRY_MSVC_INVAL \ - do \ - { \ - gl_msvc_inval_ensure_handler (); \ - if (1) -# define CATCH_MSVC_INVAL \ - else -# define DONE_MSVC_INVAL \ - } \ - while (0) - -# else -/* Handling for hairy libraries. */ - -# include - -/* Gnulib can define its own status codes, as described in the page - "Raising Software Exceptions" on microsoft.com - . - Our status codes are composed of - - 0xE0000000, mandatory for all user-defined status codes, - - 0x474E550, a API identifier ("GNU"), - - 0, 1, 2, ..., used to distinguish different status codes from the - same API. */ -# define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0) - -# if defined _MSC_VER -/* A compiler that supports __try/__except, as described in the page - "try-except statement" on microsoft.com - . - With __try/__except, we can use the multithread-safe exception handling. */ - -# ifdef __cplusplus -extern "C" { -# endif - -/* Ensure that the invalid parameter handler in installed that raises a - software exception with code STATUS_GNULIB_INVALID_PARAMETER. - Because we assume no other part of the program installs a different - invalid parameter handler, this solution is multithread-safe. */ -extern void gl_msvc_inval_ensure_handler (void); - -# ifdef __cplusplus -} -# endif - -# define TRY_MSVC_INVAL \ - do \ - { \ - gl_msvc_inval_ensure_handler (); \ - __try -# define CATCH_MSVC_INVAL \ - __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ - ? EXCEPTION_EXECUTE_HANDLER \ - : EXCEPTION_CONTINUE_SEARCH) -# define DONE_MSVC_INVAL \ - } \ - while (0) - -# else -/* Any compiler. - We can only use setjmp/longjmp. */ - -# include - -# ifdef __cplusplus -extern "C" { -# endif - -struct gl_msvc_inval_per_thread -{ - /* The restart that will resume execution at the code between - CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between - TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */ - jmp_buf restart; - - /* Tells whether the contents of restart is valid. */ - int restart_valid; -}; - -/* Ensure that the invalid parameter handler in installed that passes - control to the gl_msvc_inval_restart if it is valid, or raises a - software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise. - Because we assume no other part of the program installs a different - invalid parameter handler, this solution is multithread-safe. */ -extern void gl_msvc_inval_ensure_handler (void); - -/* Return a pointer to the per-thread data for the current thread. */ -extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void); - -# ifdef __cplusplus -} -# endif - -# define TRY_MSVC_INVAL \ - do \ - { \ - struct gl_msvc_inval_per_thread *msvc_inval_current; \ - gl_msvc_inval_ensure_handler (); \ - msvc_inval_current = gl_msvc_inval_current (); \ - /* First, initialize gl_msvc_inval_restart. */ \ - if (setjmp (msvc_inval_current->restart) == 0) \ - { \ - /* Then, mark it as valid. */ \ - msvc_inval_current->restart_valid = 1; -# define CATCH_MSVC_INVAL \ - /* Execution completed. \ - Mark gl_msvc_inval_restart as invalid. */ \ - msvc_inval_current->restart_valid = 0; \ - } \ - else \ - { \ - /* Execution triggered an invalid parameter notification. \ - Mark gl_msvc_inval_restart as invalid. */ \ - msvc_inval_current->restart_valid = 0; -# define DONE_MSVC_INVAL \ - } \ - } \ - while (0) - -# endif - -# endif - -#else -/* A platform that does not need to the invalid parameter handler, - or when SANE_LIBRARY_HANDLING is desired. */ - -/* The braces here avoid GCC warnings like - "warning: suggest explicit braces to avoid ambiguous 'else'". */ -# define TRY_MSVC_INVAL \ - do \ - { \ - if (1) -# define CATCH_MSVC_INVAL \ - else -# define DONE_MSVC_INVAL \ - } \ - while (0) - -#endif - -#endif /* _MSVC_INVAL_H */ diff --git a/grub-core/gnulib/msvc-nothrow.c b/grub-core/gnulib/msvc-nothrow.c deleted file mode 100644 index 8d65472a8..000000000 --- a/grub-core/gnulib/msvc-nothrow.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Wrappers that don't throw invalid parameter notifications - with MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#include - -/* Specification. */ -#include "msvc-nothrow.h" - -/* Get declarations of the native Windows API functions. */ -#define WIN32_LEAN_AND_MEAN -#include - -#include "msvc-inval.h" - -#undef _get_osfhandle - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER -intptr_t -_gl_nothrow_get_osfhandle (int fd) -{ - intptr_t result; - - TRY_MSVC_INVAL - { - result = _get_osfhandle (fd); - } - CATCH_MSVC_INVAL - { - result = (intptr_t) INVALID_HANDLE_VALUE; - } - DONE_MSVC_INVAL; - - return result; -} -#endif diff --git a/grub-core/gnulib/msvc-nothrow.h b/grub-core/gnulib/msvc-nothrow.h deleted file mode 100644 index 5f521813d..000000000 --- a/grub-core/gnulib/msvc-nothrow.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Wrappers that don't throw invalid parameter notifications - with MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _MSVC_NOTHROW_H -#define _MSVC_NOTHROW_H - -/* With MSVC runtime libraries with the "invalid parameter handler" concept, - functions like fprintf(), dup2(), or close() crash when the caller passes - an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) - instead. - This file defines wrappers that turn such an invalid parameter notification - into an error code. */ - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -/* Get original declaration of _get_osfhandle. */ -# include - -# if HAVE_MSVC_INVALID_PARAMETER_HANDLER - -/* Override _get_osfhandle. */ -extern intptr_t _gl_nothrow_get_osfhandle (int fd); -# define _get_osfhandle _gl_nothrow_get_osfhandle - -# endif - -#endif - -#endif /* _MSVC_NOTHROW_H */ diff --git a/grub-core/gnulib/nl_langinfo.c b/grub-core/gnulib/nl_langinfo.c deleted file mode 100644 index 771c9533a..000000000 --- a/grub-core/gnulib/nl_langinfo.c +++ /dev/null @@ -1,271 +0,0 @@ -/* nl_langinfo() replacement: query locale dependent information. - - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#if REPLACE_NL_LANGINFO - -/* Override nl_langinfo with support for added nl_item values. */ - -# include -# include - -# undef nl_langinfo - -char * -rpl_nl_langinfo (nl_item item) -{ - switch (item) - { -# if GNULIB_defined_CODESET - case CODESET: - { - const char *locale; - static char buf[2 + 10 + 1]; - - locale = setlocale (LC_CTYPE, NULL); - if (locale != NULL && locale[0] != '\0') - { - /* If the locale name contains an encoding after the dot, return - it. */ - const char *dot = strchr (locale, '.'); - - if (dot != NULL) - { - const char *modifier; - - dot++; - /* Look for the possible @... trailer and remove it, if any. */ - modifier = strchr (dot, '@'); - if (modifier == NULL) - return dot; - if (modifier - dot < sizeof (buf)) - { - memcpy (buf, dot, modifier - dot); - buf [modifier - dot] = '\0'; - return buf; - } - } - } - return ""; - } -# endif -# if GNULIB_defined_T_FMT_AMPM - case T_FMT_AMPM: - return "%I:%M:%S %p"; -# endif -# if GNULIB_defined_ERA - case ERA: - /* The format is not standardized. In glibc it is a sequence of strings - of the form "direction:offset:start_date:end_date:era_name:era_format" - with an empty string at the end. */ - return ""; - case ERA_D_FMT: - /* The %Ex conversion in strftime behaves like %x if the locale does not - have an alternative time format. */ - item = D_FMT; - break; - case ERA_D_T_FMT: - /* The %Ec conversion in strftime behaves like %c if the locale does not - have an alternative time format. */ - item = D_T_FMT; - break; - case ERA_T_FMT: - /* The %EX conversion in strftime behaves like %X if the locale does not - have an alternative time format. */ - item = T_FMT; - break; - case ALT_DIGITS: - /* The format is not standardized. In glibc it is a sequence of 10 - strings, appended in memory. */ - return "\0\0\0\0\0\0\0\0\0\0"; -# endif -# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS - case YESEXPR: - return "^[yY]"; - case NOEXPR: - return "^[nN]"; -# endif - default: - break; - } - return nl_langinfo (item); -} - -#else - -/* Provide nl_langinfo from scratch. */ - -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -/* Native Windows platforms. */ - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include - -# include - -# else - -/* An old Unix platform without locales, such as Linux libc5 or BeOS. */ - -# endif - -# include - -char * -nl_langinfo (nl_item item) -{ - switch (item) - { - /* nl_langinfo items of the LC_CTYPE category */ - case CODESET: -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - { - static char buf[2 + 10 + 1]; - - /* The Windows API has a function returning the locale's codepage as - a number. */ - sprintf (buf, "CP%u", GetACP ()); - return buf; - } -# elif defined __BEOS__ - return "UTF-8"; -# else - return "ISO-8859-1"; -# endif - /* nl_langinfo items of the LC_NUMERIC category */ - case RADIXCHAR: - return localeconv () ->decimal_point; - case THOUSEP: - return localeconv () ->thousands_sep; - /* nl_langinfo items of the LC_TIME category. - TODO: Really use the locale. */ - case D_T_FMT: - case ERA_D_T_FMT: - return "%a %b %e %H:%M:%S %Y"; - case D_FMT: - case ERA_D_FMT: - return "%m/%d/%y"; - case T_FMT: - case ERA_T_FMT: - return "%H:%M:%S"; - case T_FMT_AMPM: - return "%I:%M:%S %p"; - case AM_STR: - return "AM"; - case PM_STR: - return "PM"; - case DAY_1: - return "Sunday"; - case DAY_2: - return "Monday"; - case DAY_3: - return "Tuesday"; - case DAY_4: - return "Wednesday"; - case DAY_5: - return "Thursday"; - case DAY_6: - return "Friday"; - case DAY_7: - return "Saturday"; - case ABDAY_1: - return "Sun"; - case ABDAY_2: - return "Mon"; - case ABDAY_3: - return "Tue"; - case ABDAY_4: - return "Wed"; - case ABDAY_5: - return "Thu"; - case ABDAY_6: - return "Fri"; - case ABDAY_7: - return "Sat"; - case MON_1: - return "January"; - case MON_2: - return "February"; - case MON_3: - return "March"; - case MON_4: - return "April"; - case MON_5: - return "May"; - case MON_6: - return "June"; - case MON_7: - return "July"; - case MON_8: - return "August"; - case MON_9: - return "September"; - case MON_10: - return "October"; - case MON_11: - return "November"; - case MON_12: - return "December"; - case ABMON_1: - return "Jan"; - case ABMON_2: - return "Feb"; - case ABMON_3: - return "Mar"; - case ABMON_4: - return "Apr"; - case ABMON_5: - return "May"; - case ABMON_6: - return "Jun"; - case ABMON_7: - return "Jul"; - case ABMON_8: - return "Aug"; - case ABMON_9: - return "Sep"; - case ABMON_10: - return "Oct"; - case ABMON_11: - return "Nov"; - case ABMON_12: - return "Dec"; - case ERA: - return ""; - case ALT_DIGITS: - return "\0\0\0\0\0\0\0\0\0\0"; - /* nl_langinfo items of the LC_MONETARY category - TODO: Really use the locale. */ - case CRNCYSTR: - return "-"; - /* nl_langinfo items of the LC_MESSAGES category - TODO: Really use the locale. */ - case YESEXPR: - return "^[yY]"; - case NOEXPR: - return "^[nN]"; - default: - return ""; - } -} - -#endif diff --git a/grub-core/gnulib/printf-args.c b/grub-core/gnulib/printf-args.c deleted file mode 100644 index c27e6bc6b..000000000 --- a/grub-core/gnulib/printf-args.c +++ /dev/null @@ -1,187 +0,0 @@ -/* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software - Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -/* This file can be parametrized with the following macros: - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. - PRINTF_FETCHARGS Name of the function to be defined. - STATIC Set to 'static' to declare the function static. */ - -#ifndef PRINTF_FETCHARGS -# include -#endif - -/* Specification. */ -#ifndef PRINTF_FETCHARGS -# include "printf-args.h" -#endif - -#ifdef STATIC -STATIC -#endif -int -PRINTF_FETCHARGS (va_list args, arguments *a) -{ - size_t i; - argument *ap; - - for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) - switch (ap->type) - { - case TYPE_SCHAR: - ap->a.a_schar = va_arg (args, /*signed char*/ int); - break; - case TYPE_UCHAR: - ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); - break; - case TYPE_SHORT: - ap->a.a_short = va_arg (args, /*short*/ int); - break; - case TYPE_USHORT: - ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); - break; - case TYPE_INT: - ap->a.a_int = va_arg (args, int); - break; - case TYPE_UINT: - ap->a.a_uint = va_arg (args, unsigned int); - break; - case TYPE_LONGINT: - ap->a.a_longint = va_arg (args, long int); - break; - case TYPE_ULONGINT: - ap->a.a_ulongint = va_arg (args, unsigned long int); - break; -#if HAVE_LONG_LONG_INT - case TYPE_LONGLONGINT: - ap->a.a_longlongint = va_arg (args, long long int); - break; - case TYPE_ULONGLONGINT: - ap->a.a_ulonglongint = va_arg (args, unsigned long long int); - break; -#endif - case TYPE_DOUBLE: - ap->a.a_double = va_arg (args, double); - break; - case TYPE_LONGDOUBLE: - ap->a.a_longdouble = va_arg (args, long double); - break; - case TYPE_CHAR: - ap->a.a_char = va_arg (args, int); - break; -#if HAVE_WINT_T - case TYPE_WIDE_CHAR: - /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by - default argument promotions", this is not the case in mingw32, - where wint_t is 'unsigned short'. */ - ap->a.a_wide_char = - (sizeof (wint_t) < sizeof (int) - ? (wint_t) va_arg (args, int) - : va_arg (args, wint_t)); - break; -#endif - case TYPE_STRING: - ap->a.a_string = va_arg (args, const char *); - /* A null pointer is an invalid argument for "%s", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_string == NULL) - ap->a.a_string = "(NULL)"; - break; -#if HAVE_WCHAR_T - case TYPE_WIDE_STRING: - ap->a.a_wide_string = va_arg (args, const wchar_t *); - /* A null pointer is an invalid argument for "%ls", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_wide_string == NULL) - { - static const wchar_t wide_null_string[] = - { - (wchar_t)'(', - (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', - (wchar_t)')', - (wchar_t)0 - }; - ap->a.a_wide_string = wide_null_string; - } - break; -#endif - case TYPE_POINTER: - ap->a.a_pointer = va_arg (args, void *); - break; - case TYPE_COUNT_SCHAR_POINTER: - ap->a.a_count_schar_pointer = va_arg (args, signed char *); - break; - case TYPE_COUNT_SHORT_POINTER: - ap->a.a_count_short_pointer = va_arg (args, short *); - break; - case TYPE_COUNT_INT_POINTER: - ap->a.a_count_int_pointer = va_arg (args, int *); - break; - case TYPE_COUNT_LONGINT_POINTER: - ap->a.a_count_longint_pointer = va_arg (args, long int *); - break; -#if HAVE_LONG_LONG_INT - case TYPE_COUNT_LONGLONGINT_POINTER: - ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); - break; -#endif -#if ENABLE_UNISTDIO - /* The unistdio extensions. */ - case TYPE_U8_STRING: - ap->a.a_u8_string = va_arg (args, const uint8_t *); - /* A null pointer is an invalid argument for "%U", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u8_string == NULL) - { - static const uint8_t u8_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u8_string = u8_null_string; - } - break; - case TYPE_U16_STRING: - ap->a.a_u16_string = va_arg (args, const uint16_t *); - /* A null pointer is an invalid argument for "%lU", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u16_string == NULL) - { - static const uint16_t u16_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u16_string = u16_null_string; - } - break; - case TYPE_U32_STRING: - ap->a.a_u32_string = va_arg (args, const uint32_t *); - /* A null pointer is an invalid argument for "%llU", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u32_string == NULL) - { - static const uint32_t u32_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u32_string = u32_null_string; - } - break; -#endif - default: - /* Unknown type. */ - return -1; - } - return 0; -} diff --git a/grub-core/gnulib/printf-args.h b/grub-core/gnulib/printf-args.h deleted file mode 100644 index 2a9c2a3f8..000000000 --- a/grub-core/gnulib/printf-args.h +++ /dev/null @@ -1,158 +0,0 @@ -/* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software - Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _PRINTF_ARGS_H -#define _PRINTF_ARGS_H - -/* This file can be parametrized with the following macros: - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. - PRINTF_FETCHARGS Name of the function to be declared. - STATIC Set to 'static' to declare the function static. */ - -/* Default parameters. */ -#ifndef PRINTF_FETCHARGS -# define PRINTF_FETCHARGS printf_fetchargs -#endif - -/* Get size_t. */ -#include - -/* Get wchar_t. */ -#if HAVE_WCHAR_T -# include -#endif - -/* Get wint_t. */ -#if HAVE_WINT_T -# include -#endif - -/* Get va_list. */ -#include - - -/* Argument types */ -typedef enum -{ - TYPE_NONE, - TYPE_SCHAR, - TYPE_UCHAR, - TYPE_SHORT, - TYPE_USHORT, - TYPE_INT, - TYPE_UINT, - TYPE_LONGINT, - TYPE_ULONGINT, -#if HAVE_LONG_LONG_INT - TYPE_LONGLONGINT, - TYPE_ULONGLONGINT, -#endif - TYPE_DOUBLE, - TYPE_LONGDOUBLE, - TYPE_CHAR, -#if HAVE_WINT_T - TYPE_WIDE_CHAR, -#endif - TYPE_STRING, -#if HAVE_WCHAR_T - TYPE_WIDE_STRING, -#endif - TYPE_POINTER, - TYPE_COUNT_SCHAR_POINTER, - TYPE_COUNT_SHORT_POINTER, - TYPE_COUNT_INT_POINTER, - TYPE_COUNT_LONGINT_POINTER -#if HAVE_LONG_LONG_INT -, TYPE_COUNT_LONGLONGINT_POINTER -#endif -#if ENABLE_UNISTDIO - /* The unistdio extensions. */ -, TYPE_U8_STRING -, TYPE_U16_STRING -, TYPE_U32_STRING -#endif -} arg_type; - -/* Polymorphic argument */ -typedef struct -{ - arg_type type; - union - { - signed char a_schar; - unsigned char a_uchar; - short a_short; - unsigned short a_ushort; - int a_int; - unsigned int a_uint; - long int a_longint; - unsigned long int a_ulongint; -#if HAVE_LONG_LONG_INT - long long int a_longlongint; - unsigned long long int a_ulonglongint; -#endif - float a_float; - double a_double; - long double a_longdouble; - int a_char; -#if HAVE_WINT_T - wint_t a_wide_char; -#endif - const char* a_string; -#if HAVE_WCHAR_T - const wchar_t* a_wide_string; -#endif - void* a_pointer; - signed char * a_count_schar_pointer; - short * a_count_short_pointer; - int * a_count_int_pointer; - long int * a_count_longint_pointer; -#if HAVE_LONG_LONG_INT - long long int * a_count_longlongint_pointer; -#endif -#if ENABLE_UNISTDIO - /* The unistdio extensions. */ - const uint8_t * a_u8_string; - const uint16_t * a_u16_string; - const uint32_t * a_u32_string; -#endif - } - a; -} -argument; - -/* Number of directly allocated arguments (no malloc() needed). */ -#define N_DIRECT_ALLOC_ARGUMENTS 7 - -typedef struct -{ - size_t count; - argument *arg; - argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS]; -} -arguments; - - -/* Fetch the arguments, putting them into a. */ -#ifdef STATIC -STATIC -#else -extern -#endif -int PRINTF_FETCHARGS (va_list args, arguments *a); - -#endif /* _PRINTF_ARGS_H */ diff --git a/grub-core/gnulib/printf-parse.c b/grub-core/gnulib/printf-parse.c deleted file mode 100644 index 23cacc1da..000000000 --- a/grub-core/gnulib/printf-parse.c +++ /dev/null @@ -1,638 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -/* This file can be parametrized with the following macros: - CHAR_T The element type of the format string. - CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters - in the format string are ASCII. - DIRECTIVE Structure denoting a format directive. - Depends on CHAR_T. - DIRECTIVES Structure denoting the set of format directives of a - format string. Depends on CHAR_T. - PRINTF_PARSE Function that parses a format string. - Depends on CHAR_T. - STATIC Set to 'static' to declare the function static. - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */ - -#ifndef PRINTF_PARSE -# include -#endif - -/* Specification. */ -#ifndef PRINTF_PARSE -# include "printf-parse.h" -#endif - -/* Default parameters. */ -#ifndef PRINTF_PARSE -# define PRINTF_PARSE printf_parse -# define CHAR_T char -# define DIRECTIVE char_directive -# define DIRECTIVES char_directives -#endif - -/* Get size_t, NULL. */ -#include - -/* Get intmax_t. */ -#if defined IN_LIBINTL || defined IN_LIBASPRINTF -# if HAVE_STDINT_H_WITH_UINTMAX -# include -# endif -# if HAVE_INTTYPES_H_WITH_UINTMAX -# include -# endif -#else -# include -#endif - -/* malloc(), realloc(), free(). */ -#include - -/* memcpy(). */ -#include - -/* errno. */ -#include - -/* Checked size_t computations. */ -#include "xsize.h" - -#if CHAR_T_ONLY_ASCII -/* c_isascii(). */ -# include "c-ctype.h" -#endif - -#ifdef STATIC -STATIC -#endif -int -PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) -{ - const CHAR_T *cp = format; /* pointer into format */ - size_t arg_posn = 0; /* number of regular arguments consumed */ - size_t d_allocated; /* allocated elements of d->dir */ - size_t a_allocated; /* allocated elements of a->arg */ - size_t max_width_length = 0; - size_t max_precision_length = 0; - - d->count = 0; - d_allocated = N_DIRECT_ALLOC_DIRECTIVES; - d->dir = d->direct_alloc_dir; - - a->count = 0; - a_allocated = N_DIRECT_ALLOC_ARGUMENTS; - a->arg = a->direct_alloc_arg; - -#define REGISTER_ARG(_index_,_type_) \ - { \ - size_t n = (_index_); \ - if (n >= a_allocated) \ - { \ - size_t memory_size; \ - argument *memory; \ - \ - a_allocated = xtimes (a_allocated, 2); \ - if (a_allocated <= n) \ - a_allocated = xsum (n, 1); \ - memory_size = xtimes (a_allocated, sizeof (argument)); \ - if (size_overflow_p (memory_size)) \ - /* Overflow, would lead to out of memory. */ \ - goto out_of_memory; \ - memory = (argument *) (a->arg != a->direct_alloc_arg \ - ? realloc (a->arg, memory_size) \ - : malloc (memory_size)); \ - if (memory == NULL) \ - /* Out of memory. */ \ - goto out_of_memory; \ - if (a->arg == a->direct_alloc_arg) \ - memcpy (memory, a->arg, a->count * sizeof (argument)); \ - a->arg = memory; \ - } \ - while (a->count <= n) \ - a->arg[a->count++].type = TYPE_NONE; \ - if (a->arg[n].type == TYPE_NONE) \ - a->arg[n].type = (_type_); \ - else if (a->arg[n].type != (_type_)) \ - /* Ambiguous type for positional argument. */ \ - goto error; \ - } - - while (*cp != '\0') - { - CHAR_T c = *cp++; - if (c == '%') - { - size_t arg_index = ARG_NONE; - DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ - - /* Initialize the next directive. */ - dp->dir_start = cp - 1; - dp->flags = 0; - dp->width_start = NULL; - dp->width_end = NULL; - dp->width_arg_index = ARG_NONE; - dp->precision_start = NULL; - dp->precision_end = NULL; - dp->precision_arg_index = ARG_NONE; - dp->arg_index = ARG_NONE; - - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory later. */ - goto error; - arg_index = n - 1; - cp = np + 1; - } - } - - /* Read the flags. */ - for (;;) - { - if (*cp == '\'') - { - dp->flags |= FLAG_GROUP; - cp++; - } - else if (*cp == '-') - { - dp->flags |= FLAG_LEFT; - cp++; - } - else if (*cp == '+') - { - dp->flags |= FLAG_SHOWSIGN; - cp++; - } - else if (*cp == ' ') - { - dp->flags |= FLAG_SPACE; - cp++; - } - else if (*cp == '#') - { - dp->flags |= FLAG_ALT; - cp++; - } - else if (*cp == '0') - { - dp->flags |= FLAG_ZERO; - cp++; - } -#if __GLIBC__ >= 2 && !defined __UCLIBC__ - else if (*cp == 'I') - { - dp->flags |= FLAG_LOCALIZED; - cp++; - } -#endif - else - break; - } - - /* Parse the field width. */ - if (*cp == '*') - { - dp->width_start = cp; - cp++; - dp->width_end = cp; - if (max_width_length < 1) - max_width_length = 1; - - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory later. */ - goto error; - dp->width_arg_index = n - 1; - cp = np + 1; - } - } - if (dp->width_arg_index == ARG_NONE) - { - dp->width_arg_index = arg_posn++; - if (dp->width_arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->width_arg_index, TYPE_INT); - } - else if (*cp >= '0' && *cp <= '9') - { - size_t width_length; - - dp->width_start = cp; - for (; *cp >= '0' && *cp <= '9'; cp++) - ; - dp->width_end = cp; - width_length = dp->width_end - dp->width_start; - if (max_width_length < width_length) - max_width_length = width_length; - } - - /* Parse the precision. */ - if (*cp == '.') - { - cp++; - if (*cp == '*') - { - dp->precision_start = cp - 1; - cp++; - dp->precision_end = cp; - if (max_precision_length < 2) - max_precision_length = 2; - - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; - - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory - later. */ - goto error; - dp->precision_arg_index = n - 1; - cp = np + 1; - } - } - if (dp->precision_arg_index == ARG_NONE) - { - dp->precision_arg_index = arg_posn++; - if (dp->precision_arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->precision_arg_index, TYPE_INT); - } - else - { - size_t precision_length; - - dp->precision_start = cp - 1; - for (; *cp >= '0' && *cp <= '9'; cp++) - ; - dp->precision_end = cp; - precision_length = dp->precision_end - dp->precision_start; - if (max_precision_length < precision_length) - max_precision_length = precision_length; - } - } - - { - arg_type type; - - /* Parse argument type/size specifiers. */ - { - int flags = 0; - - for (;;) - { - if (*cp == 'h') - { - flags |= (1 << (flags & 1)); - cp++; - } - else if (*cp == 'L') - { - flags |= 4; - cp++; - } - else if (*cp == 'l') - { - flags += 8; - cp++; - } - else if (*cp == 'j') - { - if (sizeof (intmax_t) > sizeof (long)) - { - /* intmax_t = long long */ - flags += 16; - } - else if (sizeof (intmax_t) > sizeof (int)) - { - /* intmax_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 'z' || *cp == 'Z') - { - /* 'z' is standardized in ISO C 99, but glibc uses 'Z' - because the warning facility in gcc-2.95.2 understands - only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ - if (sizeof (size_t) > sizeof (long)) - { - /* size_t = long long */ - flags += 16; - } - else if (sizeof (size_t) > sizeof (int)) - { - /* size_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 't') - { - if (sizeof (ptrdiff_t) > sizeof (long)) - { - /* ptrdiff_t = long long */ - flags += 16; - } - else if (sizeof (ptrdiff_t) > sizeof (int)) - { - /* ptrdiff_t = long */ - flags += 8; - } - cp++; - } -#if defined __APPLE__ && defined __MACH__ - /* On Mac OS X 10.3, PRIdMAX is defined as "qd". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'q') - { - if (64 / 8 > sizeof (long)) - { - /* int64_t = long long */ - flags += 16; - } - else - { - /* int64_t = long */ - flags += 8; - } - cp++; - } -#endif -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* On native Windows, PRIdMAX is defined as "I64d". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') - { - if (64 / 8 > sizeof (long)) - { - /* __int64 = long long */ - flags += 16; - } - else - { - /* __int64 = long */ - flags += 8; - } - cp += 3; - } -#endif - else - break; - } - - /* Read the conversion character. */ - c = *cp++; - switch (c) - { - case 'd': case 'i': -#if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGLONGINT; - else -#endif - /* If 'long long' exists and is the same as 'long', we parse - "lld" into TYPE_LONGINT. */ - if (flags >= 8) - type = TYPE_LONGINT; - else if (flags & 2) - type = TYPE_SCHAR; - else if (flags & 1) - type = TYPE_SHORT; - else - type = TYPE_INT; - break; - case 'o': case 'u': case 'x': case 'X': -#if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_ULONGLONGINT; - else -#endif - /* If 'unsigned long long' exists and is the same as - 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ - if (flags >= 8) - type = TYPE_ULONGINT; - else if (flags & 2) - type = TYPE_UCHAR; - else if (flags & 1) - type = TYPE_USHORT; - else - type = TYPE_UINT; - break; - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGDOUBLE; - else - type = TYPE_DOUBLE; - break; - case 'c': - if (flags >= 8) -#if HAVE_WINT_T - type = TYPE_WIDE_CHAR; -#else - goto error; -#endif - else - type = TYPE_CHAR; - break; -#if HAVE_WINT_T - case 'C': - type = TYPE_WIDE_CHAR; - c = 'c'; - break; -#endif - case 's': - if (flags >= 8) -#if HAVE_WCHAR_T - type = TYPE_WIDE_STRING; -#else - goto error; -#endif - else - type = TYPE_STRING; - break; -#if HAVE_WCHAR_T - case 'S': - type = TYPE_WIDE_STRING; - c = 's'; - break; -#endif - case 'p': - type = TYPE_POINTER; - break; - case 'n': -#if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_COUNT_LONGLONGINT_POINTER; - else -#endif - /* If 'long long' exists and is the same as 'long', we parse - "lln" into TYPE_COUNT_LONGINT_POINTER. */ - if (flags >= 8) - type = TYPE_COUNT_LONGINT_POINTER; - else if (flags & 2) - type = TYPE_COUNT_SCHAR_POINTER; - else if (flags & 1) - type = TYPE_COUNT_SHORT_POINTER; - else - type = TYPE_COUNT_INT_POINTER; - break; -#if ENABLE_UNISTDIO - /* The unistdio extensions. */ - case 'U': - if (flags >= 16) - type = TYPE_U32_STRING; - else if (flags >= 8) - type = TYPE_U16_STRING; - else - type = TYPE_U8_STRING; - break; -#endif - case '%': - type = TYPE_NONE; - break; - default: - /* Unknown conversion character. */ - goto error; - } - } - - if (type != TYPE_NONE) - { - dp->arg_index = arg_index; - if (dp->arg_index == ARG_NONE) - { - dp->arg_index = arg_posn++; - if (dp->arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->arg_index, type); - } - dp->conversion = c; - dp->dir_end = cp; - } - - d->count++; - if (d->count >= d_allocated) - { - size_t memory_size; - DIRECTIVE *memory; - - d_allocated = xtimes (d_allocated, 2); - memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); - if (size_overflow_p (memory_size)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir - ? realloc (d->dir, memory_size) - : malloc (memory_size)); - if (memory == NULL) - /* Out of memory. */ - goto out_of_memory; - if (d->dir == d->direct_alloc_dir) - memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE)); - d->dir = memory; - } - } -#if CHAR_T_ONLY_ASCII - else if (!c_isascii (c)) - { - /* Non-ASCII character. Not supported. */ - goto error; - } -#endif - } - d->dir[d->count].dir_start = cp; - - d->max_width_length = max_width_length; - d->max_precision_length = max_precision_length; - return 0; - -error: - if (a->arg != a->direct_alloc_arg) - free (a->arg); - if (d->dir != d->direct_alloc_dir) - free (d->dir); - errno = EINVAL; - return -1; - -out_of_memory: - if (a->arg != a->direct_alloc_arg) - free (a->arg); - if (d->dir != d->direct_alloc_dir) - free (d->dir); - errno = ENOMEM; - return -1; -} - -#undef PRINTF_PARSE -#undef DIRECTIVES -#undef DIRECTIVE -#undef CHAR_T_ONLY_ASCII -#undef CHAR_T diff --git a/grub-core/gnulib/printf-parse.h b/grub-core/gnulib/printf-parse.h deleted file mode 100644 index d8474bee1..000000000 --- a/grub-core/gnulib/printf-parse.h +++ /dev/null @@ -1,193 +0,0 @@ -/* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software - Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _PRINTF_PARSE_H -#define _PRINTF_PARSE_H - -/* This file can be parametrized with the following macros: - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. - STATIC Set to 'static' to declare the function static. */ - -#if HAVE_FEATURES_H -# include /* for __GLIBC__, __UCLIBC__ */ -#endif - -#include "printf-args.h" - - -/* Flags */ -#define FLAG_GROUP 1 /* ' flag */ -#define FLAG_LEFT 2 /* - flag */ -#define FLAG_SHOWSIGN 4 /* + flag */ -#define FLAG_SPACE 8 /* space flag */ -#define FLAG_ALT 16 /* # flag */ -#define FLAG_ZERO 32 -#if __GLIBC__ >= 2 && !defined __UCLIBC__ -# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */ -#endif - -/* arg_index value indicating that no argument is consumed. */ -#define ARG_NONE (~(size_t)0) - -/* xxx_directive: A parsed directive. - xxx_directives: A parsed format string. */ - -/* Number of directly allocated directives (no malloc() needed). */ -#define N_DIRECT_ALLOC_DIRECTIVES 7 - -/* A parsed directive. */ -typedef struct -{ - const char* dir_start; - const char* dir_end; - int flags; - const char* width_start; - const char* width_end; - size_t width_arg_index; - const char* precision_start; - const char* precision_end; - size_t precision_arg_index; - char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ - size_t arg_index; -} -char_directive; - -/* A parsed format string. */ -typedef struct -{ - size_t count; - char_directive *dir; - size_t max_width_length; - size_t max_precision_length; - char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; -} -char_directives; - -#if ENABLE_UNISTDIO - -/* A parsed directive. */ -typedef struct -{ - const uint8_t* dir_start; - const uint8_t* dir_end; - int flags; - const uint8_t* width_start; - const uint8_t* width_end; - size_t width_arg_index; - const uint8_t* precision_start; - const uint8_t* precision_end; - size_t precision_arg_index; - uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ - size_t arg_index; -} -u8_directive; - -/* A parsed format string. */ -typedef struct -{ - size_t count; - u8_directive *dir; - size_t max_width_length; - size_t max_precision_length; - u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; -} -u8_directives; - -/* A parsed directive. */ -typedef struct -{ - const uint16_t* dir_start; - const uint16_t* dir_end; - int flags; - const uint16_t* width_start; - const uint16_t* width_end; - size_t width_arg_index; - const uint16_t* precision_start; - const uint16_t* precision_end; - size_t precision_arg_index; - uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ - size_t arg_index; -} -u16_directive; - -/* A parsed format string. */ -typedef struct -{ - size_t count; - u16_directive *dir; - size_t max_width_length; - size_t max_precision_length; - u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; -} -u16_directives; - -/* A parsed directive. */ -typedef struct -{ - const uint32_t* dir_start; - const uint32_t* dir_end; - int flags; - const uint32_t* width_start; - const uint32_t* width_end; - size_t width_arg_index; - const uint32_t* precision_start; - const uint32_t* precision_end; - size_t precision_arg_index; - uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ - size_t arg_index; -} -u32_directive; - -/* A parsed format string. */ -typedef struct -{ - size_t count; - u32_directive *dir; - size_t max_width_length; - size_t max_precision_length; - u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; -} -u32_directives; - -#endif - - -/* Parses the format string. Fills in the number N of directives, and fills - in directives[0], ..., directives[N-1], and sets directives[N].dir_start - to the end of the format string. Also fills in the arg_type fields of the - arguments and the needed count of arguments. */ -#if ENABLE_UNISTDIO -extern int - ulc_printf_parse (const char *format, char_directives *d, arguments *a); -extern int - u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); -extern int - u16_printf_parse (const uint16_t *format, u16_directives *d, - arguments *a); -extern int - u32_printf_parse (const uint32_t *format, u32_directives *d, - arguments *a); -#else -# ifdef STATIC -STATIC -# else -extern -# endif -int printf_parse (const char *format, char_directives *d, arguments *a); -#endif - -#endif /* _PRINTF_PARSE_H */ diff --git a/grub-core/gnulib/progname.c b/grub-core/gnulib/progname.c deleted file mode 100644 index 0c195e521..000000000 --- a/grub-core/gnulib/progname.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Program name management. - Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - - -#include - -/* Specification. */ -#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */ -#include "progname.h" - -#include /* get program_invocation_name declaration */ -#include -#include -#include - - -/* String containing name the program is called with. - To be initialized by main(). */ -const char *program_name = NULL; - -/* Set program_name, based on argv[0]. - argv0 must be a string allocated with indefinite extent, and must not be - modified after this call. */ -void -set_program_name (const char *argv0) -{ - /* libtool creates a temporary executable whose name is sometimes prefixed - with "lt-" (depends on the platform). It also makes argv[0] absolute. - But the name of the temporary executable is a detail that should not be - visible to the end user and to the test suite. - Remove this "/.libs/" or "/.libs/lt-" prefix here. */ - const char *slash; - const char *base; - - /* Sanity check. POSIX requires the invoking process to pass a non-NULL - argv[0]. */ - if (argv0 == NULL) - { - /* It's a bug in the invoking program. Help diagnosing it. */ - fputs ("A NULL argv[0] was passed through an exec system call.\n", - stderr); - abort (); - } - - slash = strrchr (argv0, '/'); - base = (slash != NULL ? slash + 1 : argv0); - if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0) - { - argv0 = base; - if (strncmp (base, "lt-", 3) == 0) - { - argv0 = base + 3; - /* On glibc systems, remove the "lt-" prefix from the variable - program_invocation_short_name. */ -#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME - program_invocation_short_name = (char *) argv0; -#endif - } - } - - /* But don't strip off a leading / in general, because when the user - runs - /some/hidden/place/bin/cp foo foo - he should get the error message - /some/hidden/place/bin/cp: `foo' and `foo' are the same file - not - cp: `foo' and `foo' are the same file - */ - - program_name = argv0; - - /* On glibc systems, the error() function comes from libc and uses the - variable program_invocation_name, not program_name. So set this variable - as well. */ -#if HAVE_DECL_PROGRAM_INVOCATION_NAME - program_invocation_name = (char *) argv0; -#endif -} diff --git a/grub-core/gnulib/progname.h b/grub-core/gnulib/progname.h deleted file mode 100644 index b4f3c2778..000000000 --- a/grub-core/gnulib/progname.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Program name management. - Copyright (C) 2001-2004, 2006, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _PROGNAME_H -#define _PROGNAME_H - -/* Programs using this file should do the following in main(): - set_program_name (argv[0]); - */ - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* String containing name the program is called with. */ -extern const char *program_name; - -/* Set program_name, based on argv[0]. - argv0 must be a string allocated with indefinite extent, and must not be - modified after this call. */ -extern void set_program_name (const char *argv0); - -#if ENABLE_RELOCATABLE - -/* Set program_name, based on argv[0], and original installation prefix and - directory, for relocatability. */ -extern void set_program_name_and_installdir (const char *argv0, - const char *orig_installprefix, - const char *orig_installdir); -#undef set_program_name -#define set_program_name(ARG0) \ - set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR) - -/* Return the full pathname of the current executable, based on the earlier - call to set_program_name_and_installdir. Return NULL if unknown. */ -extern char *get_full_program_name (void); - -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* _PROGNAME_H */ diff --git a/grub-core/gnulib/rawmemchr.c b/grub-core/gnulib/rawmemchr.c deleted file mode 100644 index a0298ce64..000000000 --- a/grub-core/gnulib/rawmemchr.c +++ /dev/null @@ -1,136 +0,0 @@ -/* Searching in a string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -/* Find the first occurrence of C in S. */ -void * -rawmemchr (const void *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (*char_ptr == c) - return (void *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 is zero. - - We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 is zero is equivalent - to testing whether tmp is nonzero. - - This test can read beyond the end of a string, depending on where - C_IN is encountered. However, this is considered safe since the - initialization phase ensured that the read will be aligned, - therefore, the read will not cross page boundaries and will not - cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - - if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == c. On little-endian machines, we - could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr != c) - char_ptr++; - return (void *) char_ptr; -} diff --git a/grub-core/gnulib/rawmemchr.valgrind b/grub-core/gnulib/rawmemchr.valgrind deleted file mode 100644 index 636392368..000000000 --- a/grub-core/gnulib/rawmemchr.valgrind +++ /dev/null @@ -1,12 +0,0 @@ -# Suppress a valgrind message about use of uninitialized memory in rawmemchr(). -# This use is OK because it provides only a speedup. -{ - rawmemchr-value4 - Memcheck:Value4 - fun:rawmemchr -} -{ - rawmemchr-value8 - Memcheck:Value8 - fun:rawmemchr -} diff --git a/grub-core/gnulib/realloc.c b/grub-core/gnulib/realloc.c deleted file mode 100644 index b51010a62..000000000 --- a/grub-core/gnulib/realloc.c +++ /dev/null @@ -1,79 +0,0 @@ -/* realloc() function that is glibc compatible. - - Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2013 Free Software - Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* written by Jim Meyering and Bruno Haible */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include - -/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ -#ifdef realloc -# define NEED_REALLOC_GNU 1 -/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ -#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU -# define NEED_REALLOC_GNU 1 -#endif - -/* Infer the properties of the system's malloc function. - The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU -# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 -#endif - -#include - -#include - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. If N is zero, change it to 1. If P is NULL, - use malloc. */ - -void * -rpl_realloc (void *p, size_t n) -{ - void *result; - -#if NEED_REALLOC_GNU - if (n == 0) - { - n = 1; - - /* In theory realloc might fail, so don't rely on it to free. */ - free (p); - p = NULL; - } -#endif - - if (p == NULL) - { -#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE - if (n == 0) - n = 1; -#endif - result = malloc (n); - } - else - result = realloc (p, n); - -#if !HAVE_REALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} diff --git a/grub-core/gnulib/ref-add.sin b/grub-core/gnulib/ref-add.sin deleted file mode 100644 index 112bcdc64..000000000 --- a/grub-core/gnulib/ref-add.sin +++ /dev/null @@ -1,29 +0,0 @@ -# Add this package to a list of references stored in a text file. -# -# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. -# -# This program 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, 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, see . -# -# Written by Bruno Haible . -# -/^# Packages using this file: / { - s/# Packages using this file:// - ta - :a - s/ @PACKAGE@ / @PACKAGE@ / - tb - s/ $/ @PACKAGE@ / - :b - s/^/# Packages using this file:/ -} diff --git a/grub-core/gnulib/ref-del.sin b/grub-core/gnulib/ref-del.sin deleted file mode 100644 index 6f7386847..000000000 --- a/grub-core/gnulib/ref-del.sin +++ /dev/null @@ -1,24 +0,0 @@ -# Remove this package from a list of references stored in a text file. -# -# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. -# -# This program 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, 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, see . -# -# Written by Bruno Haible . -# -/^# Packages using this file: / { - s/# Packages using this file:// - s/ @PACKAGE@ / / - s/^/# Packages using this file:/ -} diff --git a/grub-core/gnulib/regcomp.c b/grub-core/gnulib/regcomp.c deleted file mode 100644 index 596e0cf3e..000000000 --- a/grub-core/gnulib/regcomp.c +++ /dev/null @@ -1,3913 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, - size_t length, reg_syntax_t syntax); -static void re_compile_fastmap_iter (regex_t *bufp, - const re_dfastate_t *init_state, - char *fastmap); -static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); -#ifdef RE_ENABLE_I18N -static void free_charset (re_charset_t *cset); -#endif /* RE_ENABLE_I18N */ -static void free_workarea_compile (regex_t *preg); -static reg_errcode_t create_initial_state (re_dfa_t *dfa); -#ifdef RE_ENABLE_I18N -static void optimize_utf8 (re_dfa_t *dfa); -#endif -static reg_errcode_t analyze (regex_t *preg); -static reg_errcode_t preorder (bin_tree_t *root, - reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra); -static reg_errcode_t postorder (bin_tree_t *root, - reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra); -static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node); -static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node); -static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg, - bin_tree_t *node); -static reg_errcode_t calc_first (void *extra, bin_tree_t *node); -static reg_errcode_t calc_next (void *extra, bin_tree_t *node); -static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); -static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint); -static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node, - unsigned int constraint); -static reg_errcode_t calc_eclosure (re_dfa_t *dfa); -static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, - Idx node, bool root); -static reg_errcode_t calc_inveclosure (re_dfa_t *dfa); -static Idx fetch_number (re_string_t *input, re_token_t *token, - reg_syntax_t syntax); -static int peek_token (re_token_t *token, re_string_t *input, - reg_syntax_t syntax) internal_function; -static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, - reg_syntax_t syntax, reg_errcode_t *err); -static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - Idx nest, reg_errcode_t *err); -static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - Idx nest, reg_errcode_t *err); -static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - Idx nest, reg_errcode_t *err); -static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - Idx nest, reg_errcode_t *err); -static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp, - re_dfa_t *dfa, re_token_t *token, - reg_syntax_t syntax, reg_errcode_t *err); -static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, - re_token_t *token, reg_syntax_t syntax, - reg_errcode_t *err); -static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, - re_string_t *regexp, - re_token_t *token, int token_len, - re_dfa_t *dfa, - reg_syntax_t syntax, - bool accept_hyphen); -static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, - re_string_t *regexp, - re_token_t *token); -#ifdef RE_ENABLE_I18N -static reg_errcode_t build_equiv_class (bitset_t sbcset, - re_charset_t *mbcset, - Idx *equiv_class_alloc, - const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, - bitset_t sbcset, - re_charset_t *mbcset, - Idx *char_class_alloc, - const char *class_name, - reg_syntax_t syntax); -#else /* not RE_ENABLE_I18N */ -static reg_errcode_t build_equiv_class (bitset_t sbcset, - const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, - bitset_t sbcset, - const char *class_name, - reg_syntax_t syntax); -#endif /* not RE_ENABLE_I18N */ -static bin_tree_t *build_charclass_op (re_dfa_t *dfa, - RE_TRANSLATE_TYPE trans, - const char *class_name, - const char *extra, - bool non_match, reg_errcode_t *err); -static bin_tree_t *create_tree (re_dfa_t *dfa, - bin_tree_t *left, bin_tree_t *right, - re_token_type_t type); -static bin_tree_t *create_token_tree (re_dfa_t *dfa, - bin_tree_t *left, bin_tree_t *right, - const re_token_t *token); -static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); -static void free_token (re_token_t *node); -static reg_errcode_t free_tree (void *extra, bin_tree_t *node); -static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. - POSIX doesn't require that we do anything for REG_NOERROR, - but why not be nice? */ - -static const char __re_error_msgid[] = - { -#define REG_NOERROR_IDX 0 - gettext_noop ("Success") /* REG_NOERROR */ - "\0" -#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") - gettext_noop ("No match") /* REG_NOMATCH */ - "\0" -#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") - gettext_noop ("Invalid regular expression") /* REG_BADPAT */ - "\0" -#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") - gettext_noop ("Invalid collation character") /* REG_ECOLLATE */ - "\0" -#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") - gettext_noop ("Invalid character class name") /* REG_ECTYPE */ - "\0" -#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") - gettext_noop ("Trailing backslash") /* REG_EESCAPE */ - "\0" -#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") - gettext_noop ("Invalid back reference") /* REG_ESUBREG */ - "\0" -#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") - gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ - "\0" -#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") - gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ - "\0" -#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") - gettext_noop ("Unmatched \\{") /* REG_EBRACE */ - "\0" -#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") - gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ - "\0" -#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") - gettext_noop ("Invalid range end") /* REG_ERANGE */ - "\0" -#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") - gettext_noop ("Memory exhausted") /* REG_ESPACE */ - "\0" -#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") - gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ - "\0" -#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") - gettext_noop ("Premature end of regular expression") /* REG_EEND */ - "\0" -#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") - gettext_noop ("Regular expression too big") /* REG_ESIZE */ - "\0" -#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") - gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */ - }; - -static const size_t __re_error_msgid_idx[] = - { - REG_NOERROR_IDX, - REG_NOMATCH_IDX, - REG_BADPAT_IDX, - REG_ECOLLATE_IDX, - REG_ECTYPE_IDX, - REG_EESCAPE_IDX, - REG_ESUBREG_IDX, - REG_EBRACK_IDX, - REG_EPAREN_IDX, - REG_EBRACE_IDX, - REG_BADBR_IDX, - REG_ERANGE_IDX, - REG_ESPACE_IDX, - REG_BADRPT_IDX, - REG_EEND_IDX, - REG_ESIZE_IDX, - REG_ERPAREN_IDX - }; - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length LENGTH) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields - are set in BUFP on entry. */ - -#ifdef _LIBC -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - size_t length; - struct re_pattern_buffer *bufp; -#else /* size_t might promote */ -const char * -re_compile_pattern (const char *pattern, size_t length, - struct re_pattern_buffer *bufp) -#endif -{ - reg_errcode_t ret; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub, unless RE_NO_SUB is set. */ - bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = re_compile_internal (bufp, pattern, length, re_syntax_options); - - if (!ret) - return NULL; - return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); -} -#ifdef _LIBC -weak_alias (__re_compile_pattern, re_compile_pattern) -#endif - -/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -/* This has no initializer because initialized variables in Emacs - become read-only after dumping. */ -reg_syntax_t re_syntax_options; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} -#ifdef _LIBC -weak_alias (__re_set_syntax, re_set_syntax) -#endif - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - re_dfa_t *dfa = bufp->buffer; - char *fastmap = bufp->fastmap; - - memset (fastmap, '\0', sizeof (char) * SBC_MAX); - re_compile_fastmap_iter (bufp, dfa->init_state, fastmap); - if (dfa->init_state != dfa->init_state_word) - re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap); - if (dfa->init_state != dfa->init_state_nl) - re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap); - if (dfa->init_state != dfa->init_state_begbuf) - re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap); - bufp->fastmap_accurate = 1; - return 0; -} -#ifdef _LIBC -weak_alias (__re_compile_fastmap, re_compile_fastmap) -#endif - -static inline void -__attribute__ ((always_inline)) -re_set_fastmap (char *fastmap, bool icase, int ch) -{ - fastmap[ch] = 1; - if (icase) - fastmap[tolower (ch)] = 1; -} - -/* Helper function for re_compile_fastmap. - Compile fastmap for the initial_state INIT_STATE. */ - -static void -re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, - char *fastmap) -{ - re_dfa_t *dfa = bufp->buffer; - Idx node_cnt; - bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); - for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) - { - Idx node = init_state->nodes.elems[node_cnt]; - re_token_type_t type = dfa->nodes[node].type; - - if (type == CHARACTER) - { - re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); -#ifdef RE_ENABLE_I18N - if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) - { - unsigned char buf[MB_LEN_MAX]; - unsigned char *p; - wchar_t wc; - mbstate_t state; - - p = buf; - *p++ = dfa->nodes[node].opr.c; - while (++node < dfa->nodes_len - && dfa->nodes[node].type == CHARACTER - && dfa->nodes[node].mb_partial) - *p++ = dfa->nodes[node].opr.c; - memset (&state, '\0', sizeof (state)); - if (__mbrtowc (&wc, (const char *) buf, p - buf, - &state) == p - buf - && (__wcrtomb ((char *) buf, towlower (wc), &state) - != (size_t) -1)) - re_set_fastmap (fastmap, false, buf[0]); - } -#endif - } - else if (type == SIMPLE_BRACKET) - { - int i, ch; - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - { - int j; - bitset_word_t w = dfa->nodes[node].opr.sbcset[i]; - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - if (w & ((bitset_word_t) 1 << j)) - re_set_fastmap (fastmap, icase, ch); - } - } -#ifdef RE_ENABLE_I18N - else if (type == COMPLEX_BRACKET) - { - re_charset_t *cset = dfa->nodes[node].opr.mbcset; - Idx i; - -# ifdef _LIBC - /* See if we have to try all bytes which start multiple collation - elements. - e.g. In da_DK, we want to catch 'a' since "aa" is a valid - collation element, and don't catch 'b' since 'b' is - the only collation element which starts from 'b' (and - it is caught by SIMPLE_BRACKET). */ - if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0 - && (cset->ncoll_syms || cset->nranges)) - { - const int32_t *table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - for (i = 0; i < SBC_MAX; ++i) - if (table[i] < 0) - re_set_fastmap (fastmap, icase, i); - } -# endif /* _LIBC */ - - /* See if we have to start the match at all multibyte characters, - i.e. where we would not find an invalid sequence. This only - applies to multibyte character sets; for single byte character - sets, the SIMPLE_BRACKET again suffices. */ - if (dfa->mb_cur_max > 1 - && (cset->nchar_classes || cset->non_match || cset->nranges -# ifdef _LIBC - || cset->nequiv_classes -# endif /* _LIBC */ - )) - { - unsigned char c = 0; - do - { - mbstate_t mbs; - memset (&mbs, 0, sizeof (mbs)); - if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2) - re_set_fastmap (fastmap, false, (int) c); - } - while (++c != 0); - } - - else - { - /* ... Else catch all bytes which can start the mbchars. */ - for (i = 0; i < cset->nmbchars; ++i) - { - char buf[256]; - mbstate_t state; - memset (&state, '\0', sizeof (state)); - if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1) - re_set_fastmap (fastmap, icase, *(unsigned char *) buf); - if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) - { - if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) - != (size_t) -1) - re_set_fastmap (fastmap, false, *(unsigned char *) buf); - } - } - } - } -#endif /* RE_ENABLE_I18N */ - else if (type == OP_PERIOD -#ifdef RE_ENABLE_I18N - || type == OP_UTF8_PERIOD -#endif /* RE_ENABLE_I18N */ - || type == END_OF_RE) - { - memset (fastmap, '\1', sizeof (char) * SBC_MAX); - if (type == END_OF_RE) - bufp->can_be_null = 1; - return; - } - } -} - -/* Entry point for POSIX code. */ -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - 'buffer' to the compiled pattern; - 'used' to the length of the compiled pattern; - 'syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - 'newline_anchor' to REG_NEWLINE being set in CFLAGS; - 'fastmap' to an allocated space for the fastmap; - 'fastmap_accurate' to zero; - 're_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *_Restrict_ preg; - const char *_Restrict_ pattern; - int cflags; -{ - reg_errcode_t ret; - reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED - : RE_SYNTAX_POSIX_BASIC); - - preg->buffer = NULL; - preg->allocated = 0; - preg->used = 0; - - /* Try to allocate space for the fastmap. */ - preg->fastmap = re_malloc (char, SBC_MAX); - if (BE (preg->fastmap == NULL, 0)) - return REG_ESPACE; - - syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - preg->no_sub = !!(cflags & REG_NOSUB); - preg->translate = NULL; - - ret = re_compile_internal (preg, pattern, strlen (pattern), syntax); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) - ret = REG_EPAREN; - - /* We have already checked preg->fastmap != NULL. */ - if (BE (ret == REG_NOERROR, 1)) - /* Compute the fastmap now, since regexec cannot modify the pattern - buffer. This function never fails in this implementation. */ - (void) re_compile_fastmap (preg); - else - { - /* Some error occurred while compiling the expression. */ - re_free (preg->fastmap); - preg->fastmap = NULL; - } - - return (int) ret; -} -#ifdef _LIBC -weak_alias (__regcomp, regcomp) -#endif - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -#ifdef _LIBC -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *_Restrict_ preg; - char *_Restrict_ errbuf; - size_t errbuf_size; -#else /* size_t might promote */ -size_t -regerror (int errcode, const regex_t *_Restrict_ preg, - char *_Restrict_ errbuf, size_t errbuf_size) -#endif -{ - const char *msg; - size_t msg_size; - - if (BE (errcode < 0 - || errcode >= (int) (sizeof (__re_error_msgid_idx) - / sizeof (__re_error_msgid_idx[0])), 0)) - msg = gettext ("unknown regexp error"); - else - msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (BE (errbuf_size != 0, 1)) - { - size_t cpy_size = msg_size; - if (BE (msg_size > errbuf_size, 0)) - { - cpy_size = errbuf_size - 1; - errbuf[cpy_size] = '\0'; - } - memcpy (errbuf, msg, cpy_size); - } - - return msg_size; -} -#ifdef _LIBC -weak_alias (__regerror, regerror) -#endif - - -#ifdef RE_ENABLE_I18N -/* This static array is used for the map to single-byte characters when - UTF-8 is used. Otherwise we would allocate memory just to initialize - it the same all the time. UTF-8 is the preferred encoding so this is - a worthwhile optimization. */ -static const bitset_t utf8_sb_map = -{ - /* Set the first 128 bits. */ -# ifdef __GNUC__ - [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX -# else -# if 4 * BITSET_WORD_BITS < ASCII_CHARS -# error "bitset_word_t is narrower than 32 bits" -# elif 3 * BITSET_WORD_BITS < ASCII_CHARS - BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, -# elif 2 * BITSET_WORD_BITS < ASCII_CHARS - BITSET_WORD_MAX, BITSET_WORD_MAX, -# elif 1 * BITSET_WORD_BITS < ASCII_CHARS - BITSET_WORD_MAX, -# endif - (BITSET_WORD_MAX - >> (SBC_MAX % BITSET_WORD_BITS == 0 - ? 0 - : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) -# endif -}; -#endif - - -static void -free_dfa_content (re_dfa_t *dfa) -{ - Idx i, j; - - if (dfa->nodes) - for (i = 0; i < dfa->nodes_len; ++i) - free_token (dfa->nodes + i); - re_free (dfa->nexts); - for (i = 0; i < dfa->nodes_len; ++i) - { - if (dfa->eclosures != NULL) - re_node_set_free (dfa->eclosures + i); - if (dfa->inveclosures != NULL) - re_node_set_free (dfa->inveclosures + i); - if (dfa->edests != NULL) - re_node_set_free (dfa->edests + i); - } - re_free (dfa->edests); - re_free (dfa->eclosures); - re_free (dfa->inveclosures); - re_free (dfa->nodes); - - if (dfa->state_table) - for (i = 0; i <= dfa->state_hash_mask; ++i) - { - struct re_state_table_entry *entry = dfa->state_table + i; - for (j = 0; j < entry->num; ++j) - { - re_dfastate_t *state = entry->array[j]; - free_state (state); - } - re_free (entry->array); - } - re_free (dfa->state_table); -#ifdef RE_ENABLE_I18N - if (dfa->sb_char != utf8_sb_map) - re_free (dfa->sb_char); -#endif - re_free (dfa->subexp_map); -#ifdef DEBUG - re_free (dfa->re_str); -#endif - - re_free (dfa); -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - re_dfa_t *dfa = preg->buffer; - if (BE (dfa != NULL, 1)) - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - - re_free (preg->fastmap); - preg->fastmap = NULL; - - re_free (preg->translate); - preg->translate = NULL; -} -#ifdef _LIBC -weak_alias (__regfree, regfree) -#endif - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them unless specifically requested. */ - -#if defined _REGEX_RE_COMP || defined _LIBC - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -# ifdef _LIBC -/* Make these definitions weak in libc, so POSIX programs can redefine - these names if they don't use our functions, and still use - regcomp/regexec above without link errors. */ -weak_function -# endif -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - char *fastmap; - - if (!s) - { - if (!re_comp_buf.buffer) - return gettext ("No previous regular expression"); - return 0; - } - - if (re_comp_buf.buffer) - { - fastmap = re_comp_buf.fastmap; - re_comp_buf.fastmap = NULL; - __regfree (&re_comp_buf); - memset (&re_comp_buf, '\0', sizeof (re_comp_buf)); - re_comp_buf.fastmap = fastmap; - } - - if (re_comp_buf.fastmap == NULL) - { - re_comp_buf.fastmap = (char *) malloc (SBC_MAX); - if (re_comp_buf.fastmap == NULL) - return (char *) gettext (__re_error_msgid - + __re_error_msgid_idx[(int) REG_ESPACE]); - } - - /* Since 're_exec' always passes NULL for the 'regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); - - if (!ret) - return NULL; - - /* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */ - return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); -} - -#ifdef _LIBC -libc_freeres_fn (free_mem) -{ - __regfree (&re_comp_buf); -} -#endif - -#endif /* _REGEX_RE_COMP */ - -/* Internal entry point. - Compile the regular expression PATTERN, whose length is LENGTH. - SYNTAX indicate regular expression's syntax. */ - -static reg_errcode_t -re_compile_internal (regex_t *preg, const char * pattern, size_t length, - reg_syntax_t syntax) -{ - reg_errcode_t err = REG_NOERROR; - re_dfa_t *dfa; - re_string_t regexp; - - /* Initialize the pattern buffer. */ - preg->fastmap_accurate = 0; - preg->syntax = syntax; - preg->not_bol = preg->not_eol = 0; - preg->used = 0; - preg->re_nsub = 0; - preg->can_be_null = 0; - preg->regs_allocated = REGS_UNALLOCATED; - - /* Initialize the dfa. */ - dfa = preg->buffer; - if (BE (preg->allocated < sizeof (re_dfa_t), 0)) - { - /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. If ->buffer is NULL this - is a simple allocation. */ - dfa = re_realloc (preg->buffer, re_dfa_t, 1); - if (dfa == NULL) - return REG_ESPACE; - preg->allocated = sizeof (re_dfa_t); - preg->buffer = dfa; - } - preg->used = sizeof (re_dfa_t); - - err = init_dfa (dfa, length); - if (BE (err != REG_NOERROR, 0)) - { - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - return err; - } -#ifdef DEBUG - /* Note: length+1 will not overflow since it is checked in init_dfa. */ - dfa->re_str = re_malloc (char, length + 1); - strncpy (dfa->re_str, pattern, length + 1); -#endif - - __libc_lock_init (dfa->lock); - - err = re_string_construct (®exp, pattern, length, preg->translate, - (syntax & RE_ICASE) != 0, dfa); - if (BE (err != REG_NOERROR, 0)) - { - re_compile_internal_free_return: - free_workarea_compile (preg); - re_string_destruct (®exp); - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - return err; - } - - /* Parse the regular expression, and build a structure tree. */ - preg->re_nsub = 0; - dfa->str_tree = parse (®exp, preg, syntax, &err); - if (BE (dfa->str_tree == NULL, 0)) - goto re_compile_internal_free_return; - - /* Analyze the tree and create the nfa. */ - err = analyze (preg); - if (BE (err != REG_NOERROR, 0)) - goto re_compile_internal_free_return; - -#ifdef RE_ENABLE_I18N - /* If possible, do searching in single byte encoding to speed things up. */ - if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) - optimize_utf8 (dfa); -#endif - - /* Then create the initial state of the dfa. */ - err = create_initial_state (dfa); - - /* Release work areas. */ - free_workarea_compile (preg); - re_string_destruct (®exp); - - if (BE (err != REG_NOERROR, 0)) - { - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - } - - return err; -} - -/* Initialize DFA. We use the length of the regular expression PAT_LEN - as the initial length of some arrays. */ - -static reg_errcode_t -init_dfa (re_dfa_t *dfa, size_t pat_len) -{ - __re_size_t table_size; -#ifndef _LIBC - const char *codeset_name; -#endif -#ifdef RE_ENABLE_I18N - size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); -#else - size_t max_i18n_object_size = 0; -#endif - size_t max_object_size = - MAX (sizeof (struct re_state_table_entry), - MAX (sizeof (re_token_t), - MAX (sizeof (re_node_set), - MAX (sizeof (regmatch_t), - max_i18n_object_size)))); - - memset (dfa, '\0', sizeof (re_dfa_t)); - - /* Force allocation of str_tree_storage the first time. */ - dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; - - /* Avoid overflows. The extra "/ 2" is for the table_size doubling - calculation below, and for similar doubling calculations - elsewhere. And it's <= rather than <, because some of the - doubling calculations add 1 afterwards. */ - if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) - return REG_ESPACE; - - dfa->nodes_alloc = pat_len + 1; - dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); - - /* table_size = 2 ^ ceil(log pat_len) */ - for (table_size = 1; ; table_size <<= 1) - if (table_size > pat_len) - break; - - dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); - dfa->state_hash_mask = table_size - 1; - - dfa->mb_cur_max = MB_CUR_MAX; -#ifdef _LIBC - if (dfa->mb_cur_max == 6 - && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) - dfa->is_utf8 = 1; - dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) - != 0); -#else - codeset_name = nl_langinfo (CODESET); - if ((codeset_name[0] == 'U' || codeset_name[0] == 'u') - && (codeset_name[1] == 'T' || codeset_name[1] == 't') - && (codeset_name[2] == 'F' || codeset_name[2] == 'f') - && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0) - dfa->is_utf8 = 1; - - /* We check exhaustively in the loop below if this charset is a - superset of ASCII. */ - dfa->map_notascii = 0; -#endif - -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - if (dfa->is_utf8) - dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map; - else - { - int i, j, ch; - - dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); - if (BE (dfa->sb_char == NULL, 0)) - return REG_ESPACE; - - /* Set the bits corresponding to single byte chars. */ - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - { - wint_t wch = __btowc (ch); - if (wch != WEOF) - dfa->sb_char[i] |= (bitset_word_t) 1 << j; -# ifndef _LIBC - if (isascii (ch) && wch != ch) - dfa->map_notascii = 1; -# endif - } - } - } -#endif - - if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) - return REG_ESPACE; - return REG_NOERROR; -} - -/* Initialize WORD_CHAR table, which indicate which character is - "word". In this case "word" means that it is the word construction - character used by some operators like "\<", "\>", etc. */ - -static void -internal_function -init_word_char (re_dfa_t *dfa) -{ - int i = 0; - int j; - int ch = 0; - dfa->word_ops_used = 1; - if (BE (dfa->map_notascii == 0, 1)) - { - bitset_word_t bits0 = 0x00000000; - bitset_word_t bits1 = 0x03ff0000; - bitset_word_t bits2 = 0x87fffffe; - bitset_word_t bits3 = 0x07fffffe; - if (BITSET_WORD_BITS == 64) - { - dfa->word_char[0] = bits1 << 31 << 1 | bits0; - dfa->word_char[1] = bits3 << 31 << 1 | bits2; - i = 2; - } - else if (BITSET_WORD_BITS == 32) - { - dfa->word_char[0] = bits0; - dfa->word_char[1] = bits1; - dfa->word_char[2] = bits2; - dfa->word_char[3] = bits3; - i = 4; - } - else - goto general_case; - ch = 128; - - if (BE (dfa->is_utf8, 1)) - { - memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); - return; - } - } - - general_case: - for (; i < BITSET_WORDS; ++i) - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - if (isalnum (ch) || ch == '_') - dfa->word_char[i] |= (bitset_word_t) 1 << j; -} - -/* Free the work area which are only used while compiling. */ - -static void -free_workarea_compile (regex_t *preg) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_storage_t *storage, *next; - for (storage = dfa->str_tree_storage; storage; storage = next) - { - next = storage->next; - re_free (storage); - } - dfa->str_tree_storage = NULL; - dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; - dfa->str_tree = NULL; - re_free (dfa->org_indices); - dfa->org_indices = NULL; -} - -/* Create initial states for all contexts. */ - -static reg_errcode_t -create_initial_state (re_dfa_t *dfa) -{ - Idx first, i; - reg_errcode_t err; - re_node_set init_nodes; - - /* Initial states have the epsilon closure of the node which is - the first node of the regular expression. */ - first = dfa->str_tree->first->node_idx; - dfa->init_node = first; - err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* The back-references which are in initial states can epsilon transit, - since in this case all of the subexpressions can be null. - Then we add epsilon closures of the nodes which are the next nodes of - the back-references. */ - if (dfa->nbackref > 0) - for (i = 0; i < init_nodes.nelem; ++i) - { - Idx node_idx = init_nodes.elems[i]; - re_token_type_t type = dfa->nodes[node_idx].type; - - Idx clexp_idx; - if (type != OP_BACK_REF) - continue; - for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx) - { - re_token_t *clexp_node; - clexp_node = dfa->nodes + init_nodes.elems[clexp_idx]; - if (clexp_node->type == OP_CLOSE_SUBEXP - && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx) - break; - } - if (clexp_idx == init_nodes.nelem) - continue; - - if (type == OP_BACK_REF) - { - Idx dest_idx = dfa->edests[node_idx].elems[0]; - if (!re_node_set_contains (&init_nodes, dest_idx)) - { - reg_errcode_t merge_err - = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx); - if (merge_err != REG_NOERROR) - return merge_err; - i = 0; - } - } - } - - /* It must be the first time to invoke acquire_state. */ - dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); - /* We don't check ERR here, since the initial state must not be NULL. */ - if (BE (dfa->init_state == NULL, 0)) - return err; - if (dfa->init_state->has_constraint) - { - dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, - CONTEXT_WORD); - dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes, - CONTEXT_NEWLINE); - dfa->init_state_begbuf = re_acquire_state_context (&err, dfa, - &init_nodes, - CONTEXT_NEWLINE - | CONTEXT_BEGBUF); - if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL - || dfa->init_state_begbuf == NULL, 0)) - return err; - } - else - dfa->init_state_word = dfa->init_state_nl - = dfa->init_state_begbuf = dfa->init_state; - - re_node_set_free (&init_nodes); - return REG_NOERROR; -} - -#ifdef RE_ENABLE_I18N -/* If it is possible to do searching in single byte encoding instead of UTF-8 - to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change - DFA nodes where needed. */ - -static void -optimize_utf8 (re_dfa_t *dfa) -{ - Idx node; - int i; - bool mb_chars = false; - bool has_period = false; - - for (node = 0; node < dfa->nodes_len; ++node) - switch (dfa->nodes[node].type) - { - case CHARACTER: - if (dfa->nodes[node].opr.c >= ASCII_CHARS) - mb_chars = true; - break; - case ANCHOR: - switch (dfa->nodes[node].opr.ctx_type) - { - case LINE_FIRST: - case LINE_LAST: - case BUF_FIRST: - case BUF_LAST: - break; - default: - /* Word anchors etc. cannot be handled. It's okay to test - opr.ctx_type since constraints (for all DFA nodes) are - created by ORing one or more opr.ctx_type values. */ - return; - } - break; - case OP_PERIOD: - has_period = true; - break; - case OP_BACK_REF: - case OP_ALT: - case END_OF_RE: - case OP_DUP_ASTERISK: - case OP_OPEN_SUBEXP: - case OP_CLOSE_SUBEXP: - break; - case COMPLEX_BRACKET: - return; - case SIMPLE_BRACKET: - /* Just double check. */ - { - int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0 - ? 0 - : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS); - for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) - { - if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0) - return; - rshift = 0; - } - } - break; - default: - break; - } - - if (mb_chars || has_period) - for (node = 0; node < dfa->nodes_len; ++node) - { - if (dfa->nodes[node].type == CHARACTER - && dfa->nodes[node].opr.c >= ASCII_CHARS) - dfa->nodes[node].mb_partial = 0; - else if (dfa->nodes[node].type == OP_PERIOD) - dfa->nodes[node].type = OP_UTF8_PERIOD; - } - - /* The search can be in single byte locale. */ - dfa->mb_cur_max = 1; - dfa->is_utf8 = 0; - dfa->has_mb_node = dfa->nbackref > 0 || has_period; -} -#endif - -/* Analyze the structure tree, and calculate "first", "next", "edest", - "eclosure", and "inveclosure". */ - -static reg_errcode_t -analyze (regex_t *preg) -{ - re_dfa_t *dfa = preg->buffer; - reg_errcode_t ret; - - /* Allocate arrays. */ - dfa->nexts = re_malloc (Idx, dfa->nodes_alloc); - dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); - dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); - dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); - if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL - || dfa->eclosures == NULL, 0)) - return REG_ESPACE; - - dfa->subexp_map = re_malloc (Idx, preg->re_nsub); - if (dfa->subexp_map != NULL) - { - Idx i; - for (i = 0; i < preg->re_nsub; i++) - dfa->subexp_map[i] = i; - preorder (dfa->str_tree, optimize_subexps, dfa); - for (i = 0; i < preg->re_nsub; i++) - if (dfa->subexp_map[i] != i) - break; - if (i == preg->re_nsub) - { - free (dfa->subexp_map); - dfa->subexp_map = NULL; - } - } - - ret = postorder (dfa->str_tree, lower_subexps, preg); - if (BE (ret != REG_NOERROR, 0)) - return ret; - ret = postorder (dfa->str_tree, calc_first, dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - preorder (dfa->str_tree, calc_next, dfa); - ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - ret = calc_eclosure (dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - /* We only need this during the prune_impossible_nodes pass in regexec.c; - skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */ - if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match) - || dfa->nbackref) - { - dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); - if (BE (dfa->inveclosures == NULL, 0)) - return REG_ESPACE; - ret = calc_inveclosure (dfa); - } - - return ret; -} - -/* Our parse trees are very unbalanced, so we cannot use a stack to - implement parse tree visits. Instead, we use parent pointers and - some hairy code in these two functions. */ -static reg_errcode_t -postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra) -{ - bin_tree_t *node, *prev; - - for (node = root; ; ) - { - /* Descend down the tree, preferably to the left (or to the right - if that's the only child). */ - while (node->left || node->right) - if (node->left) - node = node->left; - else - node = node->right; - - do - { - reg_errcode_t err = fn (extra, node); - if (BE (err != REG_NOERROR, 0)) - return err; - if (node->parent == NULL) - return REG_NOERROR; - prev = node; - node = node->parent; - } - /* Go up while we have a node that is reached from the right. */ - while (node->right == prev || node->right == NULL); - node = node->right; - } -} - -static reg_errcode_t -preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra) -{ - bin_tree_t *node; - - for (node = root; ; ) - { - reg_errcode_t err = fn (extra, node); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* Go to the left node, or up and to the right. */ - if (node->left) - node = node->left; - else - { - bin_tree_t *prev = NULL; - while (node->right == prev || node->right == NULL) - { - prev = node; - node = node->parent; - if (!node) - return REG_NOERROR; - } - node = node->right; - } - } -} - -/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell - re_search_internal to map the inner one's opr.idx to this one's. Adjust - backreferences as well. Requires a preorder visit. */ -static reg_errcode_t -optimize_subexps (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - - if (node->token.type == OP_BACK_REF && dfa->subexp_map) - { - int idx = node->token.opr.idx; - node->token.opr.idx = dfa->subexp_map[idx]; - dfa->used_bkref_map |= 1 << node->token.opr.idx; - } - - else if (node->token.type == SUBEXP - && node->left && node->left->token.type == SUBEXP) - { - Idx other_idx = node->left->token.opr.idx; - - node->left = node->left->left; - if (node->left) - node->left->parent = node; - - dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; - if (other_idx < BITSET_WORD_BITS) - dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx); - } - - return REG_NOERROR; -} - -/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation - of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */ -static reg_errcode_t -lower_subexps (void *extra, bin_tree_t *node) -{ - regex_t *preg = (regex_t *) extra; - reg_errcode_t err = REG_NOERROR; - - if (node->left && node->left->token.type == SUBEXP) - { - node->left = lower_subexp (&err, preg, node->left); - if (node->left) - node->left->parent = node; - } - if (node->right && node->right->token.type == SUBEXP) - { - node->right = lower_subexp (&err, preg, node->right); - if (node->right) - node->right->parent = node; - } - - return err; -} - -static bin_tree_t * -lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_t *body = node->left; - bin_tree_t *op, *cls, *tree1, *tree; - - if (preg->no_sub - /* We do not optimize empty subexpressions, because otherwise we may - have bad CONCAT nodes with NULL children. This is obviously not - very common, so we do not lose much. An example that triggers - this case is the sed "script" /\(\)/x. */ - && node->left != NULL - && (node->token.opr.idx >= BITSET_WORD_BITS - || !(dfa->used_bkref_map - & ((bitset_word_t) 1 << node->token.opr.idx)))) - return node->left; - - /* Convert the SUBEXP node to the concatenation of an - OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */ - op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP); - cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); - tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; - tree = create_tree (dfa, op, tree1, CONCAT); - if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - - op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; - op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; - return tree; -} - -/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton - nodes. Requires a postorder visit. */ -static reg_errcode_t -calc_first (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - if (node->token.type == CONCAT) - { - node->first = node->left->first; - node->node_idx = node->left->node_idx; - } - else - { - node->first = node; - node->node_idx = re_dfa_add_node (dfa, node->token); - if (BE (node->node_idx == REG_MISSING, 0)) - return REG_ESPACE; - if (node->token.type == ANCHOR) - dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; - } - return REG_NOERROR; -} - -/* Pass 2: compute NEXT on the tree. Preorder visit. */ -static reg_errcode_t -calc_next (void *extra, bin_tree_t *node) -{ - switch (node->token.type) - { - case OP_DUP_ASTERISK: - node->left->next = node; - break; - case CONCAT: - node->left->next = node->right->first; - node->right->next = node->next; - break; - default: - if (node->left) - node->left->next = node->next; - if (node->right) - node->right->next = node->next; - break; - } - return REG_NOERROR; -} - -/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */ -static reg_errcode_t -link_nfa_nodes (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - Idx idx = node->node_idx; - reg_errcode_t err = REG_NOERROR; - - switch (node->token.type) - { - case CONCAT: - break; - - case END_OF_RE: - assert (node->next == NULL); - break; - - case OP_DUP_ASTERISK: - case OP_ALT: - { - Idx left, right; - dfa->has_plural_match = 1; - if (node->left != NULL) - left = node->left->first->node_idx; - else - left = node->next->node_idx; - if (node->right != NULL) - right = node->right->first->node_idx; - else - right = node->next->node_idx; - assert (REG_VALID_INDEX (left)); - assert (REG_VALID_INDEX (right)); - err = re_node_set_init_2 (dfa->edests + idx, left, right); - } - break; - - case ANCHOR: - case OP_OPEN_SUBEXP: - case OP_CLOSE_SUBEXP: - err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx); - break; - - case OP_BACK_REF: - dfa->nexts[idx] = node->next->node_idx; - if (node->token.type == OP_BACK_REF) - err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]); - break; - - default: - assert (!IS_EPSILON_NODE (node->token.type)); - dfa->nexts[idx] = node->next->node_idx; - break; - } - - return err; -} - -/* Duplicate the epsilon closure of the node ROOT_NODE. - Note that duplicated nodes have constraint INIT_CONSTRAINT in addition - to their own constraint. */ - -static reg_errcode_t -internal_function -duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, - Idx root_node, unsigned int init_constraint) -{ - Idx org_node, clone_node; - bool ok; - unsigned int constraint = init_constraint; - for (org_node = top_org_node, clone_node = top_clone_node;;) - { - Idx org_dest, clone_dest; - if (dfa->nodes[org_node].type == OP_BACK_REF) - { - /* If the back reference epsilon-transit, its destination must - also have the constraint. Then duplicate the epsilon closure - of the destination of the back reference, and store it in - edests of the back reference. */ - org_dest = dfa->nexts[org_node]; - re_node_set_empty (dfa->edests + clone_node); - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == REG_MISSING, 0)) - return REG_ESPACE; - dfa->nexts[clone_node] = dfa->nexts[org_node]; - ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - } - else if (dfa->edests[org_node].nelem == 0) - { - /* In case of the node can't epsilon-transit, don't duplicate the - destination and store the original destination as the - destination of the node. */ - dfa->nexts[clone_node] = dfa->nexts[org_node]; - break; - } - else if (dfa->edests[org_node].nelem == 1) - { - /* In case of the node can epsilon-transit, and it has only one - destination. */ - org_dest = dfa->edests[org_node].elems[0]; - re_node_set_empty (dfa->edests + clone_node); - /* If the node is root_node itself, it means the epsilon closure - has a loop. Then tie it to the destination of the root_node. */ - if (org_node == root_node && clone_node != org_node) - { - ok = re_node_set_insert (dfa->edests + clone_node, org_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - break; - } - /* In case the node has another constraint, append it. */ - constraint |= dfa->nodes[org_node].constraint; - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == REG_MISSING, 0)) - return REG_ESPACE; - ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - } - else /* dfa->edests[org_node].nelem == 2 */ - { - /* In case of the node can epsilon-transit, and it has two - destinations. In the bin_tree_t and DFA, that's '|' and '*'. */ - org_dest = dfa->edests[org_node].elems[0]; - re_node_set_empty (dfa->edests + clone_node); - /* Search for a duplicated node which satisfies the constraint. */ - clone_dest = search_duplicated_node (dfa, org_dest, constraint); - if (clone_dest == REG_MISSING) - { - /* There is no such duplicated node, create a new one. */ - reg_errcode_t err; - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == REG_MISSING, 0)) - return REG_ESPACE; - ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - err = duplicate_node_closure (dfa, org_dest, clone_dest, - root_node, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - { - /* There is a duplicated node which satisfies the constraint, - use it to avoid infinite loop. */ - ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - } - - org_dest = dfa->edests[org_node].elems[1]; - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == REG_MISSING, 0)) - return REG_ESPACE; - ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (! ok, 0)) - return REG_ESPACE; - } - org_node = org_dest; - clone_node = clone_dest; - } - return REG_NOERROR; -} - -/* Search for a node which is duplicated from the node ORG_NODE, and - satisfies the constraint CONSTRAINT. */ - -static Idx -search_duplicated_node (const re_dfa_t *dfa, Idx org_node, - unsigned int constraint) -{ - Idx idx; - for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) - { - if (org_node == dfa->org_indices[idx] - && constraint == dfa->nodes[idx].constraint) - return idx; /* Found. */ - } - return REG_MISSING; /* Not found. */ -} - -/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. - Return the index of the new node, or REG_MISSING if insufficient storage is - available. */ - -static Idx -duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) -{ - Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); - if (BE (dup_idx != REG_MISSING, 1)) - { - dfa->nodes[dup_idx].constraint = constraint; - dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; - dfa->nodes[dup_idx].duplicated = 1; - - /* Store the index of the original node. */ - dfa->org_indices[dup_idx] = org_idx; - } - return dup_idx; -} - -static reg_errcode_t -calc_inveclosure (re_dfa_t *dfa) -{ - Idx src, idx; - bool ok; - for (idx = 0; idx < dfa->nodes_len; ++idx) - re_node_set_init_empty (dfa->inveclosures + idx); - - for (src = 0; src < dfa->nodes_len; ++src) - { - Idx *elems = dfa->eclosures[src].elems; - for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) - { - ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); - if (BE (! ok, 0)) - return REG_ESPACE; - } - } - - return REG_NOERROR; -} - -/* Calculate "eclosure" for all the node in DFA. */ - -static reg_errcode_t -calc_eclosure (re_dfa_t *dfa) -{ - Idx node_idx; - bool incomplete; -#ifdef DEBUG - assert (dfa->nodes_len > 0); -#endif - incomplete = false; - /* For each nodes, calculate epsilon closure. */ - for (node_idx = 0; ; ++node_idx) - { - reg_errcode_t err; - re_node_set eclosure_elem; - if (node_idx == dfa->nodes_len) - { - if (!incomplete) - break; - incomplete = false; - node_idx = 0; - } - -#ifdef DEBUG - assert (dfa->eclosures[node_idx].nelem != REG_MISSING); -#endif - - /* If we have already calculated, skip it. */ - if (dfa->eclosures[node_idx].nelem != 0) - continue; - /* Calculate epsilon closure of 'node_idx'. */ - err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (dfa->eclosures[node_idx].nelem == 0) - { - incomplete = true; - re_node_set_free (&eclosure_elem); - } - } - return REG_NOERROR; -} - -/* Calculate epsilon closure of NODE. */ - -static reg_errcode_t -calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) -{ - reg_errcode_t err; - Idx i; - re_node_set eclosure; - bool ok; - bool incomplete = false; - err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* This indicates that we are calculating this node now. - We reference this value to avoid infinite loop. */ - dfa->eclosures[node].nelem = REG_MISSING; - - /* If the current node has constraints, duplicate all nodes - since they must inherit the constraints. */ - if (dfa->nodes[node].constraint - && dfa->edests[node].nelem - && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) - { - err = duplicate_node_closure (dfa, node, node, node, - dfa->nodes[node].constraint); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - /* Expand each epsilon destination nodes. */ - if (IS_EPSILON_NODE(dfa->nodes[node].type)) - for (i = 0; i < dfa->edests[node].nelem; ++i) - { - re_node_set eclosure_elem; - Idx edest = dfa->edests[node].elems[i]; - /* If calculating the epsilon closure of 'edest' is in progress, - return intermediate result. */ - if (dfa->eclosures[edest].nelem == REG_MISSING) - { - incomplete = true; - continue; - } - /* If we haven't calculated the epsilon closure of 'edest' yet, - calculate now. Otherwise use calculated epsilon closure. */ - if (dfa->eclosures[edest].nelem == 0) - { - err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - eclosure_elem = dfa->eclosures[edest]; - /* Merge the epsilon closure of 'edest'. */ - err = re_node_set_merge (&eclosure, &eclosure_elem); - if (BE (err != REG_NOERROR, 0)) - return err; - /* If the epsilon closure of 'edest' is incomplete, - the epsilon closure of this node is also incomplete. */ - if (dfa->eclosures[edest].nelem == 0) - { - incomplete = true; - re_node_set_free (&eclosure_elem); - } - } - - /* An epsilon closure includes itself. */ - ok = re_node_set_insert (&eclosure, node); - if (BE (! ok, 0)) - return REG_ESPACE; - if (incomplete && !root) - dfa->eclosures[node].nelem = 0; - else - dfa->eclosures[node] = eclosure; - *new_set = eclosure; - return REG_NOERROR; -} - -/* Functions for token which are used in the parser. */ - -/* Fetch a token from INPUT. - We must not use this function inside bracket expressions. */ - -static void -internal_function -fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) -{ - re_string_skip_bytes (input, peek_token (result, input, syntax)); -} - -/* Peek a token from INPUT, and return the length of the token. - We must not use this function inside bracket expressions. */ - -static int -internal_function -peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) -{ - unsigned char c; - - if (re_string_eoi (input)) - { - token->type = END_OF_RE; - return 0; - } - - c = re_string_peek_byte (input, 0); - token->opr.c = c; - - token->word_char = 0; -#ifdef RE_ENABLE_I18N - token->mb_partial = 0; - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) - { - token->type = CHARACTER; - token->mb_partial = 1; - return 1; - } -#endif - if (c == '\\') - { - unsigned char c2; - if (re_string_cur_idx (input) + 1 >= re_string_length (input)) - { - token->type = BACK_SLASH; - return 1; - } - - c2 = re_string_peek_byte_case (input, 1); - token->opr.c = c2; - token->type = CHARACTER; -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc = re_string_wchar_at (input, - re_string_cur_idx (input) + 1); - token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; - } - else -#endif - token->word_char = IS_WORD_CHAR (c2) != 0; - - switch (c2) - { - case '|': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR)) - token->type = OP_ALT; - break; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (!(syntax & RE_NO_BK_REFS)) - { - token->type = OP_BACK_REF; - token->opr.idx = c2 - '1'; - } - break; - case '<': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_FIRST; - } - break; - case '>': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_LAST; - } - break; - case 'b': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_DELIM; - } - break; - case 'B': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = NOT_WORD_DELIM; - } - break; - case 'w': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_WORD; - break; - case 'W': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_NOTWORD; - break; - case 's': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_SPACE; - break; - case 'S': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_NOTSPACE; - break; - case '`': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = BUF_FIRST; - } - break; - case '\'': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = BUF_LAST; - } - break; - case '(': - if (!(syntax & RE_NO_BK_PARENS)) - token->type = OP_OPEN_SUBEXP; - break; - case ')': - if (!(syntax & RE_NO_BK_PARENS)) - token->type = OP_CLOSE_SUBEXP; - break; - case '+': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_PLUS; - break; - case '?': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_QUESTION; - break; - case '{': - if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) - token->type = OP_OPEN_DUP_NUM; - break; - case '}': - if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) - token->type = OP_CLOSE_DUP_NUM; - break; - default: - break; - } - return 2; - } - - token->type = CHARACTER; -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); - token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; - } - else -#endif - token->word_char = IS_WORD_CHAR (token->opr.c); - - switch (c) - { - case '\n': - if (syntax & RE_NEWLINE_ALT) - token->type = OP_ALT; - break; - case '|': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR)) - token->type = OP_ALT; - break; - case '*': - token->type = OP_DUP_ASTERISK; - break; - case '+': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_PLUS; - break; - case '?': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_QUESTION; - break; - case '{': - if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - token->type = OP_OPEN_DUP_NUM; - break; - case '}': - if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - token->type = OP_CLOSE_DUP_NUM; - break; - case '(': - if (syntax & RE_NO_BK_PARENS) - token->type = OP_OPEN_SUBEXP; - break; - case ')': - if (syntax & RE_NO_BK_PARENS) - token->type = OP_CLOSE_SUBEXP; - break; - case '[': - token->type = OP_OPEN_BRACKET; - break; - case '.': - token->type = OP_PERIOD; - break; - case '^': - if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && - re_string_cur_idx (input) != 0) - { - char prev = re_string_peek_byte (input, -1); - if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') - break; - } - token->type = ANCHOR; - token->opr.ctx_type = LINE_FIRST; - break; - case '$': - if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && - re_string_cur_idx (input) + 1 != re_string_length (input)) - { - re_token_t next; - re_string_skip_bytes (input, 1); - peek_token (&next, input, syntax); - re_string_skip_bytes (input, -1); - if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP) - break; - } - token->type = ANCHOR; - token->opr.ctx_type = LINE_LAST; - break; - default: - break; - } - return 1; -} - -/* Peek a token from INPUT, and return the length of the token. - We must not use this function out of bracket expressions. */ - -static int -internal_function -peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) -{ - unsigned char c; - if (re_string_eoi (input)) - { - token->type = END_OF_RE; - return 0; - } - c = re_string_peek_byte (input, 0); - token->opr.c = c; - -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) - { - token->type = CHARACTER; - return 1; - } -#endif /* RE_ENABLE_I18N */ - - if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) - && re_string_cur_idx (input) + 1 < re_string_length (input)) - { - /* In this case, '\' escape a character. */ - unsigned char c2; - re_string_skip_bytes (input, 1); - c2 = re_string_peek_byte (input, 0); - token->opr.c = c2; - token->type = CHARACTER; - return 1; - } - if (c == '[') /* '[' is a special char in a bracket exps. */ - { - unsigned char c2; - int token_len; - if (re_string_cur_idx (input) + 1 < re_string_length (input)) - c2 = re_string_peek_byte (input, 1); - else - c2 = 0; - token->opr.c = c2; - token_len = 2; - switch (c2) - { - case '.': - token->type = OP_OPEN_COLL_ELEM; - break; - case '=': - token->type = OP_OPEN_EQUIV_CLASS; - break; - case ':': - if (syntax & RE_CHAR_CLASSES) - { - token->type = OP_OPEN_CHAR_CLASS; - break; - } - /* else fall through. */ - default: - token->type = CHARACTER; - token->opr.c = c; - token_len = 1; - break; - } - return token_len; - } - switch (c) - { - case '-': - token->type = OP_CHARSET_RANGE; - break; - case ']': - token->type = OP_CLOSE_BRACKET; - break; - case '^': - token->type = OP_NON_MATCH_LIST; - break; - default: - token->type = CHARACTER; - } - return 1; -} - -/* Functions for parser. */ - -/* Entry point of the parser. - Parse the regular expression REGEXP and return the structure tree. - If an error occurs, ERR is set by error code, and return NULL. - This function build the following tree, from regular expression : - CAT - / \ - / \ - EOR - - CAT means concatenation. - EOR means end of regular expression. */ - -static bin_tree_t * -parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, - reg_errcode_t *err) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_t *tree, *eor, *root; - re_token_t current_token; - dfa->syntax = syntax; - fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); - tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - eor = create_tree (dfa, NULL, NULL, END_OF_RE); - if (tree != NULL) - root = create_tree (dfa, tree, eor, CONCAT); - else - root = eor; - if (BE (eor == NULL || root == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - return root; -} - -/* This function build the following tree, from regular expression - |: - ALT - / \ - / \ - - - ALT means alternative, which represents the operator '|'. */ - -static bin_tree_t * -parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, Idx nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_t *tree, *branch = NULL; - tree = parse_branch (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - - while (token->type == OP_ALT) - { - fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); - if (token->type != OP_ALT && token->type != END_OF_RE - && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) - { - branch = parse_branch (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && branch == NULL, 0)) - return NULL; - } - else - branch = NULL; - tree = create_tree (dfa, tree, branch, OP_ALT); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - return tree; -} - -/* This function build the following tree, from regular expression - : - CAT - / \ - / \ - - - CAT means concatenation. */ - -static bin_tree_t * -parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, Idx nest, reg_errcode_t *err) -{ - bin_tree_t *tree, *expr; - re_dfa_t *dfa = preg->buffer; - tree = parse_expression (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - - while (token->type != OP_ALT && token->type != END_OF_RE - && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) - { - expr = parse_expression (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && expr == NULL, 0)) - { - if (tree != NULL) - postorder (tree, free_tree, NULL); - return NULL; - } - if (tree != NULL && expr != NULL) - { - bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT); - if (newtree == NULL) - { - postorder (expr, free_tree, NULL); - postorder (tree, free_tree, NULL); - *err = REG_ESPACE; - return NULL; - } - tree = newtree; - } - else if (tree == NULL) - tree = expr; - /* Otherwise expr == NULL, we don't need to create new tree. */ - } - return tree; -} - -/* This function build the following tree, from regular expression a*: - * - | - a -*/ - -static bin_tree_t * -parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, Idx nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_t *tree; - switch (token->type) - { - case CHARACTER: - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - while (!re_string_eoi (regexp) - && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) - { - bin_tree_t *mbc_remain; - fetch_token (token, regexp, syntax); - mbc_remain = create_token_tree (dfa, NULL, NULL, token); - tree = create_tree (dfa, tree, mbc_remain, CONCAT); - if (BE (mbc_remain == NULL || tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - } -#endif - break; - case OP_OPEN_SUBEXP: - tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_OPEN_BRACKET: - tree = parse_bracket_exp (regexp, dfa, token, syntax, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_BACK_REF: - if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) - { - *err = REG_ESUBREG; - return NULL; - } - dfa->used_bkref_map |= 1 << token->opr.idx; - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - ++dfa->nbackref; - dfa->has_mb_node = 1; - break; - case OP_OPEN_DUP_NUM: - if (syntax & RE_CONTEXT_INVALID_DUP) - { - *err = REG_BADRPT; - return NULL; - } - /* FALLTHROUGH */ - case OP_DUP_ASTERISK: - case OP_DUP_PLUS: - case OP_DUP_QUESTION: - if (syntax & RE_CONTEXT_INVALID_OPS) - { - *err = REG_BADRPT; - return NULL; - } - else if (syntax & RE_CONTEXT_INDEP_OPS) - { - fetch_token (token, regexp, syntax); - return parse_expression (regexp, preg, token, syntax, nest, err); - } - /* else fall through */ - case OP_CLOSE_SUBEXP: - if ((token->type == OP_CLOSE_SUBEXP) && - !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) - { - *err = REG_ERPAREN; - return NULL; - } - /* else fall through */ - case OP_CLOSE_DUP_NUM: - /* We treat it as a normal character. */ - - /* Then we can these characters as normal characters. */ - token->type = CHARACTER; - /* mb_partial and word_char bits should be initialized already - by peek_token. */ - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - break; - case ANCHOR: - if ((token->opr.ctx_type - & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) - && dfa->word_ops_used == 0) - init_word_char (dfa); - if (token->opr.ctx_type == WORD_DELIM - || token->opr.ctx_type == NOT_WORD_DELIM) - { - bin_tree_t *tree_first, *tree_last; - if (token->opr.ctx_type == WORD_DELIM) - { - token->opr.ctx_type = WORD_FIRST; - tree_first = create_token_tree (dfa, NULL, NULL, token); - token->opr.ctx_type = WORD_LAST; - } - else - { - token->opr.ctx_type = INSIDE_WORD; - tree_first = create_token_tree (dfa, NULL, NULL, token); - token->opr.ctx_type = INSIDE_NOTWORD; - } - tree_last = create_token_tree (dfa, NULL, NULL, token); - tree = create_tree (dfa, tree_first, tree_last, OP_ALT); - if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - else - { - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - /* We must return here, since ANCHORs can't be followed - by repetition operators. - eg. RE"^*" is invalid or "", - it must not be "". */ - fetch_token (token, regexp, syntax); - return tree; - case OP_PERIOD: - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - if (dfa->mb_cur_max > 1) - dfa->has_mb_node = 1; - break; - case OP_WORD: - case OP_NOTWORD: - tree = build_charclass_op (dfa, regexp->trans, - "alnum", - "_", - token->type == OP_NOTWORD, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_SPACE: - case OP_NOTSPACE: - tree = build_charclass_op (dfa, regexp->trans, - "space", - "", - token->type == OP_NOTSPACE, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_ALT: - case END_OF_RE: - return NULL; - case BACK_SLASH: - *err = REG_EESCAPE; - return NULL; - default: - /* Must not happen? */ -#ifdef DEBUG - assert (0); -#endif - return NULL; - } - fetch_token (token, regexp, syntax); - - while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS - || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) - { - tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - /* In BRE consecutive duplications are not allowed. */ - if ((syntax & RE_CONTEXT_INVALID_DUP) - && (token->type == OP_DUP_ASTERISK - || token->type == OP_OPEN_DUP_NUM)) - { - *err = REG_BADRPT; - return NULL; - } - } - - return tree; -} - -/* This function build the following tree, from regular expression - (): - SUBEXP - | - -*/ - -static bin_tree_t * -parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, Idx nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = preg->buffer; - bin_tree_t *tree; - size_t cur_nsub; - cur_nsub = preg->re_nsub++; - - fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); - - /* The subexpression may be a null string. */ - if (token->type == OP_CLOSE_SUBEXP) - tree = NULL; - else - { - tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); - if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) - { - if (tree != NULL) - postorder (tree, free_tree, NULL); - *err = REG_EPAREN; - } - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } - - if (cur_nsub <= '9' - '1') - dfa->completed_bkref_map |= 1 << cur_nsub; - - tree = create_tree (dfa, tree, NULL, SUBEXP); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - tree->token.opr.idx = cur_nsub; - return tree; -} - -/* This function parse repetition operators like "*", "+", "{1,3}" etc. */ - -static bin_tree_t * -parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, - re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) -{ - bin_tree_t *tree = NULL, *old_tree = NULL; - Idx i, start, end, start_idx = re_string_cur_idx (regexp); - re_token_t start_token = *token; - - if (token->type == OP_OPEN_DUP_NUM) - { - end = 0; - start = fetch_number (regexp, token, syntax); - if (start == REG_MISSING) - { - if (token->type == CHARACTER && token->opr.c == ',') - start = 0; /* We treat "{,m}" as "{0,m}". */ - else - { - *err = REG_BADBR; /* {} is invalid. */ - return NULL; - } - } - if (BE (start != REG_ERROR, 1)) - { - /* We treat "{n}" as "{n,n}". */ - end = ((token->type == OP_CLOSE_DUP_NUM) ? start - : ((token->type == CHARACTER && token->opr.c == ',') - ? fetch_number (regexp, token, syntax) : REG_ERROR)); - } - if (BE (start == REG_ERROR || end == REG_ERROR, 0)) - { - /* Invalid sequence. */ - if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) - { - if (token->type == END_OF_RE) - *err = REG_EBRACE; - else - *err = REG_BADBR; - - return NULL; - } - - /* If the syntax bit is set, rollback. */ - re_string_set_index (regexp, start_idx); - *token = start_token; - token->type = CHARACTER; - /* mb_partial and word_char bits should be already initialized by - peek_token. */ - return elem; - } - - if (BE ((end != REG_MISSING && start > end) - || token->type != OP_CLOSE_DUP_NUM, 0)) - { - /* First number greater than second. */ - *err = REG_BADBR; - return NULL; - } - - if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0)) - { - *err = REG_ESIZE; - return NULL; - } - } - else - { - start = (token->type == OP_DUP_PLUS) ? 1 : 0; - end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING; - } - - fetch_token (token, regexp, syntax); - - if (BE (elem == NULL, 0)) - return NULL; - if (BE (start == 0 && end == 0, 0)) - { - postorder (elem, free_tree, NULL); - return NULL; - } - - /* Extract "{n,m}" to "...{0,}". */ - if (BE (start > 0, 0)) - { - tree = elem; - for (i = 2; i <= start; ++i) - { - elem = duplicate_tree (elem, dfa); - tree = create_tree (dfa, tree, elem, CONCAT); - if (BE (elem == NULL || tree == NULL, 0)) - goto parse_dup_op_espace; - } - - if (start == end) - return tree; - - /* Duplicate ELEM before it is marked optional. */ - elem = duplicate_tree (elem, dfa); - old_tree = tree; - } - else - old_tree = NULL; - - if (elem->token.type == SUBEXP) - { - uintptr_t subidx = elem->token.opr.idx; - postorder (elem, mark_opt_subexp, (void *) subidx); - } - - tree = create_tree (dfa, elem, NULL, - (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); - if (BE (tree == NULL, 0)) - goto parse_dup_op_espace; - -/* From gnulib's "intprops.h": - True if the arithmetic type T is signed. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) - - /* This loop is actually executed only when end != REG_MISSING, - to rewrite {0,n} as ((...?)?)?... We have - already created the start+1-th copy. */ - if (TYPE_SIGNED (Idx) || end != REG_MISSING) - for (i = start + 2; i <= end; ++i) - { - elem = duplicate_tree (elem, dfa); - tree = create_tree (dfa, tree, elem, CONCAT); - if (BE (elem == NULL || tree == NULL, 0)) - goto parse_dup_op_espace; - - tree = create_tree (dfa, tree, NULL, OP_ALT); - if (BE (tree == NULL, 0)) - goto parse_dup_op_espace; - } - - if (old_tree) - tree = create_tree (dfa, old_tree, tree, CONCAT); - - return tree; - - parse_dup_op_espace: - *err = REG_ESPACE; - return NULL; -} - -/* Size of the names for collating symbol/equivalence_class/character_class. - I'm not sure, but maybe enough. */ -#define BRACKET_NAME_BUF_SIZE 32 - -#ifndef _LIBC - /* Local function for parse_bracket_exp only used in case of NOT _LIBC. - Build the range expression which starts from START_ELEM, and ends - at END_ELEM. The result are written to MBCSET and SBCSET. - RANGE_ALLOC is the allocated size of mbcset->range_starts, and - mbcset->range_ends, is a pointer argument since we may - update it. */ - -static reg_errcode_t -internal_function -# ifdef RE_ENABLE_I18N -build_range_exp (const reg_syntax_t syntax, - bitset_t sbcset, - re_charset_t *mbcset, - Idx *range_alloc, - const bracket_elem_t *start_elem, - const bracket_elem_t *end_elem) -# else /* not RE_ENABLE_I18N */ -build_range_exp (const reg_syntax_t syntax, - bitset_t sbcset, - const bracket_elem_t *start_elem, - const bracket_elem_t *end_elem) -# endif /* not RE_ENABLE_I18N */ -{ - unsigned int start_ch, end_ch; - /* Equivalence Classes and Character Classes can't be a range start/end. */ - if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS - || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, - 0)) - return REG_ERANGE; - - /* We can handle no multi character collating elements without libc - support. */ - if (BE ((start_elem->type == COLL_SYM - && strlen ((char *) start_elem->opr.name) > 1) - || (end_elem->type == COLL_SYM - && strlen ((char *) end_elem->opr.name) > 1), 0)) - return REG_ECOLLATE; - -# ifdef RE_ENABLE_I18N - { - wchar_t wc; - wint_t start_wc; - wint_t end_wc; - - start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch - : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] - : 0)); - end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch - : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] - : 0)); - start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) - ? __btowc (start_ch) : start_elem->opr.wch); - end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) - ? __btowc (end_ch) : end_elem->opr.wch); - if (start_wc == WEOF || end_wc == WEOF) - return REG_ECOLLATE; - else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0)) - return REG_ERANGE; - - /* Got valid collation sequence values, add them as a new entry. - However, for !_LIBC we have no collation elements: if the - character set is single byte, the single byte character set - that we build below suffices. parse_bracket_exp passes - no MBCSET if dfa->mb_cur_max == 1. */ - if (mbcset) - { - /* Check the space of the arrays. */ - if (BE (*range_alloc == mbcset->nranges, 0)) - { - /* There is not enough space, need realloc. */ - wchar_t *new_array_start, *new_array_end; - Idx new_nranges; - - /* +1 in case of mbcset->nranges is 0. */ - new_nranges = 2 * mbcset->nranges + 1; - /* Use realloc since mbcset->range_starts and mbcset->range_ends - are NULL if *range_alloc == 0. */ - new_array_start = re_realloc (mbcset->range_starts, wchar_t, - new_nranges); - new_array_end = re_realloc (mbcset->range_ends, wchar_t, - new_nranges); - - if (BE (new_array_start == NULL || new_array_end == NULL, 0)) - return REG_ESPACE; - - mbcset->range_starts = new_array_start; - mbcset->range_ends = new_array_end; - *range_alloc = new_nranges; - } - - mbcset->range_starts[mbcset->nranges] = start_wc; - mbcset->range_ends[mbcset->nranges++] = end_wc; - } - - /* Build the table for single byte characters. */ - for (wc = 0; wc < SBC_MAX; ++wc) - { - if (start_wc <= wc && wc <= end_wc) - bitset_set (sbcset, wc); - } - } -# else /* not RE_ENABLE_I18N */ - { - unsigned int ch; - start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch - : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] - : 0)); - end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch - : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] - : 0)); - if (start_ch > end_ch) - return REG_ERANGE; - /* Build the table for single byte characters. */ - for (ch = 0; ch < SBC_MAX; ++ch) - if (start_ch <= ch && ch <= end_ch) - bitset_set (sbcset, ch); - } -# endif /* not RE_ENABLE_I18N */ - return REG_NOERROR; -} -#endif /* not _LIBC */ - -#ifndef _LIBC -/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. - Build the collating element which is represented by NAME. - The result are written to MBCSET and SBCSET. - COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a - pointer argument since we may update it. */ - -static reg_errcode_t -internal_function -# ifdef RE_ENABLE_I18N -build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, - Idx *coll_sym_alloc, const unsigned char *name) -# else /* not RE_ENABLE_I18N */ -build_collating_symbol (bitset_t sbcset, const unsigned char *name) -# endif /* not RE_ENABLE_I18N */ -{ - size_t name_len = strlen ((const char *) name); - if (BE (name_len != 1, 0)) - return REG_ECOLLATE; - else - { - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } -} -#endif /* not _LIBC */ - -/* This function parse bracket expression like "[abc]", "[a-c]", - "[[.a-a.]]" etc. */ - -static bin_tree_t * -parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, - reg_syntax_t syntax, reg_errcode_t *err) -{ -#ifdef _LIBC - const unsigned char *collseqmb; - const char *collseqwc; - uint32_t nrules; - int32_t table_size; - const int32_t *symb_table; - const unsigned char *extra; - - /* Local function for parse_bracket_exp used in _LIBC environment. - Seek the collating symbol entry corresponding to NAME. - Return the index of the symbol in the SYMB_TABLE, - or -1 if not found. */ - - auto inline int32_t - __attribute__ ((always_inline)) - seek_collating_symbol_entry (const unsigned char *name, size_t name_len) - { - int32_t elem; - - for (elem = 0; elem < table_size; elem++) - if (symb_table[2 * elem] != 0) - { - int32_t idx = symb_table[2 * elem + 1]; - /* Skip the name of collating element name. */ - idx += 1 + extra[idx]; - if (/* Compare the length of the name. */ - name_len == extra[idx] - /* Compare the name. */ - && memcmp (name, &extra[idx + 1], name_len) == 0) - /* Yep, this is the entry. */ - return elem; - } - return -1; - } - - /* Local function for parse_bracket_exp used in _LIBC environment. - Look up the collation sequence value of BR_ELEM. - Return the value if succeeded, UINT_MAX otherwise. */ - - auto inline unsigned int - __attribute__ ((always_inline)) - lookup_collation_sequence_value (bracket_elem_t *br_elem) - { - if (br_elem->type == SB_CHAR) - { - /* - if (MB_CUR_MAX == 1) - */ - if (nrules == 0) - return collseqmb[br_elem->opr.ch]; - else - { - wint_t wc = __btowc (br_elem->opr.ch); - return __collseq_table_lookup (collseqwc, wc); - } - } - else if (br_elem->type == MB_CHAR) - { - if (nrules != 0) - return __collseq_table_lookup (collseqwc, br_elem->opr.wch); - } - else if (br_elem->type == COLL_SYM) - { - size_t sym_name_len = strlen ((char *) br_elem->opr.name); - if (nrules != 0) - { - int32_t elem, idx; - elem = seek_collating_symbol_entry (br_elem->opr.name, - sym_name_len); - if (elem != -1) - { - /* We found the entry. */ - idx = symb_table[2 * elem + 1]; - /* Skip the name of collating element name. */ - idx += 1 + extra[idx]; - /* Skip the byte sequence of the collating element. */ - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; - /* Skip the multibyte collation sequence value. */ - idx += sizeof (unsigned int); - /* Skip the wide char sequence of the collating element. */ - idx += sizeof (unsigned int) * - (1 + *(unsigned int *) (extra + idx)); - /* Return the collation sequence value. */ - return *(unsigned int *) (extra + idx); - } - else if (sym_name_len == 1) - { - /* No valid character. Match it as a single byte - character. */ - return collseqmb[br_elem->opr.name[0]]; - } - } - else if (sym_name_len == 1) - return collseqmb[br_elem->opr.name[0]]; - } - return UINT_MAX; - } - - /* Local function for parse_bracket_exp used in _LIBC environment. - Build the range expression which starts from START_ELEM, and ends - at END_ELEM. The result are written to MBCSET and SBCSET. - RANGE_ALLOC is the allocated size of mbcset->range_starts, and - mbcset->range_ends, is a pointer argument since we may - update it. */ - - auto inline reg_errcode_t - __attribute__ ((always_inline)) - build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, - bracket_elem_t *start_elem, bracket_elem_t *end_elem) - { - unsigned int ch; - uint32_t start_collseq; - uint32_t end_collseq; - - /* Equivalence Classes and Character Classes can't be a range - start/end. */ - if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS - || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, - 0)) - return REG_ERANGE; - - /* FIXME: Implement rational ranges here, too. */ - start_collseq = lookup_collation_sequence_value (start_elem); - end_collseq = lookup_collation_sequence_value (end_elem); - /* Check start/end collation sequence values. */ - if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) - return REG_ECOLLATE; - if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) - return REG_ERANGE; - - /* Got valid collation sequence values, add them as a new entry. - However, if we have no collation elements, and the character set - is single byte, the single byte character set that we - build below suffices. */ - if (nrules > 0 || dfa->mb_cur_max > 1) - { - /* Check the space of the arrays. */ - if (BE (*range_alloc == mbcset->nranges, 0)) - { - /* There is not enough space, need realloc. */ - uint32_t *new_array_start; - uint32_t *new_array_end; - Idx new_nranges; - - /* +1 in case of mbcset->nranges is 0. */ - new_nranges = 2 * mbcset->nranges + 1; - new_array_start = re_realloc (mbcset->range_starts, uint32_t, - new_nranges); - new_array_end = re_realloc (mbcset->range_ends, uint32_t, - new_nranges); - - if (BE (new_array_start == NULL || new_array_end == NULL, 0)) - return REG_ESPACE; - - mbcset->range_starts = new_array_start; - mbcset->range_ends = new_array_end; - *range_alloc = new_nranges; - } - - mbcset->range_starts[mbcset->nranges] = start_collseq; - mbcset->range_ends[mbcset->nranges++] = end_collseq; - } - - /* Build the table for single byte characters. */ - for (ch = 0; ch < SBC_MAX; ch++) - { - uint32_t ch_collseq; - /* - if (MB_CUR_MAX == 1) - */ - if (nrules == 0) - ch_collseq = collseqmb[ch]; - else - ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch)); - if (start_collseq <= ch_collseq && ch_collseq <= end_collseq) - bitset_set (sbcset, ch); - } - return REG_NOERROR; - } - - /* Local function for parse_bracket_exp used in _LIBC environment. - Build the collating element which is represented by NAME. - The result are written to MBCSET and SBCSET. - COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a - pointer argument since we may update it. */ - - auto inline reg_errcode_t - __attribute__ ((always_inline)) - build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, - Idx *coll_sym_alloc, const unsigned char *name) - { - int32_t elem, idx; - size_t name_len = strlen ((const char *) name); - if (nrules != 0) - { - elem = seek_collating_symbol_entry (name, name_len); - if (elem != -1) - { - /* We found the entry. */ - idx = symb_table[2 * elem + 1]; - /* Skip the name of collating element name. */ - idx += 1 + extra[idx]; - } - else if (name_len == 1) - { - /* No valid character, treat it as a normal - character. */ - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } - else - return REG_ECOLLATE; - - /* Got valid collation sequence, add it as a new entry. */ - /* Check the space of the arrays. */ - if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->ncoll_syms is 0. */ - Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1; - /* Use realloc since mbcset->coll_syms is NULL - if *alloc == 0. */ - int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, - new_coll_sym_alloc); - if (BE (new_coll_syms == NULL, 0)) - return REG_ESPACE; - mbcset->coll_syms = new_coll_syms; - *coll_sym_alloc = new_coll_sym_alloc; - } - mbcset->coll_syms[mbcset->ncoll_syms++] = idx; - return REG_NOERROR; - } - else - { - if (BE (name_len != 1, 0)) - return REG_ECOLLATE; - else - { - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } - } - } -#endif - - re_token_t br_token; - re_bitset_ptr_t sbcset; -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; - Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; - Idx equiv_class_alloc = 0, char_class_alloc = 0; -#endif /* not RE_ENABLE_I18N */ - bool non_match = false; - bin_tree_t *work_tree; - int token_len; - bool first_round = true; -#ifdef _LIBC - collseqmb = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); - nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules) - { - /* - if (MB_CUR_MAX > 1) - */ - collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); - table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); - } -#endif - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); -#ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); -#endif /* RE_ENABLE_I18N */ -#ifdef RE_ENABLE_I18N - if (BE (sbcset == NULL || mbcset == NULL, 0)) -#else - if (BE (sbcset == NULL, 0)) -#endif /* RE_ENABLE_I18N */ - { - re_free (sbcset); -#ifdef RE_ENABLE_I18N - re_free (mbcset); -#endif - *err = REG_ESPACE; - return NULL; - } - - token_len = peek_token_bracket (token, regexp, syntax); - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_BADPAT; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_NON_MATCH_LIST) - { -#ifdef RE_ENABLE_I18N - mbcset->non_match = 1; -#endif /* not RE_ENABLE_I18N */ - non_match = true; - if (syntax & RE_HAT_LISTS_NOT_NEWLINE) - bitset_set (sbcset, '\n'); - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - token_len = peek_token_bracket (token, regexp, syntax); - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_BADPAT; - goto parse_bracket_exp_free_return; - } - } - - /* We treat the first ']' as a normal character. */ - if (token->type == OP_CLOSE_BRACKET) - token->type = CHARACTER; - - while (1) - { - bracket_elem_t start_elem, end_elem; - unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; - unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; - reg_errcode_t ret; - int token_len2 = 0; - bool is_range_exp = false; - re_token_t token2; - - start_elem.opr.name = start_name_buf; - ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, - syntax, first_round); - if (BE (ret != REG_NOERROR, 0)) - { - *err = ret; - goto parse_bracket_exp_free_return; - } - first_round = false; - - /* Get information about the next token. We need it in any case. */ - token_len = peek_token_bracket (token, regexp, syntax); - - /* Do not check for ranges if we know they are not allowed. */ - if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) - { - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_CHARSET_RANGE) - { - re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ - token_len2 = peek_token_bracket (&token2, regexp, syntax); - if (BE (token2.type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token2.type == OP_CLOSE_BRACKET) - { - /* We treat the last '-' as a normal character. */ - re_string_skip_bytes (regexp, -token_len); - token->type = CHARACTER; - } - else - is_range_exp = true; - } - } - - if (is_range_exp == true) - { - end_elem.opr.name = end_name_buf; - ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, - dfa, syntax, true); - if (BE (ret != REG_NOERROR, 0)) - { - *err = ret; - goto parse_bracket_exp_free_return; - } - - token_len = peek_token_bracket (token, regexp, syntax); - -#ifdef _LIBC - *err = build_range_exp (sbcset, mbcset, &range_alloc, - &start_elem, &end_elem); -#else -# ifdef RE_ENABLE_I18N - *err = build_range_exp (syntax, sbcset, - dfa->mb_cur_max > 1 ? mbcset : NULL, - &range_alloc, &start_elem, &end_elem); -# else - *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); -# endif -#endif /* RE_ENABLE_I18N */ - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - } - else - { - switch (start_elem.type) - { - case SB_CHAR: - bitset_set (sbcset, start_elem.opr.ch); - break; -#ifdef RE_ENABLE_I18N - case MB_CHAR: - /* Check whether the array has enough space. */ - if (BE (mbchar_alloc == mbcset->nmbchars, 0)) - { - wchar_t *new_mbchars; - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nmbchars is 0. */ - mbchar_alloc = 2 * mbcset->nmbchars + 1; - /* Use realloc since array is NULL if *alloc == 0. */ - new_mbchars = re_realloc (mbcset->mbchars, wchar_t, - mbchar_alloc); - if (BE (new_mbchars == NULL, 0)) - goto parse_bracket_exp_espace; - mbcset->mbchars = new_mbchars; - } - mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; - break; -#endif /* RE_ENABLE_I18N */ - case EQUIV_CLASS: - *err = build_equiv_class (sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &equiv_class_alloc, -#endif /* RE_ENABLE_I18N */ - start_elem.opr.name); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - case COLL_SYM: - *err = build_collating_symbol (sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &coll_sym_alloc, -#endif /* RE_ENABLE_I18N */ - start_elem.opr.name); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - case CHAR_CLASS: - *err = build_charclass (regexp->trans, sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &char_class_alloc, -#endif /* RE_ENABLE_I18N */ - (const char *) start_elem.opr.name, - syntax); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - default: - assert (0); - break; - } - } - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_CLOSE_BRACKET) - break; - } - - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - - /* If it is non-matching list. */ - if (non_match) - bitset_not (sbcset); - -#ifdef RE_ENABLE_I18N - /* Ensure only single byte characters are set. */ - if (dfa->mb_cur_max > 1) - bitset_mask (sbcset, dfa->sb_char); - - if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes - || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes - || mbcset->non_match))) - { - bin_tree_t *mbc_tree; - int sbc_idx; - /* Build a tree for complex bracket. */ - dfa->has_mb_node = 1; - br_token.type = COMPLEX_BRACKET; - br_token.opr.mbcset = mbcset; - mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (mbc_tree == NULL, 0)) - goto parse_bracket_exp_espace; - for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) - if (sbcset[sbc_idx]) - break; - /* If there are no bits set in sbcset, there is no point - of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */ - if (sbc_idx < BITSET_WORDS) - { - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - work_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - - /* Then join them by ALT node. */ - work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - } - else - { - re_free (sbcset); - work_tree = mbc_tree; - } - } - else -#endif /* not RE_ENABLE_I18N */ - { -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - work_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - } - return work_tree; - - parse_bracket_exp_espace: - *err = REG_ESPACE; - parse_bracket_exp_free_return: - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - return NULL; -} - -/* Parse an element in the bracket expression. */ - -static reg_errcode_t -parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, - re_token_t *token, int token_len, re_dfa_t *dfa, - reg_syntax_t syntax, bool accept_hyphen) -{ -#ifdef RE_ENABLE_I18N - int cur_char_size; - cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); - if (cur_char_size > 1) - { - elem->type = MB_CHAR; - elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp)); - re_string_skip_bytes (regexp, cur_char_size); - return REG_NOERROR; - } -#endif /* RE_ENABLE_I18N */ - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS - || token->type == OP_OPEN_EQUIV_CLASS) - return parse_bracket_symbol (elem, regexp, token); - if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) - { - /* A '-' must only appear as anything but a range indicator before - the closing bracket. Everything else is an error. */ - re_token_t token2; - (void) peek_token_bracket (&token2, regexp, syntax); - if (token2.type != OP_CLOSE_BRACKET) - /* The actual error value is not standardized since this whole - case is undefined. But ERANGE makes good sense. */ - return REG_ERANGE; - } - elem->type = SB_CHAR; - elem->opr.ch = token->opr.c; - return REG_NOERROR; -} - -/* Parse a bracket symbol in the bracket expression. Bracket symbols are - such as [::], [..], and - [==]. */ - -static reg_errcode_t -parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, - re_token_t *token) -{ - unsigned char ch, delim = token->opr.c; - int i = 0; - if (re_string_eoi(regexp)) - return REG_EBRACK; - for (;; ++i) - { - if (i >= BRACKET_NAME_BUF_SIZE) - return REG_EBRACK; - if (token->type == OP_OPEN_CHAR_CLASS) - ch = re_string_fetch_byte_case (regexp); - else - ch = re_string_fetch_byte (regexp); - if (re_string_eoi(regexp)) - return REG_EBRACK; - if (ch == delim && re_string_peek_byte (regexp, 0) == ']') - break; - elem->opr.name[i] = ch; - } - re_string_skip_bytes (regexp, 1); - elem->opr.name[i] = '\0'; - switch (token->type) - { - case OP_OPEN_COLL_ELEM: - elem->type = COLL_SYM; - break; - case OP_OPEN_EQUIV_CLASS: - elem->type = EQUIV_CLASS; - break; - case OP_OPEN_CHAR_CLASS: - elem->type = CHAR_CLASS; - break; - default: - break; - } - return REG_NOERROR; -} - - /* Helper function for parse_bracket_exp. - Build the equivalence class which is represented by NAME. - The result are written to MBCSET and SBCSET. - EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, - is a pointer argument since we may update it. */ - -static reg_errcode_t -#ifdef RE_ENABLE_I18N -build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, - Idx *equiv_class_alloc, const unsigned char *name) -#else /* not RE_ENABLE_I18N */ -build_equiv_class (bitset_t sbcset, const unsigned char *name) -#endif /* not RE_ENABLE_I18N */ -{ -#ifdef _LIBC - uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules != 0) - { - const int32_t *table, *indirect; - const unsigned char *weights, *extra, *cp; - unsigned char char_buf[2]; - int32_t idx1, idx2; - unsigned int ch; - size_t len; - /* This #include defines a local function! */ -# include - /* Calculate the index for equivalence class. */ - cp = name; - table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_INDIRECTMB); - idx1 = findidx (&cp, -1); - if (BE (idx1 == 0 || *cp != '\0', 0)) - /* This isn't a valid character. */ - return REG_ECOLLATE; - - /* Build single byte matching table for this equivalence class. */ - len = weights[idx1 & 0xffffff]; - for (ch = 0; ch < SBC_MAX; ++ch) - { - char_buf[0] = ch; - cp = char_buf; - idx2 = findidx (&cp, 1); -/* - idx2 = table[ch]; -*/ - if (idx2 == 0) - /* This isn't a valid character. */ - continue; - /* Compare only if the length matches and the collation rule - index is the same. */ - if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) - { - int cnt = 0; - - while (cnt <= len && - weights[(idx1 & 0xffffff) + 1 + cnt] - == weights[(idx2 & 0xffffff) + 1 + cnt]) - ++cnt; - - if (cnt > len) - bitset_set (sbcset, ch); - } - } - /* Check whether the array has enough space. */ - if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nequiv_classes is 0. */ - Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1; - /* Use realloc since the array is NULL if *alloc == 0. */ - int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, - int32_t, - new_equiv_class_alloc); - if (BE (new_equiv_classes == NULL, 0)) - return REG_ESPACE; - mbcset->equiv_classes = new_equiv_classes; - *equiv_class_alloc = new_equiv_class_alloc; - } - mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1; - } - else -#endif /* _LIBC */ - { - if (BE (strlen ((const char *) name) != 1, 0)) - return REG_ECOLLATE; - bitset_set (sbcset, *name); - } - return REG_NOERROR; -} - - /* Helper function for parse_bracket_exp. - Build the character class which is represented by NAME. - The result are written to MBCSET and SBCSET. - CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, - is a pointer argument since we may update it. */ - -static reg_errcode_t -#ifdef RE_ENABLE_I18N -build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, - re_charset_t *mbcset, Idx *char_class_alloc, - const char *class_name, reg_syntax_t syntax) -#else /* not RE_ENABLE_I18N */ -build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, - const char *class_name, reg_syntax_t syntax) -#endif /* not RE_ENABLE_I18N */ -{ - int i; - const char *name = class_name; - - /* In case of REG_ICASE "upper" and "lower" match the both of - upper and lower cases. */ - if ((syntax & RE_ICASE) - && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) - name = "alpha"; - -#ifdef RE_ENABLE_I18N - /* Check the space of the arrays. */ - if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nchar_classes is 0. */ - Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1; - /* Use realloc since array is NULL if *alloc == 0. */ - wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, - new_char_class_alloc); - if (BE (new_char_classes == NULL, 0)) - return REG_ESPACE; - mbcset->char_classes = new_char_classes; - *char_class_alloc = new_char_class_alloc; - } - mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); -#endif /* RE_ENABLE_I18N */ - -#define BUILD_CHARCLASS_LOOP(ctype_func) \ - do { \ - if (BE (trans != NULL, 0)) \ - { \ - for (i = 0; i < SBC_MAX; ++i) \ - if (ctype_func (i)) \ - bitset_set (sbcset, trans[i]); \ - } \ - else \ - { \ - for (i = 0; i < SBC_MAX; ++i) \ - if (ctype_func (i)) \ - bitset_set (sbcset, i); \ - } \ - } while (0) - - if (strcmp (name, "alnum") == 0) - BUILD_CHARCLASS_LOOP (isalnum); - else if (strcmp (name, "cntrl") == 0) - BUILD_CHARCLASS_LOOP (iscntrl); - else if (strcmp (name, "lower") == 0) - BUILD_CHARCLASS_LOOP (islower); - else if (strcmp (name, "space") == 0) - BUILD_CHARCLASS_LOOP (isspace); - else if (strcmp (name, "alpha") == 0) - BUILD_CHARCLASS_LOOP (isalpha); - else if (strcmp (name, "digit") == 0) - BUILD_CHARCLASS_LOOP (isdigit); - else if (strcmp (name, "print") == 0) - BUILD_CHARCLASS_LOOP (isprint); - else if (strcmp (name, "upper") == 0) - BUILD_CHARCLASS_LOOP (isupper); - else if (strcmp (name, "blank") == 0) - BUILD_CHARCLASS_LOOP (isblank); - else if (strcmp (name, "graph") == 0) - BUILD_CHARCLASS_LOOP (isgraph); - else if (strcmp (name, "punct") == 0) - BUILD_CHARCLASS_LOOP (ispunct); - else if (strcmp (name, "xdigit") == 0) - BUILD_CHARCLASS_LOOP (isxdigit); - else - return REG_ECTYPE; - - return REG_NOERROR; -} - -static bin_tree_t * -build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, - const char *class_name, - const char *extra, bool non_match, - reg_errcode_t *err) -{ - re_bitset_ptr_t sbcset; -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; - Idx alloc = 0; -#endif /* not RE_ENABLE_I18N */ - reg_errcode_t ret; - re_token_t br_token; - bin_tree_t *tree; - - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); -#ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); -#endif /* RE_ENABLE_I18N */ - -#ifdef RE_ENABLE_I18N - if (BE (sbcset == NULL || mbcset == NULL, 0)) -#else /* not RE_ENABLE_I18N */ - if (BE (sbcset == NULL, 0)) -#endif /* not RE_ENABLE_I18N */ - { - *err = REG_ESPACE; - return NULL; - } - - if (non_match) - { -#ifdef RE_ENABLE_I18N - mbcset->non_match = 1; -#endif /* not RE_ENABLE_I18N */ - } - - /* We don't care the syntax in this case. */ - ret = build_charclass (trans, sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &alloc, -#endif /* RE_ENABLE_I18N */ - class_name, 0); - - if (BE (ret != REG_NOERROR, 0)) - { - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - *err = ret; - return NULL; - } - /* \w match '_' also. */ - for (; *extra; extra++) - bitset_set (sbcset, *extra); - - /* If it is non-matching list. */ - if (non_match) - bitset_not (sbcset); - -#ifdef RE_ENABLE_I18N - /* Ensure only single byte characters are set. */ - if (dfa->mb_cur_max > 1) - bitset_mask (sbcset, dfa->sb_char); -#endif - - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (tree == NULL, 0)) - goto build_word_op_espace; - -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - bin_tree_t *mbc_tree; - /* Build a tree for complex bracket. */ - br_token.type = COMPLEX_BRACKET; - br_token.opr.mbcset = mbcset; - dfa->has_mb_node = 1; - mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (mbc_tree == NULL, 0)) - goto build_word_op_espace; - /* Then join them by ALT node. */ - tree = create_tree (dfa, tree, mbc_tree, OP_ALT); - if (BE (mbc_tree != NULL, 1)) - return tree; - } - else - { - free_charset (mbcset); - return tree; - } -#else /* not RE_ENABLE_I18N */ - return tree; -#endif /* not RE_ENABLE_I18N */ - - build_word_op_espace: - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - *err = REG_ESPACE; - return NULL; -} - -/* This is intended for the expressions like "a{1,3}". - Fetch a number from 'input', and return the number. - Return REG_MISSING if the number field is empty like "{,1}". - Return RE_DUP_MAX + 1 if the number field is too large. - Return REG_ERROR if an error occurred. */ - -static Idx -fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) -{ - Idx num = REG_MISSING; - unsigned char c; - while (1) - { - fetch_token (token, input, syntax); - c = token->opr.c; - if (BE (token->type == END_OF_RE, 0)) - return REG_ERROR; - if (token->type == OP_CLOSE_DUP_NUM || c == ',') - break; - num = ((token->type != CHARACTER || c < '0' || '9' < c - || num == REG_ERROR) - ? REG_ERROR - : num == REG_MISSING - ? c - '0' - : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); - } - return num; -} - -#ifdef RE_ENABLE_I18N -static void -free_charset (re_charset_t *cset) -{ - re_free (cset->mbchars); -# ifdef _LIBC - re_free (cset->coll_syms); - re_free (cset->equiv_classes); - re_free (cset->range_starts); - re_free (cset->range_ends); -# endif - re_free (cset->char_classes); - re_free (cset); -} -#endif /* RE_ENABLE_I18N */ - -/* Functions for binary tree operation. */ - -/* Create a tree node. */ - -static bin_tree_t * -create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, - re_token_type_t type) -{ - re_token_t t; - t.type = type; - return create_token_tree (dfa, left, right, &t); -} - -static bin_tree_t * -create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, - const re_token_t *token) -{ - bin_tree_t *tree; - if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) - { - bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); - - if (storage == NULL) - return NULL; - storage->next = dfa->str_tree_storage; - dfa->str_tree_storage = storage; - dfa->str_tree_storage_idx = 0; - } - tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++]; - - tree->parent = NULL; - tree->left = left; - tree->right = right; - tree->token = *token; - tree->token.duplicated = 0; - tree->token.opt_subexp = 0; - tree->first = NULL; - tree->next = NULL; - tree->node_idx = REG_MISSING; - - if (left != NULL) - left->parent = tree; - if (right != NULL) - right->parent = tree; - return tree; -} - -/* Mark the tree SRC as an optional subexpression. - To be called from preorder or postorder. */ - -static reg_errcode_t -mark_opt_subexp (void *extra, bin_tree_t *node) -{ - Idx idx = (uintptr_t) extra; - if (node->token.type == SUBEXP && node->token.opr.idx == idx) - node->token.opt_subexp = 1; - - return REG_NOERROR; -} - -/* Free the allocated memory inside NODE. */ - -static void -free_token (re_token_t *node) -{ -#ifdef RE_ENABLE_I18N - if (node->type == COMPLEX_BRACKET && node->duplicated == 0) - free_charset (node->opr.mbcset); - else -#endif /* RE_ENABLE_I18N */ - if (node->type == SIMPLE_BRACKET && node->duplicated == 0) - re_free (node->opr.sbcset); -} - -/* Worker function for tree walking. Free the allocated memory inside NODE - and its children. */ - -static reg_errcode_t -free_tree (void *extra, bin_tree_t *node) -{ - free_token (&node->token); - return REG_NOERROR; -} - - -/* Duplicate the node SRC, and return new node. This is a preorder - visit similar to the one implemented by the generic visitor, but - we need more infrastructure to maintain two parallel trees --- so, - it's easier to duplicate. */ - -static bin_tree_t * -duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa) -{ - const bin_tree_t *node; - bin_tree_t *dup_root; - bin_tree_t **p_new = &dup_root, *dup_node = root->parent; - - for (node = root; ; ) - { - /* Create a new tree and link it back to the current parent. */ - *p_new = create_token_tree (dfa, NULL, NULL, &node->token); - if (*p_new == NULL) - return NULL; - (*p_new)->parent = dup_node; - (*p_new)->token.duplicated = 1; - dup_node = *p_new; - - /* Go to the left node, or up and to the right. */ - if (node->left) - { - node = node->left; - p_new = &dup_node->left; - } - else - { - const bin_tree_t *prev = NULL; - while (node->right == prev || node->right == NULL) - { - prev = node; - node = node->parent; - dup_node = dup_node->parent; - if (!node) - return dup_root; - } - node = node->right; - p_new = &dup_node->right; - } - } -} diff --git a/grub-core/gnulib/regex.c b/grub-core/gnulib/regex.c deleted file mode 100644 index 5a0332e00..000000000 --- a/grub-core/gnulib/regex.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -#ifndef _LIBC -# include - -# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ -# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" -# endif -# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ -# pragma GCC diagnostic ignored "-Wold-style-definition" -# pragma GCC diagnostic ignored "-Wtype-limits" -# endif -#endif - -/* Make sure no one compiles this code with a C++ compiler. */ -#if defined __cplusplus && defined _LIBC -# error "This is C code, use a C compiler" -#endif - -#ifdef _LIBC -/* We have to keep the namespace clean. */ -# define regfree(preg) __regfree (preg) -# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) -# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) -# define regerror(errcode, preg, errbuf, errbuf_size) \ - __regerror(errcode, preg, errbuf, errbuf_size) -# define re_set_registers(bu, re, nu, st, en) \ - __re_set_registers (bu, re, nu, st, en) -# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ - __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) -# define re_match(bufp, string, size, pos, regs) \ - __re_match (bufp, string, size, pos, regs) -# define re_search(bufp, string, size, startpos, range, regs) \ - __re_search (bufp, string, size, startpos, range, regs) -# define re_compile_pattern(pattern, length, bufp) \ - __re_compile_pattern (pattern, length, bufp) -# define re_set_syntax(syntax) __re_set_syntax (syntax) -# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ - __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) -# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) - -# include "../locale/localeinfo.h" -#endif - -/* On some systems, limits.h sets RE_DUP_MAX to a lower value than - GNU regex allows. Include it before , which correctly - #undefs RE_DUP_MAX and sets it to the right value. */ -#include - -#include -#include "regex_internal.h" - -#include "regex_internal.c" -#include "regcomp.c" -#include "regexec.c" - -/* Binary backward compatibility. */ -#if _LIBC -# include -# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) -link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") -int re_max_failures = 2000; -# endif -#endif diff --git a/grub-core/gnulib/regex.h b/grub-core/gnulib/regex.h deleted file mode 100644 index 854c6edaf..000000000 --- a/grub-core/gnulib/regex.h +++ /dev/null @@ -1,667 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library. - Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -#ifndef _REGEX_H -#define _REGEX_H 1 - -#include - -/* Allow the use in C++ code. */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Define __USE_GNU to declare GNU extensions that violate the - POSIX name space rules. */ -#ifdef _GNU_SOURCE -# define __USE_GNU 1 -#endif - -#ifdef _REGEX_LARGE_OFFSETS - -/* Use types and values that are wide enough to represent signed and - unsigned byte offsets in memory. This currently works only when - the regex code is used outside of the GNU C library; it is not yet - supported within glibc itself, and glibc users should not define - _REGEX_LARGE_OFFSETS. */ - -/* The type of nonnegative object indexes. Traditionally, GNU regex - uses 'int' for these. Code that uses __re_idx_t should work - regardless of whether the type is signed. */ -typedef size_t __re_idx_t; - -/* The type of object sizes. */ -typedef size_t __re_size_t; - -/* The type of object sizes, in places where the traditional code - uses unsigned long int. */ -typedef size_t __re_long_size_t; - -#else - -/* The traditional GNU regex implementation mishandles strings longer - than INT_MAX. */ -typedef int __re_idx_t; -typedef unsigned int __re_size_t; -typedef unsigned long int __re_long_size_t; - -#endif - -/* The following two types have to be signed and unsigned integer type - wide enough to hold a value of a pointer. For most ANSI compilers - ptrdiff_t and size_t should be likely OK. Still size of these two - types is 2 for Microsoft C. Ugh... */ -typedef long int s_reg_t; -typedef unsigned long int active_reg_t; - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned long int reg_syntax_t; - -#ifdef __USE_GNU -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* If this bit is set, then character classes are supported. They are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -# define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then '{...}' defines an interval, and \{ and \} - are literals. - If not set, then '\{...\}' defines an interval. */ -# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* If this bit is set, succeed as soon as we match the whole pattern, - without further backtracking. */ -# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) - -/* If this bit is set, do not process the GNU regex operators. - If not set, then the GNU regex operators are recognized. */ -# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) - -/* If this bit is set, turn on internal regex debugging. - If not set, and debugging was on, turn it off. - This only works if regex.c is compiled -DDEBUG. - We define this bit always, so that all that's needed to turn on - debugging is to recompile regex.c; the calling code can always have - this bit set, and it won't affect anything in the normal case. */ -# define RE_DEBUG (RE_NO_GNU_OPS << 1) - -/* If this bit is set, a syntactically invalid interval is treated as - a string of ordinary characters. For example, the ERE 'a{1' is - treated as 'a\{1'. */ -# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) - -/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only - for ^, because it is difficult to scan the regex backwards to find - whether ^ should be special. */ -# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) - -/* If this bit is set, then \{ cannot be first in a regex or - immediately after an alternation, open-group or \} operator. */ -# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) - -/* If this bit is set, then no_sub will be set to 1 during - re_compile_pattern. */ -# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) -#endif - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -#ifdef __USE_GNU -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -# define RE_SYNTAX_EMACS 0 - -# define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CHAR_CLASSES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) - -# define RE_SYNTAX_GNU_AWK \ - ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ - | RE_INVALID_INTERVAL_ORD) \ - & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \ - | RE_CONTEXT_INVALID_OPS )) - -# define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ - | RE_INTERVALS | RE_NO_GNU_OPS \ - | RE_INVALID_INTERVAL_ORD) - -# define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -# define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -# define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ - | RE_INVALID_INTERVAL_ORD) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -# define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -# define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -# define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -# define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is - removed and RE_NO_BK_REFS is added. */ -# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. POSIX-conforming - systems might define this in , but we want our - value, so remove any previous define. */ -# ifdef _REGEX_INCLUDE_LIMITS_H -# include -# endif -# ifdef RE_DUP_MAX -# undef RE_DUP_MAX -# endif - -/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored - the counter as a 2-byte signed integer. This is no longer true, so - RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to - ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined. - However, there would be a huge performance problem if someone - actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains - its historical value. */ -# define RE_DUP_MAX (0x7fff) -#endif - - -/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (1 << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (1 << 2) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (1 << 3) - - -/* POSIX 'eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - -/* Use PMATCH[0] to delimit the start and end of the search in the - buffer. */ -#define REG_STARTEND (1 << 2) - - -/* If any error codes are removed, changed, or added, update the - '__re_error_msgid' table in regcomp.c. */ - -typedef enum -{ - _REG_ENOSYS = -1, /* This will never happen for this implementation. */ - _REG_NOERROR = 0, /* Success. */ - _REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - _REG_BADPAT, /* Invalid pattern. */ - _REG_ECOLLATE, /* Invalid collating element. */ - _REG_ECTYPE, /* Invalid character class name. */ - _REG_EESCAPE, /* Trailing backslash. */ - _REG_ESUBREG, /* Invalid back reference. */ - _REG_EBRACK, /* Unmatched left bracket. */ - _REG_EPAREN, /* Parenthesis imbalance. */ - _REG_EBRACE, /* Unmatched \{. */ - _REG_BADBR, /* Invalid contents of \{\}. */ - _REG_ERANGE, /* Invalid range end. */ - _REG_ESPACE, /* Ran out of memory. */ - _REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - _REG_EEND, /* Premature end. */ - _REG_ESIZE, /* Too large (e.g., repeat count too large). */ - _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K -# define REG_ENOSYS _REG_ENOSYS -#endif -#define REG_NOERROR _REG_NOERROR -#define REG_NOMATCH _REG_NOMATCH -#define REG_BADPAT _REG_BADPAT -#define REG_ECOLLATE _REG_ECOLLATE -#define REG_ECTYPE _REG_ECTYPE -#define REG_EESCAPE _REG_EESCAPE -#define REG_ESUBREG _REG_ESUBREG -#define REG_EBRACK _REG_EBRACK -#define REG_EPAREN _REG_EPAREN -#define REG_EBRACE _REG_EBRACE -#define REG_BADBR _REG_BADBR -#define REG_ERANGE _REG_ERANGE -#define REG_ESPACE _REG_ESPACE -#define REG_BADRPT _REG_BADRPT -#define REG_EEND _REG_EEND -#define REG_ESIZE _REG_ESIZE -#define REG_ERPAREN _REG_ERPAREN - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields 'buffer', 'allocated', 'fastmap', - and 'translate' can be set. After the pattern has been compiled, - the fields 're_nsub', 'not_bol' and 'not_eol' are available. All - other fields are private to the regex routines. */ - -#ifndef RE_TRANSLATE_TYPE -# define __RE_TRANSLATE_TYPE unsigned char * -# ifdef __USE_GNU -# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE -# endif -#endif - -#ifdef __USE_GNU -# define __REPB_PREFIX(name) name -#else -# define __REPB_PREFIX(name) __##name -#endif - -struct re_pattern_buffer -{ - /* Space that holds the compiled pattern. The type - 'struct re_dfa_t' is private and is not declared here. */ - struct re_dfa_t *__REPB_PREFIX(buffer); - - /* Number of bytes to which 'buffer' points. */ - __re_long_size_t __REPB_PREFIX(allocated); - - /* Number of bytes actually used in 'buffer'. */ - __re_long_size_t __REPB_PREFIX(used); - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t __REPB_PREFIX(syntax); - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses the - fastmap, if there is one, to skip over impossible starting points - for matches. */ - char *__REPB_PREFIX(fastmap); - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation is - applied to a pattern when it is compiled and to a string when it - is matched. */ - __RE_TRANSLATE_TYPE __REPB_PREFIX(translate); - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in 're_search_2', to see whether or - not we should use the fastmap, so we don't set this absolutely - perfectly; see 're_compile_fastmap' (the "duplicate" case). */ - unsigned __REPB_PREFIX(can_be_null) : 1; - - /* If REGS_UNALLOCATED, allocate space in the 'regs' structure - for 'max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#ifdef __USE_GNU -# define REGS_UNALLOCATED 0 -# define REGS_REALLOCATE 1 -# define REGS_FIXED 2 -#endif - unsigned __REPB_PREFIX(regs_allocated) : 2; - - /* Set to zero when 're_compile_pattern' compiles a pattern; set to - one by 're_compile_fastmap' if it updates the fastmap. */ - unsigned __REPB_PREFIX(fastmap_accurate) : 1; - - /* If set, 're_match_2' does not return information about - subexpressions. */ - unsigned __REPB_PREFIX(no_sub) : 1; - - /* If set, a beginning-of-line anchor doesn't match at the beginning - of the string. */ - unsigned __REPB_PREFIX(not_bol) : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned __REPB_PREFIX(not_eol) : 1; - - /* If true, an anchor at a newline matches. */ - unsigned __REPB_PREFIX(newline_anchor) : 1; -}; - -typedef struct re_pattern_buffer regex_t; - -/* Type for byte offsets within the string. POSIX mandates this. */ -#ifdef _REGEX_LARGE_OFFSETS -/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as - ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t - is wider than ssize_t, so ssize_t is safe. */ -typedef ssize_t regoff_t; -#else -/* The traditional GNU regex implementation mishandles strings longer - than INT_MAX. */ -typedef int regoff_t; -#endif - - -#ifdef __USE_GNU -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - __re_size_t num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - 're_match_2' returns information about at least this many registers - the first time a 'regs' structure is passed. */ -# ifndef RE_NREGS -# define RE_NREGS 30 -# endif -#endif - - -/* POSIX specification for registers. Aside from the different names than - 're_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -#ifdef __USE_GNU -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the 're_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global 're_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. - - To free the allocated storage, you must call 'regfree' on BUFFER. - Note that the translate table must either have been initialised by - 'regcomp', with a malloc'ed value, or set to NULL before calling - 'regfree'. */ -extern const char *re_compile_pattern (const char *__pattern, size_t __length, - struct re_pattern_buffer *__buffer); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern regoff_t re_search (struct re_pattern_buffer *__buffer, - const char *__string, __re_idx_t __length, - __re_idx_t __start, regoff_t __range, - struct re_registers *__regs); - - -/* Like 're_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, - const char *__string1, __re_idx_t __length1, - const char *__string2, __re_idx_t __length2, - __re_idx_t __start, regoff_t __range, - struct re_registers *__regs, - __re_idx_t __stop); - - -/* Like 're_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern regoff_t re_match (struct re_pattern_buffer *__buffer, - const char *__string, __re_idx_t __length, - __re_idx_t __start, struct re_registers *__regs); - - -/* Relates to 're_match' as 're_search_2' relates to 're_search'. */ -extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, - const char *__string1, __re_idx_t __length1, - const char *__string2, __re_idx_t __length2, - __re_idx_t __start, struct re_registers *__regs, - __re_idx_t __stop); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least 'NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers (struct re_pattern_buffer *__buffer, - struct re_registers *__regs, - __re_size_t __num_regs, - regoff_t *__starts, regoff_t *__ends); -#endif /* Use GNU */ - -#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD) -# ifndef _CRAY -/* 4.2 bsd compatibility. */ -extern char *re_comp (const char *); -extern int re_exec (const char *); -# endif -#endif - -/* GCC 2.95 and later have "__restrict"; C99 compilers have - "restrict", and "configure" may have defined "restrict". - Other compilers use __restrict, __restrict__, and _Restrict, and - 'configure' might #define 'restrict' to those words, so pick a - different name. */ -#ifndef _Restrict_ -# if 199901L <= __STDC_VERSION__ -# define _Restrict_ restrict -# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) -# define _Restrict_ __restrict -# else -# define _Restrict_ -# endif -#endif -/* gcc 3.1 and up support the [restrict] syntax. Don't trust - sys/cdefs.h's definition of __restrict_arr, though, as it - mishandles gcc -ansi -pedantic. */ -#ifndef _Restrict_arr_ -# if ((199901L <= __STDC_VERSION__ \ - || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ - && !defined __STRICT_ANSI__)) \ - && !defined __GNUG__) -# define _Restrict_arr_ _Restrict_ -# else -# define _Restrict_arr_ -# endif -#endif - -/* POSIX compatibility. */ -extern int regcomp (regex_t *_Restrict_ __preg, - const char *_Restrict_ __pattern, - int __cflags); - -extern int regexec (const regex_t *_Restrict_ __preg, - const char *_Restrict_ __string, size_t __nmatch, - regmatch_t __pmatch[_Restrict_arr_], - int __eflags); - -extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, - char *_Restrict_ __errbuf, size_t __errbuf_size); - -extern void regfree (regex_t *__preg); - - -#ifdef __cplusplus -} -#endif /* C++ */ - -#endif /* regex.h */ diff --git a/grub-core/gnulib/regex_internal.c b/grub-core/gnulib/regex_internal.c deleted file mode 100644 index 899b0ae67..000000000 --- a/grub-core/gnulib/regex_internal.c +++ /dev/null @@ -1,1741 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -static void re_string_construct_common (const char *str, Idx len, - re_string_t *pstr, - RE_TRANSLATE_TYPE trans, bool icase, - const re_dfa_t *dfa) internal_function; -static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, - const re_node_set *nodes, - re_hashval_t hash) internal_function; -static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, - const re_node_set *nodes, - unsigned int context, - re_hashval_t hash) internal_function; - -/* Functions for string operation. */ - -/* This function allocate the buffers. It is necessary to call - re_string_reconstruct before using the object. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, - RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) -{ - reg_errcode_t ret; - Idx init_buf_len; - - /* Ensure at least one character fits into the buffers. */ - if (init_len < dfa->mb_cur_max) - init_len = dfa->mb_cur_max; - init_buf_len = (len + 1 < init_len) ? len + 1: init_len; - re_string_construct_common (str, len, pstr, trans, icase, dfa); - - ret = re_string_realloc_buffers (pstr, init_buf_len); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - pstr->word_char = dfa->word_char; - pstr->word_ops_used = dfa->word_ops_used; - pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; - pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; - pstr->valid_raw_len = pstr->valid_len; - return REG_NOERROR; -} - -/* This function allocate the buffers, and initialize them. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_string_construct (re_string_t *pstr, const char *str, Idx len, - RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) -{ - reg_errcode_t ret; - memset (pstr, '\0', sizeof (re_string_t)); - re_string_construct_common (str, len, pstr, trans, icase, dfa); - - if (len > 0) - { - ret = re_string_realloc_buffers (pstr, len + 1); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; - - if (icase) - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - while (1) - { - ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - if (pstr->valid_raw_len >= len) - break; - if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) - break; - ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - } - else -#endif /* RE_ENABLE_I18N */ - build_upper_buffer (pstr); - } - else - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - build_wcs_buffer (pstr); - else -#endif /* RE_ENABLE_I18N */ - { - if (trans != NULL) - re_string_translate_buffer (pstr); - else - { - pstr->valid_len = pstr->bufs_len; - pstr->valid_raw_len = pstr->bufs_len; - } - } - } - - return REG_NOERROR; -} - -/* Helper functions for re_string_allocate, and re_string_construct. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) -{ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - wint_t *new_wcs; - - /* Avoid overflow in realloc. */ - const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); - if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0)) - return REG_ESPACE; - - new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); - if (BE (new_wcs == NULL, 0)) - return REG_ESPACE; - pstr->wcs = new_wcs; - if (pstr->offsets != NULL) - { - Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); - if (BE (new_offsets == NULL, 0)) - return REG_ESPACE; - pstr->offsets = new_offsets; - } - } -#endif /* RE_ENABLE_I18N */ - if (pstr->mbs_allocated) - { - unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, - new_buf_len); - if (BE (new_mbs == NULL, 0)) - return REG_ESPACE; - pstr->mbs = new_mbs; - } - pstr->bufs_len = new_buf_len; - return REG_NOERROR; -} - - -static void -internal_function -re_string_construct_common (const char *str, Idx len, re_string_t *pstr, - RE_TRANSLATE_TYPE trans, bool icase, - const re_dfa_t *dfa) -{ - pstr->raw_mbs = (const unsigned char *) str; - pstr->len = len; - pstr->raw_len = len; - pstr->trans = trans; - pstr->icase = icase; - pstr->mbs_allocated = (trans != NULL || icase); - pstr->mb_cur_max = dfa->mb_cur_max; - pstr->is_utf8 = dfa->is_utf8; - pstr->map_notascii = dfa->map_notascii; - pstr->stop = pstr->len; - pstr->raw_stop = pstr->stop; -} - -#ifdef RE_ENABLE_I18N - -/* Build wide character buffer PSTR->WCS. - If the byte sequence of the string are: - (0), (1), (0), (1), - Then wide character buffer will be: - , WEOF , , WEOF , - We use WEOF for padding, they indicate that the position isn't - a first byte of a multibyte character. - - Note that this function assumes PSTR->VALID_LEN elements are already - built and starts from PSTR->VALID_LEN. */ - -static void -internal_function -build_wcs_buffer (re_string_t *pstr) -{ -#ifdef _LIBC - unsigned char buf[MB_LEN_MAX]; - assert (MB_LEN_MAX >= pstr->mb_cur_max); -#else - unsigned char buf[64]; -#endif - mbstate_t prev_st; - Idx byte_idx, end_idx, remain_len; - size_t mbclen; - - /* Build the buffers from pstr->valid_len to either pstr->len or - pstr->bufs_len. */ - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - for (byte_idx = pstr->valid_len; byte_idx < end_idx;) - { - wchar_t wc; - const char *p; - - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - /* Apply the translation if we need. */ - if (BE (pstr->trans != NULL, 0)) - { - int i, ch; - - for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) - { - ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i]; - buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch]; - } - p = (const char *) buf; - } - else - p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; - mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); - if (BE (mbclen == (size_t) -1 || mbclen == 0 - || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) - { - /* We treat these cases as a singlebyte character. */ - mbclen = 1; - wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; - if (BE (pstr->trans != NULL, 0)) - wc = pstr->trans[wc]; - pstr->cur_state = prev_st; - } - else if (BE (mbclen == (size_t) -2, 0)) - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - - /* Write wide character and padding. */ - pstr->wcs[byte_idx++] = wc; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = byte_idx; -} - -/* Build wide character buffer PSTR->WCS like build_wcs_buffer, - but for REG_ICASE. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -build_wcs_upper_buffer (re_string_t *pstr) -{ - mbstate_t prev_st; - Idx src_idx, byte_idx, end_idx, remain_len; - size_t mbclen; -#ifdef _LIBC - char buf[MB_LEN_MAX]; - assert (MB_LEN_MAX >= pstr->mb_cur_max); -#else - char buf[64]; -#endif - - byte_idx = pstr->valid_len; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - /* The following optimization assumes that ASCII characters can be - mapped to wide characters with a simple cast. */ - if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed) - { - while (byte_idx < end_idx) - { - wchar_t wc; - - if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) - && mbsinit (&pstr->cur_state)) - { - /* In case of a singlebyte character. */ - pstr->mbs[byte_idx] - = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]); - /* The next step uses the assumption that wchar_t is encoded - ASCII-safe: all ASCII values can be converted like this. */ - pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; - ++byte_idx; - continue; - } - - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - mbclen = __mbrtowc (&wc, - ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx - + byte_idx), remain_len, &pstr->cur_state); - if (BE (mbclen < (size_t) -2, 1)) - { - wchar_t wcu = wc; - if (iswlower (wc)) - { - size_t mbcdlen; - - wcu = towupper (wc); - mbcdlen = wcrtomb (buf, wcu, &prev_st); - if (BE (mbclen == mbcdlen, 1)) - memcpy (pstr->mbs + byte_idx, buf, mbclen); - else - { - src_idx = byte_idx; - goto offsets_needed; - } - } - else - memcpy (pstr->mbs + byte_idx, - pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen); - pstr->wcs[byte_idx++] = wcu; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - else if (mbclen == (size_t) -1 || mbclen == 0 - || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) - { - /* It is an invalid character, an incomplete character - at the end of the string, or '\0'. Just use the byte. */ - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; - pstr->mbs[byte_idx] = ch; - /* And also cast it to wide char. */ - pstr->wcs[byte_idx++] = (wchar_t) ch; - if (BE (mbclen == (size_t) -1, 0)) - pstr->cur_state = prev_st; - } - else - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = byte_idx; - return REG_NOERROR; - } - else - for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;) - { - wchar_t wc; - const char *p; - offsets_needed: - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - if (BE (pstr->trans != NULL, 0)) - { - int i, ch; - - for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) - { - ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i]; - buf[i] = pstr->trans[ch]; - } - p = (const char *) buf; - } - else - p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; - mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); - if (BE (mbclen < (size_t) -2, 1)) - { - wchar_t wcu = wc; - if (iswlower (wc)) - { - size_t mbcdlen; - - wcu = towupper (wc); - mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); - if (BE (mbclen == mbcdlen, 1)) - memcpy (pstr->mbs + byte_idx, buf, mbclen); - else if (mbcdlen != (size_t) -1) - { - size_t i; - - if (byte_idx + mbcdlen > pstr->bufs_len) - { - pstr->cur_state = prev_st; - break; - } - - if (pstr->offsets == NULL) - { - pstr->offsets = re_malloc (Idx, pstr->bufs_len); - - if (pstr->offsets == NULL) - return REG_ESPACE; - } - if (!pstr->offsets_needed) - { - for (i = 0; i < (size_t) byte_idx; ++i) - pstr->offsets[i] = i; - pstr->offsets_needed = 1; - } - - memcpy (pstr->mbs + byte_idx, buf, mbcdlen); - pstr->wcs[byte_idx] = wcu; - pstr->offsets[byte_idx] = src_idx; - for (i = 1; i < mbcdlen; ++i) - { - pstr->offsets[byte_idx + i] - = src_idx + (i < mbclen ? i : mbclen - 1); - pstr->wcs[byte_idx + i] = WEOF; - } - pstr->len += mbcdlen - mbclen; - if (pstr->raw_stop > src_idx) - pstr->stop += mbcdlen - mbclen; - end_idx = (pstr->bufs_len > pstr->len) - ? pstr->len : pstr->bufs_len; - byte_idx += mbcdlen; - src_idx += mbclen; - continue; - } - else - memcpy (pstr->mbs + byte_idx, p, mbclen); - } - else - memcpy (pstr->mbs + byte_idx, p, mbclen); - - if (BE (pstr->offsets_needed != 0, 0)) - { - size_t i; - for (i = 0; i < mbclen; ++i) - pstr->offsets[byte_idx + i] = src_idx + i; - } - src_idx += mbclen; - - pstr->wcs[byte_idx++] = wcu; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - else if (mbclen == (size_t) -1 || mbclen == 0 - || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) - { - /* It is an invalid character or '\0'. Just use the byte. */ - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; - - if (BE (pstr->trans != NULL, 0)) - ch = pstr->trans [ch]; - pstr->mbs[byte_idx] = ch; - - if (BE (pstr->offsets_needed != 0, 0)) - pstr->offsets[byte_idx] = src_idx; - ++src_idx; - - /* And also cast it to wide char. */ - pstr->wcs[byte_idx++] = (wchar_t) ch; - if (BE (mbclen == (size_t) -1, 0)) - pstr->cur_state = prev_st; - } - else - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = src_idx; - return REG_NOERROR; -} - -/* Skip characters until the index becomes greater than NEW_RAW_IDX. - Return the index. */ - -static Idx -internal_function -re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) -{ - mbstate_t prev_st; - Idx rawbuf_idx; - size_t mbclen; - wint_t wc = WEOF; - - /* Skip the characters which are not necessary to check. */ - for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; - rawbuf_idx < new_raw_idx;) - { - wchar_t wc2; - Idx remain_len = pstr->raw_len - rawbuf_idx; - prev_st = pstr->cur_state; - mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, - remain_len, &pstr->cur_state); - if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) - { - /* We treat these cases as a single byte character. */ - if (mbclen == 0 || remain_len == 0) - wc = L'\0'; - else - wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); - mbclen = 1; - pstr->cur_state = prev_st; - } - else - wc = wc2; - /* Then proceed the next character. */ - rawbuf_idx += mbclen; - } - *last_wc = wc; - return rawbuf_idx; -} -#endif /* RE_ENABLE_I18N */ - -/* Build the buffer PSTR->MBS, and apply the translation if we need. - This function is used in case of REG_ICASE. */ - -static void -internal_function -build_upper_buffer (re_string_t *pstr) -{ - Idx char_idx, end_idx; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) - { - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; - if (BE (pstr->trans != NULL, 0)) - ch = pstr->trans[ch]; - if (islower (ch)) - pstr->mbs[char_idx] = toupper (ch); - else - pstr->mbs[char_idx] = ch; - } - pstr->valid_len = char_idx; - pstr->valid_raw_len = char_idx; -} - -/* Apply TRANS to the buffer in PSTR. */ - -static void -internal_function -re_string_translate_buffer (re_string_t *pstr) -{ - Idx buf_idx, end_idx; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx) - { - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx]; - pstr->mbs[buf_idx] = pstr->trans[ch]; - } - - pstr->valid_len = buf_idx; - pstr->valid_raw_len = buf_idx; -} - -/* This function re-construct the buffers. - Concretely, convert to wide character in case of pstr->mb_cur_max > 1, - convert to upper case in case of REG_ICASE, apply translation. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) -{ - Idx offset; - - if (BE (pstr->raw_mbs_idx <= idx, 0)) - offset = idx - pstr->raw_mbs_idx; - else - { - /* Reset buffer. */ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); -#endif /* RE_ENABLE_I18N */ - pstr->len = pstr->raw_len; - pstr->stop = pstr->raw_stop; - pstr->valid_len = 0; - pstr->raw_mbs_idx = 0; - pstr->valid_raw_len = 0; - pstr->offsets_needed = 0; - pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF - : CONTEXT_NEWLINE | CONTEXT_BEGBUF); - if (!pstr->mbs_allocated) - pstr->mbs = (unsigned char *) pstr->raw_mbs; - offset = idx; - } - - if (BE (offset != 0, 1)) - { - /* Should the already checked characters be kept? */ - if (BE (offset < pstr->valid_raw_len, 1)) - { - /* Yes, move them to the front of the buffer. */ -#ifdef RE_ENABLE_I18N - if (BE (pstr->offsets_needed, 0)) - { - Idx low = 0, high = pstr->valid_len, mid; - do - { - mid = (high + low) / 2; - if (pstr->offsets[mid] > offset) - high = mid; - else if (pstr->offsets[mid] < offset) - low = mid + 1; - else - break; - } - while (low < high); - if (pstr->offsets[mid] < offset) - ++mid; - pstr->tip_context = re_string_context_at (pstr, mid - 1, - eflags); - /* This can be quite complicated, so handle specially - only the common and easy case where the character with - different length representation of lower and upper - case is present at or after offset. */ - if (pstr->valid_len > offset - && mid == offset && pstr->offsets[mid] == offset) - { - memmove (pstr->wcs, pstr->wcs + offset, - (pstr->valid_len - offset) * sizeof (wint_t)); - memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); - pstr->valid_len -= offset; - pstr->valid_raw_len -= offset; - for (low = 0; low < pstr->valid_len; low++) - pstr->offsets[low] = pstr->offsets[low + offset] - offset; - } - else - { - /* Otherwise, just find out how long the partial multibyte - character at offset is and fill it with WEOF/255. */ - pstr->len = pstr->raw_len - idx + offset; - pstr->stop = pstr->raw_stop - idx + offset; - pstr->offsets_needed = 0; - while (mid > 0 && pstr->offsets[mid - 1] == offset) - --mid; - while (mid < pstr->valid_len) - if (pstr->wcs[mid] != WEOF) - break; - else - ++mid; - if (mid == pstr->valid_len) - pstr->valid_len = 0; - else - { - pstr->valid_len = pstr->offsets[mid] - offset; - if (pstr->valid_len) - { - for (low = 0; low < pstr->valid_len; ++low) - pstr->wcs[low] = WEOF; - memset (pstr->mbs, 255, pstr->valid_len); - } - } - pstr->valid_raw_len = pstr->valid_len; - } - } - else -#endif - { - pstr->tip_context = re_string_context_at (pstr, offset - 1, - eflags); -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - memmove (pstr->wcs, pstr->wcs + offset, - (pstr->valid_len - offset) * sizeof (wint_t)); -#endif /* RE_ENABLE_I18N */ - if (BE (pstr->mbs_allocated, 0)) - memmove (pstr->mbs, pstr->mbs + offset, - pstr->valid_len - offset); - pstr->valid_len -= offset; - pstr->valid_raw_len -= offset; -#if DEBUG - assert (pstr->valid_len > 0); -#endif - } - } - else - { -#ifdef RE_ENABLE_I18N - /* No, skip all characters until IDX. */ - Idx prev_valid_len = pstr->valid_len; - - if (BE (pstr->offsets_needed, 0)) - { - pstr->len = pstr->raw_len - idx + offset; - pstr->stop = pstr->raw_stop - idx + offset; - pstr->offsets_needed = 0; - } -#endif - pstr->valid_len = 0; -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - Idx wcs_idx; - wint_t wc = WEOF; - - if (pstr->is_utf8) - { - const unsigned char *raw, *p, *end; - - /* Special case UTF-8. Multi-byte chars start with any - byte other than 0x80 - 0xbf. */ - raw = pstr->raw_mbs + pstr->raw_mbs_idx; - end = raw + (offset - pstr->mb_cur_max); - if (end < pstr->raw_mbs) - end = pstr->raw_mbs; - p = raw + offset - 1; -#ifdef _LIBC - /* We know the wchar_t encoding is UCS4, so for the simple - case, ASCII characters, skip the conversion step. */ - if (isascii (*p) && BE (pstr->trans == NULL, 1)) - { - memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); - /* pstr->valid_len = 0; */ - wc = (wchar_t) *p; - } - else -#endif - for (; p >= end; --p) - if ((*p & 0xc0) != 0x80) - { - mbstate_t cur_state; - wchar_t wc2; - Idx mlen = raw + pstr->len - p; - unsigned char buf[6]; - size_t mbclen; - - const unsigned char *pp = p; - if (BE (pstr->trans != NULL, 0)) - { - int i = mlen < 6 ? mlen : 6; - while (--i >= 0) - buf[i] = pstr->trans[p[i]]; - pp = buf; - } - /* XXX Don't use mbrtowc, we know which conversion - to use (UTF-8 -> UCS4). */ - memset (&cur_state, 0, sizeof (cur_state)); - mbclen = __mbrtowc (&wc2, (const char *) pp, mlen, - &cur_state); - if (raw + offset - p <= mbclen - && mbclen < (size_t) -2) - { - memset (&pstr->cur_state, '\0', - sizeof (mbstate_t)); - pstr->valid_len = mbclen - (raw + offset - p); - wc = wc2; - } - break; - } - } - - if (wc == WEOF) - pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; - if (wc == WEOF) - pstr->tip_context - = re_string_context_at (pstr, prev_valid_len - 1, eflags); - else - pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) - && IS_WIDE_WORD_CHAR (wc)) - ? CONTEXT_WORD - : ((IS_WIDE_NEWLINE (wc) - && pstr->newline_anchor) - ? CONTEXT_NEWLINE : 0)); - if (BE (pstr->valid_len, 0)) - { - for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) - pstr->wcs[wcs_idx] = WEOF; - if (pstr->mbs_allocated) - memset (pstr->mbs, 255, pstr->valid_len); - } - pstr->valid_raw_len = pstr->valid_len; - } - else -#endif /* RE_ENABLE_I18N */ - { - int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; - pstr->valid_raw_len = 0; - if (pstr->trans) - c = pstr->trans[c]; - pstr->tip_context = (bitset_contain (pstr->word_char, c) - ? CONTEXT_WORD - : ((IS_NEWLINE (c) && pstr->newline_anchor) - ? CONTEXT_NEWLINE : 0)); - } - } - if (!BE (pstr->mbs_allocated, 0)) - pstr->mbs += offset; - } - pstr->raw_mbs_idx = idx; - pstr->len -= offset; - pstr->stop -= offset; - - /* Then build the buffers. */ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - if (pstr->icase) - { - reg_errcode_t ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - else - build_wcs_buffer (pstr); - } - else -#endif /* RE_ENABLE_I18N */ - if (BE (pstr->mbs_allocated, 0)) - { - if (pstr->icase) - build_upper_buffer (pstr); - else if (pstr->trans != NULL) - re_string_translate_buffer (pstr); - } - else - pstr->valid_len = pstr->len; - - pstr->cur_idx = 0; - return REG_NOERROR; -} - -static unsigned char -internal_function __attribute__ ((pure)) -re_string_peek_byte_case (const re_string_t *pstr, Idx idx) -{ - int ch; - Idx off; - - /* Handle the common (easiest) cases first. */ - if (BE (!pstr->mbs_allocated, 1)) - return re_string_peek_byte (pstr, idx); - -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1 - && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) - return re_string_peek_byte (pstr, idx); -#endif - - off = pstr->cur_idx + idx; -#ifdef RE_ENABLE_I18N - if (pstr->offsets_needed) - off = pstr->offsets[off]; -#endif - - ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - -#ifdef RE_ENABLE_I18N - /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I - this function returns CAPITAL LETTER I instead of first byte of - DOTLESS SMALL LETTER I. The latter would confuse the parser, - since peek_byte_case doesn't advance cur_idx in any way. */ - if (pstr->offsets_needed && !isascii (ch)) - return re_string_peek_byte (pstr, idx); -#endif - - return ch; -} - -static unsigned char -internal_function -re_string_fetch_byte_case (re_string_t *pstr) -{ - if (BE (!pstr->mbs_allocated, 1)) - return re_string_fetch_byte (pstr); - -#ifdef RE_ENABLE_I18N - if (pstr->offsets_needed) - { - Idx off; - int ch; - - /* For tr_TR.UTF-8 [[:islower:]] there is - [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip - in that case the whole multi-byte character and return - the original letter. On the other side, with - [[: DOTLESS SMALL LETTER I return [[:I, as doing - anything else would complicate things too much. */ - - if (!re_string_first_byte (pstr, pstr->cur_idx)) - return re_string_fetch_byte (pstr); - - off = pstr->offsets[pstr->cur_idx]; - ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - - if (! isascii (ch)) - return re_string_fetch_byte (pstr); - - re_string_skip_bytes (pstr, - re_string_char_size_at (pstr, pstr->cur_idx)); - return ch; - } -#endif - - return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; -} - -static void -internal_function -re_string_destruct (re_string_t *pstr) -{ -#ifdef RE_ENABLE_I18N - re_free (pstr->wcs); - re_free (pstr->offsets); -#endif /* RE_ENABLE_I18N */ - if (pstr->mbs_allocated) - re_free (pstr->mbs); -} - -/* Return the context at IDX in INPUT. */ - -static unsigned int -internal_function -re_string_context_at (const re_string_t *input, Idx idx, int eflags) -{ - int c; - if (BE (! REG_VALID_INDEX (idx), 0)) - /* In this case, we use the value stored in input->tip_context, - since we can't know the character in input->mbs[-1] here. */ - return input->tip_context; - if (BE (idx == input->len, 0)) - return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF - : CONTEXT_NEWLINE | CONTEXT_ENDBUF); -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc; - Idx wc_idx = idx; - while(input->wcs[wc_idx] == WEOF) - { -#ifdef DEBUG - /* It must not happen. */ - assert (REG_VALID_INDEX (wc_idx)); -#endif - --wc_idx; - if (! REG_VALID_INDEX (wc_idx)) - return input->tip_context; - } - wc = input->wcs[wc_idx]; - if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) - return CONTEXT_WORD; - return (IS_WIDE_NEWLINE (wc) && input->newline_anchor - ? CONTEXT_NEWLINE : 0); - } - else -#endif - { - c = re_string_byte_at (input, idx); - if (bitset_contain (input->word_char, c)) - return CONTEXT_WORD; - return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; - } -} - -/* Functions for set operation. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_alloc (re_node_set *set, Idx size) -{ - set->alloc = size; - set->nelem = 0; - set->elems = re_malloc (Idx, size); - if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) - return REG_ESPACE; - return REG_NOERROR; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_init_1 (re_node_set *set, Idx elem) -{ - set->alloc = 1; - set->nelem = 1; - set->elems = re_malloc (Idx, 1); - if (BE (set->elems == NULL, 0)) - { - set->alloc = set->nelem = 0; - return REG_ESPACE; - } - set->elems[0] = elem; - return REG_NOERROR; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) -{ - set->alloc = 2; - set->elems = re_malloc (Idx, 2); - if (BE (set->elems == NULL, 0)) - return REG_ESPACE; - if (elem1 == elem2) - { - set->nelem = 1; - set->elems[0] = elem1; - } - else - { - set->nelem = 2; - if (elem1 < elem2) - { - set->elems[0] = elem1; - set->elems[1] = elem2; - } - else - { - set->elems[0] = elem2; - set->elems[1] = elem1; - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_init_copy (re_node_set *dest, const re_node_set *src) -{ - dest->nelem = src->nelem; - if (src->nelem > 0) - { - dest->alloc = dest->nelem; - dest->elems = re_malloc (Idx, dest->alloc); - if (BE (dest->elems == NULL, 0)) - { - dest->alloc = dest->nelem = 0; - return REG_ESPACE; - } - memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); - } - else - re_node_set_init_empty (dest); - return REG_NOERROR; -} - -/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. - Note: We assume dest->elems is NULL, when dest->alloc is 0. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, - const re_node_set *src2) -{ - Idx i1, i2, is, id, delta, sbase; - if (src1->nelem == 0 || src2->nelem == 0) - return REG_NOERROR; - - /* We need dest->nelem + 2 * elems_in_intersection; this is a - conservative estimate. */ - if (src1->nelem + src2->nelem + dest->nelem > dest->alloc) - { - Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; - Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); - if (BE (new_elems == NULL, 0)) - return REG_ESPACE; - dest->elems = new_elems; - dest->alloc = new_alloc; - } - - /* Find the items in the intersection of SRC1 and SRC2, and copy - into the top of DEST those that are not already in DEST itself. */ - sbase = dest->nelem + src1->nelem + src2->nelem; - i1 = src1->nelem - 1; - i2 = src2->nelem - 1; - id = dest->nelem - 1; - for (;;) - { - if (src1->elems[i1] == src2->elems[i2]) - { - /* Try to find the item in DEST. Maybe we could binary search? */ - while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1]) - --id; - - if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1]) - dest->elems[--sbase] = src1->elems[i1]; - - if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2)) - break; - } - - /* Lower the highest of the two items. */ - else if (src1->elems[i1] < src2->elems[i2]) - { - if (! REG_VALID_INDEX (--i2)) - break; - } - else - { - if (! REG_VALID_INDEX (--i1)) - break; - } - } - - id = dest->nelem - 1; - is = dest->nelem + src1->nelem + src2->nelem - 1; - delta = is - sbase + 1; - - /* Now copy. When DELTA becomes zero, the remaining - DEST elements are already in place; this is more or - less the same loop that is in re_node_set_merge. */ - dest->nelem += delta; - if (delta > 0 && REG_VALID_INDEX (id)) - for (;;) - { - if (dest->elems[is] > dest->elems[id]) - { - /* Copy from the top. */ - dest->elems[id + delta--] = dest->elems[is--]; - if (delta == 0) - break; - } - else - { - /* Slide from the bottom. */ - dest->elems[id + delta] = dest->elems[id]; - if (! REG_VALID_INDEX (--id)) - break; - } - } - - /* Copy remaining SRC elements. */ - memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx)); - - return REG_NOERROR; -} - -/* Calculate the union set of the sets SRC1 and SRC2. And store it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_init_union (re_node_set *dest, const re_node_set *src1, - const re_node_set *src2) -{ - Idx i1, i2, id; - if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0) - { - dest->alloc = src1->nelem + src2->nelem; - dest->elems = re_malloc (Idx, dest->alloc); - if (BE (dest->elems == NULL, 0)) - return REG_ESPACE; - } - else - { - if (src1 != NULL && src1->nelem > 0) - return re_node_set_init_copy (dest, src1); - else if (src2 != NULL && src2->nelem > 0) - return re_node_set_init_copy (dest, src2); - else - re_node_set_init_empty (dest); - return REG_NOERROR; - } - for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;) - { - if (src1->elems[i1] > src2->elems[i2]) - { - dest->elems[id++] = src2->elems[i2++]; - continue; - } - if (src1->elems[i1] == src2->elems[i2]) - ++i2; - dest->elems[id++] = src1->elems[i1++]; - } - if (i1 < src1->nelem) - { - memcpy (dest->elems + id, src1->elems + i1, - (src1->nelem - i1) * sizeof (Idx)); - id += src1->nelem - i1; - } - else if (i2 < src2->nelem) - { - memcpy (dest->elems + id, src2->elems + i2, - (src2->nelem - i2) * sizeof (Idx)); - id += src2->nelem - i2; - } - dest->nelem = id; - return REG_NOERROR; -} - -/* Calculate the union set of the sets DEST and SRC. And store it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -re_node_set_merge (re_node_set *dest, const re_node_set *src) -{ - Idx is, id, sbase, delta; - if (src == NULL || src->nelem == 0) - return REG_NOERROR; - if (dest->alloc < 2 * src->nelem + dest->nelem) - { - Idx new_alloc = 2 * (src->nelem + dest->alloc); - Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); - if (BE (new_buffer == NULL, 0)) - return REG_ESPACE; - dest->elems = new_buffer; - dest->alloc = new_alloc; - } - - if (BE (dest->nelem == 0, 0)) - { - dest->nelem = src->nelem; - memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); - return REG_NOERROR; - } - - /* Copy into the top of DEST the items of SRC that are not - found in DEST. Maybe we could binary search in DEST? */ - for (sbase = dest->nelem + 2 * src->nelem, - is = src->nelem - 1, id = dest->nelem - 1; - REG_VALID_INDEX (is) && REG_VALID_INDEX (id); ) - { - if (dest->elems[id] == src->elems[is]) - is--, id--; - else if (dest->elems[id] < src->elems[is]) - dest->elems[--sbase] = src->elems[is--]; - else /* if (dest->elems[id] > src->elems[is]) */ - --id; - } - - if (REG_VALID_INDEX (is)) - { - /* If DEST is exhausted, the remaining items of SRC must be unique. */ - sbase -= is + 1; - memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx)); - } - - id = dest->nelem - 1; - is = dest->nelem + 2 * src->nelem - 1; - delta = is - sbase + 1; - if (delta == 0) - return REG_NOERROR; - - /* Now copy. When DELTA becomes zero, the remaining - DEST elements are already in place. */ - dest->nelem += delta; - for (;;) - { - if (dest->elems[is] > dest->elems[id]) - { - /* Copy from the top. */ - dest->elems[id + delta--] = dest->elems[is--]; - if (delta == 0) - break; - } - else - { - /* Slide from the bottom. */ - dest->elems[id + delta] = dest->elems[id]; - if (! REG_VALID_INDEX (--id)) - { - /* Copy remaining SRC elements. */ - memcpy (dest->elems, dest->elems + sbase, - delta * sizeof (Idx)); - break; - } - } - } - - return REG_NOERROR; -} - -/* Insert the new element ELEM to the re_node_set* SET. - SET should not already have ELEM. - Return true if successful. */ - -static bool -internal_function __attribute_warn_unused_result__ -re_node_set_insert (re_node_set *set, Idx elem) -{ - Idx idx; - /* In case the set is empty. */ - if (set->alloc == 0) - return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1); - - if (BE (set->nelem, 0) == 0) - { - /* We already guaranteed above that set->alloc != 0. */ - set->elems[0] = elem; - ++set->nelem; - return true; - } - - /* Realloc if we need. */ - if (set->alloc == set->nelem) - { - Idx *new_elems; - set->alloc = set->alloc * 2; - new_elems = re_realloc (set->elems, Idx, set->alloc); - if (BE (new_elems == NULL, 0)) - return false; - set->elems = new_elems; - } - - /* Move the elements which follows the new element. Test the - first element separately to skip a check in the inner loop. */ - if (elem < set->elems[0]) - { - idx = 0; - for (idx = set->nelem; idx > 0; idx--) - set->elems[idx] = set->elems[idx - 1]; - } - else - { - for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) - set->elems[idx] = set->elems[idx - 1]; - } - - /* Insert the new element. */ - set->elems[idx] = elem; - ++set->nelem; - return true; -} - -/* Insert the new element ELEM to the re_node_set* SET. - SET should not already have any element greater than or equal to ELEM. - Return true if successful. */ - -static bool -internal_function __attribute_warn_unused_result__ -re_node_set_insert_last (re_node_set *set, Idx elem) -{ - /* Realloc if we need. */ - if (set->alloc == set->nelem) - { - Idx *new_elems; - set->alloc = (set->alloc + 1) * 2; - new_elems = re_realloc (set->elems, Idx, set->alloc); - if (BE (new_elems == NULL, 0)) - return false; - set->elems = new_elems; - } - - /* Insert the new element. */ - set->elems[set->nelem++] = elem; - return true; -} - -/* Compare two node sets SET1 and SET2. - Return true if SET1 and SET2 are equivalent. */ - -static bool -internal_function __attribute__ ((pure)) -re_node_set_compare (const re_node_set *set1, const re_node_set *set2) -{ - Idx i; - if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) - return false; - for (i = set1->nelem ; REG_VALID_INDEX (--i) ; ) - if (set1->elems[i] != set2->elems[i]) - return false; - return true; -} - -/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ - -static Idx -internal_function __attribute__ ((pure)) -re_node_set_contains (const re_node_set *set, Idx elem) -{ - __re_size_t idx, right, mid; - if (! REG_VALID_NONZERO_INDEX (set->nelem)) - return 0; - - /* Binary search the element. */ - idx = 0; - right = set->nelem - 1; - while (idx < right) - { - mid = (idx + right) / 2; - if (set->elems[mid] < elem) - idx = mid + 1; - else - right = mid; - } - return set->elems[idx] == elem ? idx + 1 : 0; -} - -static void -internal_function -re_node_set_remove_at (re_node_set *set, Idx idx) -{ - if (idx < 0 || idx >= set->nelem) - return; - --set->nelem; - for (; idx < set->nelem; idx++) - set->elems[idx] = set->elems[idx + 1]; -} - - -/* Add the token TOKEN to dfa->nodes, and return the index of the token. - Or return REG_MISSING if an error occurred. */ - -static Idx -internal_function -re_dfa_add_node (re_dfa_t *dfa, re_token_t token) -{ - if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) - { - size_t new_nodes_alloc = dfa->nodes_alloc * 2; - Idx *new_nexts, *new_indices; - re_node_set *new_edests, *new_eclosures; - re_token_t *new_nodes; - - /* Avoid overflows in realloc. */ - const size_t max_object_size = MAX (sizeof (re_token_t), - MAX (sizeof (re_node_set), - sizeof (Idx))); - if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0)) - return REG_MISSING; - - new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); - if (BE (new_nodes == NULL, 0)) - return REG_MISSING; - dfa->nodes = new_nodes; - new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); - new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); - new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); - new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); - if (BE (new_nexts == NULL || new_indices == NULL - || new_edests == NULL || new_eclosures == NULL, 0)) - return REG_MISSING; - dfa->nexts = new_nexts; - dfa->org_indices = new_indices; - dfa->edests = new_edests; - dfa->eclosures = new_eclosures; - dfa->nodes_alloc = new_nodes_alloc; - } - dfa->nodes[dfa->nodes_len] = token; - dfa->nodes[dfa->nodes_len].constraint = 0; -#ifdef RE_ENABLE_I18N - dfa->nodes[dfa->nodes_len].accept_mb = - ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) - || token.type == COMPLEX_BRACKET); -#endif - dfa->nexts[dfa->nodes_len] = REG_MISSING; - re_node_set_init_empty (dfa->edests + dfa->nodes_len); - re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); - return dfa->nodes_len++; -} - -static re_hashval_t -internal_function -calc_state_hash (const re_node_set *nodes, unsigned int context) -{ - re_hashval_t hash = nodes->nelem + context; - Idx i; - for (i = 0 ; i < nodes->nelem ; i++) - hash += nodes->elems[i]; - return hash; -} - -/* Search for the state whose node_set is equivalent to NODES. - Return the pointer to the state, if we found it in the DFA. - Otherwise create the new one and return it. In case of an error - return NULL and set the error code in ERR. - Note: - We assume NULL as the invalid state, then it is possible that - return value is NULL and ERR is REG_NOERROR. - - We never return non-NULL value in case of any errors, it is for - optimization. */ - -static re_dfastate_t * -internal_function __attribute_warn_unused_result__ -re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, - const re_node_set *nodes) -{ - re_hashval_t hash; - re_dfastate_t *new_state; - struct re_state_table_entry *spot; - Idx i; -#ifdef lint - /* Suppress bogus uninitialized-variable warnings. */ - *err = REG_NOERROR; -#endif - if (BE (nodes->nelem == 0, 0)) - { - *err = REG_NOERROR; - return NULL; - } - hash = calc_state_hash (nodes, 0); - spot = dfa->state_table + (hash & dfa->state_hash_mask); - - for (i = 0 ; i < spot->num ; i++) - { - re_dfastate_t *state = spot->array[i]; - if (hash != state->hash) - continue; - if (re_node_set_compare (&state->nodes, nodes)) - return state; - } - - /* There are no appropriate state in the dfa, create the new one. */ - new_state = create_ci_newstate (dfa, nodes, hash); - if (BE (new_state == NULL, 0)) - *err = REG_ESPACE; - - return new_state; -} - -/* Search for the state whose node_set is equivalent to NODES and - whose context is equivalent to CONTEXT. - Return the pointer to the state, if we found it in the DFA. - Otherwise create the new one and return it. In case of an error - return NULL and set the error code in ERR. - Note: - We assume NULL as the invalid state, then it is possible that - return value is NULL and ERR is REG_NOERROR. - - We never return non-NULL value in case of any errors, it is for - optimization. */ - -static re_dfastate_t * -internal_function __attribute_warn_unused_result__ -re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, - const re_node_set *nodes, unsigned int context) -{ - re_hashval_t hash; - re_dfastate_t *new_state; - struct re_state_table_entry *spot; - Idx i; -#ifdef lint - /* Suppress bogus uninitialized-variable warnings. */ - *err = REG_NOERROR; -#endif - if (nodes->nelem == 0) - { - *err = REG_NOERROR; - return NULL; - } - hash = calc_state_hash (nodes, context); - spot = dfa->state_table + (hash & dfa->state_hash_mask); - - for (i = 0 ; i < spot->num ; i++) - { - re_dfastate_t *state = spot->array[i]; - if (state->hash == hash - && state->context == context - && re_node_set_compare (state->entrance_nodes, nodes)) - return state; - } - /* There are no appropriate state in 'dfa', create the new one. */ - new_state = create_cd_newstate (dfa, nodes, context, hash); - if (BE (new_state == NULL, 0)) - *err = REG_ESPACE; - - return new_state; -} - -/* Finish initialization of the new state NEWSTATE, and using its hash value - HASH put in the appropriate bucket of DFA's state table. Return value - indicates the error code if failed. */ - -static reg_errcode_t -__attribute_warn_unused_result__ -register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, - re_hashval_t hash) -{ - struct re_state_table_entry *spot; - reg_errcode_t err; - Idx i; - - newstate->hash = hash; - err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); - if (BE (err != REG_NOERROR, 0)) - return REG_ESPACE; - for (i = 0; i < newstate->nodes.nelem; i++) - { - Idx elem = newstate->nodes.elems[i]; - if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) - if (! re_node_set_insert_last (&newstate->non_eps_nodes, elem)) - return REG_ESPACE; - } - - spot = dfa->state_table + (hash & dfa->state_hash_mask); - if (BE (spot->alloc <= spot->num, 0)) - { - Idx new_alloc = 2 * spot->num + 2; - re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, - new_alloc); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - spot->array = new_array; - spot->alloc = new_alloc; - } - spot->array[spot->num++] = newstate; - return REG_NOERROR; -} - -static void -free_state (re_dfastate_t *state) -{ - re_node_set_free (&state->non_eps_nodes); - re_node_set_free (&state->inveclosure); - if (state->entrance_nodes != &state->nodes) - { - re_node_set_free (state->entrance_nodes); - re_free (state->entrance_nodes); - } - re_node_set_free (&state->nodes); - re_free (state->word_trtable); - re_free (state->trtable); - re_free (state); -} - -/* Create the new state which is independent of contexts. - Return the new state if succeeded, otherwise return NULL. */ - -static re_dfastate_t * -internal_function __attribute_warn_unused_result__ -create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, - re_hashval_t hash) -{ - Idx i; - reg_errcode_t err; - re_dfastate_t *newstate; - - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); - if (BE (newstate == NULL, 0)) - return NULL; - err = re_node_set_init_copy (&newstate->nodes, nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_free (newstate); - return NULL; - } - - newstate->entrance_nodes = &newstate->nodes; - for (i = 0 ; i < nodes->nelem ; i++) - { - re_token_t *node = dfa->nodes + nodes->elems[i]; - re_token_type_t type = node->type; - if (type == CHARACTER && !node->constraint) - continue; -#ifdef RE_ENABLE_I18N - newstate->accept_mb |= node->accept_mb; -#endif /* RE_ENABLE_I18N */ - - /* If the state has the halt node, the state is a halt state. */ - if (type == END_OF_RE) - newstate->halt = 1; - else if (type == OP_BACK_REF) - newstate->has_backref = 1; - else if (type == ANCHOR || node->constraint) - newstate->has_constraint = 1; - } - err = register_state (dfa, newstate, hash); - if (BE (err != REG_NOERROR, 0)) - { - free_state (newstate); - newstate = NULL; - } - return newstate; -} - -/* Create the new state which is depend on the context CONTEXT. - Return the new state if succeeded, otherwise return NULL. */ - -static re_dfastate_t * -internal_function __attribute_warn_unused_result__ -create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, - unsigned int context, re_hashval_t hash) -{ - Idx i, nctx_nodes = 0; - reg_errcode_t err; - re_dfastate_t *newstate; - - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); - if (BE (newstate == NULL, 0)) - return NULL; - err = re_node_set_init_copy (&newstate->nodes, nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_free (newstate); - return NULL; - } - - newstate->context = context; - newstate->entrance_nodes = &newstate->nodes; - - for (i = 0 ; i < nodes->nelem ; i++) - { - re_token_t *node = dfa->nodes + nodes->elems[i]; - re_token_type_t type = node->type; - unsigned int constraint = node->constraint; - - if (type == CHARACTER && !constraint) - continue; -#ifdef RE_ENABLE_I18N - newstate->accept_mb |= node->accept_mb; -#endif /* RE_ENABLE_I18N */ - - /* If the state has the halt node, the state is a halt state. */ - if (type == END_OF_RE) - newstate->halt = 1; - else if (type == OP_BACK_REF) - newstate->has_backref = 1; - - if (constraint) - { - if (newstate->entrance_nodes == &newstate->nodes) - { - newstate->entrance_nodes = re_malloc (re_node_set, 1); - if (BE (newstate->entrance_nodes == NULL, 0)) - { - free_state (newstate); - return NULL; - } - if (re_node_set_init_copy (newstate->entrance_nodes, nodes) - != REG_NOERROR) - return NULL; - nctx_nodes = 0; - newstate->has_constraint = 1; - } - - if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context)) - { - re_node_set_remove_at (&newstate->nodes, i - nctx_nodes); - ++nctx_nodes; - } - } - } - err = register_state (dfa, newstate, hash); - if (BE (err != REG_NOERROR, 0)) - { - free_state (newstate); - newstate = NULL; - } - return newstate; -} diff --git a/grub-core/gnulib/regex_internal.h b/grub-core/gnulib/regex_internal.h deleted file mode 100644 index c467b2907..000000000 --- a/grub-core/gnulib/regex_internal.h +++ /dev/null @@ -1,873 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -#ifndef _REGEX_INTERNAL_H -#define _REGEX_INTERNAL_H 1 - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#if defined _LIBC -# include -#else -# define __libc_lock_init(NAME) do { } while (0) -# define __libc_lock_lock(NAME) do { } while (0) -# define __libc_lock_unlock(NAME) do { } while (0) -#endif - -/* In case that the system doesn't have isblank(). */ -#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) -# define isblank(ch) ((ch) == ' ' || (ch) == '\t') -#endif - -#ifdef _LIBC -# ifndef _RE_DEFINE_LOCALE_FUNCTIONS -# define _RE_DEFINE_LOCALE_FUNCTIONS 1 -# include -# include -# include -# endif -#endif - -/* This is for other GNU distributions with internationalized messages. */ -#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC -# include -# ifdef _LIBC -# undef gettext -# define gettext(msgid) \ - __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) -# endif -#else -# define gettext(msgid) (msgid) -#endif - -#ifndef gettext_noop -/* This define is so xgettext can find the internationalizable - strings. */ -# define gettext_noop(String) String -#endif - -#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC -# define RE_ENABLE_I18N -#endif - -#if __GNUC__ >= 3 -# define BE(expr, val) __builtin_expect (expr, val) -#else -# define BE(expr, val) (expr) -#endif - -/* Number of ASCII characters. */ -#define ASCII_CHARS 0x80 - -/* Number of single byte characters. */ -#define SBC_MAX (UCHAR_MAX + 1) - -#define COLL_ELEM_LEN_MAX 8 - -/* The character which represents newline. */ -#define NEWLINE_CHAR '\n' -#define WIDE_NEWLINE_CHAR L'\n' - -/* Rename to standard API for using out of glibc. */ -#ifndef _LIBC -# undef __wctype -# undef __iswctype -# define __wctype wctype -# define __iswctype iswctype -# define __btowc btowc -# define __mbrtowc mbrtowc -# define __wcrtomb wcrtomb -# define __regfree regfree -# define attribute_hidden -#endif /* not _LIBC */ - -#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1) -# define __attribute__(arg) -#endif - -typedef __re_idx_t Idx; -#ifdef _REGEX_LARGE_OFFSETS -# define IDX_MAX (SIZE_MAX - 2) -#else -# define IDX_MAX INT_MAX -#endif - -/* Special return value for failure to match. */ -#define REG_MISSING ((Idx) -1) - -/* Special return value for internal error. */ -#define REG_ERROR ((Idx) -2) - -/* Test whether N is a valid index, and is not one of the above. */ -#ifdef _REGEX_LARGE_OFFSETS -# define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR) -#else -# define REG_VALID_INDEX(n) (0 <= (n)) -#endif - -/* Test whether N is a valid nonzero index. */ -#ifdef _REGEX_LARGE_OFFSETS -# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1)) -#else -# define REG_VALID_NONZERO_INDEX(n) (0 < (n)) -#endif - -/* A hash value, suitable for computing hash tables. */ -typedef __re_size_t re_hashval_t; - -/* An integer used to represent a set of bits. It must be unsigned, - and must be at least as wide as unsigned int. */ -typedef unsigned long int bitset_word_t; -/* All bits set in a bitset_word_t. */ -#define BITSET_WORD_MAX ULONG_MAX - -/* Number of bits in a bitset_word_t. For portability to hosts with - padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)'; - instead, deduce it directly from BITSET_WORD_MAX. Avoid - greater-than-32-bit integers and unconditional shifts by more than - 31 bits, as they're not portable. */ -#if BITSET_WORD_MAX == 0xffffffffUL -# define BITSET_WORD_BITS 32 -#elif BITSET_WORD_MAX >> 31 >> 4 == 1 -# define BITSET_WORD_BITS 36 -#elif BITSET_WORD_MAX >> 31 >> 16 == 1 -# define BITSET_WORD_BITS 48 -#elif BITSET_WORD_MAX >> 31 >> 28 == 1 -# define BITSET_WORD_BITS 60 -#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1 -# define BITSET_WORD_BITS 64 -#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1 -# define BITSET_WORD_BITS 72 -#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1 -# define BITSET_WORD_BITS 128 -#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1 -# define BITSET_WORD_BITS 256 -#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1 -# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */ -# if BITSET_WORD_BITS <= SBC_MAX -# error "Invalid SBC_MAX" -# endif -#else -# error "Add case for new bitset_word_t size" -#endif - -/* Number of bitset_word_t values in a bitset_t. */ -#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) - -typedef bitset_word_t bitset_t[BITSET_WORDS]; -typedef bitset_word_t *re_bitset_ptr_t; -typedef const bitset_word_t *re_const_bitset_ptr_t; - -#define PREV_WORD_CONSTRAINT 0x0001 -#define PREV_NOTWORD_CONSTRAINT 0x0002 -#define NEXT_WORD_CONSTRAINT 0x0004 -#define NEXT_NOTWORD_CONSTRAINT 0x0008 -#define PREV_NEWLINE_CONSTRAINT 0x0010 -#define NEXT_NEWLINE_CONSTRAINT 0x0020 -#define PREV_BEGBUF_CONSTRAINT 0x0040 -#define NEXT_ENDBUF_CONSTRAINT 0x0080 -#define WORD_DELIM_CONSTRAINT 0x0100 -#define NOT_WORD_DELIM_CONSTRAINT 0x0200 - -typedef enum -{ - INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, - WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, - WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, - INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, - LINE_FIRST = PREV_NEWLINE_CONSTRAINT, - LINE_LAST = NEXT_NEWLINE_CONSTRAINT, - BUF_FIRST = PREV_BEGBUF_CONSTRAINT, - BUF_LAST = NEXT_ENDBUF_CONSTRAINT, - WORD_DELIM = WORD_DELIM_CONSTRAINT, - NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT -} re_context_type; - -typedef struct -{ - Idx alloc; - Idx nelem; - Idx *elems; -} re_node_set; - -typedef enum -{ - NON_TYPE = 0, - - /* Node type, These are used by token, node, tree. */ - CHARACTER = 1, - END_OF_RE = 2, - SIMPLE_BRACKET = 3, - OP_BACK_REF = 4, - OP_PERIOD = 5, -#ifdef RE_ENABLE_I18N - COMPLEX_BRACKET = 6, - OP_UTF8_PERIOD = 7, -#endif /* RE_ENABLE_I18N */ - - /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used - when the debugger shows values of this enum type. */ -#define EPSILON_BIT 8 - OP_OPEN_SUBEXP = EPSILON_BIT | 0, - OP_CLOSE_SUBEXP = EPSILON_BIT | 1, - OP_ALT = EPSILON_BIT | 2, - OP_DUP_ASTERISK = EPSILON_BIT | 3, - ANCHOR = EPSILON_BIT | 4, - - /* Tree type, these are used only by tree. */ - CONCAT = 16, - SUBEXP = 17, - - /* Token type, these are used only by token. */ - OP_DUP_PLUS = 18, - OP_DUP_QUESTION, - OP_OPEN_BRACKET, - OP_CLOSE_BRACKET, - OP_CHARSET_RANGE, - OP_OPEN_DUP_NUM, - OP_CLOSE_DUP_NUM, - OP_NON_MATCH_LIST, - OP_OPEN_COLL_ELEM, - OP_CLOSE_COLL_ELEM, - OP_OPEN_EQUIV_CLASS, - OP_CLOSE_EQUIV_CLASS, - OP_OPEN_CHAR_CLASS, - OP_CLOSE_CHAR_CLASS, - OP_WORD, - OP_NOTWORD, - OP_SPACE, - OP_NOTSPACE, - BACK_SLASH - -} re_token_type_t; - -#ifdef RE_ENABLE_I18N -typedef struct -{ - /* Multibyte characters. */ - wchar_t *mbchars; - - /* Collating symbols. */ -# ifdef _LIBC - int32_t *coll_syms; -# endif - - /* Equivalence classes. */ -# ifdef _LIBC - int32_t *equiv_classes; -# endif - - /* Range expressions. */ -# ifdef _LIBC - uint32_t *range_starts; - uint32_t *range_ends; -# else /* not _LIBC */ - wchar_t *range_starts; - wchar_t *range_ends; -# endif /* not _LIBC */ - - /* Character classes. */ - wctype_t *char_classes; - - /* If this character set is the non-matching list. */ - unsigned int non_match : 1; - - /* # of multibyte characters. */ - Idx nmbchars; - - /* # of collating symbols. */ - Idx ncoll_syms; - - /* # of equivalence classes. */ - Idx nequiv_classes; - - /* # of range expressions. */ - Idx nranges; - - /* # of character classes. */ - Idx nchar_classes; -} re_charset_t; -#endif /* RE_ENABLE_I18N */ - -typedef struct -{ - union - { - unsigned char c; /* for CHARACTER */ - re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; /* for COMPLEX_BRACKET */ -#endif /* RE_ENABLE_I18N */ - Idx idx; /* for BACK_REF */ - re_context_type ctx_type; /* for ANCHOR */ - } opr; -#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ - re_token_type_t type : 8; -#else - re_token_type_t type; -#endif - unsigned int constraint : 10; /* context constraint */ - unsigned int duplicated : 1; - unsigned int opt_subexp : 1; -#ifdef RE_ENABLE_I18N - unsigned int accept_mb : 1; - /* These 2 bits can be moved into the union if needed (e.g. if running out - of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ - unsigned int mb_partial : 1; -#endif - unsigned int word_char : 1; -} re_token_t; - -#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) - -struct re_string_t -{ - /* Indicate the raw buffer which is the original string passed as an - argument of regexec(), re_search(), etc.. */ - const unsigned char *raw_mbs; - /* Store the multibyte string. In case of "case insensitive mode" like - REG_ICASE, upper cases of the string are stored, otherwise MBS points - the same address that RAW_MBS points. */ - unsigned char *mbs; -#ifdef RE_ENABLE_I18N - /* Store the wide character string which is corresponding to MBS. */ - wint_t *wcs; - Idx *offsets; - mbstate_t cur_state; -#endif - /* Index in RAW_MBS. Each character mbs[i] corresponds to - raw_mbs[raw_mbs_idx + i]. */ - Idx raw_mbs_idx; - /* The length of the valid characters in the buffers. */ - Idx valid_len; - /* The corresponding number of bytes in raw_mbs array. */ - Idx valid_raw_len; - /* The length of the buffers MBS and WCS. */ - Idx bufs_len; - /* The index in MBS, which is updated by re_string_fetch_byte. */ - Idx cur_idx; - /* length of RAW_MBS array. */ - Idx raw_len; - /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ - Idx len; - /* End of the buffer may be shorter than its length in the cases such - as re_match_2, re_search_2. Then, we use STOP for end of the buffer - instead of LEN. */ - Idx raw_stop; - /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ - Idx stop; - - /* The context of mbs[0]. We store the context independently, since - the context of mbs[0] may be different from raw_mbs[0], which is - the beginning of the input string. */ - unsigned int tip_context; - /* The translation passed as a part of an argument of re_compile_pattern. */ - RE_TRANSLATE_TYPE trans; - /* Copy of re_dfa_t's word_char. */ - re_const_bitset_ptr_t word_char; - /* true if REG_ICASE. */ - unsigned char icase; - unsigned char is_utf8; - unsigned char map_notascii; - unsigned char mbs_allocated; - unsigned char offsets_needed; - unsigned char newline_anchor; - unsigned char word_ops_used; - int mb_cur_max; -}; -typedef struct re_string_t re_string_t; - - -struct re_dfa_t; -typedef struct re_dfa_t re_dfa_t; - -#ifndef _LIBC -# define internal_function -#endif - -#ifndef NOT_IN_libc -static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, - Idx new_buf_len) - internal_function; -# ifdef RE_ENABLE_I18N -static void build_wcs_buffer (re_string_t *pstr) internal_function; -static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) - internal_function; -# endif /* RE_ENABLE_I18N */ -static void build_upper_buffer (re_string_t *pstr) internal_function; -static void re_string_translate_buffer (re_string_t *pstr) internal_function; -static unsigned int re_string_context_at (const re_string_t *input, Idx idx, - int eflags) - internal_function __attribute__ ((pure)); -#endif -#define re_string_peek_byte(pstr, offset) \ - ((pstr)->mbs[(pstr)->cur_idx + offset]) -#define re_string_fetch_byte(pstr) \ - ((pstr)->mbs[(pstr)->cur_idx++]) -#define re_string_first_byte(pstr, idx) \ - ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) -#define re_string_is_single_byte_char(pstr, idx) \ - ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ - || (pstr)->wcs[(idx) + 1] != WEOF)) -#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) -#define re_string_cur_idx(pstr) ((pstr)->cur_idx) -#define re_string_get_buffer(pstr) ((pstr)->mbs) -#define re_string_length(pstr) ((pstr)->len) -#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) -#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) -#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) - -#if defined _LIBC || HAVE_ALLOCA -# include -#endif - -#ifndef _LIBC -# if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. */ -# define __libc_use_alloca(n) ((n) < 4032) -# else -/* alloca is implemented with malloc, so just use malloc. */ -# define __libc_use_alloca(n) 0 -# undef alloca -# define alloca(n) malloc (n) -# endif -#endif - -#ifdef _LIBC -# define MALLOC_0_IS_NONNULL 1 -#elif !defined MALLOC_0_IS_NONNULL -# define MALLOC_0_IS_NONNULL 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) < (b) ? (b) : (a)) -#endif -#ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) -#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) -#define re_free(p) free (p) - -struct bin_tree_t -{ - struct bin_tree_t *parent; - struct bin_tree_t *left; - struct bin_tree_t *right; - struct bin_tree_t *first; - struct bin_tree_t *next; - - re_token_t token; - - /* 'node_idx' is the index in dfa->nodes, if 'type' == 0. - Otherwise 'type' indicate the type of this node. */ - Idx node_idx; -}; -typedef struct bin_tree_t bin_tree_t; - -#define BIN_TREE_STORAGE_SIZE \ - ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) - -struct bin_tree_storage_t -{ - struct bin_tree_storage_t *next; - bin_tree_t data[BIN_TREE_STORAGE_SIZE]; -}; -typedef struct bin_tree_storage_t bin_tree_storage_t; - -#define CONTEXT_WORD 1 -#define CONTEXT_NEWLINE (CONTEXT_WORD << 1) -#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) -#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) - -#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) -#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) -#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) -#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) -#define IS_ORDINARY_CONTEXT(c) ((c) == 0) - -#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') -#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) -#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') -#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) - -#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ - ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ - || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ - || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ - || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) - -#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ - ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ - || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ - || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ - || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) - -struct re_dfastate_t -{ - re_hashval_t hash; - re_node_set nodes; - re_node_set non_eps_nodes; - re_node_set inveclosure; - re_node_set *entrance_nodes; - struct re_dfastate_t **trtable, **word_trtable; - unsigned int context : 4; - unsigned int halt : 1; - /* If this state can accept "multi byte". - Note that we refer to multibyte characters, and multi character - collating elements as "multi byte". */ - unsigned int accept_mb : 1; - /* If this state has backreference node(s). */ - unsigned int has_backref : 1; - unsigned int has_constraint : 1; -}; -typedef struct re_dfastate_t re_dfastate_t; - -struct re_state_table_entry -{ - Idx num; - Idx alloc; - re_dfastate_t **array; -}; - -/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ - -typedef struct -{ - Idx next_idx; - Idx alloc; - re_dfastate_t **array; -} state_array_t; - -/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ - -typedef struct -{ - Idx node; - Idx str_idx; /* The position NODE match at. */ - state_array_t path; -} re_sub_match_last_t; - -/* Store information about the node NODE whose type is OP_OPEN_SUBEXP. - And information about the node, whose type is OP_CLOSE_SUBEXP, - corresponding to NODE is stored in LASTS. */ - -typedef struct -{ - Idx str_idx; - Idx node; - state_array_t *path; - Idx alasts; /* Allocation size of LASTS. */ - Idx nlasts; /* The number of LASTS. */ - re_sub_match_last_t **lasts; -} re_sub_match_top_t; - -struct re_backref_cache_entry -{ - Idx node; - Idx str_idx; - Idx subexp_from; - Idx subexp_to; - char more; - char unused; - unsigned short int eps_reachable_subexps_map; -}; - -typedef struct -{ - /* The string object corresponding to the input string. */ - re_string_t input; -#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) - const re_dfa_t *const dfa; -#else - const re_dfa_t *dfa; -#endif - /* EFLAGS of the argument of regexec. */ - int eflags; - /* Where the matching ends. */ - Idx match_last; - Idx last_node; - /* The state log used by the matcher. */ - re_dfastate_t **state_log; - Idx state_log_top; - /* Back reference cache. */ - Idx nbkref_ents; - Idx abkref_ents; - struct re_backref_cache_entry *bkref_ents; - int max_mb_elem_len; - Idx nsub_tops; - Idx asub_tops; - re_sub_match_top_t **sub_tops; -} re_match_context_t; - -typedef struct -{ - re_dfastate_t **sifted_states; - re_dfastate_t **limited_states; - Idx last_node; - Idx last_str_idx; - re_node_set limits; -} re_sift_context_t; - -struct re_fail_stack_ent_t -{ - Idx idx; - Idx node; - regmatch_t *regs; - re_node_set eps_via_nodes; -}; - -struct re_fail_stack_t -{ - Idx num; - Idx alloc; - struct re_fail_stack_ent_t *stack; -}; - -struct re_dfa_t -{ - re_token_t *nodes; - size_t nodes_alloc; - size_t nodes_len; - Idx *nexts; - Idx *org_indices; - re_node_set *edests; - re_node_set *eclosures; - re_node_set *inveclosures; - struct re_state_table_entry *state_table; - re_dfastate_t *init_state; - re_dfastate_t *init_state_word; - re_dfastate_t *init_state_nl; - re_dfastate_t *init_state_begbuf; - bin_tree_t *str_tree; - bin_tree_storage_t *str_tree_storage; - re_bitset_ptr_t sb_char; - int str_tree_storage_idx; - - /* number of subexpressions 're_nsub' is in regex_t. */ - re_hashval_t state_hash_mask; - Idx init_node; - Idx nbackref; /* The number of backreference in this dfa. */ - - /* Bitmap expressing which backreference is used. */ - bitset_word_t used_bkref_map; - bitset_word_t completed_bkref_map; - - unsigned int has_plural_match : 1; - /* If this dfa has "multibyte node", which is a backreference or - a node which can accept multibyte character or multi character - collating element. */ - unsigned int has_mb_node : 1; - unsigned int is_utf8 : 1; - unsigned int map_notascii : 1; - unsigned int word_ops_used : 1; - int mb_cur_max; - bitset_t word_char; - reg_syntax_t syntax; - Idx *subexp_map; -#ifdef DEBUG - char* re_str; -#endif -#ifdef _LIBC - __libc_lock_define (, lock) -#endif -}; - -#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) -#define re_node_set_remove(set,id) \ - (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) -#define re_node_set_empty(p) ((p)->nelem = 0) -#define re_node_set_free(set) re_free ((set)->elems) - - -typedef enum -{ - SB_CHAR, - MB_CHAR, - EQUIV_CLASS, - COLL_SYM, - CHAR_CLASS -} bracket_elem_type; - -typedef struct -{ - bracket_elem_type type; - union - { - unsigned char ch; - unsigned char *name; - wchar_t wch; - } opr; -} bracket_elem_t; - - -/* Functions for bitset_t operation. */ - -static void -bitset_set (bitset_t set, Idx i) -{ - set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; -} - -static void -bitset_clear (bitset_t set, Idx i) -{ - set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); -} - -static bool -bitset_contain (const bitset_t set, Idx i) -{ - return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; -} - -static void -bitset_empty (bitset_t set) -{ - memset (set, '\0', sizeof (bitset_t)); -} - -static void -bitset_set_all (bitset_t set) -{ - memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); - if (SBC_MAX % BITSET_WORD_BITS != 0) - set[BITSET_WORDS - 1] = - ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; -} - -static void -bitset_copy (bitset_t dest, const bitset_t src) -{ - memcpy (dest, src, sizeof (bitset_t)); -} - -static void __attribute__ ((unused)) -bitset_not (bitset_t set) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i) - set[bitset_i] = ~set[bitset_i]; - if (SBC_MAX % BITSET_WORD_BITS != 0) - set[BITSET_WORDS - 1] = - ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1) - & ~set[BITSET_WORDS - 1]); -} - -static void __attribute__ ((unused)) -bitset_merge (bitset_t dest, const bitset_t src) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) - dest[bitset_i] |= src[bitset_i]; -} - -static void __attribute__ ((unused)) -bitset_mask (bitset_t dest, const bitset_t src) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) - dest[bitset_i] &= src[bitset_i]; -} - -#ifdef RE_ENABLE_I18N -/* Functions for re_string. */ -static int -internal_function __attribute__ ((pure, unused)) -re_string_char_size_at (const re_string_t *pstr, Idx idx) -{ - int byte_idx; - if (pstr->mb_cur_max == 1) - return 1; - for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) - if (pstr->wcs[idx + byte_idx] != WEOF) - break; - return byte_idx; -} - -static wint_t -internal_function __attribute__ ((pure, unused)) -re_string_wchar_at (const re_string_t *pstr, Idx idx) -{ - if (pstr->mb_cur_max == 1) - return (wint_t) pstr->mbs[idx]; - return (wint_t) pstr->wcs[idx]; -} - -# ifndef NOT_IN_libc -static int -internal_function __attribute__ ((pure, unused)) -re_string_elem_size_at (const re_string_t *pstr, Idx idx) -{ -# ifdef _LIBC - const unsigned char *p, *extra; - const int32_t *table, *indirect; -# include - uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - - if (nrules != 0) - { - table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_INDIRECTMB); - p = pstr->mbs + idx; - findidx (&p, pstr->len - idx); - return p - pstr->mbs - idx; - } - else -# endif /* _LIBC */ - return 1; -} -# endif -#endif /* RE_ENABLE_I18N */ - -#ifndef __GNUC_PREREQ -# if defined __GNUC__ && defined __GNUC_MINOR__ -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -# else -# define __GNUC_PREREQ(maj, min) 0 -# endif -#endif - -#if __GNUC_PREREQ (3,4) -# undef __attribute_warn_unused_result__ -# define __attribute_warn_unused_result__ \ - __attribute__ ((__warn_unused_result__)) -#else -# define __attribute_warn_unused_result__ /* empty */ -#endif - -#endif /* _REGEX_INTERNAL_H */ diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c deleted file mode 100644 index a7776f088..000000000 --- a/grub-core/gnulib/regexec.c +++ /dev/null @@ -1,4417 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, see - . */ - -static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, - Idx n) internal_function; -static void match_ctx_clean (re_match_context_t *mctx) internal_function; -static void match_ctx_free (re_match_context_t *cache) internal_function; -static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node, - Idx str_idx, Idx from, Idx to) - internal_function; -static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) - internal_function; -static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node, - Idx str_idx) internal_function; -static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, - Idx node, Idx str_idx) - internal_function; -static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, - re_dfastate_t **limited_sts, Idx last_node, - Idx last_str_idx) - internal_function; -static reg_errcode_t re_search_internal (const regex_t *preg, - const char *string, Idx length, - Idx start, Idx last_start, Idx stop, - size_t nmatch, regmatch_t pmatch[], - int eflags) internal_function; -static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, - const char *string1, Idx length1, - const char *string2, Idx length2, - Idx start, regoff_t range, - struct re_registers *regs, - Idx stop, bool ret_len) internal_function; -static regoff_t re_search_stub (struct re_pattern_buffer *bufp, - const char *string, Idx length, Idx start, - regoff_t range, Idx stop, - struct re_registers *regs, - bool ret_len) internal_function; -static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, - Idx nregs, int regs_allocated) internal_function; -static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) - internal_function; -static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, - Idx *p_match_first) internal_function; -static Idx check_halt_state_context (const re_match_context_t *mctx, - const re_dfastate_t *state, Idx idx) - internal_function; -static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, - regmatch_t *prev_idx_match, Idx cur_node, - Idx cur_idx, Idx nmatch) internal_function; -static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, - Idx str_idx, Idx dest_node, Idx nregs, - regmatch_t *regs, - re_node_set *eps_via_nodes) - internal_function; -static reg_errcode_t set_regs (const regex_t *preg, - const re_match_context_t *mctx, - size_t nmatch, regmatch_t *pmatch, - bool fl_backtrack) internal_function; -static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) - internal_function; - -#ifdef RE_ENABLE_I18N -static int sift_states_iter_mb (const re_match_context_t *mctx, - re_sift_context_t *sctx, - Idx node_idx, Idx str_idx, Idx max_str_idx) - internal_function; -#endif /* RE_ENABLE_I18N */ -static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, - re_sift_context_t *sctx) - internal_function; -static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, - re_sift_context_t *sctx, Idx str_idx, - re_node_set *cur_dest) - internal_function; -static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, - re_sift_context_t *sctx, - Idx str_idx, - re_node_set *dest_nodes) - internal_function; -static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, - re_node_set *dest_nodes, - const re_node_set *candidates) - internal_function; -static bool check_dst_limits (const re_match_context_t *mctx, - const re_node_set *limits, - Idx dst_node, Idx dst_idx, Idx src_node, - Idx src_idx) internal_function; -static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, - int boundaries, Idx subexp_idx, - Idx from_node, Idx bkref_idx) - internal_function; -static int check_dst_limits_calc_pos (const re_match_context_t *mctx, - Idx limit, Idx subexp_idx, - Idx node, Idx str_idx, - Idx bkref_idx) internal_function; -static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, - re_node_set *dest_nodes, - const re_node_set *candidates, - re_node_set *limits, - struct re_backref_cache_entry *bkref_ents, - Idx str_idx) internal_function; -static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, - re_sift_context_t *sctx, - Idx str_idx, const re_node_set *candidates) - internal_function; -static reg_errcode_t merge_state_array (const re_dfa_t *dfa, - re_dfastate_t **dst, - re_dfastate_t **src, Idx num) - internal_function; -static re_dfastate_t *find_recover_state (reg_errcode_t *err, - re_match_context_t *mctx) internal_function; -static re_dfastate_t *transit_state (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *state) internal_function; -static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *next_state) - internal_function; -static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, - re_node_set *cur_nodes, - Idx str_idx) internal_function; -#if 0 -static re_dfastate_t *transit_state_sb (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *pstate) - internal_function; -#endif -#ifdef RE_ENABLE_I18N -static reg_errcode_t transit_state_mb (re_match_context_t *mctx, - re_dfastate_t *pstate) - internal_function; -#endif /* RE_ENABLE_I18N */ -static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, - const re_node_set *nodes) - internal_function; -static reg_errcode_t get_subexp (re_match_context_t *mctx, - Idx bkref_node, Idx bkref_str_idx) - internal_function; -static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, - const re_sub_match_top_t *sub_top, - re_sub_match_last_t *sub_last, - Idx bkref_node, Idx bkref_str) - internal_function; -static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, - Idx subexp_idx, int type) internal_function; -static reg_errcode_t check_arrival (re_match_context_t *mctx, - state_array_t *path, Idx top_node, - Idx top_str, Idx last_node, Idx last_str, - int type) internal_function; -static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, - Idx str_idx, - re_node_set *cur_nodes, - re_node_set *next_nodes) - internal_function; -static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, - re_node_set *cur_nodes, - Idx ex_subexp, int type) - internal_function; -static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, - re_node_set *dst_nodes, - Idx target, Idx ex_subexp, - int type) internal_function; -static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, - re_node_set *cur_nodes, Idx cur_str, - Idx subexp_num, int type) - internal_function; -static bool build_trtable (const re_dfa_t *dfa, - re_dfastate_t *state) internal_function; -#ifdef RE_ENABLE_I18N -static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, - const re_string_t *input, Idx idx) - internal_function; -# ifdef _LIBC -static unsigned int find_collation_sequence_value (const unsigned char *mbs, - size_t name_len) - internal_function; -# endif /* _LIBC */ -#endif /* RE_ENABLE_I18N */ -static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, - const re_dfastate_t *state, - re_node_set *states_node, - bitset_t *states_ch) internal_function; -static bool check_node_accept (const re_match_context_t *mctx, - const re_token_t *node, Idx idx) - internal_function; -static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len) - internal_function; - -/* Entry point for POSIX code. */ - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - 'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies "execution flags" which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *_Restrict_ preg; - const char *_Restrict_ string; - size_t nmatch; - regmatch_t pmatch[_Restrict_arr_]; - int eflags; -{ - reg_errcode_t err; - Idx start, length; -#ifdef _LIBC - re_dfa_t *dfa = preg->buffer; -#endif - - if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) - return REG_BADPAT; - - if (eflags & REG_STARTEND) - { - start = pmatch[0].rm_so; - length = pmatch[0].rm_eo; - } - else - { - start = 0; - length = strlen (string); - } - - __libc_lock_lock (dfa->lock); - if (preg->no_sub) - err = re_search_internal (preg, string, length, start, length, - length, 0, NULL, eflags); - else - err = re_search_internal (preg, string, length, start, length, - length, nmatch, pmatch, eflags); - __libc_lock_unlock (dfa->lock); - return err != REG_NOERROR; -} - -#ifdef _LIBC -# include -versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); - -# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) -__typeof__ (__regexec) __compat_regexec; - -int -attribute_compat_text_section -__compat_regexec (const regex_t *_Restrict_ preg, - const char *_Restrict_ string, size_t nmatch, - regmatch_t pmatch[], int eflags) -{ - return regexec (preg, string, nmatch, pmatch, - eflags & (REG_NOTBOL | REG_NOTEOL)); -} -compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0); -# endif -#endif - -/* Entry points for GNU code. */ - -/* re_match, re_search, re_match_2, re_search_2 - - The former two functions operate on STRING with length LENGTH, - while the later two operate on concatenation of STRING1 and STRING2 - with lengths LENGTH1 and LENGTH2, respectively. - - re_match() matches the compiled pattern in BUFP against the string, - starting at index START. - - re_search() first tries matching at index START, then it tries to match - starting from index START + 1, and so on. The last start position tried - is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same - way as re_match().) - - The parameter STOP of re_{match,search}_2 specifies that no match exceeding - the first STOP characters of the concatenation of the strings should be - concerned. - - If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match - and all groups is stored in REGS. (For the "_2" variants, the offsets are - computed relative to the concatenation, not relative to the individual - strings.) - - On success, re_match* functions return the length of the match, re_search* - return the position of the start of the match. Return value -1 means no - match was found and -2 indicates an internal error. */ - -regoff_t -re_match (bufp, string, length, start, regs) - struct re_pattern_buffer *bufp; - const char *string; - Idx length, start; - struct re_registers *regs; -{ - return re_search_stub (bufp, string, length, start, 0, length, regs, true); -} -#ifdef _LIBC -weak_alias (__re_match, re_match) -#endif - -regoff_t -re_search (bufp, string, length, start, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - Idx length, start; - regoff_t range; - struct re_registers *regs; -{ - return re_search_stub (bufp, string, length, start, range, length, regs, - false); -} -#ifdef _LIBC -weak_alias (__re_search, re_search) -#endif - -regoff_t -re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - Idx length1, length2, start, stop; - struct re_registers *regs; -{ - return re_search_2_stub (bufp, string1, length1, string2, length2, - start, 0, regs, stop, true); -} -#ifdef _LIBC -weak_alias (__re_match_2, re_match_2) -#endif - -regoff_t -re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - Idx length1, length2, start, stop; - regoff_t range; - struct re_registers *regs; -{ - return re_search_2_stub (bufp, string1, length1, string2, length2, - start, range, regs, stop, false); -} -#ifdef _LIBC -weak_alias (__re_search_2, re_search_2) -#endif - -static regoff_t -re_search_2_stub (struct re_pattern_buffer *bufp, - const char *string1, Idx length1, - const char *string2, Idx length2, - Idx start, regoff_t range, struct re_registers *regs, - Idx stop, bool ret_len) -{ - const char *str; - regoff_t rval; - Idx len = length1 + length2; - char *s = NULL; - - if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) - return -2; - - /* Concatenate the strings. */ - if (length2 > 0) - if (length1 > 0) - { - s = re_malloc (char, len); - - if (BE (s == NULL, 0)) - return -2; -#ifdef _LIBC - memcpy (__mempcpy (s, string1, length1), string2, length2); -#else - memcpy (s, string1, length1); - memcpy (s + length1, string2, length2); -#endif - str = s; - } - else - str = string2; - else - str = string1; - - rval = re_search_stub (bufp, str, len, start, range, stop, regs, - ret_len); - re_free (s); - return rval; -} - -/* The parameters have the same meaning as those of re_search. - Additional parameters: - If RET_LEN is true the length of the match is returned (re_match style); - otherwise the position of the match is returned. */ - -static regoff_t -re_search_stub (struct re_pattern_buffer *bufp, - const char *string, Idx length, - Idx start, regoff_t range, Idx stop, struct re_registers *regs, - bool ret_len) -{ - reg_errcode_t result; - regmatch_t *pmatch; - Idx nregs; - regoff_t rval; - int eflags = 0; -#ifdef _LIBC - re_dfa_t *dfa = bufp->buffer; -#endif - Idx last_start = start + range; - - /* Check for out-of-range. */ - if (BE (start < 0 || start > length, 0)) - return -1; - if (BE (length < last_start || (0 <= range && last_start < start), 0)) - last_start = length; - else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) - last_start = 0; - - __libc_lock_lock (dfa->lock); - - eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; - eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; - - /* Compile fastmap if we haven't yet. */ - if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) - re_compile_fastmap (bufp); - - if (BE (bufp->no_sub, 0)) - regs = NULL; - - /* We need at least 1 register. */ - if (regs == NULL) - nregs = 1; - else if (BE (bufp->regs_allocated == REGS_FIXED - && regs->num_regs <= bufp->re_nsub, 0)) - { - nregs = regs->num_regs; - if (BE (nregs < 1, 0)) - { - /* Nothing can be copied to regs. */ - regs = NULL; - nregs = 1; - } - } - else - nregs = bufp->re_nsub + 1; - pmatch = re_malloc (regmatch_t, nregs); - if (BE (pmatch == NULL, 0)) - { - rval = -2; - goto out; - } - - result = re_search_internal (bufp, string, length, start, last_start, stop, - nregs, pmatch, eflags); - - rval = 0; - - /* I hope we needn't fill their regs with -1's when no match was found. */ - if (result != REG_NOERROR) - rval = result == REG_NOMATCH ? -1 : -2; - else if (regs != NULL) - { - /* If caller wants register contents data back, copy them. */ - bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, - bufp->regs_allocated); - if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) - rval = -2; - } - - if (BE (rval == 0, 1)) - { - if (ret_len) - { - assert (pmatch[0].rm_so == start); - rval = pmatch[0].rm_eo - start; - } - else - rval = pmatch[0].rm_so; - } - re_free (pmatch); - out: - __libc_lock_unlock (dfa->lock); - return rval; -} - -static unsigned -re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs, - int regs_allocated) -{ - int rval = REGS_REALLOCATE; - Idx i; - Idx need_regs = nregs + 1; - /* We need one extra element beyond 'num_regs' for the '-1' marker GNU code - uses. */ - - /* Have the register data arrays been allocated? */ - if (regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. */ - regs->start = re_malloc (regoff_t, need_regs); - if (BE (regs->start == NULL, 0)) - return REGS_UNALLOCATED; - regs->end = re_malloc (regoff_t, need_regs); - if (BE (regs->end == NULL, 0)) - { - re_free (regs->start); - return REGS_UNALLOCATED; - } - regs->num_regs = need_regs; - } - else if (regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (BE (need_regs > regs->num_regs, 0)) - { - regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); - regoff_t *new_end; - if (BE (new_start == NULL, 0)) - return REGS_UNALLOCATED; - new_end = re_realloc (regs->end, regoff_t, need_regs); - if (BE (new_end == NULL, 0)) - { - re_free (new_start); - return REGS_UNALLOCATED; - } - regs->start = new_start; - regs->end = new_end; - regs->num_regs = need_regs; - } - } - else - { - assert (regs_allocated == REGS_FIXED); - /* This function may not be called with REGS_FIXED and nregs too big. */ - assert (regs->num_regs >= nregs); - rval = REGS_FIXED; - } - - /* Copy the regs. */ - for (i = 0; i < nregs; ++i) - { - regs->start[i] = pmatch[i].rm_so; - regs->end[i] = pmatch[i].rm_eo; - } - for ( ; i < regs->num_regs; ++i) - regs->start[i] = regs->end[i] = -1; - - return rval; -} - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - __re_size_t num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = NULL; - } -} -#ifdef _LIBC -weak_alias (__re_set_registers, re_set_registers) -#endif - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them unless specifically requested. */ - -#if defined _REGEX_RE_COMP || defined _LIBC -int -# ifdef _LIBC -weak_function -# endif -re_exec (s) - const char *s; -{ - return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); -} -#endif /* _REGEX_RE_COMP */ - -/* Internal entry point. */ - -/* Searches for a compiled pattern PREG in the string STRING, whose - length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same - meaning as with regexec. LAST_START is START + RANGE, where - START and RANGE have the same meaning as with re_search. - Return REG_NOERROR if we find a match, and REG_NOMATCH if not, - otherwise return the error code. - Note: We assume front end functions already check ranges. - (0 <= LAST_START && LAST_START <= LENGTH) */ - -static reg_errcode_t -__attribute_warn_unused_result__ -re_search_internal (const regex_t *preg, - const char *string, Idx length, - Idx start, Idx last_start, Idx stop, - size_t nmatch, regmatch_t pmatch[], - int eflags) -{ - reg_errcode_t err; - const re_dfa_t *dfa = preg->buffer; - Idx left_lim, right_lim; - int incr; - bool fl_longest_match; - int match_kind; - Idx match_first; - Idx match_last = REG_MISSING; - Idx extra_nmatch; - bool sb; - int ch; -#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) - re_match_context_t mctx = { .dfa = dfa }; -#else - re_match_context_t mctx; -#endif - char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate - && start != last_start && !preg->can_be_null) - ? preg->fastmap : NULL); - RE_TRANSLATE_TYPE t = preg->translate; - -#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) - memset (&mctx, '\0', sizeof (re_match_context_t)); - mctx.dfa = dfa; -#endif - - extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; - nmatch -= extra_nmatch; - - /* Check if the DFA haven't been compiled. */ - if (BE (preg->used == 0 || dfa->init_state == NULL - || dfa->init_state_word == NULL || dfa->init_state_nl == NULL - || dfa->init_state_begbuf == NULL, 0)) - return REG_NOMATCH; - -#ifdef DEBUG - /* We assume front-end functions already check them. */ - assert (0 <= last_start && last_start <= length); -#endif - - /* If initial states with non-begbuf contexts have no elements, - the regex must be anchored. If preg->newline_anchor is set, - we'll never use init_state_nl, so do not check it. */ - if (dfa->init_state->nodes.nelem == 0 - && dfa->init_state_word->nodes.nelem == 0 - && (dfa->init_state_nl->nodes.nelem == 0 - || !preg->newline_anchor)) - { - if (start != 0 && last_start != 0) - return REG_NOMATCH; - start = last_start = 0; - } - - /* We must check the longest matching, if nmatch > 0. */ - fl_longest_match = (nmatch != 0 || dfa->nbackref); - - err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, - preg->translate, (preg->syntax & RE_ICASE) != 0, - dfa); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - mctx.input.stop = stop; - mctx.input.raw_stop = stop; - mctx.input.newline_anchor = preg->newline_anchor; - - err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* We will log all the DFA states through which the dfa pass, - if nmatch > 1, or this dfa has "multibyte node", which is a - back-reference or a node which can accept multibyte character or - multi character collating element. */ - if (nmatch > 1 || dfa->has_mb_node) - { - /* Avoid overflow. */ - if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) - <= mctx.input.bufs_len), 0)) - { - err = REG_ESPACE; - goto free_return; - } - - mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); - if (BE (mctx.state_log == NULL, 0)) - { - err = REG_ESPACE; - goto free_return; - } - } - else - mctx.state_log = NULL; - - match_first = start; - mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF - : CONTEXT_NEWLINE | CONTEXT_BEGBUF; - - /* Check incrementally whether the input string matches. */ - incr = (last_start < start) ? -1 : 1; - left_lim = (last_start < start) ? last_start : start; - right_lim = (last_start < start) ? start : last_start; - sb = dfa->mb_cur_max == 1; - match_kind = - (fastmap - ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0) - | (start <= last_start ? 2 : 0) - | (t != NULL ? 1 : 0)) - : 8); - - for (;; match_first += incr) - { - err = REG_NOMATCH; - if (match_first < left_lim || right_lim < match_first) - goto free_return; - - /* Advance as rapidly as possible through the string, until we - find a plausible place to start matching. This may be done - with varying efficiency, so there are various possibilities: - only the most common of them are specialized, in order to - save on code size. We use a switch statement for speed. */ - switch (match_kind) - { - case 8: - /* No fastmap. */ - break; - - case 7: - /* Fastmap with single-byte translation, match forward. */ - while (BE (match_first < right_lim, 1) - && !fastmap[t[(unsigned char) string[match_first]]]) - ++match_first; - goto forward_match_found_start_or_reached_end; - - case 6: - /* Fastmap without translation, match forward. */ - while (BE (match_first < right_lim, 1) - && !fastmap[(unsigned char) string[match_first]]) - ++match_first; - - forward_match_found_start_or_reached_end: - if (BE (match_first == right_lim, 0)) - { - ch = match_first >= length - ? 0 : (unsigned char) string[match_first]; - if (!fastmap[t ? t[ch] : ch]) - goto free_return; - } - break; - - case 4: - case 5: - /* Fastmap without multi-byte translation, match backwards. */ - while (match_first >= left_lim) - { - ch = match_first >= length - ? 0 : (unsigned char) string[match_first]; - if (fastmap[t ? t[ch] : ch]) - break; - --match_first; - } - if (match_first < left_lim) - goto free_return; - break; - - default: - /* In this case, we can't determine easily the current byte, - since it might be a component byte of a multibyte - character. Then we use the constructed buffer instead. */ - for (;;) - { - /* If MATCH_FIRST is out of the valid range, reconstruct the - buffers. */ - __re_size_t offset = match_first - mctx.input.raw_mbs_idx; - if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0)) - { - err = re_string_reconstruct (&mctx.input, match_first, - eflags); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - offset = match_first - mctx.input.raw_mbs_idx; - } - /* If MATCH_FIRST is out of the buffer, leave it as '\0'. - Note that MATCH_FIRST must not be smaller than 0. */ - ch = (match_first >= length - ? 0 : re_string_byte_at (&mctx.input, offset)); - if (fastmap[ch]) - break; - match_first += incr; - if (match_first < left_lim || match_first > right_lim) - { - err = REG_NOMATCH; - goto free_return; - } - } - break; - } - - /* Reconstruct the buffers so that the matcher can assume that - the matching starts from the beginning of the buffer. */ - err = re_string_reconstruct (&mctx.input, match_first, eflags); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - -#ifdef RE_ENABLE_I18N - /* Don't consider this char as a possible match start if it part, - yet isn't the head, of a multibyte character. */ - if (!sb && !re_string_first_byte (&mctx.input, 0)) - continue; -#endif - - /* It seems to be appropriate one, then use the matcher. */ - /* We assume that the matching starts from 0. */ - mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; - match_last = check_matching (&mctx, fl_longest_match, - start <= last_start ? &match_first : NULL); - if (match_last != REG_MISSING) - { - if (BE (match_last == REG_ERROR, 0)) - { - err = REG_ESPACE; - goto free_return; - } - else - { - mctx.match_last = match_last; - if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) - { - re_dfastate_t *pstate = mctx.state_log[match_last]; - mctx.last_node = check_halt_state_context (&mctx, pstate, - match_last); - } - if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) - || dfa->nbackref) - { - err = prune_impossible_nodes (&mctx); - if (err == REG_NOERROR) - break; - if (BE (err != REG_NOMATCH, 0)) - goto free_return; - match_last = REG_MISSING; - } - else - break; /* We found a match. */ - } - } - - match_ctx_clean (&mctx); - } - -#ifdef DEBUG - assert (match_last != REG_MISSING); - assert (err == REG_NOERROR); -#endif - - /* Set pmatch[] if we need. */ - if (nmatch > 0) - { - Idx reg_idx; - - /* Initialize registers. */ - for (reg_idx = 1; reg_idx < nmatch; ++reg_idx) - pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1; - - /* Set the points where matching start/end. */ - pmatch[0].rm_so = 0; - pmatch[0].rm_eo = mctx.match_last; - /* FIXME: This function should fail if mctx.match_last exceeds - the maximum possible regoff_t value. We need a new error - code REG_OVERFLOW. */ - - if (!preg->no_sub && nmatch > 1) - { - err = set_regs (preg, &mctx, nmatch, pmatch, - dfa->has_plural_match && dfa->nbackref > 0); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - - /* At last, add the offset to each register, since we slid - the buffers so that we could assume that the matching starts - from 0. */ - for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) - if (pmatch[reg_idx].rm_so != -1) - { -#ifdef RE_ENABLE_I18N - if (BE (mctx.input.offsets_needed != 0, 0)) - { - pmatch[reg_idx].rm_so = - (pmatch[reg_idx].rm_so == mctx.input.valid_len - ? mctx.input.valid_raw_len - : mctx.input.offsets[pmatch[reg_idx].rm_so]); - pmatch[reg_idx].rm_eo = - (pmatch[reg_idx].rm_eo == mctx.input.valid_len - ? mctx.input.valid_raw_len - : mctx.input.offsets[pmatch[reg_idx].rm_eo]); - } -#else - assert (mctx.input.offsets_needed == 0); -#endif - pmatch[reg_idx].rm_so += match_first; - pmatch[reg_idx].rm_eo += match_first; - } - for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx) - { - pmatch[nmatch + reg_idx].rm_so = -1; - pmatch[nmatch + reg_idx].rm_eo = -1; - } - - if (dfa->subexp_map) - for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++) - if (dfa->subexp_map[reg_idx] != reg_idx) - { - pmatch[reg_idx + 1].rm_so - = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so; - pmatch[reg_idx + 1].rm_eo - = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo; - } - } - - free_return: - re_free (mctx.state_log); - if (dfa->nbackref) - match_ctx_free (&mctx); - re_string_destruct (&mctx.input); - return err; -} - -static reg_errcode_t -__attribute_warn_unused_result__ -prune_impossible_nodes (re_match_context_t *mctx) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx halt_node, match_last; - reg_errcode_t ret; - re_dfastate_t **sifted_states; - re_dfastate_t **lim_states = NULL; - re_sift_context_t sctx; -#ifdef DEBUG - assert (mctx->state_log != NULL); -#endif - match_last = mctx->match_last; - halt_node = mctx->last_node; - - /* Avoid overflow. */ - if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0)) - return REG_ESPACE; - - sifted_states = re_malloc (re_dfastate_t *, match_last + 1); - if (BE (sifted_states == NULL, 0)) - { - ret = REG_ESPACE; - goto free_return; - } - if (dfa->nbackref) - { - lim_states = re_malloc (re_dfastate_t *, match_last + 1); - if (BE (lim_states == NULL, 0)) - { - ret = REG_ESPACE; - goto free_return; - } - while (1) - { - memset (lim_states, '\0', - sizeof (re_dfastate_t *) * (match_last + 1)); - sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, - match_last); - ret = sift_states_backward (mctx, &sctx); - re_node_set_free (&sctx.limits); - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - if (sifted_states[0] != NULL || lim_states[0] != NULL) - break; - do - { - --match_last; - if (! REG_VALID_INDEX (match_last)) - { - ret = REG_NOMATCH; - goto free_return; - } - } while (mctx->state_log[match_last] == NULL - || !mctx->state_log[match_last]->halt); - halt_node = check_halt_state_context (mctx, - mctx->state_log[match_last], - match_last); - } - ret = merge_state_array (dfa, sifted_states, lim_states, - match_last + 1); - re_free (lim_states); - lim_states = NULL; - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - } - else - { - sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); - ret = sift_states_backward (mctx, &sctx); - re_node_set_free (&sctx.limits); - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - if (sifted_states[0] == NULL) - { - ret = REG_NOMATCH; - goto free_return; - } - } - re_free (mctx->state_log); - mctx->state_log = sifted_states; - sifted_states = NULL; - mctx->last_node = halt_node; - mctx->match_last = match_last; - ret = REG_NOERROR; - free_return: - re_free (sifted_states); - re_free (lim_states); - return ret; -} - -/* Acquire an initial state and return it. - We must select appropriate initial state depending on the context, - since initial states may have constraints like "\<", "^", etc.. */ - -static inline re_dfastate_t * -__attribute__ ((always_inline)) internal_function -acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, - Idx idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - if (dfa->init_state->has_constraint) - { - unsigned int context; - context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); - if (IS_WORD_CONTEXT (context)) - return dfa->init_state_word; - else if (IS_ORDINARY_CONTEXT (context)) - return dfa->init_state; - else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) - return dfa->init_state_begbuf; - else if (IS_NEWLINE_CONTEXT (context)) - return dfa->init_state_nl; - else if (IS_BEGBUF_CONTEXT (context)) - { - /* It is relatively rare case, then calculate on demand. */ - return re_acquire_state_context (err, dfa, - dfa->init_state->entrance_nodes, - context); - } - else - /* Must not happen? */ - return dfa->init_state; - } - else - return dfa->init_state; -} - -/* Check whether the regular expression match input string INPUT or not, - and return the index where the matching end. Return REG_MISSING if - there is no match, and return REG_ERROR in case of an error. - FL_LONGEST_MATCH means we want the POSIX longest matching. - If P_MATCH_FIRST is not NULL, and the match fails, it is set to the - next place where we may want to try matching. - Note that the matcher assumes that the matching starts from the current - index of the buffer. */ - -static Idx -internal_function __attribute_warn_unused_result__ -check_matching (re_match_context_t *mctx, bool fl_longest_match, - Idx *p_match_first) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - Idx match = 0; - Idx match_last = REG_MISSING; - Idx cur_str_idx = re_string_cur_idx (&mctx->input); - re_dfastate_t *cur_state; - bool at_init_state = p_match_first != NULL; - Idx next_start_idx = cur_str_idx; - - err = REG_NOERROR; - cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); - /* An initial state must not be NULL (invalid). */ - if (BE (cur_state == NULL, 0)) - { - assert (err == REG_ESPACE); - return REG_ERROR; - } - - if (mctx->state_log != NULL) - { - mctx->state_log[cur_str_idx] = cur_state; - - /* Check OP_OPEN_SUBEXP in the initial state in case that we use them - later. E.g. Processing back references. */ - if (BE (dfa->nbackref, 0)) - { - at_init_state = false; - err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (cur_state->has_backref) - { - err = transit_state_bkref (mctx, &cur_state->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - } - - /* If the RE accepts NULL string. */ - if (BE (cur_state->halt, 0)) - { - if (!cur_state->has_constraint - || check_halt_state_context (mctx, cur_state, cur_str_idx)) - { - if (!fl_longest_match) - return cur_str_idx; - else - { - match_last = cur_str_idx; - match = 1; - } - } - } - - while (!re_string_eoi (&mctx->input)) - { - re_dfastate_t *old_state = cur_state; - Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; - - if ((BE (next_char_idx >= mctx->input.bufs_len, 0) - && mctx->input.bufs_len < mctx->input.len) - || (BE (next_char_idx >= mctx->input.valid_len, 0) - && mctx->input.valid_len < mctx->input.len)) - { - err = extend_buffers (mctx, next_char_idx + 1); - if (BE (err != REG_NOERROR, 0)) - { - assert (err == REG_ESPACE); - return REG_ERROR; - } - } - - cur_state = transit_state (&err, mctx, cur_state); - if (mctx->state_log != NULL) - cur_state = merge_state_with_log (&err, mctx, cur_state); - - if (cur_state == NULL) - { - /* Reached the invalid state or an error. Try to recover a valid - state using the state log, if available and if we have not - already found a valid (even if not the longest) match. */ - if (BE (err != REG_NOERROR, 0)) - return REG_ERROR; - - if (mctx->state_log == NULL - || (match && !fl_longest_match) - || (cur_state = find_recover_state (&err, mctx)) == NULL) - break; - } - - if (BE (at_init_state, 0)) - { - if (old_state == cur_state) - next_start_idx = next_char_idx; - else - at_init_state = false; - } - - if (cur_state->halt) - { - /* Reached a halt state. - Check the halt state can satisfy the current context. */ - if (!cur_state->has_constraint - || check_halt_state_context (mctx, cur_state, - re_string_cur_idx (&mctx->input))) - { - /* We found an appropriate halt state. */ - match_last = re_string_cur_idx (&mctx->input); - match = 1; - - /* We found a match, do not modify match_first below. */ - p_match_first = NULL; - if (!fl_longest_match) - break; - } - } - } - - if (p_match_first) - *p_match_first += next_start_idx; - - return match_last; -} - -/* Check NODE match the current context. */ - -static bool -internal_function -check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context) -{ - re_token_type_t type = dfa->nodes[node].type; - unsigned int constraint = dfa->nodes[node].constraint; - if (type != END_OF_RE) - return false; - if (!constraint) - return true; - if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context)) - return false; - return true; -} - -/* Check the halt state STATE match the current context. - Return 0 if not match, if the node, STATE has, is a halt node and - match the context, return the node. */ - -static Idx -internal_function -check_halt_state_context (const re_match_context_t *mctx, - const re_dfastate_t *state, Idx idx) -{ - Idx i; - unsigned int context; -#ifdef DEBUG - assert (state->halt); -#endif - context = re_string_context_at (&mctx->input, idx, mctx->eflags); - for (i = 0; i < state->nodes.nelem; ++i) - if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) - return state->nodes.elems[i]; - return 0; -} - -/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA - corresponding to the DFA). - Return the destination node, and update EPS_VIA_NODES; - return REG_MISSING in case of errors. */ - -static Idx -internal_function -proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, - Idx *pidx, Idx node, re_node_set *eps_via_nodes, - struct re_fail_stack_t *fs) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx i; - bool ok; - if (IS_EPSILON_NODE (dfa->nodes[node].type)) - { - re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; - re_node_set *edests = &dfa->edests[node]; - Idx dest_node; - ok = re_node_set_insert (eps_via_nodes, node); - if (BE (! ok, 0)) - return REG_ERROR; - /* Pick up a valid destination, or return REG_MISSING if none - is found. */ - for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i) - { - Idx candidate = edests->elems[i]; - if (!re_node_set_contains (cur_nodes, candidate)) - continue; - if (dest_node == REG_MISSING) - dest_node = candidate; - - else - { - /* In order to avoid infinite loop like "(a*)*", return the second - epsilon-transition if the first was already considered. */ - if (re_node_set_contains (eps_via_nodes, dest_node)) - return candidate; - - /* Otherwise, push the second epsilon-transition on the fail stack. */ - else if (fs != NULL - && push_fail_stack (fs, *pidx, candidate, nregs, regs, - eps_via_nodes)) - return REG_ERROR; - - /* We know we are going to exit. */ - break; - } - } - return dest_node; - } - else - { - Idx naccepted = 0; - re_token_type_t type = dfa->nodes[node].type; - -#ifdef RE_ENABLE_I18N - if (dfa->nodes[node].accept_mb) - naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); - else -#endif /* RE_ENABLE_I18N */ - if (type == OP_BACK_REF) - { - Idx subexp_idx = dfa->nodes[node].opr.idx + 1; - naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; - if (fs != NULL) - { - if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) - return REG_MISSING; - else if (naccepted) - { - char *buf = (char *) re_string_get_buffer (&mctx->input); - if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, - naccepted) != 0) - return REG_MISSING; - } - } - - if (naccepted == 0) - { - Idx dest_node; - ok = re_node_set_insert (eps_via_nodes, node); - if (BE (! ok, 0)) - return REG_ERROR; - dest_node = dfa->edests[node].elems[0]; - if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, - dest_node)) - return dest_node; - } - } - - if (naccepted != 0 - || check_node_accept (mctx, dfa->nodes + node, *pidx)) - { - Idx dest_node = dfa->nexts[node]; - *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; - if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL - || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, - dest_node))) - return REG_MISSING; - re_node_set_empty (eps_via_nodes); - return dest_node; - } - } - return REG_MISSING; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, - Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) -{ - reg_errcode_t err; - Idx num = fs->num++; - if (fs->num == fs->alloc) - { - struct re_fail_stack_ent_t *new_array; - new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) - * fs->alloc * 2)); - if (new_array == NULL) - return REG_ESPACE; - fs->alloc *= 2; - fs->stack = new_array; - } - fs->stack[num].idx = str_idx; - fs->stack[num].node = dest_node; - fs->stack[num].regs = re_malloc (regmatch_t, nregs); - if (fs->stack[num].regs == NULL) - return REG_ESPACE; - memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); - err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); - return err; -} - -static Idx -internal_function -pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs, - regmatch_t *regs, re_node_set *eps_via_nodes) -{ - Idx num = --fs->num; - assert (REG_VALID_INDEX (num)); - *pidx = fs->stack[num].idx; - memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); - re_node_set_free (eps_via_nodes); - re_free (fs->stack[num].regs); - *eps_via_nodes = fs->stack[num].eps_via_nodes; - return fs->stack[num].node; -} - -/* Set the positions where the subexpressions are starts/ends to registers - PMATCH. - Note: We assume that pmatch[0] is already set, and - pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, - regmatch_t *pmatch, bool fl_backtrack) -{ - const re_dfa_t *dfa = preg->buffer; - Idx idx, cur_node; - re_node_set eps_via_nodes; - struct re_fail_stack_t *fs; - struct re_fail_stack_t fs_body = { 0, 2, NULL }; - regmatch_t *prev_idx_match; - bool prev_idx_match_malloced = false; - -#ifdef DEBUG - assert (nmatch > 1); - assert (mctx->state_log != NULL); -#endif - if (fl_backtrack) - { - fs = &fs_body; - fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc); - if (fs->stack == NULL) - return REG_ESPACE; - } - else - fs = NULL; - - cur_node = dfa->init_node; - re_node_set_init_empty (&eps_via_nodes); - - if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) - prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t)); - else - { - prev_idx_match = re_malloc (regmatch_t, nmatch); - if (prev_idx_match == NULL) - { - free_fail_stack_return (fs); - return REG_ESPACE; - } - prev_idx_match_malloced = true; - } - memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); - - for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) - { - update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); - - if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) - { - Idx reg_idx; - if (fs) - { - for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) - if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) - break; - if (reg_idx == nmatch) - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return free_fail_stack_return (fs); - } - cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, - &eps_via_nodes); - } - else - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return REG_NOERROR; - } - } - - /* Proceed to next node. */ - cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, - &eps_via_nodes, fs); - - if (BE (! REG_VALID_INDEX (cur_node), 0)) - { - if (BE (cur_node == REG_ERROR, 0)) - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - free_fail_stack_return (fs); - return REG_ESPACE; - } - if (fs) - cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, - &eps_via_nodes); - else - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return REG_NOMATCH; - } - } - } - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return free_fail_stack_return (fs); -} - -static reg_errcode_t -internal_function -free_fail_stack_return (struct re_fail_stack_t *fs) -{ - if (fs) - { - Idx fs_idx; - for (fs_idx = 0; fs_idx < fs->num; ++fs_idx) - { - re_node_set_free (&fs->stack[fs_idx].eps_via_nodes); - re_free (fs->stack[fs_idx].regs); - } - re_free (fs->stack); - } - return REG_NOERROR; -} - -static void -internal_function -update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, - regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) -{ - int type = dfa->nodes[cur_node].type; - if (type == OP_OPEN_SUBEXP) - { - Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; - - /* We are at the first node of this sub expression. */ - if (reg_num < nmatch) - { - pmatch[reg_num].rm_so = cur_idx; - pmatch[reg_num].rm_eo = -1; - } - } - else if (type == OP_CLOSE_SUBEXP) - { - Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; - if (reg_num < nmatch) - { - /* We are at the last node of this sub expression. */ - if (pmatch[reg_num].rm_so < cur_idx) - { - pmatch[reg_num].rm_eo = cur_idx; - /* This is a non-empty match or we are not inside an optional - subexpression. Accept this right away. */ - memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); - } - else - { - if (dfa->nodes[cur_node].opt_subexp - && prev_idx_match[reg_num].rm_so != -1) - /* We transited through an empty match for an optional - subexpression, like (a?)*, and this is not the subexp's - first match. Copy back the old content of the registers - so that matches of an inner subexpression are undone as - well, like in ((a?))*. */ - memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch); - else - /* We completed a subexpression, but it may be part of - an optional one, so do not update PREV_IDX_MATCH. */ - pmatch[reg_num].rm_eo = cur_idx; - } - } - } -} - -/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0 - and sift the nodes in each states according to the following rules. - Updated state_log will be wrote to STATE_LOG. - - Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if... - 1. When STR_IDX == MATCH_LAST(the last index in the state_log): - If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to - the LAST_NODE, we throw away the node 'a'. - 2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts - string 's' and transit to 'b': - i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw - away the node 'a'. - ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is - thrown away, we throw away the node 'a'. - 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': - i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the - node 'a'. - ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, - we throw away the node 'a'. */ - -#define STATE_NODE_CONTAINS(state,node) \ - ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) - -static reg_errcode_t -internal_function -sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) -{ - reg_errcode_t err; - int null_cnt = 0; - Idx str_idx = sctx->last_str_idx; - re_node_set cur_dest; - -#ifdef DEBUG - assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL); -#endif - - /* Build sifted state_log[str_idx]. It has the nodes which can epsilon - transit to the last_node and the last_node itself. */ - err = re_node_set_init_1 (&cur_dest, sctx->last_node); - if (BE (err != REG_NOERROR, 0)) - return err; - err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* Then check each states in the state_log. */ - while (str_idx > 0) - { - /* Update counters. */ - null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0; - if (null_cnt > mctx->max_mb_elem_len) - { - memset (sctx->sifted_states, '\0', - sizeof (re_dfastate_t *) * str_idx); - re_node_set_free (&cur_dest); - return REG_NOERROR; - } - re_node_set_empty (&cur_dest); - --str_idx; - - if (mctx->state_log[str_idx]) - { - err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - - /* Add all the nodes which satisfy the following conditions: - - It can epsilon transit to a node in CUR_DEST. - - It is in CUR_SRC. - And update state_log. */ - err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - err = REG_NOERROR; - free_return: - re_node_set_free (&cur_dest); - return err; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, - Idx str_idx, re_node_set *cur_dest) -{ - const re_dfa_t *const dfa = mctx->dfa; - const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; - Idx i; - - /* Then build the next sifted state. - We build the next sifted state on 'cur_dest', and update - 'sifted_states[str_idx]' with 'cur_dest'. - Note: - 'cur_dest' is the sifted state from 'state_log[str_idx + 1]'. - 'cur_src' points the node_set of the old 'state_log[str_idx]' - (with the epsilon nodes pre-filtered out). */ - for (i = 0; i < cur_src->nelem; i++) - { - Idx prev_node = cur_src->elems[i]; - int naccepted = 0; - bool ok; - -#ifdef DEBUG - re_token_type_t type = dfa->nodes[prev_node].type; - assert (!IS_EPSILON_NODE (type)); -#endif -#ifdef RE_ENABLE_I18N - /* If the node may accept "multi byte". */ - if (dfa->nodes[prev_node].accept_mb) - naccepted = sift_states_iter_mb (mctx, sctx, prev_node, - str_idx, sctx->last_str_idx); -#endif /* RE_ENABLE_I18N */ - - /* We don't check backreferences here. - See update_cur_sifted_state(). */ - if (!naccepted - && check_node_accept (mctx, dfa->nodes + prev_node, str_idx) - && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], - dfa->nexts[prev_node])) - naccepted = 1; - - if (naccepted == 0) - continue; - - if (sctx->limits.nelem) - { - Idx to_idx = str_idx + naccepted; - if (check_dst_limits (mctx, &sctx->limits, - dfa->nexts[prev_node], to_idx, - prev_node, str_idx)) - continue; - } - ok = re_node_set_insert (cur_dest, prev_node); - if (BE (! ok, 0)) - return REG_ESPACE; - } - - return REG_NOERROR; -} - -/* Helper functions. */ - -static reg_errcode_t -internal_function -clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx) -{ - Idx top = mctx->state_log_top; - - if ((next_state_log_idx >= mctx->input.bufs_len - && mctx->input.bufs_len < mctx->input.len) - || (next_state_log_idx >= mctx->input.valid_len - && mctx->input.valid_len < mctx->input.len)) - { - reg_errcode_t err; - err = extend_buffers (mctx, next_state_log_idx + 1); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (top < next_state_log_idx) - { - memset (mctx->state_log + top + 1, '\0', - sizeof (re_dfastate_t *) * (next_state_log_idx - top)); - mctx->state_log_top = next_state_log_idx; - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, - re_dfastate_t **src, Idx num) -{ - Idx st_idx; - reg_errcode_t err; - for (st_idx = 0; st_idx < num; ++st_idx) - { - if (dst[st_idx] == NULL) - dst[st_idx] = src[st_idx]; - else if (src[st_idx] != NULL) - { - re_node_set merged_set; - err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, - &src[st_idx]->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); - re_node_set_free (&merged_set); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -update_cur_sifted_state (const re_match_context_t *mctx, - re_sift_context_t *sctx, Idx str_idx, - re_node_set *dest_nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err = REG_NOERROR; - const re_node_set *candidates; - candidates = ((mctx->state_log[str_idx] == NULL) ? NULL - : &mctx->state_log[str_idx]->nodes); - - if (dest_nodes->nelem == 0) - sctx->sifted_states[str_idx] = NULL; - else - { - if (candidates) - { - /* At first, add the nodes which can epsilon transit to a node in - DEST_NODE. */ - err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* Then, check the limitations in the current sift_context. */ - if (sctx->limits.nelem) - { - err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, - mctx->bkref_ents, str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - - sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (candidates && mctx->state_log[str_idx]->has_backref) - { - err = sift_states_bkref (mctx, sctx, str_idx, candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, - const re_node_set *candidates) -{ - reg_errcode_t err = REG_NOERROR; - Idx i; - - re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (!state->inveclosure.alloc) - { - err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); - if (BE (err != REG_NOERROR, 0)) - return REG_ESPACE; - for (i = 0; i < dest_nodes->nelem; i++) - { - err = re_node_set_merge (&state->inveclosure, - dfa->inveclosures + dest_nodes->elems[i]); - if (BE (err != REG_NOERROR, 0)) - return REG_ESPACE; - } - } - return re_node_set_add_intersect (dest_nodes, candidates, - &state->inveclosure); -} - -static reg_errcode_t -internal_function -sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes, - const re_node_set *candidates) -{ - Idx ecl_idx; - reg_errcode_t err; - re_node_set *inv_eclosure = dfa->inveclosures + node; - re_node_set except_nodes; - re_node_set_init_empty (&except_nodes); - for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) - { - Idx cur_node = inv_eclosure->elems[ecl_idx]; - if (cur_node == node) - continue; - if (IS_EPSILON_NODE (dfa->nodes[cur_node].type)) - { - Idx edst1 = dfa->edests[cur_node].elems[0]; - Idx edst2 = ((dfa->edests[cur_node].nelem > 1) - ? dfa->edests[cur_node].elems[1] : REG_MISSING); - if ((!re_node_set_contains (inv_eclosure, edst1) - && re_node_set_contains (dest_nodes, edst1)) - || (REG_VALID_NONZERO_INDEX (edst2) - && !re_node_set_contains (inv_eclosure, edst2) - && re_node_set_contains (dest_nodes, edst2))) - { - err = re_node_set_add_intersect (&except_nodes, candidates, - dfa->inveclosures + cur_node); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&except_nodes); - return err; - } - } - } - } - for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) - { - Idx cur_node = inv_eclosure->elems[ecl_idx]; - if (!re_node_set_contains (&except_nodes, cur_node)) - { - Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1; - re_node_set_remove_at (dest_nodes, idx); - } - } - re_node_set_free (&except_nodes); - return REG_NOERROR; -} - -static bool -internal_function -check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, - Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx lim_idx, src_pos, dst_pos; - - Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); - Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx); - for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) - { - Idx subexp_idx; - struct re_backref_cache_entry *ent; - ent = mctx->bkref_ents + limits->elems[lim_idx]; - subexp_idx = dfa->nodes[ent->node].opr.idx; - - dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], - subexp_idx, dst_node, dst_idx, - dst_bkref_idx); - src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], - subexp_idx, src_node, src_idx, - src_bkref_idx); - - /* In case of: - ( ) - ( ) - ( ) */ - if (src_pos == dst_pos) - continue; /* This is unrelated limitation. */ - else - return true; - } - return false; -} - -static int -internal_function -check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, - Idx subexp_idx, Idx from_node, Idx bkref_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - const re_node_set *eclosures = dfa->eclosures + from_node; - Idx node_idx; - - /* Else, we are on the boundary: examine the nodes on the epsilon - closure. */ - for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx) - { - Idx node = eclosures->elems[node_idx]; - switch (dfa->nodes[node].type) - { - case OP_BACK_REF: - if (bkref_idx != REG_MISSING) - { - struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; - do - { - Idx dst; - int cpos; - - if (ent->node != node) - continue; - - if (subexp_idx < BITSET_WORD_BITS - && !(ent->eps_reachable_subexps_map - & ((bitset_word_t) 1 << subexp_idx))) - continue; - - /* Recurse trying to reach the OP_OPEN_SUBEXP and - OP_CLOSE_SUBEXP cases below. But, if the - destination node is the same node as the source - node, don't recurse because it would cause an - infinite loop: a regex that exhibits this behavior - is ()\1*\1* */ - dst = dfa->edests[node].elems[0]; - if (dst == from_node) - { - if (boundaries & 1) - return -1; - else /* if (boundaries & 2) */ - return 0; - } - - cpos = - check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, - dst, bkref_idx); - if (cpos == -1 /* && (boundaries & 1) */) - return -1; - if (cpos == 0 && (boundaries & 2)) - return 0; - - if (subexp_idx < BITSET_WORD_BITS) - ent->eps_reachable_subexps_map - &= ~((bitset_word_t) 1 << subexp_idx); - } - while (ent++->more); - } - break; - - case OP_OPEN_SUBEXP: - if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx) - return -1; - break; - - case OP_CLOSE_SUBEXP: - if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx) - return 0; - break; - - default: - break; - } - } - - return (boundaries & 2) ? 1 : 0; -} - -static int -internal_function -check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, - Idx subexp_idx, Idx from_node, Idx str_idx, - Idx bkref_idx) -{ - struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; - int boundaries; - - /* If we are outside the range of the subexpression, return -1 or 1. */ - if (str_idx < lim->subexp_from) - return -1; - - if (lim->subexp_to < str_idx) - return 1; - - /* If we are within the subexpression, return 0. */ - boundaries = (str_idx == lim->subexp_from); - boundaries |= (str_idx == lim->subexp_to) << 1; - if (boundaries == 0) - return 0; - - /* Else, examine epsilon closure. */ - return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, - from_node, bkref_idx); -} - -/* Check the limitations of sub expressions LIMITS, and remove the nodes - which are against limitations from DEST_NODES. */ - -static reg_errcode_t -internal_function -check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, - const re_node_set *candidates, re_node_set *limits, - struct re_backref_cache_entry *bkref_ents, Idx str_idx) -{ - reg_errcode_t err; - Idx node_idx, lim_idx; - - for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) - { - Idx subexp_idx; - struct re_backref_cache_entry *ent; - ent = bkref_ents + limits->elems[lim_idx]; - - if (str_idx <= ent->subexp_from || ent->str_idx < str_idx) - continue; /* This is unrelated limitation. */ - - subexp_idx = dfa->nodes[ent->node].opr.idx; - if (ent->subexp_to == str_idx) - { - Idx ops_node = REG_MISSING; - Idx cls_node = REG_MISSING; - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - Idx node = dest_nodes->elems[node_idx]; - re_token_type_t type = dfa->nodes[node].type; - if (type == OP_OPEN_SUBEXP - && subexp_idx == dfa->nodes[node].opr.idx) - ops_node = node; - else if (type == OP_CLOSE_SUBEXP - && subexp_idx == dfa->nodes[node].opr.idx) - cls_node = node; - } - - /* Check the limitation of the open subexpression. */ - /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ - if (REG_VALID_INDEX (ops_node)) - { - err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - /* Check the limitation of the close subexpression. */ - if (REG_VALID_INDEX (cls_node)) - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - Idx node = dest_nodes->elems[node_idx]; - if (!re_node_set_contains (dfa->inveclosures + node, - cls_node) - && !re_node_set_contains (dfa->eclosures + node, - cls_node)) - { - /* It is against this limitation. - Remove it form the current sifted state. */ - err = sub_epsilon_src_nodes (dfa, node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - --node_idx; - } - } - } - else /* (ent->subexp_to != str_idx) */ - { - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - Idx node = dest_nodes->elems[node_idx]; - re_token_type_t type = dfa->nodes[node].type; - if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP) - { - if (subexp_idx != dfa->nodes[node].opr.idx) - continue; - /* It is against this limitation. - Remove it form the current sifted state. */ - err = sub_epsilon_src_nodes (dfa, node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, - Idx str_idx, const re_node_set *candidates) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - Idx node_idx, node; - re_sift_context_t local_sctx; - Idx first_idx = search_cur_bkref_entry (mctx, str_idx); - - if (first_idx == REG_MISSING) - return REG_NOERROR; - - local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ - - for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) - { - Idx enabled_idx; - re_token_type_t type; - struct re_backref_cache_entry *entry; - node = candidates->elems[node_idx]; - type = dfa->nodes[node].type; - /* Avoid infinite loop for the REs like "()\1+". */ - if (node == sctx->last_node && str_idx == sctx->last_str_idx) - continue; - if (type != OP_BACK_REF) - continue; - - entry = mctx->bkref_ents + first_idx; - enabled_idx = first_idx; - do - { - Idx subexp_len; - Idx to_idx; - Idx dst_node; - bool ok; - re_dfastate_t *cur_state; - - if (entry->node != node) - continue; - subexp_len = entry->subexp_to - entry->subexp_from; - to_idx = str_idx + subexp_len; - dst_node = (subexp_len ? dfa->nexts[node] - : dfa->edests[node].elems[0]); - - if (to_idx > sctx->last_str_idx - || sctx->sifted_states[to_idx] == NULL - || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node) - || check_dst_limits (mctx, &sctx->limits, node, - str_idx, dst_node, to_idx)) - continue; - - if (local_sctx.sifted_states == NULL) - { - local_sctx = *sctx; - err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - local_sctx.last_node = node; - local_sctx.last_str_idx = str_idx; - ok = re_node_set_insert (&local_sctx.limits, enabled_idx); - if (BE (! ok, 0)) - { - err = REG_ESPACE; - goto free_return; - } - cur_state = local_sctx.sifted_states[str_idx]; - err = sift_states_backward (mctx, &local_sctx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - if (sctx->limited_states != NULL) - { - err = merge_state_array (dfa, sctx->limited_states, - local_sctx.sifted_states, - str_idx + 1); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - local_sctx.sifted_states[str_idx] = cur_state; - re_node_set_remove (&local_sctx.limits, enabled_idx); - - /* mctx->bkref_ents may have changed, reload the pointer. */ - entry = mctx->bkref_ents + enabled_idx; - } - while (enabled_idx++, entry++->more); - } - err = REG_NOERROR; - free_return: - if (local_sctx.sifted_states != NULL) - { - re_node_set_free (&local_sctx.limits); - } - - return err; -} - - -#ifdef RE_ENABLE_I18N -static int -internal_function -sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, - Idx node_idx, Idx str_idx, Idx max_str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - int naccepted; - /* Check the node can accept "multi byte". */ - naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); - if (naccepted > 0 && str_idx + naccepted <= max_str_idx && - !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], - dfa->nexts[node_idx])) - /* The node can't accept the "multi byte", or the - destination was already thrown away, then the node - could't accept the current input "multi byte". */ - naccepted = 0; - /* Otherwise, it is sure that the node could accept - 'naccepted' bytes input. */ - return naccepted; -} -#endif /* RE_ENABLE_I18N */ - - -/* Functions for state transition. */ - -/* Return the next state to which the current state STATE will transit by - accepting the current input byte, and update STATE_LOG if necessary. - If STATE can accept a multibyte char/collating element/back reference - update the destination of STATE_LOG. */ - -static re_dfastate_t * -internal_function __attribute_warn_unused_result__ -transit_state (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *state) -{ - re_dfastate_t **trtable; - unsigned char ch; - -#ifdef RE_ENABLE_I18N - /* If the current state can accept multibyte. */ - if (BE (state->accept_mb, 0)) - { - *err = transit_state_mb (mctx, state); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } -#endif /* RE_ENABLE_I18N */ - - /* Then decide the next state with the single byte. */ -#if 0 - if (0) - /* don't use transition table */ - return transit_state_sb (err, mctx, state); -#endif - - /* Use transition table */ - ch = re_string_fetch_byte (&mctx->input); - for (;;) - { - trtable = state->trtable; - if (BE (trtable != NULL, 1)) - return trtable[ch]; - - trtable = state->word_trtable; - if (BE (trtable != NULL, 1)) - { - unsigned int context; - context - = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input) - 1, - mctx->eflags); - if (IS_WORD_CONTEXT (context)) - return trtable[ch + SBC_MAX]; - else - return trtable[ch]; - } - - if (!build_trtable (mctx->dfa, state)) - { - *err = REG_ESPACE; - return NULL; - } - - /* Retry, we now have a transition table. */ - } -} - -/* Update the state_log if we need */ -static re_dfastate_t * -internal_function -merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *next_state) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx cur_idx = re_string_cur_idx (&mctx->input); - - if (cur_idx > mctx->state_log_top) - { - mctx->state_log[cur_idx] = next_state; - mctx->state_log_top = cur_idx; - } - else if (mctx->state_log[cur_idx] == 0) - { - mctx->state_log[cur_idx] = next_state; - } - else - { - re_dfastate_t *pstate; - unsigned int context; - re_node_set next_nodes, *log_nodes, *table_nodes = NULL; - /* If (state_log[cur_idx] != 0), it implies that cur_idx is - the destination of a multibyte char/collating element/ - back reference. Then the next state is the union set of - these destinations and the results of the transition table. */ - pstate = mctx->state_log[cur_idx]; - log_nodes = pstate->entrance_nodes; - if (next_state != NULL) - { - table_nodes = next_state->entrance_nodes; - *err = re_node_set_init_union (&next_nodes, table_nodes, - log_nodes); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } - else - next_nodes = *log_nodes; - /* Note: We already add the nodes of the initial state, - then we don't need to add them here. */ - - context = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input) - 1, - mctx->eflags); - next_state = mctx->state_log[cur_idx] - = re_acquire_state_context (err, dfa, &next_nodes, context); - /* We don't need to check errors here, since the return value of - this function is next_state and ERR is already set. */ - - if (table_nodes != NULL) - re_node_set_free (&next_nodes); - } - - if (BE (dfa->nbackref, 0) && next_state != NULL) - { - /* Check OP_OPEN_SUBEXP in the current state in case that we use them - later. We must check them here, since the back references in the - next state might use them. */ - *err = check_subexp_matching_top (mctx, &next_state->nodes, - cur_idx); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - - /* If the next state has back references. */ - if (next_state->has_backref) - { - *err = transit_state_bkref (mctx, &next_state->nodes); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - next_state = mctx->state_log[cur_idx]; - } - } - - return next_state; -} - -/* Skip bytes in the input that correspond to part of a - multi-byte match, then look in the log for a state - from which to restart matching. */ -static re_dfastate_t * -internal_function -find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) -{ - re_dfastate_t *cur_state; - do - { - Idx max = mctx->state_log_top; - Idx cur_str_idx = re_string_cur_idx (&mctx->input); - - do - { - if (++cur_str_idx > max) - return NULL; - re_string_skip_bytes (&mctx->input, 1); - } - while (mctx->state_log[cur_str_idx] == NULL); - - cur_state = merge_state_with_log (err, mctx, NULL); - } - while (*err == REG_NOERROR && cur_state == NULL); - return cur_state; -} - -/* Helper functions for transit_state. */ - -/* From the node set CUR_NODES, pick up the nodes whose types are - OP_OPEN_SUBEXP and which have corresponding back references in the regular - expression. And register them to use them later for evaluating the - corresponding back references. */ - -static reg_errcode_t -internal_function -check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, - Idx str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx node_idx; - reg_errcode_t err; - - /* TODO: This isn't efficient. - Because there might be more than one nodes whose types are - OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all - nodes. - E.g. RE: (a){2} */ - for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx) - { - Idx node = cur_nodes->elems[node_idx]; - if (dfa->nodes[node].type == OP_OPEN_SUBEXP - && dfa->nodes[node].opr.idx < BITSET_WORD_BITS - && (dfa->used_bkref_map - & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) - { - err = match_ctx_add_subtop (mctx, node, str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - return REG_NOERROR; -} - -#if 0 -/* Return the next state to which the current state STATE will transit by - accepting the current input byte. */ - -static re_dfastate_t * -transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *state) -{ - const re_dfa_t *const dfa = mctx->dfa; - re_node_set next_nodes; - re_dfastate_t *next_state; - Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); - unsigned int context; - - *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) - { - Idx cur_node = state->nodes.elems[node_cnt]; - if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx)) - { - *err = re_node_set_merge (&next_nodes, - dfa->eclosures + dfa->nexts[cur_node]); - if (BE (*err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return NULL; - } - } - } - context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); - next_state = re_acquire_state_context (err, dfa, &next_nodes, context); - /* We don't need to check errors here, since the return value of - this function is next_state and ERR is already set. */ - - re_node_set_free (&next_nodes); - re_string_skip_bytes (&mctx->input, 1); - return next_state; -} -#endif - -#ifdef RE_ENABLE_I18N -static reg_errcode_t -internal_function -transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - Idx i; - - for (i = 0; i < pstate->nodes.nelem; ++i) - { - re_node_set dest_nodes, *new_nodes; - Idx cur_node_idx = pstate->nodes.elems[i]; - int naccepted; - Idx dest_idx; - unsigned int context; - re_dfastate_t *dest_state; - - if (!dfa->nodes[cur_node_idx].accept_mb) - continue; - - if (dfa->nodes[cur_node_idx].constraint) - { - context = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input), - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, - context)) - continue; - } - - /* How many bytes the node can accept? */ - naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, - re_string_cur_idx (&mctx->input)); - if (naccepted == 0) - continue; - - /* The node can accepts 'naccepted' bytes. */ - dest_idx = re_string_cur_idx (&mctx->input) + naccepted; - mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted - : mctx->max_mb_elem_len); - err = clean_state_log_if_needed (mctx, dest_idx); - if (BE (err != REG_NOERROR, 0)) - return err; -#ifdef DEBUG - assert (dfa->nexts[cur_node_idx] != REG_MISSING); -#endif - new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; - - dest_state = mctx->state_log[dest_idx]; - if (dest_state == NULL) - dest_nodes = *new_nodes; - else - { - err = re_node_set_init_union (&dest_nodes, - dest_state->entrance_nodes, new_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - context = re_string_context_at (&mctx->input, dest_idx - 1, - mctx->eflags); - mctx->state_log[dest_idx] - = re_acquire_state_context (&err, dfa, &dest_nodes, context); - if (dest_state != NULL) - re_node_set_free (&dest_nodes); - if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) - return err; - } - return REG_NOERROR; -} -#endif /* RE_ENABLE_I18N */ - -static reg_errcode_t -internal_function -transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - Idx i; - Idx cur_str_idx = re_string_cur_idx (&mctx->input); - - for (i = 0; i < nodes->nelem; ++i) - { - Idx dest_str_idx, prev_nelem, bkc_idx; - Idx node_idx = nodes->elems[i]; - unsigned int context; - const re_token_t *node = dfa->nodes + node_idx; - re_node_set *new_dest_nodes; - - /* Check whether 'node' is a backreference or not. */ - if (node->type != OP_BACK_REF) - continue; - - if (node->constraint) - { - context = re_string_context_at (&mctx->input, cur_str_idx, - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) - continue; - } - - /* 'node' is a backreference. - Check the substring which the substring matched. */ - bkc_idx = mctx->nbkref_ents; - err = get_subexp (mctx, node_idx, cur_str_idx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* And add the epsilon closures (which is 'new_dest_nodes') of - the backreference to appropriate state_log. */ -#ifdef DEBUG - assert (dfa->nexts[node_idx] != REG_MISSING); -#endif - for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) - { - Idx subexp_len; - re_dfastate_t *dest_state; - struct re_backref_cache_entry *bkref_ent; - bkref_ent = mctx->bkref_ents + bkc_idx; - if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx) - continue; - subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from; - new_dest_nodes = (subexp_len == 0 - ? dfa->eclosures + dfa->edests[node_idx].elems[0] - : dfa->eclosures + dfa->nexts[node_idx]); - dest_str_idx = (cur_str_idx + bkref_ent->subexp_to - - bkref_ent->subexp_from); - context = re_string_context_at (&mctx->input, dest_str_idx - 1, - mctx->eflags); - dest_state = mctx->state_log[dest_str_idx]; - prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 - : mctx->state_log[cur_str_idx]->nodes.nelem); - /* Add 'new_dest_node' to state_log. */ - if (dest_state == NULL) - { - mctx->state_log[dest_str_idx] - = re_acquire_state_context (&err, dfa, new_dest_nodes, - context); - if (BE (mctx->state_log[dest_str_idx] == NULL - && err != REG_NOERROR, 0)) - goto free_return; - } - else - { - re_node_set dest_nodes; - err = re_node_set_init_union (&dest_nodes, - dest_state->entrance_nodes, - new_dest_nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&dest_nodes); - goto free_return; - } - mctx->state_log[dest_str_idx] - = re_acquire_state_context (&err, dfa, &dest_nodes, context); - re_node_set_free (&dest_nodes); - if (BE (mctx->state_log[dest_str_idx] == NULL - && err != REG_NOERROR, 0)) - goto free_return; - } - /* We need to check recursively if the backreference can epsilon - transit. */ - if (subexp_len == 0 - && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem) - { - err = check_subexp_matching_top (mctx, new_dest_nodes, - cur_str_idx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - err = transit_state_bkref (mctx, new_dest_nodes); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - } - } - err = REG_NOERROR; - free_return: - return err; -} - -/* Enumerate all the candidates which the backreference BKREF_NODE can match - at BKREF_STR_IDX, and register them by match_ctx_add_entry(). - Note that we might collect inappropriate candidates here. - However, the cost of checking them strictly here is too high, then we - delay these checking for prune_impossible_nodes(). */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - Idx subexp_num, sub_top_idx; - const char *buf = (const char *) re_string_get_buffer (&mctx->input); - /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ - Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); - if (cache_idx != REG_MISSING) - { - const struct re_backref_cache_entry *entry - = mctx->bkref_ents + cache_idx; - do - if (entry->node == bkref_node) - return REG_NOERROR; /* We already checked it. */ - while (entry++->more); - } - - subexp_num = dfa->nodes[bkref_node].opr.idx; - - /* For each sub expression */ - for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx) - { - reg_errcode_t err; - re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; - re_sub_match_last_t *sub_last; - Idx sub_last_idx, sl_str, bkref_str_off; - - if (dfa->nodes[sub_top->node].opr.idx != subexp_num) - continue; /* It isn't related. */ - - sl_str = sub_top->str_idx; - bkref_str_off = bkref_str_idx; - /* At first, check the last node of sub expressions we already - evaluated. */ - for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx) - { - regoff_t sl_str_diff; - sub_last = sub_top->lasts[sub_last_idx]; - sl_str_diff = sub_last->str_idx - sl_str; - /* The matched string by the sub expression match with the substring - at the back reference? */ - if (sl_str_diff > 0) - { - if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) - { - /* Not enough chars for a successful match. */ - if (bkref_str_off + sl_str_diff > mctx->input.len) - break; - - err = clean_state_log_if_needed (mctx, - bkref_str_off - + sl_str_diff); - if (BE (err != REG_NOERROR, 0)) - return err; - buf = (const char *) re_string_get_buffer (&mctx->input); - } - if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) - /* We don't need to search this sub expression any more. */ - break; - } - bkref_str_off += sl_str_diff; - sl_str += sl_str_diff; - err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, - bkref_str_idx); - - /* Reload buf, since the preceding call might have reallocated - the buffer. */ - buf = (const char *) re_string_get_buffer (&mctx->input); - - if (err == REG_NOMATCH) - continue; - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (sub_last_idx < sub_top->nlasts) - continue; - if (sub_last_idx > 0) - ++sl_str; - /* Then, search for the other last nodes of the sub expression. */ - for (; sl_str <= bkref_str_idx; ++sl_str) - { - Idx cls_node; - regoff_t sl_str_off; - const re_node_set *nodes; - sl_str_off = sl_str - sub_top->str_idx; - /* The matched string by the sub expression match with the substring - at the back reference? */ - if (sl_str_off > 0) - { - if (BE (bkref_str_off >= mctx->input.valid_len, 0)) - { - /* If we are at the end of the input, we cannot match. */ - if (bkref_str_off >= mctx->input.len) - break; - - err = extend_buffers (mctx, bkref_str_off + 1); - if (BE (err != REG_NOERROR, 0)) - return err; - - buf = (const char *) re_string_get_buffer (&mctx->input); - } - if (buf [bkref_str_off++] != buf[sl_str - 1]) - break; /* We don't need to search this sub expression - any more. */ - } - if (mctx->state_log[sl_str] == NULL) - continue; - /* Does this state have a ')' of the sub expression? */ - nodes = &mctx->state_log[sl_str]->nodes; - cls_node = find_subexp_node (dfa, nodes, subexp_num, - OP_CLOSE_SUBEXP); - if (cls_node == REG_MISSING) - continue; /* No. */ - if (sub_top->path == NULL) - { - sub_top->path = calloc (sizeof (state_array_t), - sl_str - sub_top->str_idx + 1); - if (sub_top->path == NULL) - return REG_ESPACE; - } - /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node - in the current context? */ - err = check_arrival (mctx, sub_top->path, sub_top->node, - sub_top->str_idx, cls_node, sl_str, - OP_CLOSE_SUBEXP); - if (err == REG_NOMATCH) - continue; - if (BE (err != REG_NOERROR, 0)) - return err; - sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); - if (BE (sub_last == NULL, 0)) - return REG_ESPACE; - err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, - bkref_str_idx); - if (err == REG_NOMATCH) - continue; - } - } - return REG_NOERROR; -} - -/* Helper functions for get_subexp(). */ - -/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR. - If it can arrive, register the sub expression expressed with SUB_TOP - and SUB_LAST. */ - -static reg_errcode_t -internal_function -get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, - re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) -{ - reg_errcode_t err; - Idx to_idx; - /* Can the subexpression arrive the back reference? */ - err = check_arrival (mctx, &sub_last->path, sub_last->node, - sub_last->str_idx, bkref_node, bkref_str, - OP_OPEN_SUBEXP); - if (err != REG_NOERROR) - return err; - err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, - sub_last->str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; - return clean_state_log_if_needed (mctx, to_idx); -} - -/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. - Search '(' if FL_OPEN, or search ')' otherwise. - TODO: This function isn't efficient... - Because there might be more than one nodes whose types are - OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all - nodes. - E.g. RE: (a){2} */ - -static Idx -internal_function -find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, - Idx subexp_idx, int type) -{ - Idx cls_idx; - for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx) - { - Idx cls_node = nodes->elems[cls_idx]; - const re_token_t *node = dfa->nodes + cls_node; - if (node->type == type - && node->opr.idx == subexp_idx) - return cls_node; - } - return REG_MISSING; -} - -/* Check whether the node TOP_NODE at TOP_STR can arrive to the node - LAST_NODE at LAST_STR. We record the path onto PATH since it will be - heavily reused. - Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, - Idx top_str, Idx last_node, Idx last_str, int type) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err = REG_NOERROR; - Idx subexp_num, backup_cur_idx, str_idx, null_cnt; - re_dfastate_t *cur_state = NULL; - re_node_set *cur_nodes, next_nodes; - re_dfastate_t **backup_state_log; - unsigned int context; - - subexp_num = dfa->nodes[top_node].opr.idx; - /* Extend the buffer if we need. */ - if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) - { - re_dfastate_t **new_array; - Idx old_alloc = path->alloc; - Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; - Idx new_alloc; - if (BE (IDX_MAX - old_alloc < incr_alloc, 0)) - return REG_ESPACE; - new_alloc = old_alloc + incr_alloc; - if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) - return REG_ESPACE; - new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - path->array = new_array; - path->alloc = new_alloc; - memset (new_array + old_alloc, '\0', - sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); - } - - str_idx = path->next_idx ? path->next_idx : top_str; - - /* Temporary modify MCTX. */ - backup_state_log = mctx->state_log; - backup_cur_idx = mctx->input.cur_idx; - mctx->state_log = path->array; - mctx->input.cur_idx = str_idx; - - /* Setup initial node set. */ - context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); - if (str_idx == top_str) - { - err = re_node_set_init_1 (&next_nodes, top_node); - if (BE (err != REG_NOERROR, 0)) - return err; - err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - else - { - cur_state = mctx->state_log[str_idx]; - if (cur_state && cur_state->has_backref) - { - err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - re_node_set_init_empty (&next_nodes); - } - if (str_idx == top_str || (cur_state && cur_state->has_backref)) - { - if (next_nodes.nelem) - { - err = expand_bkref_cache (mctx, &next_nodes, str_idx, - subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); - if (BE (cur_state == NULL && err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - mctx->state_log[str_idx] = cur_state; - } - - for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) - { - re_node_set_empty (&next_nodes); - if (mctx->state_log[str_idx + 1]) - { - err = re_node_set_merge (&next_nodes, - &mctx->state_log[str_idx + 1]->nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - if (cur_state) - { - err = check_arrival_add_next_nodes (mctx, str_idx, - &cur_state->non_eps_nodes, - &next_nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - ++str_idx; - if (next_nodes.nelem) - { - err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - err = expand_bkref_cache (mctx, &next_nodes, str_idx, - subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); - cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); - if (BE (cur_state == NULL && err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - mctx->state_log[str_idx] = cur_state; - null_cnt = cur_state == NULL ? null_cnt + 1 : 0; - } - re_node_set_free (&next_nodes); - cur_nodes = (mctx->state_log[last_str] == NULL ? NULL - : &mctx->state_log[last_str]->nodes); - path->next_idx = str_idx; - - /* Fix MCTX. */ - mctx->state_log = backup_state_log; - mctx->input.cur_idx = backup_cur_idx; - - /* Then check the current node set has the node LAST_NODE. */ - if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) - return REG_NOERROR; - - return REG_NOMATCH; -} - -/* Helper functions for check_arrival. */ - -/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them - to NEXT_NODES. - TODO: This function is similar to the functions transit_state*(), - however this function has many additional works. - Can't we unify them? */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, - re_node_set *cur_nodes, re_node_set *next_nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - bool ok; - Idx cur_idx; -#ifdef RE_ENABLE_I18N - reg_errcode_t err = REG_NOERROR; -#endif - re_node_set union_set; - re_node_set_init_empty (&union_set); - for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) - { - int naccepted = 0; - Idx cur_node = cur_nodes->elems[cur_idx]; -#ifdef DEBUG - re_token_type_t type = dfa->nodes[cur_node].type; - assert (!IS_EPSILON_NODE (type)); -#endif -#ifdef RE_ENABLE_I18N - /* If the node may accept "multi byte". */ - if (dfa->nodes[cur_node].accept_mb) - { - naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, - str_idx); - if (naccepted > 1) - { - re_dfastate_t *dest_state; - Idx next_node = dfa->nexts[cur_node]; - Idx next_idx = str_idx + naccepted; - dest_state = mctx->state_log[next_idx]; - re_node_set_empty (&union_set); - if (dest_state) - { - err = re_node_set_merge (&union_set, &dest_state->nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&union_set); - return err; - } - } - ok = re_node_set_insert (&union_set, next_node); - if (BE (! ok, 0)) - { - re_node_set_free (&union_set); - return REG_ESPACE; - } - mctx->state_log[next_idx] = re_acquire_state (&err, dfa, - &union_set); - if (BE (mctx->state_log[next_idx] == NULL - && err != REG_NOERROR, 0)) - { - re_node_set_free (&union_set); - return err; - } - } - } -#endif /* RE_ENABLE_I18N */ - if (naccepted - || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) - { - ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); - if (BE (! ok, 0)) - { - re_node_set_free (&union_set); - return REG_ESPACE; - } - } - } - re_node_set_free (&union_set); - return REG_NOERROR; -} - -/* For all the nodes in CUR_NODES, add the epsilon closures of them to - CUR_NODES, however exclude the nodes which are: - - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN. - - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN. -*/ - -static reg_errcode_t -internal_function -check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, - Idx ex_subexp, int type) -{ - reg_errcode_t err; - Idx idx, outside_node; - re_node_set new_nodes; -#ifdef DEBUG - assert (cur_nodes->nelem); -#endif - err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); - if (BE (err != REG_NOERROR, 0)) - return err; - /* Create a new node set NEW_NODES with the nodes which are epsilon - closures of the node in CUR_NODES. */ - - for (idx = 0; idx < cur_nodes->nelem; ++idx) - { - Idx cur_node = cur_nodes->elems[idx]; - const re_node_set *eclosure = dfa->eclosures + cur_node; - outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); - if (outside_node == REG_MISSING) - { - /* There are no problematic nodes, just merge them. */ - err = re_node_set_merge (&new_nodes, eclosure); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&new_nodes); - return err; - } - } - else - { - /* There are problematic nodes, re-calculate incrementally. */ - err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, - ex_subexp, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&new_nodes); - return err; - } - } - } - re_node_set_free (cur_nodes); - *cur_nodes = new_nodes; - return REG_NOERROR; -} - -/* Helper function for check_arrival_expand_ecl. - Check incrementally the epsilon closure of TARGET, and if it isn't - problematic append it to DST_NODES. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, - Idx target, Idx ex_subexp, int type) -{ - Idx cur_node; - for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);) - { - bool ok; - - if (dfa->nodes[cur_node].type == type - && dfa->nodes[cur_node].opr.idx == ex_subexp) - { - if (type == OP_CLOSE_SUBEXP) - { - ok = re_node_set_insert (dst_nodes, cur_node); - if (BE (! ok, 0)) - return REG_ESPACE; - } - break; - } - ok = re_node_set_insert (dst_nodes, cur_node); - if (BE (! ok, 0)) - return REG_ESPACE; - if (dfa->edests[cur_node].nelem == 0) - break; - if (dfa->edests[cur_node].nelem == 2) - { - reg_errcode_t err; - err = check_arrival_expand_ecl_sub (dfa, dst_nodes, - dfa->edests[cur_node].elems[1], - ex_subexp, type); - if (BE (err != REG_NOERROR, 0)) - return err; - } - cur_node = dfa->edests[cur_node].elems[0]; - } - return REG_NOERROR; -} - - -/* For all the back references in the current state, calculate the - destination of the back references by the appropriate entry - in MCTX->BKREF_ENTS. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, - Idx cur_str, Idx subexp_num, int type) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str); - struct re_backref_cache_entry *ent; - - if (cache_idx_start == REG_MISSING) - return REG_NOERROR; - - restart: - ent = mctx->bkref_ents + cache_idx_start; - do - { - Idx to_idx, next_node; - - /* Is this entry ENT is appropriate? */ - if (!re_node_set_contains (cur_nodes, ent->node)) - continue; /* No. */ - - to_idx = cur_str + ent->subexp_to - ent->subexp_from; - /* Calculate the destination of the back reference, and append it - to MCTX->STATE_LOG. */ - if (to_idx == cur_str) - { - /* The backreference did epsilon transit, we must re-check all the - node in the current state. */ - re_node_set new_dests; - reg_errcode_t err2, err3; - next_node = dfa->edests[ent->node].elems[0]; - if (re_node_set_contains (cur_nodes, next_node)) - continue; - err = re_node_set_init_1 (&new_dests, next_node); - err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); - err3 = re_node_set_merge (cur_nodes, &new_dests); - re_node_set_free (&new_dests); - if (BE (err != REG_NOERROR || err2 != REG_NOERROR - || err3 != REG_NOERROR, 0)) - { - err = (err != REG_NOERROR ? err - : (err2 != REG_NOERROR ? err2 : err3)); - return err; - } - /* TODO: It is still inefficient... */ - goto restart; - } - else - { - re_node_set union_set; - next_node = dfa->nexts[ent->node]; - if (mctx->state_log[to_idx]) - { - bool ok; - if (re_node_set_contains (&mctx->state_log[to_idx]->nodes, - next_node)) - continue; - err = re_node_set_init_copy (&union_set, - &mctx->state_log[to_idx]->nodes); - ok = re_node_set_insert (&union_set, next_node); - if (BE (err != REG_NOERROR || ! ok, 0)) - { - re_node_set_free (&union_set); - err = err != REG_NOERROR ? err : REG_ESPACE; - return err; - } - } - else - { - err = re_node_set_init_1 (&union_set, next_node); - if (BE (err != REG_NOERROR, 0)) - return err; - } - mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); - re_node_set_free (&union_set); - if (BE (mctx->state_log[to_idx] == NULL - && err != REG_NOERROR, 0)) - return err; - } - } - while (ent++->more); - return REG_NOERROR; -} - -/* Build transition table for the state. - Return true if successful. */ - -static bool -internal_function -build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) -{ - reg_errcode_t err; - Idx i, j; - int ch; - bool need_word_trtable = false; - bitset_word_t elem, mask; - bool dests_node_malloced = false; - bool dest_states_malloced = false; - Idx ndests; /* Number of the destination states from 'state'. */ - re_dfastate_t **trtable; - re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; - re_node_set follows, *dests_node; - bitset_t *dests_ch; - bitset_t acceptable; - - struct dests_alloc - { - re_node_set dests_node[SBC_MAX]; - bitset_t dests_ch[SBC_MAX]; - } *dests_alloc; - - /* We build DFA states which corresponds to the destination nodes - from 'state'. 'dests_node[i]' represents the nodes which i-th - destination state contains, and 'dests_ch[i]' represents the - characters which i-th destination state accepts. */ - if (__libc_use_alloca (sizeof (struct dests_alloc))) - dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); - else - { - dests_alloc = re_malloc (struct dests_alloc, 1); - if (BE (dests_alloc == NULL, 0)) - return false; - dests_node_malloced = true; - } - dests_node = dests_alloc->dests_node; - dests_ch = dests_alloc->dests_ch; - - /* Initialize transition table. */ - state->word_trtable = state->trtable = NULL; - - /* At first, group all nodes belonging to 'state' into several - destinations. */ - ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); - if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0)) - { - if (dests_node_malloced) - free (dests_alloc); - /* Return false in case of an error, true otherwise. */ - if (ndests == 0) - { - state->trtable = (re_dfastate_t **) - calloc (sizeof (re_dfastate_t *), SBC_MAX); - if (BE (state->trtable == NULL, 0)) - return false; - return true; - } - return false; - } - - err = re_node_set_alloc (&follows, ndests + 1); - if (BE (err != REG_NOERROR, 0)) - goto out_free; - - /* Avoid arithmetic overflow in size calculation. */ - if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX) - / (3 * sizeof (re_dfastate_t *))) - < ndests), - 0)) - goto out_free; - - if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX - + ndests * 3 * sizeof (re_dfastate_t *))) - dest_states = (re_dfastate_t **) - alloca (ndests * 3 * sizeof (re_dfastate_t *)); - else - { - dest_states = (re_dfastate_t **) - malloc (ndests * 3 * sizeof (re_dfastate_t *)); - if (BE (dest_states == NULL, 0)) - { -out_free: - if (dest_states_malloced) - free (dest_states); - re_node_set_free (&follows); - for (i = 0; i < ndests; ++i) - re_node_set_free (dests_node + i); - if (dests_node_malloced) - free (dests_alloc); - return false; - } - dest_states_malloced = true; - } - dest_states_word = dest_states + ndests; - dest_states_nl = dest_states_word + ndests; - bitset_empty (acceptable); - - /* Then build the states for all destinations. */ - for (i = 0; i < ndests; ++i) - { - Idx next_node; - re_node_set_empty (&follows); - /* Merge the follows of this destination states. */ - for (j = 0; j < dests_node[i].nelem; ++j) - { - next_node = dfa->nexts[dests_node[i].elems[j]]; - if (next_node != REG_MISSING) - { - err = re_node_set_merge (&follows, dfa->eclosures + next_node); - if (BE (err != REG_NOERROR, 0)) - goto out_free; - } - } - dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); - if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - /* If the new state has context constraint, - build appropriate states for these contexts. */ - if (dest_states[i]->has_constraint) - { - dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, - CONTEXT_WORD); - if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - - if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) - need_word_trtable = true; - - dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, - CONTEXT_NEWLINE); - if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - } - else - { - dest_states_word[i] = dest_states[i]; - dest_states_nl[i] = dest_states[i]; - } - bitset_merge (acceptable, dests_ch[i]); - } - - if (!BE (need_word_trtable, 0)) - { - /* We don't care about whether the following character is a word - character, or we are in a single-byte character set so we can - discern by looking at the character code: allocate a - 256-entry transition table. */ - trtable = state->trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); - if (BE (trtable == NULL, 0)) - goto out_free; - - /* For all characters ch...: */ - for (i = 0; i < BITSET_WORDS; ++i) - for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; - elem; - mask <<= 1, elem >>= 1, ++ch) - if (BE (elem & 1, 0)) - { - /* There must be exactly one destination which accepts - character ch. See group_nodes_into_DFAstates. */ - for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) - ; - - /* j-th destination accepts the word character ch. */ - if (dfa->word_char[i] & mask) - trtable[ch] = dest_states_word[j]; - else - trtable[ch] = dest_states[j]; - } - } - else - { - /* We care about whether the following character is a word - character, and we are in a multi-byte character set: discern - by looking at the character code: build two 256-entry - transition tables, one starting at trtable[0] and one - starting at trtable[SBC_MAX]. */ - trtable = state->word_trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); - if (BE (trtable == NULL, 0)) - goto out_free; - - /* For all characters ch...: */ - for (i = 0; i < BITSET_WORDS; ++i) - for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; - elem; - mask <<= 1, elem >>= 1, ++ch) - if (BE (elem & 1, 0)) - { - /* There must be exactly one destination which accepts - character ch. See group_nodes_into_DFAstates. */ - for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) - ; - - /* j-th destination accepts the word character ch. */ - trtable[ch] = dest_states[j]; - trtable[ch + SBC_MAX] = dest_states_word[j]; - } - } - - /* new line */ - if (bitset_contain (acceptable, NEWLINE_CHAR)) - { - /* The current state accepts newline character. */ - for (j = 0; j < ndests; ++j) - if (bitset_contain (dests_ch[j], NEWLINE_CHAR)) - { - /* k-th destination accepts newline character. */ - trtable[NEWLINE_CHAR] = dest_states_nl[j]; - if (need_word_trtable) - trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j]; - /* There must be only one destination which accepts - newline. See group_nodes_into_DFAstates. */ - break; - } - } - - if (dest_states_malloced) - free (dest_states); - - re_node_set_free (&follows); - for (i = 0; i < ndests; ++i) - re_node_set_free (dests_node + i); - - if (dests_node_malloced) - free (dests_alloc); - - return true; -} - -/* Group all nodes belonging to STATE into several destinations. - Then for all destinations, set the nodes belonging to the destination - to DESTS_NODE[i] and set the characters accepted by the destination - to DEST_CH[i]. This function return the number of destinations. */ - -static Idx -internal_function -group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, - re_node_set *dests_node, bitset_t *dests_ch) -{ - reg_errcode_t err; - bool ok; - Idx i, j, k; - Idx ndests; /* Number of the destinations from 'state'. */ - bitset_t accepts; /* Characters a node can accept. */ - const re_node_set *cur_nodes = &state->nodes; - bitset_empty (accepts); - ndests = 0; - - /* For all the nodes belonging to 'state', */ - for (i = 0; i < cur_nodes->nelem; ++i) - { - re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; - re_token_type_t type = node->type; - unsigned int constraint = node->constraint; - - /* Enumerate all single byte character this node can accept. */ - if (type == CHARACTER) - bitset_set (accepts, node->opr.c); - else if (type == SIMPLE_BRACKET) - { - bitset_merge (accepts, node->opr.sbcset); - } - else if (type == OP_PERIOD) - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - bitset_merge (accepts, dfa->sb_char); - else -#endif - bitset_set_all (accepts); - if (!(dfa->syntax & RE_DOT_NEWLINE)) - bitset_clear (accepts, '\n'); - if (dfa->syntax & RE_DOT_NOT_NULL) - bitset_clear (accepts, '\0'); - } -#ifdef RE_ENABLE_I18N - else if (type == OP_UTF8_PERIOD) - { - if (ASCII_CHARS % BITSET_WORD_BITS == 0) - memset (accepts, -1, ASCII_CHARS / CHAR_BIT); - else - bitset_merge (accepts, utf8_sb_map); - if (!(dfa->syntax & RE_DOT_NEWLINE)) - bitset_clear (accepts, '\n'); - if (dfa->syntax & RE_DOT_NOT_NULL) - bitset_clear (accepts, '\0'); - } -#endif - else - continue; - - /* Check the 'accepts' and sift the characters which are not - match it the context. */ - if (constraint) - { - if (constraint & NEXT_NEWLINE_CONSTRAINT) - { - bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR); - bitset_empty (accepts); - if (accepts_newline) - bitset_set (accepts, NEWLINE_CHAR); - else - continue; - } - if (constraint & NEXT_ENDBUF_CONSTRAINT) - { - bitset_empty (accepts); - continue; - } - - if (constraint & NEXT_WORD_CONSTRAINT) - { - bitset_word_t any_set = 0; - if (type == CHARACTER && !node->word_char) - { - bitset_empty (accepts); - continue; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); - else -#endif - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= dfa->word_char[j]); - if (!any_set) - continue; - } - if (constraint & NEXT_NOTWORD_CONSTRAINT) - { - bitset_word_t any_set = 0; - if (type == CHARACTER && node->word_char) - { - bitset_empty (accepts); - continue; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); - else -#endif - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= ~dfa->word_char[j]); - if (!any_set) - continue; - } - } - - /* Then divide 'accepts' into DFA states, or create a new - state. Above, we make sure that accepts is not empty. */ - for (j = 0; j < ndests; ++j) - { - bitset_t intersec; /* Intersection sets, see below. */ - bitset_t remains; - /* Flags, see below. */ - bitset_word_t has_intersec, not_subset, not_consumed; - - /* Optimization, skip if this state doesn't accept the character. */ - if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) - continue; - - /* Enumerate the intersection set of this state and 'accepts'. */ - has_intersec = 0; - for (k = 0; k < BITSET_WORDS; ++k) - has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; - /* And skip if the intersection set is empty. */ - if (!has_intersec) - continue; - - /* Then check if this state is a subset of 'accepts'. */ - not_subset = not_consumed = 0; - for (k = 0; k < BITSET_WORDS; ++k) - { - not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k]; - not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; - } - - /* If this state isn't a subset of 'accepts', create a - new group state, which has the 'remains'. */ - if (not_subset) - { - bitset_copy (dests_ch[ndests], remains); - bitset_copy (dests_ch[j], intersec); - err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); - if (BE (err != REG_NOERROR, 0)) - goto error_return; - ++ndests; - } - - /* Put the position in the current group. */ - ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); - if (BE (! ok, 0)) - goto error_return; - - /* If all characters are consumed, go to next node. */ - if (!not_consumed) - break; - } - /* Some characters remain, create a new group. */ - if (j == ndests) - { - bitset_copy (dests_ch[ndests], accepts); - err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); - if (BE (err != REG_NOERROR, 0)) - goto error_return; - ++ndests; - bitset_empty (accepts); - } - } - return ndests; - error_return: - for (j = 0; j < ndests; ++j) - re_node_set_free (dests_node + j); - return REG_MISSING; -} - -#ifdef RE_ENABLE_I18N -/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. - Return the number of the bytes the node accepts. - STR_IDX is the current index of the input string. - - This function handles the nodes which can accept one character, or - one collating element like '.', '[a-z]', opposite to the other nodes - can only accept one byte. */ - -static int -internal_function -check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, - const re_string_t *input, Idx str_idx) -{ - const re_token_t *node = dfa->nodes + node_idx; - int char_len, elem_len; - Idx i; - - if (BE (node->type == OP_UTF8_PERIOD, 0)) - { - unsigned char c = re_string_byte_at (input, str_idx), d; - if (BE (c < 0xc2, 1)) - return 0; - - if (str_idx + 2 > input->len) - return 0; - - d = re_string_byte_at (input, str_idx + 1); - if (c < 0xe0) - return (d < 0x80 || d > 0xbf) ? 0 : 2; - else if (c < 0xf0) - { - char_len = 3; - if (c == 0xe0 && d < 0xa0) - return 0; - } - else if (c < 0xf8) - { - char_len = 4; - if (c == 0xf0 && d < 0x90) - return 0; - } - else if (c < 0xfc) - { - char_len = 5; - if (c == 0xf8 && d < 0x88) - return 0; - } - else if (c < 0xfe) - { - char_len = 6; - if (c == 0xfc && d < 0x84) - return 0; - } - else - return 0; - - if (str_idx + char_len > input->len) - return 0; - - for (i = 1; i < char_len; ++i) - { - d = re_string_byte_at (input, str_idx + i); - if (d < 0x80 || d > 0xbf) - return 0; - } - return char_len; - } - - char_len = re_string_char_size_at (input, str_idx); - if (node->type == OP_PERIOD) - { - if (char_len <= 1) - return 0; - /* FIXME: I don't think this if is needed, as both '\n' - and '\0' are char_len == 1. */ - /* '.' accepts any one character except the following two cases. */ - if ((!(dfa->syntax & RE_DOT_NEWLINE) && - re_string_byte_at (input, str_idx) == '\n') || - ((dfa->syntax & RE_DOT_NOT_NULL) && - re_string_byte_at (input, str_idx) == '\0')) - return 0; - return char_len; - } - - elem_len = re_string_elem_size_at (input, str_idx); - if ((elem_len <= 1 && char_len <= 1) || char_len == 0) - return 0; - - if (node->type == COMPLEX_BRACKET) - { - const re_charset_t *cset = node->opr.mbcset; -# ifdef _LIBC - const unsigned char *pin - = ((const unsigned char *) re_string_get_buffer (input) + str_idx); - Idx j; - uint32_t nrules; -# endif /* _LIBC */ - int match_len = 0; - wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) - ? re_string_wchar_at (input, str_idx) : 0); - - /* match with multibyte character? */ - for (i = 0; i < cset->nmbchars; ++i) - if (wc == cset->mbchars[i]) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - /* match with character_class? */ - for (i = 0; i < cset->nchar_classes; ++i) - { - wctype_t wt = cset->char_classes[i]; - if (__iswctype (wc, wt)) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - } - -# ifdef _LIBC - nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules != 0) - { - unsigned int in_collseq = 0; - const int32_t *table, *indirect; - const unsigned char *weights, *extra; - const char *collseqwc; - /* This #include defines a local function! */ -# include - - /* match with collating_symbol? */ - if (cset->ncoll_syms) - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); - for (i = 0; i < cset->ncoll_syms; ++i) - { - const unsigned char *coll_sym = extra + cset->coll_syms[i]; - /* Compare the length of input collating element and - the length of current collating element. */ - if (*coll_sym != elem_len) - continue; - /* Compare each bytes. */ - for (j = 0; j < *coll_sym; j++) - if (pin[j] != coll_sym[1 + j]) - break; - if (j == *coll_sym) - { - /* Match if every bytes is equal. */ - match_len = j; - goto check_node_accept_bytes_match; - } - } - - if (cset->nranges) - { - if (elem_len <= char_len) - { - collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); - in_collseq = __collseq_table_lookup (collseqwc, wc); - } - else - in_collseq = find_collation_sequence_value (pin, elem_len); - } - /* match with range expression? */ - /* FIXME: Implement rational ranges here, too. */ - for (i = 0; i < cset->nranges; ++i) - if (cset->range_starts[i] <= in_collseq - && in_collseq <= cset->range_ends[i]) - { - match_len = elem_len; - goto check_node_accept_bytes_match; - } - - /* match with equivalence_class? */ - if (cset->nequiv_classes) - { - const unsigned char *cp = pin; - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); - int32_t idx = findidx (&cp, elem_len); - if (idx > 0) - for (i = 0; i < cset->nequiv_classes; ++i) - { - int32_t equiv_class_idx = cset->equiv_classes[i]; - size_t weight_len = weights[idx & 0xffffff]; - if (weight_len == weights[equiv_class_idx & 0xffffff] - && (idx >> 24) == (equiv_class_idx >> 24)) - { - Idx cnt = 0; - - idx &= 0xffffff; - equiv_class_idx &= 0xffffff; - - while (cnt <= weight_len - && (weights[equiv_class_idx + 1 + cnt] - == weights[idx + 1 + cnt])) - ++cnt; - if (cnt > weight_len) - { - match_len = elem_len; - goto check_node_accept_bytes_match; - } - } - } - } - } - else -# endif /* _LIBC */ - { - /* match with range expression? */ - for (i = 0; i < cset->nranges; ++i) - { - if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i]) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - } - } - check_node_accept_bytes_match: - if (!cset->non_match) - return match_len; - else - { - if (match_len > 0) - return 0; - else - return (elem_len > char_len) ? elem_len : char_len; - } - } - return 0; -} - -# ifdef _LIBC -static unsigned int -internal_function -find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) -{ - uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules == 0) - { - if (mbs_len == 1) - { - /* No valid character. Match it as a single byte character. */ - const unsigned char *collseq = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); - return collseq[mbs[0]]; - } - return UINT_MAX; - } - else - { - int32_t idx; - const unsigned char *extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); - int32_t extrasize = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; - - for (idx = 0; idx < extrasize;) - { - int mbs_cnt; - bool found = false; - int32_t elem_mbs_len; - /* Skip the name of collating element name. */ - idx = idx + extra[idx] + 1; - elem_mbs_len = extra[idx++]; - if (mbs_len == elem_mbs_len) - { - for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) - if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) - break; - if (mbs_cnt == elem_mbs_len) - /* Found the entry. */ - found = true; - } - /* Skip the byte sequence of the collating element. */ - idx += elem_mbs_len; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; - /* Skip the collation sequence value. */ - idx += sizeof (uint32_t); - /* Skip the wide char sequence of the collating element. */ - idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1); - /* If we found the entry, return the sequence value. */ - if (found) - return *(uint32_t *) (extra + idx); - /* Skip the collation sequence value. */ - idx += sizeof (uint32_t); - } - return UINT_MAX; - } -} -# endif /* _LIBC */ -#endif /* RE_ENABLE_I18N */ - -/* Check whether the node accepts the byte which is IDX-th - byte of the INPUT. */ - -static bool -internal_function -check_node_accept (const re_match_context_t *mctx, const re_token_t *node, - Idx idx) -{ - unsigned char ch; - ch = re_string_byte_at (&mctx->input, idx); - switch (node->type) - { - case CHARACTER: - if (node->opr.c != ch) - return false; - break; - - case SIMPLE_BRACKET: - if (!bitset_contain (node->opr.sbcset, ch)) - return false; - break; - -#ifdef RE_ENABLE_I18N - case OP_UTF8_PERIOD: - if (ch >= ASCII_CHARS) - return false; -#if defined __GNUC__ && __GNUC__ >= 7 - __attribute__ ((fallthrough)); -#endif - /* FALLTHROUGH */ -#endif - case OP_PERIOD: - if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) - || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) - return false; - break; - - default: - return false; - } - - if (node->constraint) - { - /* The node has constraints. Check whether the current context - satisfies the constraints. */ - unsigned int context = re_string_context_at (&mctx->input, idx, - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) - return false; - } - - return true; -} - -/* Extend the buffers, if the buffers have run out. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -extend_buffers (re_match_context_t *mctx, int min_len) -{ - reg_errcode_t ret; - re_string_t *pstr = &mctx->input; - - /* Avoid overflow. */ - if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 - <= pstr->bufs_len, 0)) - return REG_ESPACE; - - /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ - ret = re_string_realloc_buffers (pstr, - MAX (min_len, - MIN (pstr->len, pstr->bufs_len * 2))); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - if (mctx->state_log != NULL) - { - /* And double the length of state_log. */ - /* XXX We have no indication of the size of this buffer. If this - allocation fail we have no indication that the state_log array - does not have the right size. */ - re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, - pstr->bufs_len + 1); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - mctx->state_log = new_array; - } - - /* Then reconstruct the buffers. */ - if (pstr->icase) - { -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - else -#endif /* RE_ENABLE_I18N */ - build_upper_buffer (pstr); - } - else - { -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - build_wcs_buffer (pstr); - else -#endif /* RE_ENABLE_I18N */ - { - if (pstr->trans != NULL) - re_string_translate_buffer (pstr); - } - } - return REG_NOERROR; -} - - -/* Functions for matching context. */ - -/* Initialize MCTX. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -match_ctx_init (re_match_context_t *mctx, int eflags, Idx n) -{ - mctx->eflags = eflags; - mctx->match_last = REG_MISSING; - if (n > 0) - { - /* Avoid overflow. */ - size_t max_object_size = - MAX (sizeof (struct re_backref_cache_entry), - sizeof (re_sub_match_top_t *)); - if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0)) - return REG_ESPACE; - - mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); - mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); - if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) - return REG_ESPACE; - } - /* Already zero-ed by the caller. - else - mctx->bkref_ents = NULL; - mctx->nbkref_ents = 0; - mctx->nsub_tops = 0; */ - mctx->abkref_ents = n; - mctx->max_mb_elem_len = 1; - mctx->asub_tops = n; - return REG_NOERROR; -} - -/* Clean the entries which depend on the current input in MCTX. - This function must be invoked when the matcher changes the start index - of the input, or changes the input string. */ - -static void -internal_function -match_ctx_clean (re_match_context_t *mctx) -{ - Idx st_idx; - for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) - { - Idx sl_idx; - re_sub_match_top_t *top = mctx->sub_tops[st_idx]; - for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) - { - re_sub_match_last_t *last = top->lasts[sl_idx]; - re_free (last->path.array); - re_free (last); - } - re_free (top->lasts); - if (top->path) - { - re_free (top->path->array); - re_free (top->path); - } - free (top); - } - - mctx->nsub_tops = 0; - mctx->nbkref_ents = 0; -} - -/* Free all the memory associated with MCTX. */ - -static void -internal_function -match_ctx_free (re_match_context_t *mctx) -{ - /* First, free all the memory associated with MCTX->SUB_TOPS. */ - match_ctx_clean (mctx); - re_free (mctx->sub_tops); - re_free (mctx->bkref_ents); -} - -/* Add a new backreference entry to MCTX. - Note that we assume that caller never call this function with duplicate - entry, and call with STR_IDX which isn't smaller than any existing entry. -*/ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, - Idx to) -{ - if (mctx->nbkref_ents >= mctx->abkref_ents) - { - struct re_backref_cache_entry* new_entry; - new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, - mctx->abkref_ents * 2); - if (BE (new_entry == NULL, 0)) - { - re_free (mctx->bkref_ents); - return REG_ESPACE; - } - mctx->bkref_ents = new_entry; - memset (mctx->bkref_ents + mctx->nbkref_ents, '\0', - sizeof (struct re_backref_cache_entry) * mctx->abkref_ents); - mctx->abkref_ents *= 2; - } - if (mctx->nbkref_ents > 0 - && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx) - mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1; - - mctx->bkref_ents[mctx->nbkref_ents].node = node; - mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx; - mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from; - mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to; - - /* This is a cache that saves negative results of check_dst_limits_calc_pos. - If bit N is clear, means that this entry won't epsilon-transition to - an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If - it is set, check_dst_limits_calc_pos_1 will recurse and try to find one - such node. - - A backreference does not epsilon-transition unless it is empty, so set - to all zeros if FROM != TO. */ - mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map - = (from == to ? -1 : 0); - - mctx->bkref_ents[mctx->nbkref_ents++].more = 0; - if (mctx->max_mb_elem_len < to - from) - mctx->max_mb_elem_len = to - from; - return REG_NOERROR; -} - -/* Return the first entry with the same str_idx, or REG_MISSING if none is - found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ - -static Idx -internal_function -search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) -{ - Idx left, right, mid, last; - last = right = mctx->nbkref_ents; - for (left = 0; left < right;) - { - mid = (left + right) / 2; - if (mctx->bkref_ents[mid].str_idx < str_idx) - left = mid + 1; - else - right = mid; - } - if (left < last && mctx->bkref_ents[left].str_idx == str_idx) - return left; - else - return REG_MISSING; -} - -/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches - at STR_IDX. */ - -static reg_errcode_t -internal_function __attribute_warn_unused_result__ -match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) -{ -#ifdef DEBUG - assert (mctx->sub_tops != NULL); - assert (mctx->asub_tops > 0); -#endif - if (BE (mctx->nsub_tops == mctx->asub_tops, 0)) - { - Idx new_asub_tops = mctx->asub_tops * 2; - re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, - re_sub_match_top_t *, - new_asub_tops); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - mctx->sub_tops = new_array; - mctx->asub_tops = new_asub_tops; - } - mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); - if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) - return REG_ESPACE; - mctx->sub_tops[mctx->nsub_tops]->node = node; - mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; - return REG_NOERROR; -} - -/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches - at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ - -static re_sub_match_last_t * -internal_function -match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) -{ - re_sub_match_last_t *new_entry; - if (BE (subtop->nlasts == subtop->alasts, 0)) - { - Idx new_alasts = 2 * subtop->alasts + 1; - re_sub_match_last_t **new_array = re_realloc (subtop->lasts, - re_sub_match_last_t *, - new_alasts); - if (BE (new_array == NULL, 0)) - return NULL; - subtop->lasts = new_array; - subtop->alasts = new_alasts; - } - new_entry = calloc (1, sizeof (re_sub_match_last_t)); - if (BE (new_entry != NULL, 1)) - { - subtop->lasts[subtop->nlasts] = new_entry; - new_entry->node = node; - new_entry->str_idx = str_idx; - ++subtop->nlasts; - } - return new_entry; -} - -static void -internal_function -sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, - re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) -{ - sctx->sifted_states = sifted_sts; - sctx->limited_states = limited_sts; - sctx->last_node = last_node; - sctx->last_str_idx = last_str_idx; - re_node_set_init_empty (&sctx->limits); -} diff --git a/grub-core/gnulib/size_max.h b/grub-core/gnulib/size_max.h deleted file mode 100644 index 5f3312404..000000000 --- a/grub-core/gnulib/size_max.h +++ /dev/null @@ -1,30 +0,0 @@ -/* size_max.h -- declare SIZE_MAX through system headers - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. - Written by Simon Josefsson. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef GNULIB_SIZE_MAX_H -#define GNULIB_SIZE_MAX_H - -/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ -# include -/* Get SIZE_MAX declaration on systems like glibc 2. */ -# if HAVE_STDINT_H -# include -# endif -/* On systems where these include files don't define it, SIZE_MAX is defined - in config.h. */ - -#endif /* GNULIB_SIZE_MAX_H */ diff --git a/grub-core/gnulib/sleep.c b/grub-core/gnulib/sleep.c deleted file mode 100644 index 4c97d7dfa..000000000 --- a/grub-core/gnulib/sleep.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Pausing execution of the current thread. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2007. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -#include "verify.h" - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include - -unsigned int -sleep (unsigned int seconds) -{ - unsigned int remaining; - - /* Sleep for 1 second many times, because - 1. Sleep is not interruptible by Ctrl-C, - 2. we want to avoid arithmetic overflow while multiplying with 1000. */ - for (remaining = seconds; remaining > 0; remaining--) - Sleep (1000); - - return remaining; -} - -#elif HAVE_SLEEP - -# undef sleep - -/* Guarantee unlimited sleep and a reasonable return value. Cygwin - 1.5.x rejects attempts to sleep more than 49.7 days (2**32 - milliseconds), but uses uninitialized memory which results in a - garbage answer. Similarly, Linux 2.6.9 with glibc 2.3.4 has a too - small return value when asked to sleep more than 24.85 days. */ -unsigned int -rpl_sleep (unsigned int seconds) -{ - /* This requires int larger than 16 bits. */ - verify (UINT_MAX / 24 / 24 / 60 / 60); - const unsigned int limit = 24 * 24 * 60 * 60; - while (limit < seconds) - { - unsigned int result; - seconds -= limit; - result = sleep (limit); - if (result) - return seconds + result; - } - return sleep (seconds); -} - -#else /* !HAVE_SLEEP */ - - #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib." - -#endif diff --git a/grub-core/gnulib/stdalign.in.h b/grub-core/gnulib/stdalign.in.h deleted file mode 100644 index c3a67321b..000000000 --- a/grub-core/gnulib/stdalign.in.h +++ /dev/null @@ -1,90 +0,0 @@ -/* A substitute for ISO C11 . - - Copyright 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Written by Paul Eggert and Bruno Haible. */ - -#ifndef _GL_STDALIGN_H -#define _GL_STDALIGN_H - -/* ISO C11 for platforms that lack it. - - References: - ISO C11 (latest free draft - ) - sections 6.5.3.4, 6.7.5, 7.15. - C++11 (latest free draft - ) - section 18.10. */ - -/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment - requirement of a structure member (i.e., slot or field) that is of - type TYPE, as an integer constant expression. - - This differs from GCC's __alignof__ operator, which can yield a - better-performing alignment for an object of that type. For - example, on x86 with GCC, __alignof__ (double) and __alignof__ - (long long) are 8, whereas alignof (double) and alignof (long long) - are 4 unless the option '-malign-double' is used. - - The result cannot be used as a value for an 'enum' constant, if you - want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ -#include -#if defined __cplusplus - template struct __alignof_helper { char __a; __t __b; }; -# define _Alignof(type) offsetof (__alignof_helper, __b) -#else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -#endif -#define alignof _Alignof -#define __alignof_is_defined 1 - -/* alignas (A), also known as _Alignas (A), aligns a variable or type - to the alignment A, where A is an integer constant expression. For - example: - - int alignas (8) foo; - struct s { int a; int alignas (8) bar; }; - - aligns the address of FOO and the offset of BAR to be multiples of 8. - - A should be a power of two that is at least the type's alignment - and at most the implementation's alignment limit. This limit is - 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable - to MSVC through at least version 10.0, A should be an integer - constant, as MSVC does not support expressions such as 1 << 3. - To be portable to Sun C 5.11, do not align auto variables to - anything stricter than their default alignment. - - The following C11 requirements are not supported here: - - - If A is zero, alignas has no effect. - - alignas can be used multiple times; the strictest one wins. - - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). - - */ - -#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C -# define _Alignas(a) __attribute__ ((__aligned__ (a))) -#elif 1300 <= _MSC_VER -# define _Alignas(a) __declspec (align (a)) -#endif -#ifdef _Alignas -# define alignas _Alignas -# define __alignas_is_defined 1 -#endif - -#endif /* _GL_STDALIGN_H */ diff --git a/grub-core/gnulib/stdbool.in.h b/grub-core/gnulib/stdbool.in.h deleted file mode 100644 index 7c1577277..000000000 --- a/grub-core/gnulib/stdbool.in.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _GL_STDBOOL_H -#define _GL_STDBOOL_H - -/* ISO C 99 for platforms that lack it. */ - -/* Usage suggestions: - - Programs that use should be aware of some limitations - and standards compliance issues. - - Standards compliance: - - - must be #included before 'bool', 'false', 'true' - can be used. - - - You cannot assume that sizeof (bool) == 1. - - - Programs should not undefine the macros bool, true, and false, - as C99 lists that as an "obsolescent feature". - - Limitations of this substitute, when used in a C89 environment: - - - must be #included before the '_Bool' type can be used. - - - You cannot assume that _Bool is a typedef; it might be a macro. - - - Bit-fields of type 'bool' are not supported. Portable code - should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. - - - In C99, casts and automatic conversions to '_Bool' or 'bool' are - performed in such a way that every nonzero value gets converted - to 'true', and zero gets converted to 'false'. This doesn't work - with this substitute. With this substitute, only the values 0 and 1 - give the expected result when converted to _Bool' or 'bool'. - - - C99 allows the use of (_Bool)0.0 in constant expressions, but - this substitute cannot always provide this property. - - Also, it is suggested that programs use 'bool' rather than '_Bool'; - this isn't required, but 'bool' is more common. */ - - -/* 7.16. Boolean type and values */ - -/* BeOS already #defines false 0, true 1. We use the same - definitions below, but temporarily we have to #undef them. */ -#if defined __BEOS__ && !defined __HAIKU__ -# include /* defines bool but not _Bool */ -# undef false -# undef true -#endif - -#ifdef __cplusplus -# define _Bool bool -# define bool bool -#else -# if defined __BEOS__ && !defined __HAIKU__ - /* A compiler known to have 'bool'. */ - /* If the compiler already has both 'bool' and '_Bool', we can assume they - are the same types. */ -# if !@HAVE__BOOL@ -typedef bool _Bool; -# endif -# else -# if !defined __GNUC__ - /* If @HAVE__BOOL@: - Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when - the built-in _Bool type is used. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - Similar bugs are likely with other compilers as well; this file - wouldn't be used if was working. - So we override the _Bool type. - If !@HAVE__BOOL@: - Need to define _Bool ourselves. As 'signed char' or as an enum type? - Use of a typedef, with SunPRO C, leads to a stupid - "warning: _Bool is a keyword in ISO C99". - Use of an enum type, with IRIX cc, leads to a stupid - "warning(1185): enumerated type mixed with another type". - Even the existence of an enum type, without a typedef, - "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. - The only benefit of the enum, debuggability, is not important - with these compilers. So use 'signed char' and no enum. */ -# define _Bool signed char -# else - /* With this compiler, trust the _Bool type if the compiler has it. */ -# if !@HAVE__BOOL@ - /* For the sake of symbolic names in gdb, define true and false as - enum constants, not only as macros. - It is tempting to write - typedef enum { false = 0, true = 1 } _Bool; - so that gdb prints values of type 'bool' symbolically. But then - values of type '_Bool' might promote to 'int' or 'unsigned int' - (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' - (see ISO C 99 6.3.1.1.(2)). So add a negative value to the - enum; this ensures that '_Bool' promotes to 'int'. */ -typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; -# endif -# endif -# endif -# define bool _Bool -#endif - -/* The other macros must be usable in preprocessor directives. */ -#ifdef __cplusplus -# define false false -# define true true -#else -# define false 0 -# define true 1 -#endif - -#define __bool_true_false_are_defined 1 - -#endif /* _GL_STDBOOL_H */ diff --git a/grub-core/gnulib/stddef.in.h b/grub-core/gnulib/stddef.in.h deleted file mode 100644 index 40f0536aa..000000000 --- a/grub-core/gnulib/stddef.in.h +++ /dev/null @@ -1,86 +0,0 @@ -/* A substitute for POSIX 2008 , for platforms that have issues. - - Copyright (C) 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Written by Eric Blake. */ - -/* - * POSIX 2008 for platforms that have issues. - * - */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if defined __need_wchar_t || defined __need_size_t \ - || defined __need_ptrdiff_t || defined __need_NULL \ - || defined __need_wint_t -/* Special invocation convention inside gcc header files. In - particular, gcc provides a version of that blindly - redefines NULL even when __need_wint_t was defined, even though - wint_t is not normally provided by . Hence, we must - remember if special invocation has ever been used to obtain wint_t, - in which case we need to clean up NULL yet again. */ - -# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) -# ifdef __need_wint_t -# undef _@GUARD_PREFIX@_STDDEF_H -# define _GL_STDDEF_WINT_T -# endif -# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ -# endif - -#else -/* Normal invocation convention. */ - -# ifndef _@GUARD_PREFIX@_STDDEF_H - -/* The include_next requires a split double-inclusion guard. */ - -# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ - -# ifndef _@GUARD_PREFIX@_STDDEF_H -# define _@GUARD_PREFIX@_STDDEF_H - -/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ -#if @REPLACE_NULL@ -# undef NULL -# ifdef __cplusplus - /* ISO C++ says that the macro NULL must expand to an integer constant - expression, hence '((void *) 0)' is not allowed in C++. */ -# if __GNUG__ >= 3 - /* GNU C++ has a __null macro that behaves like an integer ('int' or - 'long') but has the same size as a pointer. Use that, to avoid - warnings. */ -# define NULL __null -# else -# define NULL 0L -# endif -# else -# define NULL ((void *) 0) -# endif -#endif - -/* Some platforms lack wchar_t. */ -#if !@HAVE_WCHAR_T@ -# define wchar_t int -#endif - -# endif /* _@GUARD_PREFIX@_STDDEF_H */ -# endif /* _@GUARD_PREFIX@_STDDEF_H */ -#endif /* __need_XXX */ diff --git a/grub-core/gnulib/stdint.in.h b/grub-core/gnulib/stdint.in.h deleted file mode 100644 index 2db8b2e37..000000000 --- a/grub-core/gnulib/stdint.in.h +++ /dev/null @@ -1,636 +0,0 @@ -/* Copyright (C) 2001-2002, 2004-2013 Free Software Foundation, Inc. - Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. - This file is part of gnulib. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* - * ISO C 99 for platforms that lack it. - * - */ - -#ifndef _@GUARD_PREFIX@_STDINT_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* When including a system file that in turn includes , - use the system , not our substitute. This avoids - problems with (for example) VMS, whose includes - . */ -#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H - -/* On Android (Bionic libc), includes this file before - having defined 'time_t'. Therefore in this case avoid including - other system header files; just include the system's . - Ideally we should test __BIONIC__ here, but it is only defined after - has been included; hence test __ANDROID__ instead. */ -#if defined __ANDROID__ \ - && defined _SYS_TYPES_H_ && !defined __need_size_t -# @INCLUDE_NEXT@ @NEXT_STDINT_H@ -#else - -/* Get those types that are already defined in other system include - files, so that we can "#define int8_t signed char" below without - worrying about a later system include file containing a "typedef - signed char int8_t;" that will get messed up by our macro. Our - macros should all be consistent with the system versions, except - for the "fast" types and macros, which we recommend against using - in public interfaces due to compiler differences. */ - -#if @HAVE_STDINT_H@ -# if defined __sgi && ! defined __c99 - /* Bypass IRIX's if in C89 mode, since it merely annoys users - with "This header file is to be used only for c99 mode compilations" - diagnostics. */ -# define __STDINT_H__ -# endif - - /* Some pre-C++11 implementations need this. */ -# ifdef __cplusplus -# ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS 1 -# endif -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -# endif -# endif - - /* Other systems may have an incomplete or buggy . - Include it before , since any "#include " - in would reinclude us, skipping our contents because - _@GUARD_PREFIX@_STDINT_H is defined. - The include_next requires a split double-inclusion guard. */ -# @INCLUDE_NEXT@ @NEXT_STDINT_H@ -#endif - -#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H -#define _@GUARD_PREFIX@_STDINT_H - -/* defines some of the stdint.h types as well, on glibc, - IRIX 6.5, and OpenBSD 3.8 (via ). - AIX 5.2 isn't needed and causes troubles. - Mac OS X 10.4.6 includes (which is us), but - relies on the system definitions, so include - after @NEXT_STDINT_H@. */ -#if @HAVE_SYS_TYPES_H@ && ! defined _AIX -# include -#endif - -/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, - LONG_MIN, LONG_MAX, ULONG_MAX. */ -#include - -#if @HAVE_INTTYPES_H@ - /* In OpenBSD 3.8, includes , which defines - int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. - also defines intptr_t and uintptr_t. */ -# include -#elif @HAVE_SYS_INTTYPES_H@ - /* Solaris 7 has the types except the *_fast*_t types, and - the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ -# include -#endif - -#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ - /* Linux libc4 >= 4.6.7 and libc5 have a that defines - int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is - included by . */ -# include -#endif - -#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H - -/* Minimum and maximum values for an integer type under the usual assumption. - Return an unspecified value if BITS == 0, adding a check to pacify - picky compilers. */ - -#define _STDINT_MIN(signed, bits, zero) \ - ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) - -#define _STDINT_MAX(signed, bits, zero) \ - ((signed) \ - ? ~ _STDINT_MIN (signed, bits, zero) \ - : /* The expression for the unsigned case. The subtraction of (signed) \ - is a nop in the unsigned case and avoids "signed integer overflow" \ - warnings in the signed case. */ \ - ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) - -#if !GNULIB_defined_stdint_types - -/* 7.18.1.1. Exact-width integer types */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. */ - -#undef int8_t -#undef uint8_t -typedef signed char gl_int8_t; -typedef unsigned char gl_uint8_t; -#define int8_t gl_int8_t -#define uint8_t gl_uint8_t - -#undef int16_t -#undef uint16_t -typedef short int gl_int16_t; -typedef unsigned short int gl_uint16_t; -#define int16_t gl_int16_t -#define uint16_t gl_uint16_t - -#undef int32_t -#undef uint32_t -typedef int gl_int32_t; -typedef unsigned int gl_uint32_t; -#define int32_t gl_int32_t -#define uint32_t gl_uint32_t - -/* If the system defines INT64_MAX, assume int64_t works. That way, - if the underlying platform defines int64_t to be a 64-bit long long - int, the code below won't mistakenly define it to be a 64-bit long - int, which would mess up C++ name mangling. We must use #ifdef - rather than #if, to avoid an error with HP-UX 10.20 cc. */ - -#ifdef INT64_MAX -# define GL_INT64_T -#else -/* Do not undefine int64_t if gnulib is not being used with 64-bit - types, since otherwise it breaks platforms like Tandem/NSK. */ -# if LONG_MAX >> 31 >> 31 == 1 -# undef int64_t -typedef long int gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T -# elif defined _MSC_VER -# undef int64_t -typedef __int64 gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T -# elif @HAVE_LONG_LONG_INT@ -# undef int64_t -typedef long long int gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T -# endif -#endif - -#ifdef UINT64_MAX -# define GL_UINT64_T -#else -# if ULONG_MAX >> 31 >> 31 >> 1 == 1 -# undef uint64_t -typedef unsigned long int gl_uint64_t; -# define uint64_t gl_uint64_t -# define GL_UINT64_T -# elif defined _MSC_VER -# undef uint64_t -typedef unsigned __int64 gl_uint64_t; -# define uint64_t gl_uint64_t -# define GL_UINT64_T -# elif @HAVE_UNSIGNED_LONG_LONG_INT@ -# undef uint64_t -typedef unsigned long long int gl_uint64_t; -# define uint64_t gl_uint64_t -# define GL_UINT64_T -# endif -#endif - -/* Avoid collision with Solaris 2.5.1 etc. */ -#define _UINT8_T -#define _UINT32_T -#define _UINT64_T - - -/* 7.18.1.2. Minimum-width integer types */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types - are the same as the corresponding N_t types. */ - -#undef int_least8_t -#undef uint_least8_t -#undef int_least16_t -#undef uint_least16_t -#undef int_least32_t -#undef uint_least32_t -#undef int_least64_t -#undef uint_least64_t -#define int_least8_t int8_t -#define uint_least8_t uint8_t -#define int_least16_t int16_t -#define uint_least16_t uint16_t -#define int_least32_t int32_t -#define uint_least32_t uint32_t -#ifdef GL_INT64_T -# define int_least64_t int64_t -#endif -#ifdef GL_UINT64_T -# define uint_least64_t uint64_t -#endif - -/* 7.18.1.3. Fastest minimum-width integer types */ - -/* Note: Other substitutes may define these types differently. - It is not recommended to use these types in public header files. */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types - are taken from the same list of types. The following code normally - uses types consistent with glibc, as that lessens the chance of - incompatibility with older GNU hosts. */ - -#undef int_fast8_t -#undef uint_fast8_t -#undef int_fast16_t -#undef uint_fast16_t -#undef int_fast32_t -#undef uint_fast32_t -#undef int_fast64_t -#undef uint_fast64_t -typedef signed char gl_int_fast8_t; -typedef unsigned char gl_uint_fast8_t; - -#ifdef __sun -/* Define types compatible with SunOS 5.10, so that code compiled under - earlier SunOS versions works with code compiled under SunOS 5.10. */ -typedef int gl_int_fast32_t; -typedef unsigned int gl_uint_fast32_t; -#else -typedef long int gl_int_fast32_t; -typedef unsigned long int gl_uint_fast32_t; -#endif -typedef gl_int_fast32_t gl_int_fast16_t; -typedef gl_uint_fast32_t gl_uint_fast16_t; - -#define int_fast8_t gl_int_fast8_t -#define uint_fast8_t gl_uint_fast8_t -#define int_fast16_t gl_int_fast16_t -#define uint_fast16_t gl_uint_fast16_t -#define int_fast32_t gl_int_fast32_t -#define uint_fast32_t gl_uint_fast32_t -#ifdef GL_INT64_T -# define int_fast64_t int64_t -#endif -#ifdef GL_UINT64_T -# define uint_fast64_t uint64_t -#endif - -/* 7.18.1.4. Integer types capable of holding object pointers */ - -#undef intptr_t -#undef uintptr_t -typedef long int gl_intptr_t; -typedef unsigned long int gl_uintptr_t; -#define intptr_t gl_intptr_t -#define uintptr_t gl_uintptr_t - -/* 7.18.1.5. Greatest-width integer types */ - -/* Note: These types are compiler dependent. It may be unwise to use them in - public header files. */ - -/* If the system defines INTMAX_MAX, assume that intmax_t works, and - similarly for UINTMAX_MAX and uintmax_t. This avoids problems with - assuming one type where another is used by the system. */ - -#ifndef INTMAX_MAX -# undef INTMAX_C -# undef intmax_t -# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 -typedef long long int gl_intmax_t; -# define intmax_t gl_intmax_t -# elif defined GL_INT64_T -# define intmax_t int64_t -# else -typedef long int gl_intmax_t; -# define intmax_t gl_intmax_t -# endif -#endif - -#ifndef UINTMAX_MAX -# undef UINTMAX_C -# undef uintmax_t -# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 -typedef unsigned long long int gl_uintmax_t; -# define uintmax_t gl_uintmax_t -# elif defined GL_UINT64_T -# define uintmax_t uint64_t -# else -typedef unsigned long int gl_uintmax_t; -# define uintmax_t gl_uintmax_t -# endif -#endif - -/* Verify that intmax_t and uintmax_t have the same size. Too much code - breaks if this is not the case. If this check fails, the reason is likely - to be found in the autoconf macros. */ -typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) - ? 1 : -1]; - -#define GNULIB_defined_stdint_types 1 -#endif /* !GNULIB_defined_stdint_types */ - -/* 7.18.2. Limits of specified-width integer types */ - -/* 7.18.2.1. Limits of exact-width integer types */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. */ - -#undef INT8_MIN -#undef INT8_MAX -#undef UINT8_MAX -#define INT8_MIN (~ INT8_MAX) -#define INT8_MAX 127 -#define UINT8_MAX 255 - -#undef INT16_MIN -#undef INT16_MAX -#undef UINT16_MAX -#define INT16_MIN (~ INT16_MAX) -#define INT16_MAX 32767 -#define UINT16_MAX 65535 - -#undef INT32_MIN -#undef INT32_MAX -#undef UINT32_MAX -#define INT32_MIN (~ INT32_MAX) -#define INT32_MAX 2147483647 -#define UINT32_MAX 4294967295U - -#if defined GL_INT64_T && ! defined INT64_MAX -/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 - evaluates the latter incorrectly in preprocessor expressions. */ -# define INT64_MIN (- INTMAX_C (1) << 63) -# define INT64_MAX INTMAX_C (9223372036854775807) -#endif - -#if defined GL_UINT64_T && ! defined UINT64_MAX -# define UINT64_MAX UINTMAX_C (18446744073709551615) -#endif - -/* 7.18.2.2. Limits of minimum-width integer types */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types - are the same as the corresponding N_t types. */ - -#undef INT_LEAST8_MIN -#undef INT_LEAST8_MAX -#undef UINT_LEAST8_MAX -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define UINT_LEAST8_MAX UINT8_MAX - -#undef INT_LEAST16_MIN -#undef INT_LEAST16_MAX -#undef UINT_LEAST16_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define UINT_LEAST16_MAX UINT16_MAX - -#undef INT_LEAST32_MIN -#undef INT_LEAST32_MAX -#undef UINT_LEAST32_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define UINT_LEAST32_MAX UINT32_MAX - -#undef INT_LEAST64_MIN -#undef INT_LEAST64_MAX -#ifdef GL_INT64_T -# define INT_LEAST64_MIN INT64_MIN -# define INT_LEAST64_MAX INT64_MAX -#endif - -#undef UINT_LEAST64_MAX -#ifdef GL_UINT64_T -# define UINT_LEAST64_MAX UINT64_MAX -#endif - -/* 7.18.2.3. Limits of fastest minimum-width integer types */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types - are taken from the same list of types. */ - -#undef INT_FAST8_MIN -#undef INT_FAST8_MAX -#undef UINT_FAST8_MAX -#define INT_FAST8_MIN SCHAR_MIN -#define INT_FAST8_MAX SCHAR_MAX -#define UINT_FAST8_MAX UCHAR_MAX - -#undef INT_FAST16_MIN -#undef INT_FAST16_MAX -#undef UINT_FAST16_MAX -#define INT_FAST16_MIN INT_FAST32_MIN -#define INT_FAST16_MAX INT_FAST32_MAX -#define UINT_FAST16_MAX UINT_FAST32_MAX - -#undef INT_FAST32_MIN -#undef INT_FAST32_MAX -#undef UINT_FAST32_MAX -#ifdef __sun -# define INT_FAST32_MIN INT_MIN -# define INT_FAST32_MAX INT_MAX -# define UINT_FAST32_MAX UINT_MAX -#else -# define INT_FAST32_MIN LONG_MIN -# define INT_FAST32_MAX LONG_MAX -# define UINT_FAST32_MAX ULONG_MAX -#endif - -#undef INT_FAST64_MIN -#undef INT_FAST64_MAX -#ifdef GL_INT64_T -# define INT_FAST64_MIN INT64_MIN -# define INT_FAST64_MAX INT64_MAX -#endif - -#undef UINT_FAST64_MAX -#ifdef GL_UINT64_T -# define UINT_FAST64_MAX UINT64_MAX -#endif - -/* 7.18.2.4. Limits of integer types capable of holding object pointers */ - -#undef INTPTR_MIN -#undef INTPTR_MAX -#undef UINTPTR_MAX -#define INTPTR_MIN LONG_MIN -#define INTPTR_MAX LONG_MAX -#define UINTPTR_MAX ULONG_MAX - -/* 7.18.2.5. Limits of greatest-width integer types */ - -#ifndef INTMAX_MAX -# undef INTMAX_MIN -# ifdef INT64_MAX -# define INTMAX_MIN INT64_MIN -# define INTMAX_MAX INT64_MAX -# else -# define INTMAX_MIN INT32_MIN -# define INTMAX_MAX INT32_MAX -# endif -#endif - -#ifndef UINTMAX_MAX -# ifdef UINT64_MAX -# define UINTMAX_MAX UINT64_MAX -# else -# define UINTMAX_MAX UINT32_MAX -# endif -#endif - -/* 7.18.3. Limits of other integer types */ - -/* ptrdiff_t limits */ -#undef PTRDIFF_MIN -#undef PTRDIFF_MAX -#if @APPLE_UNIVERSAL_BUILD@ -# ifdef _LP64 -# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) -# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) -# else -# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) -# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) -# endif -#else -# define PTRDIFF_MIN \ - _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) -# define PTRDIFF_MAX \ - _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) -#endif - -/* sig_atomic_t limits */ -#undef SIG_ATOMIC_MIN -#undef SIG_ATOMIC_MAX -#define SIG_ATOMIC_MIN \ - _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ - 0@SIG_ATOMIC_T_SUFFIX@) -#define SIG_ATOMIC_MAX \ - _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ - 0@SIG_ATOMIC_T_SUFFIX@) - - -/* size_t limit */ -#undef SIZE_MAX -#if @APPLE_UNIVERSAL_BUILD@ -# ifdef _LP64 -# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) -# else -# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) -# endif -#else -# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) -#endif - -/* wchar_t limits */ -/* Get WCHAR_MIN, WCHAR_MAX. - This include is not on the top, above, because on OSF/1 4.0 we have a - sequence of nested includes - -> -> -> , and the latter includes - and assumes its types are already defined. */ -#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) - /* BSD/OS 4.0.1 has a bug: , and must be - included before . */ -# include -# include -# include -# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H -# include -# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H -#endif -#undef WCHAR_MIN -#undef WCHAR_MAX -#define WCHAR_MIN \ - _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) -#define WCHAR_MAX \ - _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) - -/* wint_t limits */ -#undef WINT_MIN -#undef WINT_MAX -#define WINT_MIN \ - _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) -#define WINT_MAX \ - _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) - -/* 7.18.4. Macros for integer constants */ - -/* 7.18.4.1. Macros for minimum-width integer constants */ -/* According to ISO C 99 Technical Corrigendum 1 */ - -/* Here we assume a standard architecture where the hardware integer - types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ - -#undef INT8_C -#undef UINT8_C -#define INT8_C(x) x -#define UINT8_C(x) x - -#undef INT16_C -#undef UINT16_C -#define INT16_C(x) x -#define UINT16_C(x) x - -#undef INT32_C -#undef UINT32_C -#define INT32_C(x) x -#define UINT32_C(x) x ## U - -#undef INT64_C -#undef UINT64_C -#if LONG_MAX >> 31 >> 31 == 1 -# define INT64_C(x) x##L -#elif defined _MSC_VER -# define INT64_C(x) x##i64 -#elif @HAVE_LONG_LONG_INT@ -# define INT64_C(x) x##LL -#endif -#if ULONG_MAX >> 31 >> 31 >> 1 == 1 -# define UINT64_C(x) x##UL -#elif defined _MSC_VER -# define UINT64_C(x) x##ui64 -#elif @HAVE_UNSIGNED_LONG_LONG_INT@ -# define UINT64_C(x) x##ULL -#endif - -/* 7.18.4.2. Macros for greatest-width integer constants */ - -#ifndef INTMAX_C -# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 -# define INTMAX_C(x) x##LL -# elif defined GL_INT64_T -# define INTMAX_C(x) INT64_C(x) -# else -# define INTMAX_C(x) x##L -# endif -#endif - -#ifndef UINTMAX_C -# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 -# define UINTMAX_C(x) x##ULL -# elif defined GL_UINT64_T -# define UINTMAX_C(x) UINT64_C(x) -# else -# define UINTMAX_C(x) x##UL -# endif -#endif - -#endif /* _@GUARD_PREFIX@_STDINT_H */ -#endif /* !(defined __ANDROID__ && ...) */ -#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/grub-core/gnulib/stdio.in.h b/grub-core/gnulib/stdio.in.h deleted file mode 100644 index e1d28cebf..000000000 --- a/grub-core/gnulib/stdio.in.h +++ /dev/null @@ -1,1333 +0,0 @@ -/* A GNU-like . - - Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H -/* Special invocation convention: - - Inside glibc header files. - - On OSF/1 5.1 we have a sequence of nested includes - -> -> -> -> - -> -> -> . - In this situation, the functions are not yet declared, therefore we cannot - provide the C++ aliases. */ - -#@INCLUDE_NEXT@ @NEXT_STDIO_H@ - -#else -/* Normal invocation convention. */ - -#ifndef _@GUARD_PREFIX@_STDIO_H - -#define _GL_ALREADY_INCLUDING_STDIO_H - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_STDIO_H@ - -#undef _GL_ALREADY_INCLUDING_STDIO_H - -#ifndef _@GUARD_PREFIX@_STDIO_H -#define _@GUARD_PREFIX@_STDIO_H - -/* Get va_list. Needed on many systems, including glibc 2.8. */ -#include - -#include - -/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 - and eglibc 2.11.2. - May also define off_t to a 64-bit type on native Windows. */ -#include - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -/* _GL_ATTRIBUTE_FORMAT_PRINTF - indicates to GCC that the function takes a format string and arguments, - where the format string directives are the ones standardized by ISO C99 - and POSIX. */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument)) -#else -# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) -#endif - -/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF, - except that it indicates to GCC that the supported format string directives - are the ones of the system printf(), rather than the ones standardized by - ISO C99 and POSIX. */ -#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) - -/* _GL_ATTRIBUTE_FORMAT_SCANF - indicates to GCC that the function takes a format string and arguments, - where the format string directives are the ones standardized by ISO C99 - and POSIX. */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument)) -#else -# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) -#endif - -/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF, - except that it indicates to GCC that the supported format string directives - are the ones of the system scanf(), rather than the ones standardized by - ISO C99 and POSIX. */ -#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ - _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) - -/* Solaris 10 declares renameat in , not in . */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \ - && ! defined __GLIBC__ -# include -#endif - - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -/* Macros for stringification. */ -#define _GL_STDIO_STRINGIZE(token) #token -#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) - - -#if @GNULIB_DPRINTF@ -# if @REPLACE_DPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define dprintf rpl_dprintf -# endif -_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); -# else -# if !@HAVE_DPRINTF@ -_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); -# endif -_GL_CXXALIASWARN (dprintf); -#elif defined GNULIB_POSIXCHECK -# undef dprintf -# if HAVE_RAW_DECL_DPRINTF -_GL_WARN_ON_USE (dprintf, "dprintf is unportable - " - "use gnulib module dprintf for portability"); -# endif -#endif - -#if @GNULIB_FCLOSE@ -/* Close STREAM and its underlying file descriptor. */ -# if @REPLACE_FCLOSE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define fclose rpl_fclose -# endif -_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); -# else -_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); -# endif -_GL_CXXALIASWARN (fclose); -#elif defined GNULIB_POSIXCHECK -# undef fclose -/* Assume fclose is always declared. */ -_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " - "use gnulib module fclose for portable POSIX compliance"); -#endif - -#if @GNULIB_FDOPEN@ -# if @REPLACE_FDOPEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fdopen -# define fdopen rpl_fdopen -# endif -_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); -# else -_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); -# endif -_GL_CXXALIASWARN (fdopen); -#elif defined GNULIB_POSIXCHECK -# undef fdopen -/* Assume fdopen is always declared. */ -_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " - "use gnulib module fdopen for portability"); -#endif - -#if @GNULIB_FFLUSH@ -/* Flush all pending data on STREAM according to POSIX rules. Both - output and seekable input streams are supported. - Note! LOSS OF DATA can occur if fflush is applied on an input stream - that is _not_seekable_ or on an update stream that is _not_seekable_ - and in which the most recent operation was input. Seekability can - be tested with lseek(fileno(fp),0,SEEK_CUR). */ -# if @REPLACE_FFLUSH@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define fflush rpl_fflush -# endif -_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); -_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); -# else -_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); -# endif -_GL_CXXALIASWARN (fflush); -#elif defined GNULIB_POSIXCHECK -# undef fflush -/* Assume fflush is always declared. */ -_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " - "use gnulib module fflush for portable POSIX compliance"); -#endif - -#if @GNULIB_FGETC@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fgetc -# define fgetc rpl_fgetc -# endif -_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); -# else -_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); -# endif -_GL_CXXALIASWARN (fgetc); -#endif - -#if @GNULIB_FGETS@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fgets -# define fgets rpl_fgets -# endif -_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream) - _GL_ARG_NONNULL ((1, 3))); -_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); -# else -_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); -# endif -_GL_CXXALIASWARN (fgets); -#endif - -#if @GNULIB_FOPEN@ -# if @REPLACE_FOPEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fopen -# define fopen rpl_fopen -# endif -_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); -# else -_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); -# endif -_GL_CXXALIASWARN (fopen); -#elif defined GNULIB_POSIXCHECK -# undef fopen -/* Assume fopen is always declared. */ -_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " - "use gnulib module fopen for portability"); -#endif - -#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ -# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ - || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define fprintf rpl_fprintf -# endif -# define GNULIB_overrides_fprintf 1 -# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ -_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -# else -_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); -# else -_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); -# endif -_GL_CXXALIASWARN (fprintf); -#endif -#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_fprintf -# undef fprintf -# endif -/* Assume fprintf is always declared. */ -_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " - "use gnulib module fprintf-posix for portable " - "POSIX compliance"); -#endif - -#if @GNULIB_FPURGE@ -/* Discard all pending buffered I/O data on STREAM. - STREAM must not be wide-character oriented. - When discarding pending output, the file position is set back to where it - was before the write calls. When discarding pending input, the file - position is advanced to match the end of the previously read input. - Return 0 if successful. Upon error, return -1 and set errno. */ -# if @REPLACE_FPURGE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define fpurge rpl_fpurge -# endif -_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); -# else -# if !@HAVE_DECL_FPURGE@ -_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); -# endif -_GL_CXXALIASWARN (fpurge); -#elif defined GNULIB_POSIXCHECK -# undef fpurge -# if HAVE_RAW_DECL_FPURGE -_GL_WARN_ON_USE (fpurge, "fpurge is not always present - " - "use gnulib module fpurge for portability"); -# endif -#endif - -#if @GNULIB_FPUTC@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fputc -# define fputc rpl_fputc -# endif -_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); -# else -_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); -# endif -_GL_CXXALIASWARN (fputc); -#endif - -#if @GNULIB_FPUTS@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fputs -# define fputs rpl_fputs -# endif -_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); -# else -_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); -# endif -_GL_CXXALIASWARN (fputs); -#endif - -#if @GNULIB_FREAD@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fread -# define fread rpl_fread -# endif -_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream) - _GL_ARG_NONNULL ((4))); -_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); -# else -_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); -# endif -_GL_CXXALIASWARN (fread); -#endif - -#if @GNULIB_FREOPEN@ -# if @REPLACE_FREOPEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef freopen -# define freopen rpl_freopen -# endif -_GL_FUNCDECL_RPL (freopen, FILE *, - (const char *filename, const char *mode, FILE *stream) - _GL_ARG_NONNULL ((2, 3))); -_GL_CXXALIAS_RPL (freopen, FILE *, - (const char *filename, const char *mode, FILE *stream)); -# else -_GL_CXXALIAS_SYS (freopen, FILE *, - (const char *filename, const char *mode, FILE *stream)); -# endif -_GL_CXXALIASWARN (freopen); -#elif defined GNULIB_POSIXCHECK -# undef freopen -/* Assume freopen is always declared. */ -_GL_WARN_ON_USE (freopen, - "freopen on native Windows platforms is not POSIX compliant - " - "use gnulib module freopen for portability"); -#endif - -#if @GNULIB_FSCANF@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fscanf -# define fscanf rpl_fscanf -# endif -_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); -# else -_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); -# endif -_GL_CXXALIASWARN (fscanf); -#endif - - -/* Set up the following warnings, based on which modules are in use. - GNU Coding Standards discourage the use of fseek, since it imposes - an arbitrary limitation on some 32-bit hosts. Remember that the - fseek module depends on the fseeko module, so we only have three - cases to consider: - - 1. The developer is not using either module. Issue a warning under - GNULIB_POSIXCHECK for both functions, to remind them that both - functions have bugs on some systems. _GL_NO_LARGE_FILES has no - impact on this warning. - - 2. The developer is using both modules. They may be unaware of the - arbitrary limitations of fseek, so issue a warning under - GNULIB_POSIXCHECK. On the other hand, they may be using both - modules intentionally, so the developer can define - _GL_NO_LARGE_FILES in the compilation units where the use of fseek - is safe, to silence the warning. - - 3. The developer is using the fseeko module, but not fseek. Gnulib - guarantees that fseek will still work around platform bugs in that - case, but we presume that the developer is aware of the pitfalls of - fseek and was trying to avoid it, so issue a warning even when - GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be - defined to silence the warning in particular compilation units. - In C++ compilations with GNULIB_NAMESPACE, in order to avoid that - fseek gets defined as a macro, it is recommended that the developer - uses the fseek module, even if he is not calling the fseek function. - - Most gnulib clients that perform stream operations should fall into - category 3. */ - -#if @GNULIB_FSEEK@ -# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES -# define _GL_FSEEK_WARN /* Category 2, above. */ -# undef fseek -# endif -# if @REPLACE_FSEEK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fseek -# define fseek rpl_fseek -# endif -_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); -# else -_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); -# endif -_GL_CXXALIASWARN (fseek); -#endif - -#if @GNULIB_FSEEKO@ -# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES -# define _GL_FSEEK_WARN /* Category 3, above. */ -# undef fseek -# endif -# if @REPLACE_FSEEKO@ -/* Provide an fseeko function that is aware of a preceding fflush(), and which - detects pipes. */ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fseeko -# define fseeko rpl_fseeko -# endif -_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); -# else -# if ! @HAVE_DECL_FSEEKO@ -_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); -# endif -_GL_CXXALIASWARN (fseeko); -#elif defined GNULIB_POSIXCHECK -# define _GL_FSEEK_WARN /* Category 1, above. */ -# undef fseek -# undef fseeko -# if HAVE_RAW_DECL_FSEEKO -_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " - "use gnulib module fseeko for portability"); -# endif -#endif - -#ifdef _GL_FSEEK_WARN -# undef _GL_FSEEK_WARN -/* Here, either fseek is undefined (but C89 guarantees that it is - declared), or it is defined as rpl_fseek (declared above). */ -_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " - "on 32-bit platforms - " - "use fseeko function for handling of large files"); -#endif - - -/* ftell, ftello. See the comments on fseek/fseeko. */ - -#if @GNULIB_FTELL@ -# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES -# define _GL_FTELL_WARN /* Category 2, above. */ -# undef ftell -# endif -# if @REPLACE_FTELL@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ftell -# define ftell rpl_ftell -# endif -_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); -# else -_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); -# endif -_GL_CXXALIASWARN (ftell); -#endif - -#if @GNULIB_FTELLO@ -# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES -# define _GL_FTELL_WARN /* Category 3, above. */ -# undef ftell -# endif -# if @REPLACE_FTELLO@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ftello -# define ftello rpl_ftello -# endif -_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); -# else -# if ! @HAVE_DECL_FTELLO@ -_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); -# endif -_GL_CXXALIASWARN (ftello); -#elif defined GNULIB_POSIXCHECK -# define _GL_FTELL_WARN /* Category 1, above. */ -# undef ftell -# undef ftello -# if HAVE_RAW_DECL_FTELLO -_GL_WARN_ON_USE (ftello, "ftello is unportable - " - "use gnulib module ftello for portability"); -# endif -#endif - -#ifdef _GL_FTELL_WARN -# undef _GL_FTELL_WARN -/* Here, either ftell is undefined (but C89 guarantees that it is - declared), or it is defined as rpl_ftell (declared above). */ -_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " - "on 32-bit platforms - " - "use ftello function for handling of large files"); -#endif - - -#if @GNULIB_FWRITE@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fwrite -# define fwrite rpl_fwrite -# endif -_GL_FUNCDECL_RPL (fwrite, size_t, - (const void *ptr, size_t s, size_t n, FILE *stream) - _GL_ARG_NONNULL ((1, 4))); -_GL_CXXALIAS_RPL (fwrite, size_t, - (const void *ptr, size_t s, size_t n, FILE *stream)); -# else -_GL_CXXALIAS_SYS (fwrite, size_t, - (const void *ptr, size_t s, size_t n, FILE *stream)); - -/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 - , - which sometimes causes an unwanted diagnostic for fwrite calls. - This affects only function declaration attributes under certain - versions of gcc, and is not needed for C++. */ -# if (0 < __USE_FORTIFY_LEVEL \ - && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ - && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ - && !defined __cplusplus) -# undef fwrite -# define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; }) -# endif -# endif -_GL_CXXALIASWARN (fwrite); -#endif - -#if @GNULIB_GETC@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getc -# define getc rpl_fgetc -# endif -_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); -# else -_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); -# endif -_GL_CXXALIASWARN (getc); -#endif - -#if @GNULIB_GETCHAR@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getchar -# define getchar rpl_getchar -# endif -_GL_FUNCDECL_RPL (getchar, int, (void)); -_GL_CXXALIAS_RPL (getchar, int, (void)); -# else -_GL_CXXALIAS_SYS (getchar, int, (void)); -# endif -_GL_CXXALIASWARN (getchar); -#endif - -#if @GNULIB_GETDELIM@ -/* Read input, up to (and including) the next occurrence of DELIMITER, from - STREAM, store it in *LINEPTR (and NUL-terminate it). - *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE - bytes of space. It is realloc'd as necessary. - Return the number of bytes read and stored at *LINEPTR (not including the - NUL terminator), or -1 on error or EOF. */ -# if @REPLACE_GETDELIM@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getdelim -# define getdelim rpl_getdelim -# endif -_GL_FUNCDECL_RPL (getdelim, ssize_t, - (char **lineptr, size_t *linesize, int delimiter, - FILE *stream) - _GL_ARG_NONNULL ((1, 2, 4))); -_GL_CXXALIAS_RPL (getdelim, ssize_t, - (char **lineptr, size_t *linesize, int delimiter, - FILE *stream)); -# else -# if !@HAVE_DECL_GETDELIM@ -_GL_FUNCDECL_SYS (getdelim, ssize_t, - (char **lineptr, size_t *linesize, int delimiter, - FILE *stream) - _GL_ARG_NONNULL ((1, 2, 4))); -# endif -_GL_CXXALIAS_SYS (getdelim, ssize_t, - (char **lineptr, size_t *linesize, int delimiter, - FILE *stream)); -# endif -_GL_CXXALIASWARN (getdelim); -#elif defined GNULIB_POSIXCHECK -# undef getdelim -# if HAVE_RAW_DECL_GETDELIM -_GL_WARN_ON_USE (getdelim, "getdelim is unportable - " - "use gnulib module getdelim for portability"); -# endif -#endif - -#if @GNULIB_GETLINE@ -/* Read a line, up to (and including) the next newline, from STREAM, store it - in *LINEPTR (and NUL-terminate it). - *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE - bytes of space. It is realloc'd as necessary. - Return the number of bytes read and stored at *LINEPTR (not including the - NUL terminator), or -1 on error or EOF. */ -# if @REPLACE_GETLINE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getline -# define getline rpl_getline -# endif -_GL_FUNCDECL_RPL (getline, ssize_t, - (char **lineptr, size_t *linesize, FILE *stream) - _GL_ARG_NONNULL ((1, 2, 3))); -_GL_CXXALIAS_RPL (getline, ssize_t, - (char **lineptr, size_t *linesize, FILE *stream)); -# else -# if !@HAVE_DECL_GETLINE@ -_GL_FUNCDECL_SYS (getline, ssize_t, - (char **lineptr, size_t *linesize, FILE *stream) - _GL_ARG_NONNULL ((1, 2, 3))); -# endif -_GL_CXXALIAS_SYS (getline, ssize_t, - (char **lineptr, size_t *linesize, FILE *stream)); -# endif -# if @HAVE_DECL_GETLINE@ -_GL_CXXALIASWARN (getline); -# endif -#elif defined GNULIB_POSIXCHECK -# undef getline -# if HAVE_RAW_DECL_GETLINE -_GL_WARN_ON_USE (getline, "getline is unportable - " - "use gnulib module getline for portability"); -# endif -#endif - -/* It is very rare that the developer ever has full control of stdin, - so any use of gets warrants an unconditional warning; besides, C11 - removed it. */ -#undef gets -#if HAVE_RAW_DECL_GETS -#endif - - -#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ -struct obstack; -/* Grow an obstack with formatted output. Return the number of - bytes added to OBS. No trailing nul byte is added, and the - object should be closed with obstack_finish before use. Upon - memory allocation error, call obstack_alloc_failed_handler. Upon - other error, return -1. */ -# if @REPLACE_OBSTACK_PRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define obstack_printf rpl_obstack_printf -# endif -_GL_FUNCDECL_RPL (obstack_printf, int, - (struct obstack *obs, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (obstack_printf, int, - (struct obstack *obs, const char *format, ...)); -# else -# if !@HAVE_DECL_OBSTACK_PRINTF@ -_GL_FUNCDECL_SYS (obstack_printf, int, - (struct obstack *obs, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (obstack_printf, int, - (struct obstack *obs, const char *format, ...)); -# endif -_GL_CXXALIASWARN (obstack_printf); -# if @REPLACE_OBSTACK_PRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define obstack_vprintf rpl_obstack_vprintf -# endif -_GL_FUNCDECL_RPL (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args)); -# else -# if !@HAVE_DECL_OBSTACK_PRINTF@ -_GL_FUNCDECL_SYS (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (obstack_vprintf, int, - (struct obstack *obs, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (obstack_vprintf); -#endif - -#if @GNULIB_PCLOSE@ -# if !@HAVE_PCLOSE@ -_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); -_GL_CXXALIASWARN (pclose); -#elif defined GNULIB_POSIXCHECK -# undef pclose -# if HAVE_RAW_DECL_PCLOSE -_GL_WARN_ON_USE (pclose, "pclose is unportable - " - "use gnulib module pclose for more portability"); -# endif -#endif - -#if @GNULIB_PERROR@ -/* Print a message to standard error, describing the value of ERRNO, - (if STRING is not NULL and not empty) prefixed with STRING and ": ", - and terminated with a newline. */ -# if @REPLACE_PERROR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define perror rpl_perror -# endif -_GL_FUNCDECL_RPL (perror, void, (const char *string)); -_GL_CXXALIAS_RPL (perror, void, (const char *string)); -# else -_GL_CXXALIAS_SYS (perror, void, (const char *string)); -# endif -_GL_CXXALIASWARN (perror); -#elif defined GNULIB_POSIXCHECK -# undef perror -/* Assume perror is always declared. */ -_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " - "use gnulib module perror for portability"); -#endif - -#if @GNULIB_POPEN@ -# if @REPLACE_POPEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef popen -# define popen rpl_popen -# endif -_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); -# else -# if !@HAVE_POPEN@ -_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); -# endif -_GL_CXXALIASWARN (popen); -#elif defined GNULIB_POSIXCHECK -# undef popen -# if HAVE_RAW_DECL_POPEN -_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " - "use gnulib module popen or pipe for more portability"); -# endif -#endif - -#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ -# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ - || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) -# if defined __GNUC__ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -/* Don't break __attribute__((format(printf,M,N))). */ -# define printf __printf__ -# endif -# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ -_GL_FUNCDECL_RPL_1 (__printf__, int, - (const char *format, ...) - __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) - _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) - _GL_ARG_NONNULL ((1))); -# else -_GL_FUNCDECL_RPL_1 (__printf__, int, - (const char *format, ...) - __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) - _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); -# else -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define printf rpl_printf -# endif -_GL_FUNCDECL_RPL (printf, int, - (const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); -# endif -# define GNULIB_overrides_printf 1 -# else -_GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); -# endif -_GL_CXXALIASWARN (printf); -#endif -#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_printf -# undef printf -# endif -/* Assume printf is always declared. */ -_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " - "use gnulib module printf-posix for portable " - "POSIX compliance"); -#endif - -#if @GNULIB_PUTC@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef putc -# define putc rpl_fputc -# endif -_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); -# else -_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); -# endif -_GL_CXXALIASWARN (putc); -#endif - -#if @GNULIB_PUTCHAR@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef putchar -# define putchar rpl_putchar -# endif -_GL_FUNCDECL_RPL (putchar, int, (int c)); -_GL_CXXALIAS_RPL (putchar, int, (int c)); -# else -_GL_CXXALIAS_SYS (putchar, int, (int c)); -# endif -_GL_CXXALIASWARN (putchar); -#endif - -#if @GNULIB_PUTS@ -# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef puts -# define puts rpl_puts -# endif -_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (puts, int, (const char *string)); -# else -_GL_CXXALIAS_SYS (puts, int, (const char *string)); -# endif -_GL_CXXALIASWARN (puts); -#endif - -#if @GNULIB_REMOVE@ -# if @REPLACE_REMOVE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef remove -# define remove rpl_remove -# endif -_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (remove, int, (const char *name)); -# else -_GL_CXXALIAS_SYS (remove, int, (const char *name)); -# endif -_GL_CXXALIASWARN (remove); -#elif defined GNULIB_POSIXCHECK -# undef remove -/* Assume remove is always declared. */ -_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " - "use gnulib module remove for more portability"); -#endif - -#if @GNULIB_RENAME@ -# if @REPLACE_RENAME@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef rename -# define rename rpl_rename -# endif -_GL_FUNCDECL_RPL (rename, int, - (const char *old_filename, const char *new_filename) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (rename, int, - (const char *old_filename, const char *new_filename)); -# else -_GL_CXXALIAS_SYS (rename, int, - (const char *old_filename, const char *new_filename)); -# endif -_GL_CXXALIASWARN (rename); -#elif defined GNULIB_POSIXCHECK -# undef rename -/* Assume rename is always declared. */ -_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " - "use gnulib module rename for more portability"); -#endif - -#if @GNULIB_RENAMEAT@ -# if @REPLACE_RENAMEAT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef renameat -# define renameat rpl_renameat -# endif -_GL_FUNCDECL_RPL (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2) - _GL_ARG_NONNULL ((2, 4))); -_GL_CXXALIAS_RPL (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2)); -# else -# if !@HAVE_RENAMEAT@ -_GL_FUNCDECL_SYS (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2) - _GL_ARG_NONNULL ((2, 4))); -# endif -_GL_CXXALIAS_SYS (renameat, int, - (int fd1, char const *file1, int fd2, char const *file2)); -# endif -_GL_CXXALIASWARN (renameat); -#elif defined GNULIB_POSIXCHECK -# undef renameat -# if HAVE_RAW_DECL_RENAMEAT -_GL_WARN_ON_USE (renameat, "renameat is not portable - " - "use gnulib module renameat for portability"); -# endif -#endif - -#if @GNULIB_SCANF@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if defined __GNUC__ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef scanf -/* Don't break __attribute__((format(scanf,M,N))). */ -# define scanf __scanf__ -# endif -_GL_FUNCDECL_RPL_1 (__scanf__, int, - (const char *format, ...) - __asm__ (@ASM_SYMBOL_PREFIX@ - _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) - _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...)); -# else -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef scanf -# define scanf rpl_scanf -# endif -_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...) - _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); -# endif -# else -_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); -# endif -_GL_CXXALIASWARN (scanf); -#endif - -#if @GNULIB_SNPRINTF@ -# if @REPLACE_SNPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define snprintf rpl_snprintf -# endif -_GL_FUNCDECL_RPL (snprintf, int, - (char *str, size_t size, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) - _GL_ARG_NONNULL ((3))); -_GL_CXXALIAS_RPL (snprintf, int, - (char *str, size_t size, const char *format, ...)); -# else -# if !@HAVE_DECL_SNPRINTF@ -_GL_FUNCDECL_SYS (snprintf, int, - (char *str, size_t size, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) - _GL_ARG_NONNULL ((3))); -# endif -_GL_CXXALIAS_SYS (snprintf, int, - (char *str, size_t size, const char *format, ...)); -# endif -_GL_CXXALIASWARN (snprintf); -#elif defined GNULIB_POSIXCHECK -# undef snprintf -# if HAVE_RAW_DECL_SNPRINTF -_GL_WARN_ON_USE (snprintf, "snprintf is unportable - " - "use gnulib module snprintf for portability"); -# endif -#endif - -/* Some people would argue that all sprintf uses should be warned about - (for example, OpenBSD issues a link warning for it), - since it can cause security holes due to buffer overruns. - However, we believe that sprintf can be used safely, and is more - efficient than snprintf in those safe cases; and as proof of our - belief, we use sprintf in several gnulib modules. So this header - intentionally avoids adding a warning to sprintf except when - GNULIB_POSIXCHECK is defined. */ - -#if @GNULIB_SPRINTF_POSIX@ -# if @REPLACE_SPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define sprintf rpl_sprintf -# endif -_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); -# else -_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); -# endif -_GL_CXXALIASWARN (sprintf); -#elif defined GNULIB_POSIXCHECK -# undef sprintf -/* Assume sprintf is always declared. */ -_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " - "use gnulib module sprintf-posix for portable " - "POSIX compliance"); -#endif - -#if @GNULIB_TMPFILE@ -# if @REPLACE_TMPFILE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define tmpfile rpl_tmpfile -# endif -_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); -_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); -# else -_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); -# endif -_GL_CXXALIASWARN (tmpfile); -#elif defined GNULIB_POSIXCHECK -# undef tmpfile -# if HAVE_RAW_DECL_TMPFILE -_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " - "use gnulib module tmpfile for portability"); -# endif -#endif - -#if @GNULIB_VASPRINTF@ -/* Write formatted output to a string dynamically allocated with malloc(). - If the memory allocation succeeds, store the address of the string in - *RESULT and return the number of resulting bytes, excluding the trailing - NUL. Upon memory allocation error, or some other error, return -1. */ -# if @REPLACE_VASPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define asprintf rpl_asprintf -# endif -_GL_FUNCDECL_RPL (asprintf, int, - (char **result, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (asprintf, int, - (char **result, const char *format, ...)); -# else -# if !@HAVE_VASPRINTF@ -_GL_FUNCDECL_SYS (asprintf, int, - (char **result, const char *format, ...) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (asprintf, int, - (char **result, const char *format, ...)); -# endif -_GL_CXXALIASWARN (asprintf); -# if @REPLACE_VASPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vasprintf rpl_vasprintf -# endif -_GL_FUNCDECL_RPL (vasprintf, int, - (char **result, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (vasprintf, int, - (char **result, const char *format, va_list args)); -# else -# if !@HAVE_VASPRINTF@ -_GL_FUNCDECL_SYS (vasprintf, int, - (char **result, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (vasprintf, int, - (char **result, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vasprintf); -#endif - -#if @GNULIB_VDPRINTF@ -# if @REPLACE_VDPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vdprintf rpl_vdprintf -# endif -_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); -# else -# if !@HAVE_VDPRINTF@ -_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((2))); -# endif -/* Need to cast, because on Solaris, the third parameter will likely be - __va_list args. */ -_GL_CXXALIAS_SYS_CAST (vdprintf, int, - (int fd, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vdprintf); -#elif defined GNULIB_POSIXCHECK -# undef vdprintf -# if HAVE_RAW_DECL_VDPRINTF -_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " - "use gnulib module vdprintf for portability"); -# endif -#endif - -#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ -# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ - || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vfprintf rpl_vfprintf -# endif -# define GNULIB_overrides_vfprintf 1 -# if @GNULIB_VFPRINTF_POSIX@ -_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -# else -_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); -# else -/* Need to cast, because on Solaris, the third parameter is - __va_list args - and GCC's fixincludes did not change this to __gnuc_va_list. */ -_GL_CXXALIAS_SYS_CAST (vfprintf, int, - (FILE *fp, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vfprintf); -#endif -#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_vfprintf -# undef vfprintf -# endif -/* Assume vfprintf is always declared. */ -_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " - "use gnulib module vfprintf-posix for portable " - "POSIX compliance"); -#endif - -#if @GNULIB_VFSCANF@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef vfscanf -# define vfscanf rpl_vfscanf -# endif -_GL_FUNCDECL_RPL (vfscanf, int, - (FILE *stream, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (vfscanf, int, - (FILE *stream, const char *format, va_list args)); -# else -_GL_CXXALIAS_SYS (vfscanf, int, - (FILE *stream, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vfscanf); -#endif - -#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ -# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ - || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vprintf rpl_vprintf -# endif -# define GNULIB_overrides_vprintf 1 -# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ -_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) - _GL_ARG_NONNULL ((1))); -# else -_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); -# else -/* Need to cast, because on Solaris, the second parameter is - __va_list args - and GCC's fixincludes did not change this to __gnuc_va_list. */ -_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vprintf); -#endif -#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_vprintf -# undef vprintf -# endif -/* Assume vprintf is always declared. */ -_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " - "use gnulib module vprintf-posix for portable " - "POSIX compliance"); -#endif - -#if @GNULIB_VSCANF@ -# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef vscanf -# define vscanf rpl_vscanf -# endif -_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args)); -# else -_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vscanf); -#endif - -#if @GNULIB_VSNPRINTF@ -# if @REPLACE_VSNPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vsnprintf rpl_vsnprintf -# endif -_GL_FUNCDECL_RPL (vsnprintf, int, - (char *str, size_t size, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) - _GL_ARG_NONNULL ((3))); -_GL_CXXALIAS_RPL (vsnprintf, int, - (char *str, size_t size, const char *format, va_list args)); -# else -# if !@HAVE_DECL_VSNPRINTF@ -_GL_FUNCDECL_SYS (vsnprintf, int, - (char *str, size_t size, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) - _GL_ARG_NONNULL ((3))); -# endif -_GL_CXXALIAS_SYS (vsnprintf, int, - (char *str, size_t size, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vsnprintf); -#elif defined GNULIB_POSIXCHECK -# undef vsnprintf -# if HAVE_RAW_DECL_VSNPRINTF -_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " - "use gnulib module vsnprintf for portability"); -# endif -#endif - -#if @GNULIB_VSPRINTF_POSIX@ -# if @REPLACE_VSPRINTF@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define vsprintf rpl_vsprintf -# endif -_GL_FUNCDECL_RPL (vsprintf, int, - (char *str, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (vsprintf, int, - (char *str, const char *format, va_list args)); -# else -/* Need to cast, because on Solaris, the third parameter is - __va_list args - and GCC's fixincludes did not change this to __gnuc_va_list. */ -_GL_CXXALIAS_SYS_CAST (vsprintf, int, - (char *str, const char *format, va_list args)); -# endif -_GL_CXXALIASWARN (vsprintf); -#elif defined GNULIB_POSIXCHECK -# undef vsprintf -/* Assume vsprintf is always declared. */ -_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " - "use gnulib module vsprintf-posix for portable " - "POSIX compliance"); -#endif - -#endif /* _@GUARD_PREFIX@_STDIO_H */ -#endif /* _@GUARD_PREFIX@_STDIO_H */ -#endif diff --git a/grub-core/gnulib/stdlib.in.h b/grub-core/gnulib/stdlib.in.h deleted file mode 100644 index c9552480e..000000000 --- a/grub-core/gnulib/stdlib.in.h +++ /dev/null @@ -1,954 +0,0 @@ -/* A GNU-like . - - Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc -/* Special invocation conventions inside some gnulib header files, - and inside some glibc header files, respectively. */ - -#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ - -#else -/* Normal invocation convention. */ - -#ifndef _@GUARD_PREFIX@_STDLIB_H - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ - -#ifndef _@GUARD_PREFIX@_STDLIB_H -#define _@GUARD_PREFIX@_STDLIB_H - -/* NetBSD 5.0 mis-defines NULL. */ -#include - -/* MirBSD 10 defines WEXITSTATUS in , not in . */ -#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS -# include -#endif - -/* Solaris declares getloadavg() in . */ -#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ -# include -#endif - -/* Native Windows platforms declare mktemp() in . */ -#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -# include -#endif - -#if @GNULIB_RANDOM_R@ - -/* OSF/1 5.1 declares 'struct random_data' in , which is included - from if _REENTRANT is defined. Include it whenever we need - 'struct random_data'. */ -# if @HAVE_RANDOM_H@ -# include -# endif - -# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ -# include -# endif - -# if !@HAVE_STRUCT_RANDOM_DATA@ -/* Define 'struct random_data'. - But allow multiple gnulib generated replacements to coexist. */ -# if !GNULIB_defined_struct_random_data -struct random_data -{ - int32_t *fptr; /* Front pointer. */ - int32_t *rptr; /* Rear pointer. */ - int32_t *state; /* Array of state values. */ - int rand_type; /* Type of random number generator. */ - int rand_deg; /* Degree of random number generator. */ - int rand_sep; /* Distance between front and rear. */ - int32_t *end_ptr; /* Pointer behind state table. */ -}; -# define GNULIB_defined_struct_random_data 1 -# endif -# endif -#endif - -#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -/* On Mac OS X 10.3, only declares mkstemp. */ -/* On Mac OS X 10.5, only declares mkstemps. */ -/* On Cygwin 1.7.1, only declares getsubopt. */ -/* But avoid namespace pollution on glibc systems and native Windows. */ -# include -#endif - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The attribute __pure__ was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* The definition of _Noreturn is copied here. */ - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - - -/* Some systems do not define EXIT_*, despite otherwise supporting C89. */ -#ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -#endif -/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere - with proper operation of xargs. */ -#ifndef EXIT_FAILURE -# define EXIT_FAILURE 1 -#elif EXIT_FAILURE != 1 -# undef EXIT_FAILURE -# define EXIT_FAILURE 1 -#endif - - -#if @GNULIB__EXIT@ -/* Terminate the current process with the given return code, without running - the 'atexit' handlers. */ -# if !@HAVE__EXIT@ -_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); -# endif -_GL_CXXALIAS_SYS (_Exit, void, (int status)); -_GL_CXXALIASWARN (_Exit); -#elif defined GNULIB_POSIXCHECK -# undef _Exit -# if HAVE_RAW_DECL__EXIT -_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " - "use gnulib module _Exit for portability"); -# endif -#endif - - -#if @GNULIB_ATOLL@ -/* Parse a signed decimal integer. - Returns the value of the integer. Errors are not detected. */ -# if !@HAVE_ATOLL@ -_GL_FUNCDECL_SYS (atoll, long long, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); -_GL_CXXALIASWARN (atoll); -#elif defined GNULIB_POSIXCHECK -# undef atoll -# if HAVE_RAW_DECL_ATOLL -_GL_WARN_ON_USE (atoll, "atoll is unportable - " - "use gnulib module atoll for portability"); -# endif -#endif - -#if @GNULIB_CALLOC_POSIX@ -# if @REPLACE_CALLOC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef calloc -# define calloc rpl_calloc -# endif -_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); -_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); -# else -_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); -# endif -_GL_CXXALIASWARN (calloc); -#elif defined GNULIB_POSIXCHECK -# undef calloc -/* Assume calloc is always declared. */ -_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " - "use gnulib module calloc-posix for portability"); -#endif - -#if @GNULIB_CANONICALIZE_FILE_NAME@ -# if @REPLACE_CANONICALIZE_FILE_NAME@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define canonicalize_file_name rpl_canonicalize_file_name -# endif -_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); -# else -# if !@HAVE_CANONICALIZE_FILE_NAME@ -_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); -# endif -_GL_CXXALIASWARN (canonicalize_file_name); -#elif defined GNULIB_POSIXCHECK -# undef canonicalize_file_name -# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME -_GL_WARN_ON_USE (canonicalize_file_name, - "canonicalize_file_name is unportable - " - "use gnulib module canonicalize-lgpl for portability"); -# endif -#endif - -#if @GNULIB_GETLOADAVG@ -/* Store max(NELEM,3) load average numbers in LOADAVG[]. - The three numbers are the load average of the last 1 minute, the last 5 - minutes, and the last 15 minutes, respectively. - LOADAVG is an array of NELEM numbers. */ -# if !@HAVE_DECL_GETLOADAVG@ -_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); -_GL_CXXALIASWARN (getloadavg); -#elif defined GNULIB_POSIXCHECK -# undef getloadavg -# if HAVE_RAW_DECL_GETLOADAVG -_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " - "use gnulib module getloadavg for portability"); -# endif -#endif - -#if @GNULIB_GETSUBOPT@ -/* Assuming *OPTIONP is a comma separated list of elements of the form - "token" or "token=value", getsubopt parses the first of these elements. - If the first element refers to a "token" that is member of the given - NULL-terminated array of tokens: - - It replaces the comma with a NUL byte, updates *OPTIONP to point past - the first option and the comma, sets *VALUEP to the value of the - element (or NULL if it doesn't contain an "=" sign), - - It returns the index of the "token" in the given array of tokens. - Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. - For more details see the POSIX:2001 specification. - http://www.opengroup.org/susv3xsh/getsubopt.html */ -# if !@HAVE_GETSUBOPT@ -_GL_FUNCDECL_SYS (getsubopt, int, - (char **optionp, char *const *tokens, char **valuep) - _GL_ARG_NONNULL ((1, 2, 3))); -# endif -_GL_CXXALIAS_SYS (getsubopt, int, - (char **optionp, char *const *tokens, char **valuep)); -_GL_CXXALIASWARN (getsubopt); -#elif defined GNULIB_POSIXCHECK -# undef getsubopt -# if HAVE_RAW_DECL_GETSUBOPT -_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " - "use gnulib module getsubopt for portability"); -# endif -#endif - -#if @GNULIB_GRANTPT@ -/* Change the ownership and access permission of the slave side of the - pseudo-terminal whose master side is specified by FD. */ -# if !@HAVE_GRANTPT@ -_GL_FUNCDECL_SYS (grantpt, int, (int fd)); -# endif -_GL_CXXALIAS_SYS (grantpt, int, (int fd)); -_GL_CXXALIASWARN (grantpt); -#elif defined GNULIB_POSIXCHECK -# undef grantpt -# if HAVE_RAW_DECL_GRANTPT -_GL_WARN_ON_USE (grantpt, "grantpt is not portable - " - "use gnulib module grantpt for portability"); -# endif -#endif - -/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not - rely on GNU or POSIX semantics for malloc and realloc (for example, - by never specifying a zero size), so it does not need malloc or - realloc to be redefined. */ -#if @GNULIB_MALLOC_POSIX@ -# if @REPLACE_MALLOC@ -# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ - || _GL_USE_STDLIB_ALLOC) -# undef malloc -# define malloc rpl_malloc -# endif -_GL_FUNCDECL_RPL (malloc, void *, (size_t size)); -_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); -# else -_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); -# endif -_GL_CXXALIASWARN (malloc); -#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC -# undef malloc -/* Assume malloc is always declared. */ -_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " - "use gnulib module malloc-posix for portability"); -#endif - -/* Convert a multibyte character to a wide character. */ -#if @GNULIB_MBTOWC@ -# if @REPLACE_MBTOWC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbtowc -# define mbtowc rpl_mbtowc -# endif -_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); -_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); -# else -_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); -# endif -_GL_CXXALIASWARN (mbtowc); -#endif - -#if @GNULIB_MKDTEMP@ -/* Create a unique temporary directory from TEMPLATE. - The last six characters of TEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the directory name unique. - Returns TEMPLATE, or a null pointer if it cannot get a unique name. - The directory is created mode 700. */ -# if !@HAVE_MKDTEMP@ -_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); -_GL_CXXALIASWARN (mkdtemp); -#elif defined GNULIB_POSIXCHECK -# undef mkdtemp -# if HAVE_RAW_DECL_MKDTEMP -_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " - "use gnulib module mkdtemp for portability"); -# endif -#endif - -#if @GNULIB_MKOSTEMP@ -/* Create a unique temporary file from TEMPLATE. - The last six characters of TEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - The flags are a bitmask, possibly including O_CLOEXEC (defined in ) - and O_TEXT, O_BINARY (defined in "binary-io.h"). - The file is then created, with the specified flags, ensuring it didn't exist - before. - The file is created read-write (mask at least 0600 & ~umask), but it may be - world-readable and world-writable (mask 0666 & ~umask), depending on the - implementation. - Returns the open file descriptor if successful, otherwise -1 and errno - set. */ -# if !@HAVE_MKOSTEMP@ -_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); -_GL_CXXALIASWARN (mkostemp); -#elif defined GNULIB_POSIXCHECK -# undef mkostemp -# if HAVE_RAW_DECL_MKOSTEMP -_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " - "use gnulib module mkostemp for portability"); -# endif -#endif - -#if @GNULIB_MKOSTEMPS@ -/* Create a unique temporary file from TEMPLATE. - The last six characters of TEMPLATE before a suffix of length - SUFFIXLEN must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - The flags are a bitmask, possibly including O_CLOEXEC (defined in ) - and O_TEXT, O_BINARY (defined in "binary-io.h"). - The file is then created, with the specified flags, ensuring it didn't exist - before. - The file is created read-write (mask at least 0600 & ~umask), but it may be - world-readable and world-writable (mask 0666 & ~umask), depending on the - implementation. - Returns the open file descriptor if successful, otherwise -1 and errno - set. */ -# if !@HAVE_MKOSTEMPS@ -_GL_FUNCDECL_SYS (mkostemps, int, - (char * /*template*/, int /*suffixlen*/, int /*flags*/) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (mkostemps, int, - (char * /*template*/, int /*suffixlen*/, int /*flags*/)); -_GL_CXXALIASWARN (mkostemps); -#elif defined GNULIB_POSIXCHECK -# undef mkostemps -# if HAVE_RAW_DECL_MKOSTEMPS -_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " - "use gnulib module mkostemps for portability"); -# endif -#endif - -#if @GNULIB_MKSTEMP@ -/* Create a unique temporary file from TEMPLATE. - The last six characters of TEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - The file is then created, ensuring it didn't exist before. - The file is created read-write (mask at least 0600 & ~umask), but it may be - world-readable and world-writable (mask 0666 & ~umask), depending on the - implementation. - Returns the open file descriptor if successful, otherwise -1 and errno - set. */ -# if @REPLACE_MKSTEMP@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mkstemp rpl_mkstemp -# endif -_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); -# else -# if ! @HAVE_MKSTEMP@ -_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); -# endif -_GL_CXXALIASWARN (mkstemp); -#elif defined GNULIB_POSIXCHECK -# undef mkstemp -# if HAVE_RAW_DECL_MKSTEMP -_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " - "use gnulib module mkstemp for portability"); -# endif -#endif - -#if @GNULIB_MKSTEMPS@ -/* Create a unique temporary file from TEMPLATE. - The last six characters of TEMPLATE prior to a suffix of length - SUFFIXLEN must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - The file is then created, ensuring it didn't exist before. - The file is created read-write (mask at least 0600 & ~umask), but it may be - world-readable and world-writable (mask 0666 & ~umask), depending on the - implementation. - Returns the open file descriptor if successful, otherwise -1 and errno - set. */ -# if !@HAVE_MKSTEMPS@ -_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); -_GL_CXXALIASWARN (mkstemps); -#elif defined GNULIB_POSIXCHECK -# undef mkstemps -# if HAVE_RAW_DECL_MKSTEMPS -_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " - "use gnulib module mkstemps for portability"); -# endif -#endif - -#if @GNULIB_POSIX_OPENPT@ -/* Return an FD open to the master side of a pseudo-terminal. Flags should - include O_RDWR, and may also include O_NOCTTY. */ -# if !@HAVE_POSIX_OPENPT@ -_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); -# endif -_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); -_GL_CXXALIASWARN (posix_openpt); -#elif defined GNULIB_POSIXCHECK -# undef posix_openpt -# if HAVE_RAW_DECL_POSIX_OPENPT -_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " - "use gnulib module posix_openpt for portability"); -# endif -#endif - -#if @GNULIB_PTSNAME@ -/* Return the pathname of the pseudo-terminal slave associated with - the master FD is open on, or NULL on errors. */ -# if @REPLACE_PTSNAME@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ptsname -# define ptsname rpl_ptsname -# endif -_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); -_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); -# else -# if !@HAVE_PTSNAME@ -_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); -# endif -_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); -# endif -_GL_CXXALIASWARN (ptsname); -#elif defined GNULIB_POSIXCHECK -# undef ptsname -# if HAVE_RAW_DECL_PTSNAME -_GL_WARN_ON_USE (ptsname, "ptsname is not portable - " - "use gnulib module ptsname for portability"); -# endif -#endif - -#if @GNULIB_PTSNAME_R@ -/* Set the pathname of the pseudo-terminal slave associated with - the master FD is open on and return 0, or set errno and return - non-zero on errors. */ -# if @REPLACE_PTSNAME_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ptsname_r -# define ptsname_r rpl_ptsname_r -# endif -_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); -_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); -# else -# if !@HAVE_PTSNAME_R@ -_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); -# endif -_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); -# endif -_GL_CXXALIASWARN (ptsname_r); -#elif defined GNULIB_POSIXCHECK -# undef ptsname_r -# if HAVE_RAW_DECL_PTSNAME_R -_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " - "use gnulib module ptsname_r for portability"); -# endif -#endif - -#if @GNULIB_PUTENV@ -# if @REPLACE_PUTENV@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef putenv -# define putenv rpl_putenv -# endif -_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (putenv, int, (char *string)); -# else -_GL_CXXALIAS_SYS (putenv, int, (char *string)); -# endif -_GL_CXXALIASWARN (putenv); -#endif - - -#if @GNULIB_RANDOM_R@ -# if !@HAVE_RANDOM_R@ -# ifndef RAND_MAX -# define RAND_MAX 2147483647 -# endif -# endif -#endif - - -#if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ -_GL_FUNCDECL_SYS (random, long, (void)); -# endif -_GL_CXXALIAS_SYS (random, long, (void)); -_GL_CXXALIASWARN (random); -#elif defined GNULIB_POSIXCHECK -# undef random -# if HAVE_RAW_DECL_RANDOM -_GL_WARN_ON_USE (random, "random is unportable - " - "use gnulib module random for portability"); -# endif -#endif - -#if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ -_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); -# endif -_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed)); -_GL_CXXALIASWARN (srandom); -#elif defined GNULIB_POSIXCHECK -# undef srandom -# if HAVE_RAW_DECL_SRANDOM -_GL_WARN_ON_USE (srandom, "srandom is unportable - " - "use gnulib module random for portability"); -# endif -#endif - -#if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ -_GL_FUNCDECL_SYS (initstate, char *, - (unsigned int seed, char *buf, size_t buf_size) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (initstate, char *, - (unsigned int seed, char *buf, size_t buf_size)); -_GL_CXXALIASWARN (initstate); -#elif defined GNULIB_POSIXCHECK -# undef initstate -# if HAVE_RAW_DECL_INITSTATE_R -_GL_WARN_ON_USE (initstate, "initstate is unportable - " - "use gnulib module random for portability"); -# endif -#endif - -#if @GNULIB_RANDOM@ -# if !@HAVE_RANDOM@ -_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state)); -_GL_CXXALIASWARN (setstate); -#elif defined GNULIB_POSIXCHECK -# undef setstate -# if HAVE_RAW_DECL_SETSTATE_R -_GL_WARN_ON_USE (setstate, "setstate is unportable - " - "use gnulib module random for portability"); -# endif -#endif - - -#if @GNULIB_RANDOM_R@ -# if @REPLACE_RANDOM_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef random_r -# define random_r rpl_random_r -# endif -_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); -# else -# if !@HAVE_RANDOM_R@ -_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); -# endif -_GL_CXXALIASWARN (random_r); -#elif defined GNULIB_POSIXCHECK -# undef random_r -# if HAVE_RAW_DECL_RANDOM_R -_GL_WARN_ON_USE (random_r, "random_r is unportable - " - "use gnulib module random_r for portability"); -# endif -#endif - -#if @GNULIB_RANDOM_R@ -# if @REPLACE_RANDOM_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef srandom_r -# define srandom_r rpl_srandom_r -# endif -_GL_FUNCDECL_RPL (srandom_r, int, - (unsigned int seed, struct random_data *rand_state) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (srandom_r, int, - (unsigned int seed, struct random_data *rand_state)); -# else -# if !@HAVE_RANDOM_R@ -_GL_FUNCDECL_SYS (srandom_r, int, - (unsigned int seed, struct random_data *rand_state) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (srandom_r, int, - (unsigned int seed, struct random_data *rand_state)); -# endif -_GL_CXXALIASWARN (srandom_r); -#elif defined GNULIB_POSIXCHECK -# undef srandom_r -# if HAVE_RAW_DECL_SRANDOM_R -_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " - "use gnulib module random_r for portability"); -# endif -#endif - -#if @GNULIB_RANDOM_R@ -# if @REPLACE_RANDOM_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef initstate_r -# define initstate_r rpl_initstate_r -# endif -_GL_FUNCDECL_RPL (initstate_r, int, - (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state) - _GL_ARG_NONNULL ((2, 4))); -_GL_CXXALIAS_RPL (initstate_r, int, - (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state)); -# else -# if !@HAVE_RANDOM_R@ -_GL_FUNCDECL_SYS (initstate_r, int, - (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state) - _GL_ARG_NONNULL ((2, 4))); -# endif -_GL_CXXALIAS_SYS (initstate_r, int, - (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state)); -# endif -_GL_CXXALIASWARN (initstate_r); -#elif defined GNULIB_POSIXCHECK -# undef initstate_r -# if HAVE_RAW_DECL_INITSTATE_R -_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " - "use gnulib module random_r for portability"); -# endif -#endif - -#if @GNULIB_RANDOM_R@ -# if @REPLACE_RANDOM_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef setstate_r -# define setstate_r rpl_setstate_r -# endif -_GL_FUNCDECL_RPL (setstate_r, int, - (char *arg_state, struct random_data *rand_state) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (setstate_r, int, - (char *arg_state, struct random_data *rand_state)); -# else -# if !@HAVE_RANDOM_R@ -_GL_FUNCDECL_SYS (setstate_r, int, - (char *arg_state, struct random_data *rand_state) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (setstate_r, int, - (char *arg_state, struct random_data *rand_state)); -# endif -_GL_CXXALIASWARN (setstate_r); -#elif defined GNULIB_POSIXCHECK -# undef setstate_r -# if HAVE_RAW_DECL_SETSTATE_R -_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " - "use gnulib module random_r for portability"); -# endif -#endif - - -#if @GNULIB_REALLOC_POSIX@ -# if @REPLACE_REALLOC@ -# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ - || _GL_USE_STDLIB_ALLOC) -# undef realloc -# define realloc rpl_realloc -# endif -_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); -_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); -# else -_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); -# endif -_GL_CXXALIASWARN (realloc); -#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC -# undef realloc -/* Assume realloc is always declared. */ -_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " - "use gnulib module realloc-posix for portability"); -#endif - -#if @GNULIB_REALPATH@ -# if @REPLACE_REALPATH@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define realpath rpl_realpath -# endif -_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); -# else -# if !@HAVE_REALPATH@ -_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); -# endif -_GL_CXXALIASWARN (realpath); -#elif defined GNULIB_POSIXCHECK -# undef realpath -# if HAVE_RAW_DECL_REALPATH -_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " - "canonicalize or canonicalize-lgpl for portability"); -# endif -#endif - -#if @GNULIB_RPMATCH@ -/* Test a user response to a question. - Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ -# if !@HAVE_RPMATCH@ -_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); -_GL_CXXALIASWARN (rpmatch); -#elif defined GNULIB_POSIXCHECK -# undef rpmatch -# if HAVE_RAW_DECL_RPMATCH -_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " - "use gnulib module rpmatch for portability"); -# endif -#endif - -#if @GNULIB_SECURE_GETENV@ -/* Look up NAME in the environment, returning 0 in insecure situations. */ -# if !@HAVE_SECURE_GETENV@ -_GL_FUNCDECL_SYS (secure_getenv, char *, - (char const *name) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); -_GL_CXXALIASWARN (secure_getenv); -#elif defined GNULIB_POSIXCHECK -# undef secure_getenv -# if HAVE_RAW_DECL_SECURE_GETENV -_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " - "use gnulib module secure_getenv for portability"); -# endif -#endif - -#if @GNULIB_SETENV@ -/* Set NAME to VALUE in the environment. - If REPLACE is nonzero, overwrite an existing value. */ -# if @REPLACE_SETENV@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef setenv -# define setenv rpl_setenv -# endif -_GL_FUNCDECL_RPL (setenv, int, - (const char *name, const char *value, int replace) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (setenv, int, - (const char *name, const char *value, int replace)); -# else -# if !@HAVE_DECL_SETENV@ -_GL_FUNCDECL_SYS (setenv, int, - (const char *name, const char *value, int replace) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (setenv, int, - (const char *name, const char *value, int replace)); -# endif -# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@) -_GL_CXXALIASWARN (setenv); -# endif -#elif defined GNULIB_POSIXCHECK -# undef setenv -# if HAVE_RAW_DECL_SETENV -_GL_WARN_ON_USE (setenv, "setenv is unportable - " - "use gnulib module setenv for portability"); -# endif -#endif - -#if @GNULIB_STRTOD@ - /* Parse a double from STRING, updating ENDP if appropriate. */ -# if @REPLACE_STRTOD@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strtod rpl_strtod -# endif -_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); -# else -# if !@HAVE_STRTOD@ -_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); -# endif -_GL_CXXALIASWARN (strtod); -#elif defined GNULIB_POSIXCHECK -# undef strtod -# if HAVE_RAW_DECL_STRTOD -_GL_WARN_ON_USE (strtod, "strtod is unportable - " - "use gnulib module strtod for portability"); -# endif -#endif - -#if @GNULIB_STRTOLL@ -/* Parse a signed integer whose textual representation starts at STRING. - The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, - it may be decimal or octal (with prefix "0") or hexadecimal (with prefix - "0x"). - If ENDPTR is not NULL, the address of the first byte after the integer is - stored in *ENDPTR. - Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set - to ERANGE. */ -# if !@HAVE_STRTOLL@ -_GL_FUNCDECL_SYS (strtoll, long long, - (const char *string, char **endptr, int base) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strtoll, long long, - (const char *string, char **endptr, int base)); -_GL_CXXALIASWARN (strtoll); -#elif defined GNULIB_POSIXCHECK -# undef strtoll -# if HAVE_RAW_DECL_STRTOLL -_GL_WARN_ON_USE (strtoll, "strtoll is unportable - " - "use gnulib module strtoll for portability"); -# endif -#endif - -#if @GNULIB_STRTOULL@ -/* Parse an unsigned integer whose textual representation starts at STRING. - The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, - it may be decimal or octal (with prefix "0") or hexadecimal (with prefix - "0x"). - If ENDPTR is not NULL, the address of the first byte after the integer is - stored in *ENDPTR. - Upon overflow, the return value is ULLONG_MAX, and errno is set to - ERANGE. */ -# if !@HAVE_STRTOULL@ -_GL_FUNCDECL_SYS (strtoull, unsigned long long, - (const char *string, char **endptr, int base) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strtoull, unsigned long long, - (const char *string, char **endptr, int base)); -_GL_CXXALIASWARN (strtoull); -#elif defined GNULIB_POSIXCHECK -# undef strtoull -# if HAVE_RAW_DECL_STRTOULL -_GL_WARN_ON_USE (strtoull, "strtoull is unportable - " - "use gnulib module strtoull for portability"); -# endif -#endif - -#if @GNULIB_UNLOCKPT@ -/* Unlock the slave side of the pseudo-terminal whose master side is specified - by FD, so that it can be opened. */ -# if !@HAVE_UNLOCKPT@ -_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); -# endif -_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); -_GL_CXXALIASWARN (unlockpt); -#elif defined GNULIB_POSIXCHECK -# undef unlockpt -# if HAVE_RAW_DECL_UNLOCKPT -_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " - "use gnulib module unlockpt for portability"); -# endif -#endif - -#if @GNULIB_UNSETENV@ -/* Remove the variable NAME from the environment. */ -# if @REPLACE_UNSETENV@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef unsetenv -# define unsetenv rpl_unsetenv -# endif -_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); -# else -# if !@HAVE_DECL_UNSETENV@ -_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); -# endif -# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) -_GL_CXXALIASWARN (unsetenv); -# endif -#elif defined GNULIB_POSIXCHECK -# undef unsetenv -# if HAVE_RAW_DECL_UNSETENV -_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " - "use gnulib module unsetenv for portability"); -# endif -#endif - -/* Convert a wide character to a multibyte character. */ -#if @GNULIB_WCTOMB@ -# if @REPLACE_WCTOMB@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wctomb -# define wctomb rpl_wctomb -# endif -_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); -_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); -# else -_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); -# endif -_GL_CXXALIASWARN (wctomb); -#endif - - -#endif /* _@GUARD_PREFIX@_STDLIB_H */ -#endif /* _@GUARD_PREFIX@_STDLIB_H */ -#endif diff --git a/grub-core/gnulib/strcasecmp.c b/grub-core/gnulib/strcasecmp.c deleted file mode 100644 index 0f0a742ff..000000000 --- a/grub-core/gnulib/strcasecmp.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) - -/* Compare strings S1 and S2, ignoring case, returning less than, equal to or - greater than zero if S1 is lexicographically less than, equal to or greater - than S2. - Note: This function does not work with multibyte strings! */ - -int -strcasecmp (const char *s1, const char *s2) -{ - const unsigned char *p1 = (const unsigned char *) s1; - const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2) - return 0; - - do - { - c1 = TOLOWER (*p1); - c2 = TOLOWER (*p2); - - if (c1 == '\0') - break; - - ++p1; - ++p2; - } - while (c1 == c2); - - if (UCHAR_MAX <= INT_MAX) - return c1 - c2; - else - /* On machines where 'char' and 'int' are types of the same size, the - difference of two 'unsigned char' values - including the sign bit - - doesn't fit in an 'int'. */ - return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); -} diff --git a/grub-core/gnulib/strchrnul.c b/grub-core/gnulib/strchrnul.c deleted file mode 100644 index f6b072274..000000000 --- a/grub-core/gnulib/strchrnul.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Searching in a string. - Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -/* Find the first occurrence of C in S or the final NUL byte. */ -char * -strchrnul (const char *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - if (!c) - return rawmemchr (s, 0); - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (!*char_ptr || *char_ptr == c) - return (char *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 or - longword2 is zero. - - Let's consider longword1. We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 or longword2 is zero is equivalent - to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine - this into a single test, whether (tmp1 | tmp2) is nonzero. - - This test can read more than one byte beyond the end of a string, - depending on where the terminating NUL is encountered. However, - this is considered safe since the initialization phase ensured - that the read will be aligned, therefore, the read will not cross - page boundaries and will not cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - longword longword2 = *longword_ptr; - - if (((((longword1 - repeated_one) & ~longword1) - | ((longword2 - repeated_one) & ~longword2)) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == 0 or == c. On little-endian machines, - we could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr && (*char_ptr != c)) - char_ptr++; - return (char *) char_ptr; -} diff --git a/grub-core/gnulib/strchrnul.valgrind b/grub-core/gnulib/strchrnul.valgrind deleted file mode 100644 index b14fa1304..000000000 --- a/grub-core/gnulib/strchrnul.valgrind +++ /dev/null @@ -1,12 +0,0 @@ -# Suppress a valgrind message about use of uninitialized memory in strchrnul(). -# This use is OK because it provides only a speedup. -{ - strchrnul-value4 - Memcheck:Value4 - fun:strchrnul -} -{ - strchrnul-value8 - Memcheck:Value8 - fun:strchrnul -} diff --git a/grub-core/gnulib/streq.h b/grub-core/gnulib/streq.h deleted file mode 100644 index 12c1867c8..000000000 --- a/grub-core/gnulib/streq.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Bruno Haible . */ - -#ifndef _GL_STREQ_H -#define _GL_STREQ_H - -#include - -/* STREQ_OPT allows to optimize string comparison with a small literal string. - STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - is semantically equivalent to - strcmp (s, "EUC-KR") == 0 - just faster. */ - -/* Help GCC to generate good code for string comparisons with - immediate strings. */ -#if defined (__GNUC__) && defined (__OPTIMIZE__) - -static inline int -streq9 (const char *s1, const char *s2) -{ - return strcmp (s1 + 9, s2 + 9) == 0; -} - -static inline int -streq8 (const char *s1, const char *s2, char s28) -{ - if (s1[8] == s28) - { - if (s28 == 0) - return 1; - else - return streq9 (s1, s2); - } - else - return 0; -} - -static inline int -streq7 (const char *s1, const char *s2, char s27, char s28) -{ - if (s1[7] == s27) - { - if (s27 == 0) - return 1; - else - return streq8 (s1, s2, s28); - } - else - return 0; -} - -static inline int -streq6 (const char *s1, const char *s2, char s26, char s27, char s28) -{ - if (s1[6] == s26) - { - if (s26 == 0) - return 1; - else - return streq7 (s1, s2, s27, s28); - } - else - return 0; -} - -static inline int -streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) -{ - if (s1[5] == s25) - { - if (s25 == 0) - return 1; - else - return streq6 (s1, s2, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[4] == s24) - { - if (s24 == 0) - return 1; - else - return streq5 (s1, s2, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[3] == s23) - { - if (s23 == 0) - return 1; - else - return streq4 (s1, s2, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[2] == s22) - { - if (s22 == 0) - return 1; - else - return streq3 (s1, s2, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[1] == s21) - { - if (s21 == 0) - return 1; - else - return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[0] == s20) - { - if (s20 == 0) - return 1; - else - return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ - streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) - -#else - -#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ - (strcmp (s1, s2) == 0) - -#endif - -#endif /* _GL_STREQ_H */ diff --git a/grub-core/gnulib/strerror-override.c b/grub-core/gnulib/strerror-override.c deleted file mode 100644 index d0ed2fb86..000000000 --- a/grub-core/gnulib/strerror-override.c +++ /dev/null @@ -1,302 +0,0 @@ -/* strerror-override.c --- POSIX compatible system error routine - - Copyright (C) 2010-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Bruno Haible , 2010. */ - -#include - -#include "strerror-override.h" - -#include - -#if GNULIB_defined_EWINSOCK /* native Windows platforms */ -# if HAVE_WINSOCK2_H -# include -# endif -#endif - -/* If ERRNUM maps to an errno value defined by gnulib, return a string - describing the error. Otherwise return NULL. */ -const char * -strerror_override (int errnum) -{ - /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ - switch (errnum) - { -#if REPLACE_STRERROR_0 - case 0: - return "Success"; -#endif - -#if GNULIB_defined_ESOCK /* native Windows platforms with older */ - case EINPROGRESS: - return "Operation now in progress"; - case EALREADY: - return "Operation already in progress"; - case ENOTSOCK: - return "Socket operation on non-socket"; - case EDESTADDRREQ: - return "Destination address required"; - case EMSGSIZE: - return "Message too long"; - case EPROTOTYPE: - return "Protocol wrong type for socket"; - case ENOPROTOOPT: - return "Protocol not available"; - case EPROTONOSUPPORT: - return "Protocol not supported"; - case EOPNOTSUPP: - return "Operation not supported"; - case EAFNOSUPPORT: - return "Address family not supported by protocol"; - case EADDRINUSE: - return "Address already in use"; - case EADDRNOTAVAIL: - return "Cannot assign requested address"; - case ENETDOWN: - return "Network is down"; - case ENETUNREACH: - return "Network is unreachable"; - case ECONNRESET: - return "Connection reset by peer"; - case ENOBUFS: - return "No buffer space available"; - case EISCONN: - return "Transport endpoint is already connected"; - case ENOTCONN: - return "Transport endpoint is not connected"; - case ETIMEDOUT: - return "Connection timed out"; - case ECONNREFUSED: - return "Connection refused"; - case ELOOP: - return "Too many levels of symbolic links"; - case EHOSTUNREACH: - return "No route to host"; - case EWOULDBLOCK: - return "Operation would block"; -#endif -#if GNULIB_defined_ESTREAMS /* native Windows platforms with older */ - case ETXTBSY: - return "Text file busy"; - case ENODATA: - return "No data available"; - case ENOSR: - return "Out of streams resources"; - case ENOSTR: - return "Device not a stream"; - case ETIME: - return "Timer expired"; - case EOTHER: - return "Other error"; -#endif -#if GNULIB_defined_EWINSOCK /* native Windows platforms */ - case ESOCKTNOSUPPORT: - return "Socket type not supported"; - case EPFNOSUPPORT: - return "Protocol family not supported"; - case ESHUTDOWN: - return "Cannot send after transport endpoint shutdown"; - case ETOOMANYREFS: - return "Too many references: cannot splice"; - case EHOSTDOWN: - return "Host is down"; - case EPROCLIM: - return "Too many processes"; - case EUSERS: - return "Too many users"; - case EDQUOT: - return "Disk quota exceeded"; - case ESTALE: - return "Stale NFS file handle"; - case EREMOTE: - return "Object is remote"; -# if HAVE_WINSOCK2_H - /* WSA_INVALID_HANDLE maps to EBADF */ - /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ - /* WSA_INVALID_PARAMETER maps to EINVAL */ - case WSA_OPERATION_ABORTED: - return "Overlapped operation aborted"; - case WSA_IO_INCOMPLETE: - return "Overlapped I/O event object not in signaled state"; - case WSA_IO_PENDING: - return "Overlapped operations will complete later"; - /* WSAEINTR maps to EINTR */ - /* WSAEBADF maps to EBADF */ - /* WSAEACCES maps to EACCES */ - /* WSAEFAULT maps to EFAULT */ - /* WSAEINVAL maps to EINVAL */ - /* WSAEMFILE maps to EMFILE */ - /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ - /* WSAEINPROGRESS maps to EINPROGRESS */ - /* WSAEALREADY maps to EALREADY */ - /* WSAENOTSOCK maps to ENOTSOCK */ - /* WSAEDESTADDRREQ maps to EDESTADDRREQ */ - /* WSAEMSGSIZE maps to EMSGSIZE */ - /* WSAEPROTOTYPE maps to EPROTOTYPE */ - /* WSAENOPROTOOPT maps to ENOPROTOOPT */ - /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */ - /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ - /* WSAEOPNOTSUPP maps to EOPNOTSUPP */ - /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ - /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */ - /* WSAEADDRINUSE maps to EADDRINUSE */ - /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */ - /* WSAENETDOWN maps to ENETDOWN */ - /* WSAENETUNREACH maps to ENETUNREACH */ - /* WSAENETRESET maps to ENETRESET */ - /* WSAECONNABORTED maps to ECONNABORTED */ - /* WSAECONNRESET maps to ECONNRESET */ - /* WSAENOBUFS maps to ENOBUFS */ - /* WSAEISCONN maps to EISCONN */ - /* WSAENOTCONN maps to ENOTCONN */ - /* WSAESHUTDOWN is ESHUTDOWN */ - /* WSAETOOMANYREFS is ETOOMANYREFS */ - /* WSAETIMEDOUT maps to ETIMEDOUT */ - /* WSAECONNREFUSED maps to ECONNREFUSED */ - /* WSAELOOP maps to ELOOP */ - /* WSAENAMETOOLONG maps to ENAMETOOLONG */ - /* WSAEHOSTDOWN is EHOSTDOWN */ - /* WSAEHOSTUNREACH maps to EHOSTUNREACH */ - /* WSAENOTEMPTY maps to ENOTEMPTY */ - /* WSAEPROCLIM is EPROCLIM */ - /* WSAEUSERS is EUSERS */ - /* WSAEDQUOT is EDQUOT */ - /* WSAESTALE is ESTALE */ - /* WSAEREMOTE is EREMOTE */ - case WSASYSNOTREADY: - return "Network subsystem is unavailable"; - case WSAVERNOTSUPPORTED: - return "Winsock.dll version out of range"; - case WSANOTINITIALISED: - return "Successful WSAStartup not yet performed"; - case WSAEDISCON: - return "Graceful shutdown in progress"; - case WSAENOMORE: case WSA_E_NO_MORE: - return "No more results"; - case WSAECANCELLED: case WSA_E_CANCELLED: - return "Call was canceled"; - case WSAEINVALIDPROCTABLE: - return "Procedure call table is invalid"; - case WSAEINVALIDPROVIDER: - return "Service provider is invalid"; - case WSAEPROVIDERFAILEDINIT: - return "Service provider failed to initialize"; - case WSASYSCALLFAILURE: - return "System call failure"; - case WSASERVICE_NOT_FOUND: - return "Service not found"; - case WSATYPE_NOT_FOUND: - return "Class type not found"; - case WSAEREFUSED: - return "Database query was refused"; - case WSAHOST_NOT_FOUND: - return "Host not found"; - case WSATRY_AGAIN: - return "Nonauthoritative host not found"; - case WSANO_RECOVERY: - return "Nonrecoverable error"; - case WSANO_DATA: - return "Valid name, no data record of requested type"; - /* WSA_QOS_* omitted */ -# endif -#endif - -#if GNULIB_defined_ENOMSG - case ENOMSG: - return "No message of desired type"; -#endif - -#if GNULIB_defined_EIDRM - case EIDRM: - return "Identifier removed"; -#endif - -#if GNULIB_defined_ENOLINK - case ENOLINK: - return "Link has been severed"; -#endif - -#if GNULIB_defined_EPROTO - case EPROTO: - return "Protocol error"; -#endif - -#if GNULIB_defined_EMULTIHOP - case EMULTIHOP: - return "Multihop attempted"; -#endif - -#if GNULIB_defined_EBADMSG - case EBADMSG: - return "Bad message"; -#endif - -#if GNULIB_defined_EOVERFLOW - case EOVERFLOW: - return "Value too large for defined data type"; -#endif - -#if GNULIB_defined_ENOTSUP - case ENOTSUP: - return "Not supported"; -#endif - -#if GNULIB_defined_ENETRESET - case ENETRESET: - return "Network dropped connection on reset"; -#endif - -#if GNULIB_defined_ECONNABORTED - case ECONNABORTED: - return "Software caused connection abort"; -#endif - -#if GNULIB_defined_ESTALE - case ESTALE: - return "Stale NFS file handle"; -#endif - -#if GNULIB_defined_EDQUOT - case EDQUOT: - return "Disk quota exceeded"; -#endif - -#if GNULIB_defined_ECANCELED - case ECANCELED: - return "Operation canceled"; -#endif - -#if GNULIB_defined_EOWNERDEAD - case EOWNERDEAD: - return "Owner died"; -#endif - -#if GNULIB_defined_ENOTRECOVERABLE - case ENOTRECOVERABLE: - return "State not recoverable"; -#endif - -#if GNULIB_defined_EILSEQ - case EILSEQ: - return "Invalid or incomplete multibyte or wide character"; -#endif - - default: - return NULL; - } -} diff --git a/grub-core/gnulib/strerror-override.h b/grub-core/gnulib/strerror-override.h deleted file mode 100644 index 3b8f24b99..000000000 --- a/grub-core/gnulib/strerror-override.h +++ /dev/null @@ -1,56 +0,0 @@ -/* strerror-override.h --- POSIX compatible system error routine - - Copyright (C) 2010-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GL_STRERROR_OVERRIDE_H -# define _GL_STRERROR_OVERRIDE_H - -# include -# include - -/* Reasonable buffer size that should never trigger ERANGE; if this - proves too small, we intentionally abort(), to remind us to fix - this value. */ -# define STACKBUF_LEN 256 - -/* If ERRNUM maps to an errno value defined by gnulib, return a string - describing the error. Otherwise return NULL. */ -# if REPLACE_STRERROR_0 \ - || GNULIB_defined_ESOCK \ - || GNULIB_defined_ESTREAMS \ - || GNULIB_defined_EWINSOCK \ - || GNULIB_defined_ENOMSG \ - || GNULIB_defined_EIDRM \ - || GNULIB_defined_ENOLINK \ - || GNULIB_defined_EPROTO \ - || GNULIB_defined_EMULTIHOP \ - || GNULIB_defined_EBADMSG \ - || GNULIB_defined_EOVERFLOW \ - || GNULIB_defined_ENOTSUP \ - || GNULIB_defined_ENETRESET \ - || GNULIB_defined_ECONNABORTED \ - || GNULIB_defined_ESTALE \ - || GNULIB_defined_EDQUOT \ - || GNULIB_defined_ECANCELED \ - || GNULIB_defined_EOWNERDEAD \ - || GNULIB_defined_ENOTRECOVERABLE \ - || GNULIB_defined_EILSEQ -extern const char *strerror_override (int errnum); -# else -# define strerror_override(ignored) NULL -# endif - -#endif /* _GL_STRERROR_OVERRIDE_H */ diff --git a/grub-core/gnulib/strerror.c b/grub-core/gnulib/strerror.c deleted file mode 100644 index 80a2f2eea..000000000 --- a/grub-core/gnulib/strerror.c +++ /dev/null @@ -1,70 +0,0 @@ -/* strerror.c --- POSIX compatible system error routine - - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include -#include -#include - -#include "intprops.h" -#include "strerror-override.h" -#include "verify.h" - -/* Use the system functions, not the gnulib overrides in this file. */ -#undef sprintf - -char * -strerror (int n) -#undef strerror -{ - static char buf[STACKBUF_LEN]; - size_t len; - - /* Cast away const, due to the historical signature of strerror; - callers should not be modifying the string. */ - const char *msg = strerror_override (n); - if (msg) - return (char *) msg; - - msg = strerror (n); - - /* Our strerror_r implementation might use the system's strerror - buffer, so all other clients of strerror have to see the error - copied into a buffer that we manage. This is not thread-safe, - even if the system strerror is, but portable programs shouldn't - be using strerror if they care about thread-safety. */ - if (!msg || !*msg) - { - static char const fmt[] = "Unknown error %d"; - verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); - sprintf (buf, fmt, n); - errno = EINVAL; - return buf; - } - - /* Fix STACKBUF_LEN if this ever aborts. */ - len = strlen (msg); - if (sizeof buf <= len) - abort (); - - return memcpy (buf, msg, len + 1); -} diff --git a/grub-core/gnulib/string.in.h b/grub-core/gnulib/string.in.h deleted file mode 100644 index d7a6c9c92..000000000 --- a/grub-core/gnulib/string.in.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* A GNU-like . - - Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _@GUARD_PREFIX@_STRING_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_STRING_H@ - -#ifndef _@GUARD_PREFIX@_STRING_H -#define _@GUARD_PREFIX@_STRING_H - -/* NetBSD 5.0 mis-defines NULL. */ -#include - -/* MirBSD defines mbslen as a macro. */ -#if @GNULIB_MBSLEN@ && defined __MirBSD__ -# include -#endif - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The attribute __pure__ was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* NetBSD 5.0 declares strsignal in , not in . */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ - && ! defined __GLIBC__ -# include -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - - -/* Find the index of the least-significant set bit. */ -#if @GNULIB_FFSL@ -# if !@HAVE_FFSL@ -_GL_FUNCDECL_SYS (ffsl, int, (long int i)); -# endif -_GL_CXXALIAS_SYS (ffsl, int, (long int i)); -_GL_CXXALIASWARN (ffsl); -#elif defined GNULIB_POSIXCHECK -# undef ffsl -# if HAVE_RAW_DECL_FFSL -_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); -# endif -#endif - - -/* Find the index of the least-significant set bit. */ -#if @GNULIB_FFSLL@ -# if !@HAVE_FFSLL@ -_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); -# endif -_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); -_GL_CXXALIASWARN (ffsll); -#elif defined GNULIB_POSIXCHECK -# undef ffsll -# if HAVE_RAW_DECL_FFSLL -_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); -# endif -#endif - - -/* Return the first instance of C within N bytes of S, or NULL. */ -#if @GNULIB_MEMCHR@ -# if @REPLACE_MEMCHR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define memchr rpl_memchr -# endif -_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); -# else -# if ! @HAVE_MEMCHR@ -_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C" { const void * std::memchr (const void *, int, size_t); } - extern "C++" { void * std::memchr (void *, int, size_t); } */ -_GL_CXXALIAS_SYS_CAST2 (memchr, - void *, (void const *__s, int __c, size_t __n), - void const *, (void const *__s, int __c, size_t __n)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); -_GL_CXXALIASWARN1 (memchr, void const *, - (void const *__s, int __c, size_t __n)); -# else -_GL_CXXALIASWARN (memchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef memchr -/* Assume memchr is always declared. */ -_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " - "use gnulib module memchr for portability" ); -#endif - -/* Return the first occurrence of NEEDLE in HAYSTACK. */ -#if @GNULIB_MEMMEM@ -# if @REPLACE_MEMMEM@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define memmem rpl_memmem -# endif -_GL_FUNCDECL_RPL (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 3))); -_GL_CXXALIAS_RPL (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len)); -# else -# if ! @HAVE_DECL_MEMMEM@ -_GL_FUNCDECL_SYS (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 3))); -# endif -_GL_CXXALIAS_SYS (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len)); -# endif -_GL_CXXALIASWARN (memmem); -#elif defined GNULIB_POSIXCHECK -# undef memmem -# if HAVE_RAW_DECL_MEMMEM -_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " - "use gnulib module memmem-simple for portability, " - "and module memmem for speed" ); -# endif -#endif - -/* Copy N bytes of SRC to DEST, return pointer to bytes after the - last written byte. */ -#if @GNULIB_MEMPCPY@ -# if ! @HAVE_MEMPCPY@ -_GL_FUNCDECL_SYS (mempcpy, void *, - (void *restrict __dest, void const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (mempcpy, void *, - (void *restrict __dest, void const *restrict __src, - size_t __n)); -_GL_CXXALIASWARN (mempcpy); -#elif defined GNULIB_POSIXCHECK -# undef mempcpy -# if HAVE_RAW_DECL_MEMPCPY -_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " - "use gnulib module mempcpy for portability"); -# endif -#endif - -/* Search backwards through a block for a byte (specified as an int). */ -#if @GNULIB_MEMRCHR@ -# if ! @HAVE_DECL_MEMRCHR@ -_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const void * std::memrchr (const void *, int, size_t); } - extern "C++" { void * std::memrchr (void *, int, size_t); } */ -_GL_CXXALIAS_SYS_CAST2 (memrchr, - void *, (void const *, int, size_t), - void const *, (void const *, int, size_t)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); -_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); -# else -_GL_CXXALIASWARN (memrchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef memrchr -# if HAVE_RAW_DECL_MEMRCHR -_GL_WARN_ON_USE (memrchr, "memrchr is unportable - " - "use gnulib module memrchr for portability"); -# endif -#endif - -/* Find the first occurrence of C in S. More efficient than - memchr(S,C,N), at the expense of undefined behavior if C does not - occur within N bytes. */ -#if @GNULIB_RAWMEMCHR@ -# if ! @HAVE_RAWMEMCHR@ -_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const void * std::rawmemchr (const void *, int); } - extern "C++" { void * std::rawmemchr (void *, int); } */ -_GL_CXXALIAS_SYS_CAST2 (rawmemchr, - void *, (void const *__s, int __c_in), - void const *, (void const *__s, int __c_in)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); -_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); -# else -_GL_CXXALIASWARN (rawmemchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef rawmemchr -# if HAVE_RAW_DECL_RAWMEMCHR -_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " - "use gnulib module rawmemchr for portability"); -# endif -#endif - -/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ -#if @GNULIB_STPCPY@ -# if ! @HAVE_STPCPY@ -_GL_FUNCDECL_SYS (stpcpy, char *, - (char *restrict __dst, char const *restrict __src) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (stpcpy, char *, - (char *restrict __dst, char const *restrict __src)); -_GL_CXXALIASWARN (stpcpy); -#elif defined GNULIB_POSIXCHECK -# undef stpcpy -# if HAVE_RAW_DECL_STPCPY -_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " - "use gnulib module stpcpy for portability"); -# endif -#endif - -/* Copy no more than N bytes of SRC to DST, returning a pointer past the - last non-NUL byte written into DST. */ -#if @GNULIB_STPNCPY@ -# if @REPLACE_STPNCPY@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef stpncpy -# define stpncpy rpl_stpncpy -# endif -_GL_FUNCDECL_RPL (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n)); -# else -# if ! @HAVE_STPNCPY@ -_GL_FUNCDECL_SYS (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n)); -# endif -_GL_CXXALIASWARN (stpncpy); -#elif defined GNULIB_POSIXCHECK -# undef stpncpy -# if HAVE_RAW_DECL_STPNCPY -_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " - "use gnulib module stpncpy for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strchr() does not work with multibyte strings if the locale encoding is - GB18030 and the character to be searched is a digit. */ -# undef strchr -/* Assume strchr is always declared. */ -_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " - "in some multibyte locales - " - "use mbschr if you care about internationalization"); -#endif - -/* Find the first occurrence of C in S or the final NUL byte. */ -#if @GNULIB_STRCHRNUL@ -# if @REPLACE_STRCHRNUL@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strchrnul rpl_strchrnul -# endif -_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strchrnul, char *, - (const char *str, int ch)); -# else -# if ! @HAVE_STRCHRNUL@ -_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * std::strchrnul (const char *, int); } - extern "C++" { char * std::strchrnul (char *, int); } */ -_GL_CXXALIAS_SYS_CAST2 (strchrnul, - char *, (char const *__s, int __c_in), - char const *, (char const *__s, int __c_in)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); -_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); -# else -_GL_CXXALIASWARN (strchrnul); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strchrnul -# if HAVE_RAW_DECL_STRCHRNUL -_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " - "use gnulib module strchrnul for portability"); -# endif -#endif - -/* Duplicate S, returning an identical malloc'd string. */ -#if @GNULIB_STRDUP@ -# if @REPLACE_STRDUP@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strdup -# define strdup rpl_strdup -# endif -_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); -# else -# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup - /* strdup exists as a function and as a macro. Get rid of the macro. */ -# undef strdup -# endif -# if !(@HAVE_DECL_STRDUP@ || defined strdup) -_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); -# endif -_GL_CXXALIASWARN (strdup); -#elif defined GNULIB_POSIXCHECK -# undef strdup -# if HAVE_RAW_DECL_STRDUP -_GL_WARN_ON_USE (strdup, "strdup is unportable - " - "use gnulib module strdup for portability"); -# endif -#endif - -/* Append no more than N characters from SRC onto DEST. */ -#if @GNULIB_STRNCAT@ -# if @REPLACE_STRNCAT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strncat -# define strncat rpl_strncat -# endif -_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); -# else -_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); -# endif -_GL_CXXALIASWARN (strncat); -#elif defined GNULIB_POSIXCHECK -# undef strncat -# if HAVE_RAW_DECL_STRNCAT -_GL_WARN_ON_USE (strncat, "strncat is unportable - " - "use gnulib module strncat for portability"); -# endif -#endif - -/* Return a newly allocated copy of at most N bytes of STRING. */ -#if @GNULIB_STRNDUP@ -# if @REPLACE_STRNDUP@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strndup -# define strndup rpl_strndup -# endif -_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); -# else -# if ! @HAVE_DECL_STRNDUP@ -_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); -# endif -_GL_CXXALIASWARN (strndup); -#elif defined GNULIB_POSIXCHECK -# undef strndup -# if HAVE_RAW_DECL_STRNDUP -_GL_WARN_ON_USE (strndup, "strndup is unportable - " - "use gnulib module strndup for portability"); -# endif -#endif - -/* Find the length (number of bytes) of STRING, but scan at most - MAXLEN bytes. If no '\0' terminator is found in that many bytes, - return MAXLEN. */ -#if @GNULIB_STRNLEN@ -# if @REPLACE_STRNLEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strnlen -# define strnlen rpl_strnlen -# endif -_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); -# else -# if ! @HAVE_DECL_STRNLEN@ -_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); -# endif -_GL_CXXALIASWARN (strnlen); -#elif defined GNULIB_POSIXCHECK -# undef strnlen -# if HAVE_RAW_DECL_STRNLEN -_GL_WARN_ON_USE (strnlen, "strnlen is unportable - " - "use gnulib module strnlen for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strcspn() assumes the second argument is a list of single-byte characters. - Even in this simple case, it does not work with multibyte strings if the - locale encoding is GB18030 and one of the characters to be searched is a - digit. */ -# undef strcspn -/* Assume strcspn is always declared. */ -_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " - "in multibyte locales - " - "use mbscspn if you care about internationalization"); -#endif - -/* Find the first occurrence in S of any character in ACCEPT. */ -#if @GNULIB_STRPBRK@ -# if ! @HAVE_STRPBRK@ -_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C" { const char * strpbrk (const char *, const char *); } - extern "C++" { char * strpbrk (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strpbrk, - char *, (char const *__s, char const *__accept), - const char *, (char const *__s, char const *__accept)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); -_GL_CXXALIASWARN1 (strpbrk, char const *, - (char const *__s, char const *__accept)); -# else -_GL_CXXALIASWARN (strpbrk); -# endif -# if defined GNULIB_POSIXCHECK -/* strpbrk() assumes the second argument is a list of single-byte characters. - Even in this simple case, it does not work with multibyte strings if the - locale encoding is GB18030 and one of the characters to be searched is a - digit. */ -# undef strpbrk -_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " - "in multibyte locales - " - "use mbspbrk if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strpbrk -# if HAVE_RAW_DECL_STRPBRK -_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " - "use gnulib module strpbrk for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strspn() assumes the second argument is a list of single-byte characters. - Even in this simple case, it cannot work with multibyte strings. */ -# undef strspn -/* Assume strspn is always declared. */ -_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " - "in multibyte locales - " - "use mbsspn if you care about internationalization"); -#endif - -#if defined GNULIB_POSIXCHECK -/* strrchr() does not work with multibyte strings if the locale encoding is - GB18030 and the character to be searched is a digit. */ -# undef strrchr -/* Assume strrchr is always declared. */ -_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " - "in some multibyte locales - " - "use mbsrchr if you care about internationalization"); -#endif - -/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. - If one is found, overwrite it with a NUL, and advance *STRINGP - to point to the next char after it. Otherwise, set *STRINGP to NULL. - If *STRINGP was already NULL, nothing happens. - Return the old value of *STRINGP. - - This is a variant of strtok() that is multithread-safe and supports - empty fields. - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - Caveat: It doesn't work with multibyte strings unless all of the delimiter - characters are ASCII characters < 0x30. - - See also strtok_r(). */ -#if @GNULIB_STRSEP@ -# if ! @HAVE_STRSEP@ -_GL_FUNCDECL_SYS (strsep, char *, - (char **restrict __stringp, char const *restrict __delim) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (strsep, char *, - (char **restrict __stringp, char const *restrict __delim)); -_GL_CXXALIASWARN (strsep); -# if defined GNULIB_POSIXCHECK -# undef strsep -_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " - "in multibyte locales - " - "use mbssep if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strsep -# if HAVE_RAW_DECL_STRSEP -_GL_WARN_ON_USE (strsep, "strsep is unportable - " - "use gnulib module strsep for portability"); -# endif -#endif - -#if @GNULIB_STRSTR@ -# if @REPLACE_STRSTR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strstr rpl_strstr -# endif -_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); -# else - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * strstr (const char *, const char *); } - extern "C++" { char * strstr (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strstr, - char *, (const char *haystack, const char *needle), - const char *, (const char *haystack, const char *needle)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); -_GL_CXXALIASWARN1 (strstr, const char *, - (const char *haystack, const char *needle)); -# else -_GL_CXXALIASWARN (strstr); -# endif -#elif defined GNULIB_POSIXCHECK -/* strstr() does not work with multibyte strings if the locale encoding is - different from UTF-8: - POSIX says that it operates on "strings", and "string" in POSIX is defined - as a sequence of bytes, not of characters. */ -# undef strstr -/* Assume strstr is always declared. */ -_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " - "work correctly on character strings in most " - "multibyte locales - " - "use mbsstr if you care about internationalization, " - "or use strstr if you care about speed"); -#endif - -/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive - comparison. */ -#if @GNULIB_STRCASESTR@ -# if @REPLACE_STRCASESTR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strcasestr rpl_strcasestr -# endif -_GL_FUNCDECL_RPL (strcasestr, char *, - (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strcasestr, char *, - (const char *haystack, const char *needle)); -# else -# if ! @HAVE_STRCASESTR@ -_GL_FUNCDECL_SYS (strcasestr, char *, - (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * strcasestr (const char *, const char *); } - extern "C++" { char * strcasestr (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strcasestr, - char *, (const char *haystack, const char *needle), - const char *, (const char *haystack, const char *needle)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); -_GL_CXXALIASWARN1 (strcasestr, const char *, - (const char *haystack, const char *needle)); -# else -_GL_CXXALIASWARN (strcasestr); -# endif -#elif defined GNULIB_POSIXCHECK -/* strcasestr() does not work with multibyte strings: - It is a glibc extension, and glibc implements it only for unibyte - locales. */ -# undef strcasestr -# if HAVE_RAW_DECL_STRCASESTR -_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " - "strings in multibyte locales - " - "use mbscasestr if you care about " - "internationalization, or use c-strcasestr if you want " - "a locale independent function"); -# endif -#endif - -/* Parse S into tokens separated by characters in DELIM. - If S is NULL, the saved pointer in SAVE_PTR is used as - the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = strtok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" - - This is a variant of strtok() that is multithread-safe. - - For the POSIX documentation for this function, see: - http://www.opengroup.org/susv3xsh/strtok.html - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - Caveat: It doesn't work with multibyte strings unless all of the delimiter - characters are ASCII characters < 0x30. - - See also strsep(). */ -#if @GNULIB_STRTOK_R@ -# if @REPLACE_STRTOK_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strtok_r -# define strtok_r rpl_strtok_r -# endif -_GL_FUNCDECL_RPL (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr) - _GL_ARG_NONNULL ((2, 3))); -_GL_CXXALIAS_RPL (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr)); -# else -# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK -# undef strtok_r -# endif -# if ! @HAVE_DECL_STRTOK_R@ -_GL_FUNCDECL_SYS (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr) - _GL_ARG_NONNULL ((2, 3))); -# endif -_GL_CXXALIAS_SYS (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr)); -# endif -_GL_CXXALIASWARN (strtok_r); -# if defined GNULIB_POSIXCHECK -_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " - "strings in multibyte locales - " - "use mbstok_r if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strtok_r -# if HAVE_RAW_DECL_STRTOK_R -_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " - "use gnulib module strtok_r for portability"); -# endif -#endif - - -/* The following functions are not specified by POSIX. They are gnulib - extensions. */ - -#if @GNULIB_MBSLEN@ -/* Return the number of multibyte characters in the character string STRING. - This considers multibyte characters, unlike strlen, which counts bytes. */ -# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ -# undef mbslen -# endif -# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbslen rpl_mbslen -# endif -_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); -# else -_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); -# endif -_GL_CXXALIASWARN (mbslen); -#endif - -#if @GNULIB_MBSNLEN@ -/* Return the number of multibyte characters in the character string starting - at STRING and ending at STRING + LEN. */ -_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1)); -#endif - -#if @GNULIB_MBSCHR@ -/* Locate the first single-byte character C in the character string STRING, - and return a pointer to it. Return NULL if C is not found in STRING. - Unlike strchr(), this function works correctly in multibyte locales with - encodings such as GB18030. */ -# if defined __hpux -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ -# endif -_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); -# else -_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); -# endif -_GL_CXXALIASWARN (mbschr); -#endif - -#if @GNULIB_MBSRCHR@ -/* Locate the last single-byte character C in the character string STRING, - and return a pointer to it. Return NULL if C is not found in STRING. - Unlike strrchr(), this function works correctly in multibyte locales with - encodings such as GB18030. */ -# if defined __hpux || defined __INTERIX -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ -# endif -_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); -# else -_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); -# endif -_GL_CXXALIASWARN (mbsrchr); -#endif - -#if @GNULIB_MBSSTR@ -/* Find the first occurrence of the character string NEEDLE in the character - string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. - Unlike strstr(), this function works correctly in multibyte locales with - encodings different from UTF-8. */ -_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSCASECMP@ -/* Compare the character strings S1 and S2, ignoring case, returning less than, - equal to or greater than zero if S1 is lexicographically less than, equal to - or greater than S2. - Note: This function may, in multibyte locales, return 0 for strings of - different lengths! - Unlike strcasecmp(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSNCASECMP@ -/* Compare the initial segment of the character string S1 consisting of at most - N characters with the initial segment of the character string S2 consisting - of at most N characters, ignoring case, returning less than, equal to or - greater than zero if the initial segment of S1 is lexicographically less - than, equal to or greater than the initial segment of S2. - Note: This function may, in multibyte locales, return 0 for initial segments - of different lengths! - Unlike strncasecmp(), this function works correctly in multibyte locales. - But beware that N is not a byte count but a character count! */ -_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSPCASECMP@ -/* Compare the initial segment of the character string STRING consisting of - at most mbslen (PREFIX) characters with the character string PREFIX, - ignoring case. If the two match, return a pointer to the first byte - after this prefix in STRING. Otherwise, return NULL. - Note: This function may, in multibyte locales, return non-NULL if STRING - is of smaller length than PREFIX! - Unlike strncasecmp(), this function works correctly in multibyte - locales. */ -_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSCASESTR@ -/* Find the first occurrence of the character string NEEDLE in the character - string HAYSTACK, using case-insensitive comparison. - Note: This function may, in multibyte locales, return success even if - strlen (haystack) < strlen (needle) ! - Unlike strcasestr(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSCSPN@ -/* Find the first occurrence in the character string STRING of any character - in the character string ACCEPT. Return the number of bytes from the - beginning of the string to this occurrence, or to the end of the string - if none exists. - Unlike strcspn(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSPBRK@ -/* Find the first occurrence in the character string STRING of any character - in the character string ACCEPT. Return the pointer to it, or NULL if none - exists. - Unlike strpbrk(), this function works correctly in multibyte locales. */ -# if defined __hpux -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ -# endif -_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); -# else -_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); -# endif -_GL_CXXALIASWARN (mbspbrk); -#endif - -#if @GNULIB_MBSSPN@ -/* Find the first occurrence in the character string STRING of any character - not in the character string REJECT. Return the number of bytes from the - beginning of the string to this occurrence, or to the end of the string - if none exists. - Unlike strspn(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSSEP@ -/* Search the next delimiter (multibyte character listed in the character - string DELIM) starting at the character string *STRINGP. - If one is found, overwrite it with a NUL, and advance *STRINGP to point - to the next multibyte character after it. Otherwise, set *STRINGP to NULL. - If *STRINGP was already NULL, nothing happens. - Return the old value of *STRINGP. - - This is a variant of mbstok_r() that supports empty fields. - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - - See also mbstok_r(). */ -_GL_EXTERN_C char * mbssep (char **stringp, const char *delim) - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if @GNULIB_MBSTOK_R@ -/* Parse the character string STRING into tokens separated by characters in - the character string DELIM. - If STRING is NULL, the saved pointer in SAVE_PTR is used as - the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = mbstok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - - See also mbssep(). */ -_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) - _GL_ARG_NONNULL ((2, 3)); -#endif - -/* Map any int, typically from errno, into an error message. */ -#if @GNULIB_STRERROR@ -# if @REPLACE_STRERROR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strerror -# define strerror rpl_strerror -# endif -_GL_FUNCDECL_RPL (strerror, char *, (int)); -_GL_CXXALIAS_RPL (strerror, char *, (int)); -# else -_GL_CXXALIAS_SYS (strerror, char *, (int)); -# endif -_GL_CXXALIASWARN (strerror); -#elif defined GNULIB_POSIXCHECK -# undef strerror -/* Assume strerror is always declared. */ -_GL_WARN_ON_USE (strerror, "strerror is unportable - " - "use gnulib module strerror to guarantee non-NULL result"); -#endif - -/* Map any int, typically from errno, into an error message. Multithread-safe. - Uses the POSIX declaration, not the glibc declaration. */ -#if @GNULIB_STRERROR_R@ -# if @REPLACE_STRERROR_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strerror_r -# define strerror_r rpl_strerror_r -# endif -_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); -# else -# if !@HAVE_DECL_STRERROR_R@ -_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); -# endif -# if @HAVE_DECL_STRERROR_R@ -_GL_CXXALIASWARN (strerror_r); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strerror_r -# if HAVE_RAW_DECL_STRERROR_R -_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " - "use gnulib module strerror_r-posix for portability"); -# endif -#endif - -#if @GNULIB_STRSIGNAL@ -# if @REPLACE_STRSIGNAL@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strsignal rpl_strsignal -# endif -_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); -_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); -# else -# if ! @HAVE_DECL_STRSIGNAL@ -_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); -# endif -/* Need to cast, because on Cygwin 1.5.x systems, the return type is - 'const char *'. */ -_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); -# endif -_GL_CXXALIASWARN (strsignal); -#elif defined GNULIB_POSIXCHECK -# undef strsignal -# if HAVE_RAW_DECL_STRSIGNAL -_GL_WARN_ON_USE (strsignal, "strsignal is unportable - " - "use gnulib module strsignal for portability"); -# endif -#endif - -#if @GNULIB_STRVERSCMP@ -# if !@HAVE_STRVERSCMP@ -_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); -_GL_CXXALIASWARN (strverscmp); -#elif defined GNULIB_POSIXCHECK -# undef strverscmp -# if HAVE_RAW_DECL_STRVERSCMP -_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " - "use gnulib module strverscmp for portability"); -# endif -#endif - - -#endif /* _@GUARD_PREFIX@_STRING_H */ -#endif /* _@GUARD_PREFIX@_STRING_H */ diff --git a/grub-core/gnulib/strings.in.h b/grub-core/gnulib/strings.in.h deleted file mode 100644 index 4469f86ca..000000000 --- a/grub-core/gnulib/strings.in.h +++ /dev/null @@ -1,122 +0,0 @@ -/* A substitute . - - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _@GUARD_PREFIX@_STRINGS_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* Minix 3.1.8 has a bug: must be included before . - But avoid namespace pollution on glibc systems. */ -#if defined __minix && !defined __GLIBC__ -# include -#endif - -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_STRINGS_H@ -# @INCLUDE_NEXT@ @NEXT_STRINGS_H@ -#endif - -#ifndef _@GUARD_PREFIX@_STRINGS_H -#define _@GUARD_PREFIX@_STRINGS_H - -#if ! @HAVE_DECL_STRNCASECMP@ -/* Get size_t. */ -# include -#endif - - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -#ifdef __cplusplus -extern "C" { -#endif - - - /* Find the index of the least-significant set bit. */ -#if @GNULIB_FFS@ -# if !@HAVE_FFS@ -_GL_FUNCDECL_SYS (ffs, int, (int i)); -# endif -_GL_CXXALIAS_SYS (ffs, int, (int i)); -_GL_CXXALIASWARN (ffs); -#elif defined GNULIB_POSIXCHECK -# undef ffs -# if HAVE_RAW_DECL_FFS -_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); -# endif -#endif - -/* Compare strings S1 and S2, ignoring case, returning less than, equal to or - greater than zero if S1 is lexicographically less than, equal to or greater - than S2. - Note: This function does not work in multibyte locales. */ -#if ! @HAVE_STRCASECMP@ -extern int strcasecmp (char const *s1, char const *s2) - _GL_ARG_NONNULL ((1, 2)); -#endif -#if defined GNULIB_POSIXCHECK -/* strcasecmp() does not work with multibyte strings: - POSIX says that it operates on "strings", and "string" in POSIX is defined - as a sequence of bytes, not of characters. */ -# undef strcasecmp -# if HAVE_RAW_DECL_STRCASECMP -_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " - "strings in multibyte locales - " - "use mbscasecmp if you care about " - "internationalization, or use c_strcasecmp , " - "gnulib module c-strcase) if you want a locale " - "independent function"); -# endif -#endif - -/* Compare no more than N bytes of strings S1 and S2, ignoring case, - returning less than, equal to or greater than zero if S1 is - lexicographically less than, equal to or greater than S2. - Note: This function cannot work correctly in multibyte locales. */ -#if ! @HAVE_DECL_STRNCASECMP@ -extern int strncasecmp (char const *s1, char const *s2, size_t n) - _GL_ARG_NONNULL ((1, 2)); -#endif -#if defined GNULIB_POSIXCHECK -/* strncasecmp() does not work with multibyte strings: - POSIX says that it operates on "strings", and "string" in POSIX is defined - as a sequence of bytes, not of characters. */ -# undef strncasecmp -# if HAVE_RAW_DECL_STRNCASECMP -_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " - "strings in multibyte locales - " - "use mbsncasecmp or mbspcasecmp if you care about " - "internationalization, or use c_strncasecmp , " - "gnulib module c-strcase) if you want a locale " - "independent function"); -# endif -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _@GUARD_PREFIX@_STRING_H */ -#endif /* _@GUARD_PREFIX@_STRING_H */ diff --git a/grub-core/gnulib/stripslash.c b/grub-core/gnulib/stripslash.c deleted file mode 100644 index 0e452a95e..000000000 --- a/grub-core/gnulib/stripslash.c +++ /dev/null @@ -1,45 +0,0 @@ -/* stripslash.c -- remove redundant trailing slashes from a file name - - Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation, - Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include "dirname.h" - -/* Remove trailing slashes from FILE. Return true if a trailing slash - was removed. This is useful when using file name completion from a - shell that adds a "/" after directory names (such as tcsh and - bash), because on symlinks to directories, several system calls - have different semantics according to whether a trailing slash is - present. */ - -bool -strip_trailing_slashes (char *file) -{ - char *base = last_component (file); - char *base_lim; - bool had_slash; - - /* last_component returns "" for file system roots, but we need to turn - "///" into "/". */ - if (! *base) - base = file; - base_lim = base + base_len (base); - had_slash = (*base_lim != '\0'); - *base_lim = '\0'; - return had_slash; -} diff --git a/grub-core/gnulib/strncasecmp.c b/grub-core/gnulib/strncasecmp.c deleted file mode 100644 index 35840bc01..000000000 --- a/grub-core/gnulib/strncasecmp.c +++ /dev/null @@ -1,62 +0,0 @@ -/* strncasecmp.c -- case insensitive string comparator - Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) - -/* Compare no more than N bytes of strings S1 and S2, ignoring case, - returning less than, equal to or greater than zero if S1 is - lexicographically less than, equal to or greater than S2. - Note: This function cannot work correctly in multibyte locales. */ - -int -strncasecmp (const char *s1, const char *s2, size_t n) -{ - register const unsigned char *p1 = (const unsigned char *) s1; - register const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2 || n == 0) - return 0; - - do - { - c1 = TOLOWER (*p1); - c2 = TOLOWER (*p2); - - if (--n == 0 || c1 == '\0') - break; - - ++p1; - ++p2; - } - while (c1 == c2); - - if (UCHAR_MAX <= INT_MAX) - return c1 - c2; - else - /* On machines where 'char' and 'int' are types of the same size, the - difference of two 'unsigned char' values - including the sign bit - - doesn't fit in an 'int'. */ - return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); -} diff --git a/grub-core/gnulib/strndup.c b/grub-core/gnulib/strndup.c deleted file mode 100644 index e60268b86..000000000 --- a/grub-core/gnulib/strndup.c +++ /dev/null @@ -1,36 +0,0 @@ -/* A replacement function, for systems that lack strndup. - - Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2013 Free Software - Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#include - -#include - -#include - -char * -strndup (char const *s, size_t n) -{ - size_t len = strnlen (s, n); - char *new = malloc (len + 1); - - if (new == NULL) - return NULL; - - new[len] = '\0'; - return memcpy (new, s, len); -} diff --git a/grub-core/gnulib/strnlen.c b/grub-core/gnulib/strnlen.c deleted file mode 100644 index 57fdfe770..000000000 --- a/grub-core/gnulib/strnlen.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. - Written by Simon Josefsson. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#include - -#include - -/* Find the length of STRING, but scan at most MAXLEN characters. - If no '\0' terminator is found in that many characters, return MAXLEN. */ - -size_t -strnlen (const char *string, size_t maxlen) -{ - const char *end = memchr (string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; -} diff --git a/grub-core/gnulib/strnlen1.c b/grub-core/gnulib/strnlen1.c deleted file mode 100644 index 0c22d21ed..000000000 --- a/grub-core/gnulib/strnlen1.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include "strnlen1.h" - -#include - -/* Find the length of STRING + 1, but scan at most MAXLEN bytes. - If no '\0' terminator is found in that many characters, return MAXLEN. */ -/* This is the same as strnlen (string, maxlen - 1) + 1. */ -size_t -strnlen1 (const char *string, size_t maxlen) -{ - const char *end = (const char *) memchr (string, '\0', maxlen); - if (end != NULL) - return end - string + 1; - else - return maxlen; -} diff --git a/grub-core/gnulib/strnlen1.h b/grub-core/gnulib/strnlen1.h deleted file mode 100644 index 7c65e3161..000000000 --- a/grub-core/gnulib/strnlen1.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _STRNLEN1_H -#define _STRNLEN1_H - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Find the length of STRING + 1, but scan at most MAXLEN bytes. - If no '\0' terminator is found in that many characters, return MAXLEN. */ -/* This is the same as strnlen (string, maxlen - 1) + 1. */ -extern size_t strnlen1 (const char *string, size_t maxlen) - _GL_ATTRIBUTE_PURE; - - -#ifdef __cplusplus -} -#endif - - -#endif /* _STRNLEN1_H */ diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h deleted file mode 100644 index d7da35623..000000000 --- a/grub-core/gnulib/sys_types.in.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Provide a more complete sys/types.h. - - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#ifndef _@GUARD_PREFIX@_SYS_TYPES_H - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ - -#ifndef _@GUARD_PREFIX@_SYS_TYPES_H -#define _@GUARD_PREFIX@_SYS_TYPES_H - -/* Override off_t if Large File Support is requested on native Windows. */ -#if @WINDOWS_64_BIT_OFF_T@ -/* Same as int64_t in . */ -# if defined _MSC_VER -# define off_t __int64 -# else -# define off_t long long int -# endif -/* Indicator, for gnulib internal purposes. */ -# define _GL_WINDOWS_64_BIT_OFF_T 1 -#endif - -/* MSVC 9 defines size_t in , not in . */ -/* But avoid namespace pollution on glibc systems. */ -#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \ - && ! defined __GLIBC__ -# include -#endif - -#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ -#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ diff --git a/grub-core/gnulib/sysexits.in.h b/grub-core/gnulib/sysexits.in.h deleted file mode 100644 index fa8db8386..000000000 --- a/grub-core/gnulib/sysexits.in.h +++ /dev/null @@ -1,72 +0,0 @@ -/* exit() exit codes for some BSD system programs. - Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Simon Josefsson based on sysexits(3) man page */ - -#ifndef _@GUARD_PREFIX@_SYSEXITS_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if @HAVE_SYSEXITS_H@ - -/* IRIX 6.5 has an that defines a macro EX_OK with a nonzero - value. Override it. See - */ -# ifdef __sgi -# include -# undef EX_OK -# endif - -/* The include_next requires a split double-inclusion guard. */ -# @INCLUDE_NEXT@ @NEXT_SYSEXITS_H@ - -/* HP-UX 11 ends at EX_NOPERM. */ -# ifndef EX_CONFIG -# define EX_CONFIG 78 -# endif - -#endif - -#ifndef _@GUARD_PREFIX@_SYSEXITS_H -#define _@GUARD_PREFIX@_SYSEXITS_H - -#if !@HAVE_SYSEXITS_H@ - -# define EX_OK 0 /* same value as EXIT_SUCCESS */ - -# define EX_USAGE 64 -# define EX_DATAERR 65 -# define EX_NOINPUT 66 -# define EX_NOUSER 67 -# define EX_NOHOST 68 -# define EX_UNAVAILABLE 69 -# define EX_SOFTWARE 70 -# define EX_OSERR 71 -# define EX_OSFILE 72 -# define EX_CANTCREAT 73 -# define EX_IOERR 74 -# define EX_TEMPFAIL 75 -# define EX_PROTOCOL 76 -# define EX_NOPERM 77 -# define EX_CONFIG 78 - -#endif - -#endif /* _@GUARD_PREFIX@_SYSEXITS_H */ -#endif /* _@GUARD_PREFIX@_SYSEXITS_H */ diff --git a/grub-core/gnulib/unistd.c b/grub-core/gnulib/unistd.c deleted file mode 100644 index 6c6a8e268..000000000 --- a/grub-core/gnulib/unistd.c +++ /dev/null @@ -1,3 +0,0 @@ -#include -#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE -#include "unistd.h" diff --git a/grub-core/gnulib/unistd.in.h b/grub-core/gnulib/unistd.in.h deleted file mode 100644 index 2ea9af436..000000000 --- a/grub-core/gnulib/unistd.in.h +++ /dev/null @@ -1,1530 +0,0 @@ -/* Substitute for and wrapper around . - Copyright (C) 2003-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _@GUARD_PREFIX@_UNISTD_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_UNISTD_H@ -# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ -#endif - -/* Get all possible declarations of gethostname(). */ -#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ - && !defined _GL_INCLUDING_WINSOCK2_H -# define _GL_INCLUDING_WINSOCK2_H -# include -# undef _GL_INCLUDING_WINSOCK2_H -#endif - -#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H -#define _@GUARD_PREFIX@_UNISTD_H - -/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ -#include - -/* mingw doesn't define the SEEK_* or *_FILENO macros in . */ -/* Cygwin 1.7.1 declares symlinkat in , not in . */ -/* But avoid namespace pollution on glibc systems. */ -#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ - || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ - && defined __CYGWIN__)) \ - && ! defined __GLIBC__ -# include -#endif - -/* Cygwin 1.7.1 declares unlinkat in , not in . */ -/* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ - && ! defined __GLIBC__ -# include -#endif - -/* mingw fails to declare _exit in . */ -/* mingw, MSVC, BeOS, Haiku declare environ in , not in - . */ -/* Solaris declares getcwd not only in but also in . */ -/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system is - included here. */ -/* But avoid namespace pollution on glibc systems. */ -#if !defined __GLIBC__ && !defined __osf__ -# define __need_system_stdlib_h -# include -# undef __need_system_stdlib_h -#endif - -/* Native Windows platforms declare chdir, getcwd, rmdir in - and/or , not in . - They also declare access(), chmod(), close(), dup(), dup2(), isatty(), - lseek(), read(), unlink(), write() in . */ -#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ - || defined GNULIB_POSIXCHECK) \ - && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) -# include /* mingw32, mingw64 */ -# include /* mingw64, MSVC 9 */ -#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \ - || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \ - || defined GNULIB_POSIXCHECK) \ - && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -# include -#endif - -/* AIX and OSF/1 5.1 declare getdomainname in , not in . - NonStop Kernel declares gethostname in , not in . */ -/* But avoid namespace pollution on glibc systems. */ -#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ - || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ - && !defined __GLIBC__ -# include -#endif - -/* MSVC defines off_t in . - May also define off_t to a 64-bit type on native Windows. */ -#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ -/* Get off_t. */ -# include -#endif - -#if (@GNULIB_READ@ || @GNULIB_WRITE@ \ - || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ - || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) -/* Get ssize_t. */ -# include -#endif - -/* Get getopt(), optarg, optind, opterr, optopt. - But avoid namespace pollution on glibc systems. */ -#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT -# define __need_getopt -# include -#endif - -_GL_INLINE_HEADER_BEGIN -#ifndef _GL_UNISTD_INLINE -# define _GL_UNISTD_INLINE _GL_INLINE -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - - -/* Hide some function declarations from . */ - -#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ -# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef socket -# define socket socket_used_without_including_sys_socket_h -# undef connect -# define connect connect_used_without_including_sys_socket_h -# undef accept -# define accept accept_used_without_including_sys_socket_h -# undef bind -# define bind bind_used_without_including_sys_socket_h -# undef getpeername -# define getpeername getpeername_used_without_including_sys_socket_h -# undef getsockname -# define getsockname getsockname_used_without_including_sys_socket_h -# undef getsockopt -# define getsockopt getsockopt_used_without_including_sys_socket_h -# undef listen -# define listen listen_used_without_including_sys_socket_h -# undef recv -# define recv recv_used_without_including_sys_socket_h -# undef send -# define send send_used_without_including_sys_socket_h -# undef recvfrom -# define recvfrom recvfrom_used_without_including_sys_socket_h -# undef sendto -# define sendto sendto_used_without_including_sys_socket_h -# undef setsockopt -# define setsockopt setsockopt_used_without_including_sys_socket_h -# undef shutdown -# define shutdown shutdown_used_without_including_sys_socket_h -# else - _GL_WARN_ON_USE (socket, - "socket() used without including "); - _GL_WARN_ON_USE (connect, - "connect() used without including "); - _GL_WARN_ON_USE (accept, - "accept() used without including "); - _GL_WARN_ON_USE (bind, - "bind() used without including "); - _GL_WARN_ON_USE (getpeername, - "getpeername() used without including "); - _GL_WARN_ON_USE (getsockname, - "getsockname() used without including "); - _GL_WARN_ON_USE (getsockopt, - "getsockopt() used without including "); - _GL_WARN_ON_USE (listen, - "listen() used without including "); - _GL_WARN_ON_USE (recv, - "recv() used without including "); - _GL_WARN_ON_USE (send, - "send() used without including "); - _GL_WARN_ON_USE (recvfrom, - "recvfrom() used without including "); - _GL_WARN_ON_USE (sendto, - "sendto() used without including "); - _GL_WARN_ON_USE (setsockopt, - "setsockopt() used without including "); - _GL_WARN_ON_USE (shutdown, - "shutdown() used without including "); -# endif -# endif -# if !defined _@GUARD_PREFIX@_SYS_SELECT_H -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef select -# define select select_used_without_including_sys_select_h -# else - _GL_WARN_ON_USE (select, - "select() used without including "); -# endif -# endif -#endif - - -/* OS/2 EMX lacks these macros. */ -#ifndef STDIN_FILENO -# define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -# define STDOUT_FILENO 1 -#endif -#ifndef STDERR_FILENO -# define STDERR_FILENO 2 -#endif - -/* Ensure *_OK macros exist. */ -#ifndef F_OK -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 -#endif - - -/* Declare overridden functions. */ - - -#if defined GNULIB_POSIXCHECK -/* The access() function is a security risk. */ -_GL_WARN_ON_USE (access, "the access function is a security risk - " - "use the gnulib module faccessat instead"); -#endif - - -#if @GNULIB_CHDIR@ -_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); -_GL_CXXALIASWARN (chdir); -#elif defined GNULIB_POSIXCHECK -# undef chdir -# if HAVE_RAW_DECL_CHDIR -_GL_WARN_ON_USE (chown, "chdir is not always in - " - "use gnulib module chdir for portability"); -# endif -#endif - - -#if @GNULIB_CHOWN@ -/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE - to GID (if GID is not -1). Follow symbolic links. - Return 0 if successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if @REPLACE_DUP2@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define dup2 rpl_dup2 -# endif -_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); -_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); -# else -# if !@HAVE_DUP2@ -_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); -# endif -_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); -# endif -_GL_CXXALIASWARN (dup2); -#elif defined GNULIB_POSIXCHECK -# undef dup2 -# if HAVE_RAW_DECL_DUP2 -_GL_WARN_ON_USE (dup2, "dup2 is unportable - " - "use gnulib module dup2 for portability"); -# endif -#endif - - -#if @GNULIB_DUP3@ -/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the - specified flags. - The flags are a bitmask, possibly including O_CLOEXEC (defined in ) - and O_TEXT, O_BINARY (defined in "binary-io.h"). - Close NEWFD first if it is open. - Return newfd if successful, otherwise -1 and errno set. - See the Linux man page at - . */ -# if @HAVE_DUP3@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define dup3 rpl_dup3 -# endif -_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); -_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); -# else -_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); -_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); -# endif -_GL_CXXALIASWARN (dup3); -#elif defined GNULIB_POSIXCHECK -# undef dup3 -# if HAVE_RAW_DECL_DUP3 -_GL_WARN_ON_USE (dup3, "dup3 is unportable - " - "use gnulib module dup3 for portability"); -# endif -#endif - - -#if @GNULIB_ENVIRON@ -# if !@HAVE_DECL_ENVIRON@ -/* Set of environment variables and values. An array of strings of the form - "VARIABLE=VALUE", terminated with a NULL. */ -# if defined __APPLE__ && defined __MACH__ -# include -# define environ (*_NSGetEnviron ()) -# else -# ifdef __cplusplus -extern "C" { -# endif -extern char **environ; -# ifdef __cplusplus -} -# endif -# endif -# endif -#elif defined GNULIB_POSIXCHECK -# if HAVE_RAW_DECL_ENVIRON -_GL_UNISTD_INLINE char *** -rpl_environ (void) -{ - return &environ; -} -_GL_WARN_ON_USE (rpl_environ, "environ is unportable - " - "use gnulib module environ for portability"); -# undef environ -# define environ (*rpl_environ ()) -# endif -#endif - - -#if @GNULIB_EUIDACCESS@ -/* Like access(), except that it uses the effective user id and group id of - the current process. */ -# if !@HAVE_EUIDACCESS@ -_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); -_GL_CXXALIASWARN (euidaccess); -# if defined GNULIB_POSIXCHECK -/* Like access(), this function is a security risk. */ -_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - " - "use the gnulib module faccessat instead"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef euidaccess -# if HAVE_RAW_DECL_EUIDACCESS -_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " - "use gnulib module euidaccess for portability"); -# endif -#endif - - -#if @GNULIB_FACCESSAT@ -# if !@HAVE_FACCESSAT@ -_GL_FUNCDECL_SYS (faccessat, int, - (int fd, char const *file, int mode, int flag) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (faccessat, int, - (int fd, char const *file, int mode, int flag)); -_GL_CXXALIASWARN (faccessat); -#elif defined GNULIB_POSIXCHECK -# undef faccessat -# if HAVE_RAW_DECL_FACCESSAT -_GL_WARN_ON_USE (faccessat, "faccessat is not portable - " - "use gnulib module faccessat for portability"); -# endif -#endif - - -#if @GNULIB_FCHDIR@ -/* Change the process' current working directory to the directory on which - the given file descriptor is open. - Return 0 if successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if ! @HAVE_FCHDIR@ -_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); - -/* Gnulib internal hooks needed to maintain the fchdir metadata. */ -_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) - _GL_ARG_NONNULL ((2)); -_GL_EXTERN_C void _gl_unregister_fd (int fd); -_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); -_GL_EXTERN_C const char *_gl_directory_name (int fd); - -# else -# if !@HAVE_DECL_FCHDIR@ -_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); -# endif -# endif -_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); -_GL_CXXALIASWARN (fchdir); -#elif defined GNULIB_POSIXCHECK -# undef fchdir -# if HAVE_RAW_DECL_FCHDIR -_GL_WARN_ON_USE (fchdir, "fchdir is unportable - " - "use gnulib module fchdir for portability"); -# endif -#endif - - -#if @GNULIB_FCHOWNAT@ -# if @REPLACE_FCHOWNAT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fchownat -# define fchownat rpl_fchownat -# endif -_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag)); -# else -# if !@HAVE_FCHOWNAT@ -_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, - uid_t owner, gid_t group, int flag)); -# endif -_GL_CXXALIASWARN (fchownat); -#elif defined GNULIB_POSIXCHECK -# undef fchownat -# if HAVE_RAW_DECL_FCHOWNAT -_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " - "use gnulib module openat for portability"); -# endif -#endif - - -#if @GNULIB_FDATASYNC@ -/* Synchronize changes to a file. - Return 0 if successful, otherwise -1 and errno set. - See POSIX:2008 specification - . */ -# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ -_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); -# endif -_GL_CXXALIAS_SYS (fdatasync, int, (int fd)); -_GL_CXXALIASWARN (fdatasync); -#elif defined GNULIB_POSIXCHECK -# undef fdatasync -# if HAVE_RAW_DECL_FDATASYNC -_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " - "use gnulib module fdatasync for portability"); -# endif -#endif - - -#if @GNULIB_FSYNC@ -/* Synchronize changes, including metadata, to a file. - Return 0 if successful, otherwise -1 and errno set. - See POSIX:2008 specification - . */ -# if !@HAVE_FSYNC@ -_GL_FUNCDECL_SYS (fsync, int, (int fd)); -# endif -_GL_CXXALIAS_SYS (fsync, int, (int fd)); -_GL_CXXALIASWARN (fsync); -#elif defined GNULIB_POSIXCHECK -# undef fsync -# if HAVE_RAW_DECL_FSYNC -_GL_WARN_ON_USE (fsync, "fsync is unportable - " - "use gnulib module fsync for portability"); -# endif -#endif - - -#if @GNULIB_FTRUNCATE@ -/* Change the size of the file to which FD is opened to become equal to LENGTH. - Return 0 if successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if @REPLACE_FTRUNCATE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ftruncate -# define ftruncate rpl_ftruncate -# endif -_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length)); -_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length)); -# else -# if !@HAVE_FTRUNCATE@ -_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); -# endif -_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); -# endif -_GL_CXXALIASWARN (ftruncate); -#elif defined GNULIB_POSIXCHECK -# undef ftruncate -# if HAVE_RAW_DECL_FTRUNCATE -_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " - "use gnulib module ftruncate for portability"); -# endif -#endif - - -#if @GNULIB_GETCWD@ -/* Get the name of the current working directory, and put it in SIZE bytes - of BUF. - Return BUF if successful, or NULL if the directory couldn't be determined - or SIZE was too small. - See the POSIX:2008 specification - . - Additionally, the gnulib module 'getcwd' guarantees the following GNU - extension: If BUF is NULL, an array is allocated with 'malloc'; the array - is SIZE bytes long, unless SIZE == 0, in which case it is as big as - necessary. */ -# if @REPLACE_GETCWD@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define getcwd rpl_getcwd -# endif -_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); -_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); -# else -/* Need to cast, because on mingw, the second parameter is - int size. */ -_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); -# endif -_GL_CXXALIASWARN (getcwd); -#elif defined GNULIB_POSIXCHECK -# undef getcwd -# if HAVE_RAW_DECL_GETCWD -_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " - "use gnulib module getcwd for portability"); -# endif -#endif - - -#if @GNULIB_GETDOMAINNAME@ -/* Return the NIS domain name of the machine. - WARNING! The NIS domain name is unrelated to the fully qualified host name - of the machine. It is also unrelated to email addresses. - WARNING! The NIS domain name is usually the empty string or "(none)" when - not using NIS. - - Put up to LEN bytes of the NIS domain name into NAME. - Null terminate it if the name is shorter than LEN. - If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. - Return 0 if successful, otherwise set errno and return -1. */ -# if @REPLACE_GETDOMAINNAME@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getdomainname -# define getdomainname rpl_getdomainname -# endif -_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); -# else -# if !@HAVE_DECL_GETDOMAINNAME@ -_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); -# endif -_GL_CXXALIASWARN (getdomainname); -#elif defined GNULIB_POSIXCHECK -# undef getdomainname -# if HAVE_RAW_DECL_GETDOMAINNAME -_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " - "use gnulib module getdomainname for portability"); -# endif -#endif - - -#if @GNULIB_GETDTABLESIZE@ -/* Return the maximum number of file descriptors in the current process. - In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ -# if !@HAVE_GETDTABLESIZE@ -_GL_FUNCDECL_SYS (getdtablesize, int, (void)); -# endif -_GL_CXXALIAS_SYS (getdtablesize, int, (void)); -_GL_CXXALIASWARN (getdtablesize); -#elif defined GNULIB_POSIXCHECK -# undef getdtablesize -# if HAVE_RAW_DECL_GETDTABLESIZE -_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " - "use gnulib module getdtablesize for portability"); -# endif -#endif - - -#if @GNULIB_GETGROUPS@ -/* Return the supplemental groups that the current process belongs to. - It is unspecified whether the effective group id is in the list. - If N is 0, return the group count; otherwise, N describes how many - entries are available in GROUPS. Return -1 and set errno if N is - not 0 and not large enough. Fails with ENOSYS on some systems. */ -# if @REPLACE_GETGROUPS@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getgroups -# define getgroups rpl_getgroups -# endif -_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); -_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); -# else -# if !@HAVE_GETGROUPS@ -_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); -# endif -_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); -# endif -_GL_CXXALIASWARN (getgroups); -#elif defined GNULIB_POSIXCHECK -# undef getgroups -# if HAVE_RAW_DECL_GETGROUPS -_GL_WARN_ON_USE (getgroups, "getgroups is unportable - " - "use gnulib module getgroups for portability"); -# endif -#endif - - -#if @GNULIB_GETHOSTNAME@ -/* Return the standard host name of the machine. - WARNING! The host name may or may not be fully qualified. - - Put up to LEN bytes of the host name into NAME. - Null terminate it if the name is shorter than LEN. - If the host name is longer than LEN, set errno = EINVAL and return -1. - Return 0 if successful, otherwise set errno and return -1. */ -# if @UNISTD_H_HAVE_WINSOCK2_H@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef gethostname -# define gethostname rpl_gethostname -# endif -_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); -# else -# if !@HAVE_GETHOSTNAME@ -_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) - _GL_ARG_NONNULL ((1))); -# endif -/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second - parameter is - int len. */ -_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); -# endif -_GL_CXXALIASWARN (gethostname); -#elif @UNISTD_H_HAVE_WINSOCK2_H@ -# undef gethostname -# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname -#elif defined GNULIB_POSIXCHECK -# undef gethostname -# if HAVE_RAW_DECL_GETHOSTNAME -_GL_WARN_ON_USE (gethostname, "gethostname is unportable - " - "use gnulib module gethostname for portability"); -# endif -#endif - - -#if @GNULIB_GETLOGIN@ -/* Returns the user's login name, or NULL if it cannot be found. Upon error, - returns NULL with errno set. - - See . - - Most programs don't need to use this function, because the information is - available through environment variables: - ${LOGNAME-$USER} on Unix platforms, - $USERNAME on native Windows platforms. - */ -# if !@HAVE_GETLOGIN@ -_GL_FUNCDECL_SYS (getlogin, char *, (void)); -# endif -_GL_CXXALIAS_SYS (getlogin, char *, (void)); -_GL_CXXALIASWARN (getlogin); -#elif defined GNULIB_POSIXCHECK -# undef getlogin -# if HAVE_RAW_DECL_GETLOGIN -_GL_WARN_ON_USE (getlogin, "getlogin is unportable - " - "use gnulib module getlogin for portability"); -# endif -#endif - - -#if @GNULIB_GETLOGIN_R@ -/* Copies the user's login name to NAME. - The array pointed to by NAME has room for SIZE bytes. - - Returns 0 if successful. Upon error, an error number is returned, or -1 in - the case that the login name cannot be found but no specific error is - provided (this case is hopefully rare but is left open by the POSIX spec). - - See . - - Most programs don't need to use this function, because the information is - available through environment variables: - ${LOGNAME-$USER} on Unix platforms, - $USERNAME on native Windows platforms. - */ -# if @REPLACE_GETLOGIN_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define getlogin_r rpl_getlogin_r -# endif -_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); -# else -# if !@HAVE_DECL_GETLOGIN_R@ -_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) - _GL_ARG_NONNULL ((1))); -# endif -/* Need to cast, because on Solaris 10 systems, the second argument is - int size. */ -_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); -# endif -_GL_CXXALIASWARN (getlogin_r); -#elif defined GNULIB_POSIXCHECK -# undef getlogin_r -# if HAVE_RAW_DECL_GETLOGIN_R -_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " - "use gnulib module getlogin_r for portability"); -# endif -#endif - - -#if @GNULIB_GETPAGESIZE@ -# if @REPLACE_GETPAGESIZE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define getpagesize rpl_getpagesize -# endif -_GL_FUNCDECL_RPL (getpagesize, int, (void)); -_GL_CXXALIAS_RPL (getpagesize, int, (void)); -# else -# if !@HAVE_GETPAGESIZE@ -# if !defined getpagesize -/* This is for POSIX systems. */ -# if !defined _gl_getpagesize && defined _SC_PAGESIZE -# if ! (defined __VMS && __VMS_VER < 70000000) -# define _gl_getpagesize() sysconf (_SC_PAGESIZE) -# endif -# endif -/* This is for older VMS. */ -# if !defined _gl_getpagesize && defined __VMS -# ifdef __ALPHA -# define _gl_getpagesize() 8192 -# else -# define _gl_getpagesize() 512 -# endif -# endif -/* This is for BeOS. */ -# if !defined _gl_getpagesize && @HAVE_OS_H@ -# include -# if defined B_PAGE_SIZE -# define _gl_getpagesize() B_PAGE_SIZE -# endif -# endif -/* This is for AmigaOS4.0. */ -# if !defined _gl_getpagesize && defined __amigaos4__ -# define _gl_getpagesize() 2048 -# endif -/* This is for older Unix systems. */ -# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@ -# include -# ifdef EXEC_PAGESIZE -# define _gl_getpagesize() EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define CLSIZE 1 -# endif -# define _gl_getpagesize() (NBPG * CLSIZE) -# else -# ifdef NBPC -# define _gl_getpagesize() NBPC -# endif -# endif -# endif -# endif -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define getpagesize() _gl_getpagesize () -# else -# if !GNULIB_defined_getpagesize_function -_GL_UNISTD_INLINE int -getpagesize () -{ - return _gl_getpagesize (); -} -# define GNULIB_defined_getpagesize_function 1 -# endif -# endif -# endif -# endif -/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ -_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); -# endif -# if @HAVE_DECL_GETPAGESIZE@ -_GL_CXXALIASWARN (getpagesize); -# endif -#elif defined GNULIB_POSIXCHECK -# undef getpagesize -# if HAVE_RAW_DECL_GETPAGESIZE -_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " - "use gnulib module getpagesize for portability"); -# endif -#endif - - -#if @GNULIB_GETUSERSHELL@ -/* Return the next valid login shell on the system, or NULL when the end of - the list has been reached. */ -# if !@HAVE_DECL_GETUSERSHELL@ -_GL_FUNCDECL_SYS (getusershell, char *, (void)); -# endif -_GL_CXXALIAS_SYS (getusershell, char *, (void)); -_GL_CXXALIASWARN (getusershell); -#elif defined GNULIB_POSIXCHECK -# undef getusershell -# if HAVE_RAW_DECL_GETUSERSHELL -_GL_WARN_ON_USE (getusershell, "getusershell is unportable - " - "use gnulib module getusershell for portability"); -# endif -#endif - -#if @GNULIB_GETUSERSHELL@ -/* Rewind to pointer that is advanced at each getusershell() call. */ -# if !@HAVE_DECL_GETUSERSHELL@ -_GL_FUNCDECL_SYS (setusershell, void, (void)); -# endif -_GL_CXXALIAS_SYS (setusershell, void, (void)); -_GL_CXXALIASWARN (setusershell); -#elif defined GNULIB_POSIXCHECK -# undef setusershell -# if HAVE_RAW_DECL_SETUSERSHELL -_GL_WARN_ON_USE (setusershell, "setusershell is unportable - " - "use gnulib module getusershell for portability"); -# endif -#endif - -#if @GNULIB_GETUSERSHELL@ -/* Free the pointer that is advanced at each getusershell() call and - associated resources. */ -# if !@HAVE_DECL_GETUSERSHELL@ -_GL_FUNCDECL_SYS (endusershell, void, (void)); -# endif -_GL_CXXALIAS_SYS (endusershell, void, (void)); -_GL_CXXALIASWARN (endusershell); -#elif defined GNULIB_POSIXCHECK -# undef endusershell -# if HAVE_RAW_DECL_ENDUSERSHELL -_GL_WARN_ON_USE (endusershell, "endusershell is unportable - " - "use gnulib module getusershell for portability"); -# endif -#endif - - -#if @GNULIB_GROUP_MEMBER@ -/* Determine whether group id is in calling user's group list. */ -# if !@HAVE_GROUP_MEMBER@ -_GL_FUNCDECL_SYS (group_member, int, (gid_t gid)); -# endif -_GL_CXXALIAS_SYS (group_member, int, (gid_t gid)); -_GL_CXXALIASWARN (group_member); -#elif defined GNULIB_POSIXCHECK -# undef group_member -# if HAVE_RAW_DECL_GROUP_MEMBER -_GL_WARN_ON_USE (group_member, "group_member is unportable - " - "use gnulib module group-member for portability"); -# endif -#endif - - -#if @GNULIB_ISATTY@ -# if @REPLACE_ISATTY@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef isatty -# define isatty rpl_isatty -# endif -_GL_FUNCDECL_RPL (isatty, int, (int fd)); -_GL_CXXALIAS_RPL (isatty, int, (int fd)); -# else -_GL_CXXALIAS_SYS (isatty, int, (int fd)); -# endif -_GL_CXXALIASWARN (isatty); -#elif defined GNULIB_POSIXCHECK -# undef isatty -# if HAVE_RAW_DECL_ISATTY -_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " - "use gnulib module isatty for portability"); -# endif -#endif - - -#if @GNULIB_LCHOWN@ -/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE - to GID (if GID is not -1). Do not follow symbolic links. - Return 0 if successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if @REPLACE_LCHOWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef lchown -# define lchown rpl_lchown -# endif -_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); -# else -# if !@HAVE_LCHOWN@ -_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); -# endif -_GL_CXXALIASWARN (lchown); -#elif defined GNULIB_POSIXCHECK -# undef lchown -# if HAVE_RAW_DECL_LCHOWN -_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " - "use gnulib module lchown for portability"); -# endif -#endif - - -#if @GNULIB_LINK@ -/* Create a new hard link for an existing file. - Return 0 if successful, otherwise -1 and errno set. - See POSIX:2008 specification - . */ -# if @REPLACE_LINK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define link rpl_link -# endif -_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); -# else -# if !@HAVE_LINK@ -_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); -# endif -_GL_CXXALIASWARN (link); -#elif defined GNULIB_POSIXCHECK -# undef link -# if HAVE_RAW_DECL_LINK -_GL_WARN_ON_USE (link, "link is unportable - " - "use gnulib module link for portability"); -# endif -#endif - - -#if @GNULIB_LINKAT@ -/* Create a new hard link for an existing file, relative to two - directories. FLAG controls whether symlinks are followed. - Return 0 if successful, otherwise -1 and errno set. */ -# if @REPLACE_LINKAT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef linkat -# define linkat rpl_linkat -# endif -_GL_FUNCDECL_RPL (linkat, int, - (int fd1, const char *path1, int fd2, const char *path2, - int flag) - _GL_ARG_NONNULL ((2, 4))); -_GL_CXXALIAS_RPL (linkat, int, - (int fd1, const char *path1, int fd2, const char *path2, - int flag)); -# else -# if !@HAVE_LINKAT@ -_GL_FUNCDECL_SYS (linkat, int, - (int fd1, const char *path1, int fd2, const char *path2, - int flag) - _GL_ARG_NONNULL ((2, 4))); -# endif -_GL_CXXALIAS_SYS (linkat, int, - (int fd1, const char *path1, int fd2, const char *path2, - int flag)); -# endif -_GL_CXXALIASWARN (linkat); -#elif defined GNULIB_POSIXCHECK -# undef linkat -# if HAVE_RAW_DECL_LINKAT -_GL_WARN_ON_USE (linkat, "linkat is unportable - " - "use gnulib module linkat for portability"); -# endif -#endif - - -#if @GNULIB_LSEEK@ -/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. - Return the new offset if successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if @REPLACE_LSEEK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define lseek rpl_lseek -# endif -_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); -_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); -# else -_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); -# endif -_GL_CXXALIASWARN (lseek); -#elif defined GNULIB_POSIXCHECK -# undef lseek -# if HAVE_RAW_DECL_LSEEK -_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " - "systems - use gnulib module lseek for portability"); -# endif -#endif - - -#if @GNULIB_PIPE@ -/* Create a pipe, defaulting to O_BINARY mode. - Store the read-end as fd[0] and the write-end as fd[1]. - Return 0 upon success, or -1 with errno set upon failure. */ -# if !@HAVE_PIPE@ -_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (pipe, int, (int fd[2])); -_GL_CXXALIASWARN (pipe); -#elif defined GNULIB_POSIXCHECK -# undef pipe -# if HAVE_RAW_DECL_PIPE -_GL_WARN_ON_USE (pipe, "pipe is unportable - " - "use gnulib module pipe-posix for portability"); -# endif -#endif - - -#if @GNULIB_PIPE2@ -/* Create a pipe, applying the given flags when opening the read-end of the - pipe and the write-end of the pipe. - The flags are a bitmask, possibly including O_CLOEXEC (defined in ) - and O_TEXT, O_BINARY (defined in "binary-io.h"). - Store the read-end as fd[0] and the write-end as fd[1]. - Return 0 upon success, or -1 with errno set upon failure. - See also the Linux man page at - . */ -# if @HAVE_PIPE2@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define pipe2 rpl_pipe2 -# endif -_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); -# else -_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); -# endif -_GL_CXXALIASWARN (pipe2); -#elif defined GNULIB_POSIXCHECK -# undef pipe2 -# if HAVE_RAW_DECL_PIPE2 -_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " - "use gnulib module pipe2 for portability"); -# endif -#endif - - -#if @GNULIB_PREAD@ -/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. - Return the number of bytes placed into BUF if successful, otherwise - set errno and return -1. 0 indicates EOF. - See the POSIX:2008 specification - . */ -# if @REPLACE_PREAD@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef pread -# define pread rpl_pread -# endif -_GL_FUNCDECL_RPL (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset)); -# else -# if !@HAVE_PREAD@ -_GL_FUNCDECL_SYS (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (pread, ssize_t, - (int fd, void *buf, size_t bufsize, off_t offset)); -# endif -_GL_CXXALIASWARN (pread); -#elif defined GNULIB_POSIXCHECK -# undef pread -# if HAVE_RAW_DECL_PREAD -_GL_WARN_ON_USE (pread, "pread is unportable - " - "use gnulib module pread for portability"); -# endif -#endif - - -#if @GNULIB_PWRITE@ -/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. - Return the number of bytes written if successful, otherwise - set errno and return -1. 0 indicates nothing written. See the - POSIX:2008 specification - . */ -# if @REPLACE_PWRITE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef pwrite -# define pwrite rpl_pwrite -# endif -_GL_FUNCDECL_RPL (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset)); -# else -# if !@HAVE_PWRITE@ -_GL_FUNCDECL_SYS (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (pwrite, ssize_t, - (int fd, const void *buf, size_t bufsize, off_t offset)); -# endif -_GL_CXXALIASWARN (pwrite); -#elif defined GNULIB_POSIXCHECK -# undef pwrite -# if HAVE_RAW_DECL_PWRITE -_GL_WARN_ON_USE (pwrite, "pwrite is unportable - " - "use gnulib module pwrite for portability"); -# endif -#endif - - -#if @GNULIB_READ@ -/* Read up to COUNT bytes from file descriptor FD into the buffer starting - at BUF. See the POSIX:2008 specification - . */ -# if @REPLACE_READ@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef read -# define read rpl_read -# endif -_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); -# else -/* Need to cast, because on mingw, the third parameter is - unsigned int count - and the return type is 'int'. */ -_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count)); -# endif -_GL_CXXALIASWARN (read); -#endif - - -#if @GNULIB_READLINK@ -/* Read the contents of the symbolic link FILE and place the first BUFSIZE - bytes of it into BUF. Return the number of bytes placed into BUF if - successful, otherwise -1 and errno set. - See the POSIX:2008 specification - . */ -# if @REPLACE_READLINK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define readlink rpl_readlink -# endif -_GL_FUNCDECL_RPL (readlink, ssize_t, - (const char *file, char *buf, size_t bufsize) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (readlink, ssize_t, - (const char *file, char *buf, size_t bufsize)); -# else -# if !@HAVE_READLINK@ -_GL_FUNCDECL_SYS (readlink, ssize_t, - (const char *file, char *buf, size_t bufsize) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (readlink, ssize_t, - (const char *file, char *buf, size_t bufsize)); -# endif -_GL_CXXALIASWARN (readlink); -#elif defined GNULIB_POSIXCHECK -# undef readlink -# if HAVE_RAW_DECL_READLINK -_GL_WARN_ON_USE (readlink, "readlink is unportable - " - "use gnulib module readlink for portability"); -# endif -#endif - - -#if @GNULIB_READLINKAT@ -# if !@HAVE_READLINKAT@ -_GL_FUNCDECL_SYS (readlinkat, ssize_t, - (int fd, char const *file, char *buf, size_t len) - _GL_ARG_NONNULL ((2, 3))); -# endif -_GL_CXXALIAS_SYS (readlinkat, ssize_t, - (int fd, char const *file, char *buf, size_t len)); -_GL_CXXALIASWARN (readlinkat); -#elif defined GNULIB_POSIXCHECK -# undef readlinkat -# if HAVE_RAW_DECL_READLINKAT -_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " - "use gnulib module readlinkat for portability"); -# endif -#endif - - -#if @GNULIB_RMDIR@ -/* Remove the directory DIR. */ -# if @REPLACE_RMDIR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define rmdir rpl_rmdir -# endif -_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); -# else -_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); -# endif -_GL_CXXALIASWARN (rmdir); -#elif defined GNULIB_POSIXCHECK -# undef rmdir -# if HAVE_RAW_DECL_RMDIR -_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " - "use gnulib module rmdir for portability"); -# endif -#endif - - -#if @GNULIB_SETHOSTNAME@ -/* Set the host name of the machine. - The host name may or may not be fully qualified. - - Put LEN bytes of NAME into the host name. - Return 0 if successful, otherwise, set errno and return -1. - - Platforms with no ability to set the hostname return -1 and set - errno = ENOSYS. */ -# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ -_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) - _GL_ARG_NONNULL ((1))); -# endif -/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 - and FreeBSD 6.4 the second parameter is int. On Solaris 11 - 2011-10, the first parameter is not const. */ -_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); -_GL_CXXALIASWARN (sethostname); -#elif defined GNULIB_POSIXCHECK -# undef sethostname -# if HAVE_RAW_DECL_SETHOSTNAME -_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " - "use gnulib module sethostname for portability"); -# endif -#endif - - -#if @GNULIB_SLEEP@ -/* Pause the execution of the current thread for N seconds. - Returns the number of seconds left to sleep. - See the POSIX:2008 specification - . */ -# if @REPLACE_SLEEP@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef sleep -# define sleep rpl_sleep -# endif -_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); -_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); -# else -# if !@HAVE_SLEEP@ -_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); -# endif -_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); -# endif -_GL_CXXALIASWARN (sleep); -#elif defined GNULIB_POSIXCHECK -# undef sleep -# if HAVE_RAW_DECL_SLEEP -_GL_WARN_ON_USE (sleep, "sleep is unportable - " - "use gnulib module sleep for portability"); -# endif -#endif - - -#if @GNULIB_SYMLINK@ -# if @REPLACE_SYMLINK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef symlink -# define symlink rpl_symlink -# endif -_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); -# else -# if !@HAVE_SYMLINK@ -_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); -# endif -_GL_CXXALIASWARN (symlink); -#elif defined GNULIB_POSIXCHECK -# undef symlink -# if HAVE_RAW_DECL_SYMLINK -_GL_WARN_ON_USE (symlink, "symlink is not portable - " - "use gnulib module symlink for portability"); -# endif -#endif - - -#if @GNULIB_SYMLINKAT@ -# if !@HAVE_SYMLINKAT@ -_GL_FUNCDECL_SYS (symlinkat, int, - (char const *contents, int fd, char const *file) - _GL_ARG_NONNULL ((1, 3))); -# endif -_GL_CXXALIAS_SYS (symlinkat, int, - (char const *contents, int fd, char const *file)); -_GL_CXXALIASWARN (symlinkat); -#elif defined GNULIB_POSIXCHECK -# undef symlinkat -# if HAVE_RAW_DECL_SYMLINKAT -_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " - "use gnulib module symlinkat for portability"); -# endif -#endif - - -#if @GNULIB_TTYNAME_R@ -/* Store at most BUFLEN characters of the pathname of the terminal FD is - open on in BUF. Return 0 on success, otherwise an error number. */ -# if @REPLACE_TTYNAME_R@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ttyname_r -# define ttyname_r rpl_ttyname_r -# endif -_GL_FUNCDECL_RPL (ttyname_r, int, - (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (ttyname_r, int, - (int fd, char *buf, size_t buflen)); -# else -# if !@HAVE_DECL_TTYNAME_R@ -_GL_FUNCDECL_SYS (ttyname_r, int, - (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (ttyname_r, int, - (int fd, char *buf, size_t buflen)); -# endif -_GL_CXXALIASWARN (ttyname_r); -#elif defined GNULIB_POSIXCHECK -# undef ttyname_r -# if HAVE_RAW_DECL_TTYNAME_R -_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " - "use gnulib module ttyname_r for portability"); -# endif -#endif - - -#if @GNULIB_UNLINK@ -# if @REPLACE_UNLINK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef unlink -# define unlink rpl_unlink -# endif -_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (unlink, int, (char const *file)); -# else -_GL_CXXALIAS_SYS (unlink, int, (char const *file)); -# endif -_GL_CXXALIASWARN (unlink); -#elif defined GNULIB_POSIXCHECK -# undef unlink -# if HAVE_RAW_DECL_UNLINK -_GL_WARN_ON_USE (unlink, "unlink is not portable - " - "use gnulib module unlink for portability"); -# endif -#endif - - -#if @GNULIB_UNLINKAT@ -# if @REPLACE_UNLINKAT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef unlinkat -# define unlinkat rpl_unlinkat -# endif -_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); -# else -# if !@HAVE_UNLINKAT@ -_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); -# endif -_GL_CXXALIASWARN (unlinkat); -#elif defined GNULIB_POSIXCHECK -# undef unlinkat -# if HAVE_RAW_DECL_UNLINKAT -_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " - "use gnulib module openat for portability"); -# endif -#endif - - -#if @GNULIB_USLEEP@ -/* Pause the execution of the current thread for N microseconds. - Returns 0 on completion, or -1 on range error. - See the POSIX:2001 specification - . */ -# if @REPLACE_USLEEP@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef usleep -# define usleep rpl_usleep -# endif -_GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); -_GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); -# else -# if !@HAVE_USLEEP@ -_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); -# endif -_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); -# endif -_GL_CXXALIASWARN (usleep); -#elif defined GNULIB_POSIXCHECK -# undef usleep -# if HAVE_RAW_DECL_USLEEP -_GL_WARN_ON_USE (usleep, "usleep is unportable - " - "use gnulib module usleep for portability"); -# endif -#endif - - -#if @GNULIB_WRITE@ -/* Write up to COUNT bytes starting at BUF to file descriptor FD. - See the POSIX:2008 specification - . */ -# if @REPLACE_WRITE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef write -# define write rpl_write -# endif -_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); -# else -/* Need to cast, because on mingw, the third parameter is - unsigned int count - and the return type is 'int'. */ -_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); -# endif -_GL_CXXALIASWARN (write); -#endif - -_GL_INLINE_HEADER_END - -#endif /* _@GUARD_PREFIX@_UNISTD_H */ -#endif /* _@GUARD_PREFIX@_UNISTD_H */ diff --git a/grub-core/gnulib/unitypes.in.h b/grub-core/gnulib/unitypes.in.h deleted file mode 100644 index 06eef05ce..000000000 --- a/grub-core/gnulib/unitypes.in.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Elementary types and macros for the GNU UniString library. - Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _UNITYPES_H -#define _UNITYPES_H - -/* Get uint8_t, uint16_t, uint32_t. */ -#include - -/* Type representing a Unicode character. */ -typedef uint32_t ucs4_t; - -/* Attribute of a function whose result depends only on the arguments - (not pointers!) and which has no side effects. */ -#ifndef _UC_ATTRIBUTE_CONST -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__)) -# else -# define _UC_ATTRIBUTE_CONST -# endif -#endif - -/* Attribute of a function whose result depends only on the arguments - (possibly pointers) and global memory, and which has no side effects. */ -#ifndef _UC_ATTRIBUTE_PURE -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__)) -# else -# define _UC_ATTRIBUTE_PURE -# endif -#endif - -#endif /* _UNITYPES_H */ diff --git a/grub-core/gnulib/uniwidth.in.h b/grub-core/gnulib/uniwidth.in.h deleted file mode 100644 index 8931cc9b0..000000000 --- a/grub-core/gnulib/uniwidth.in.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Display width functions. - Copyright (C) 2001-2002, 2005, 2007, 2009-2013 Free Software Foundation, - Inc. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _UNIWIDTH_H -#define _UNIWIDTH_H - -#include "unitypes.h" - -/* Get size_t. */ -#include - -/* Get locale_charset() declaration. */ -#include "localcharset.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Display width. */ - -/* These functions are locale dependent. The encoding argument identifies - the encoding (e.g. "ISO-8859-2" for Polish). */ - -/* Determine number of column positions required for UC. */ -extern int - uc_width (ucs4_t uc, const char *encoding) - _UC_ATTRIBUTE_PURE; - -/* Determine number of column positions required for first N units - (or fewer if S ends before this) in S. */ -extern int - u8_width (const uint8_t *s, size_t n, const char *encoding) - _UC_ATTRIBUTE_PURE; -extern int - u16_width (const uint16_t *s, size_t n, const char *encoding) - _UC_ATTRIBUTE_PURE; -extern int - u32_width (const uint32_t *s, size_t n, const char *encoding) - _UC_ATTRIBUTE_PURE; - -/* Determine number of column positions required for S. */ -extern int - u8_strwidth (const uint8_t *s, const char *encoding) - _UC_ATTRIBUTE_PURE; -extern int - u16_strwidth (const uint16_t *s, const char *encoding) - _UC_ATTRIBUTE_PURE; -extern int - u32_strwidth (const uint32_t *s, const char *encoding) - _UC_ATTRIBUTE_PURE; - - -#ifdef __cplusplus -} -#endif - -#endif /* _UNIWIDTH_H */ diff --git a/grub-core/gnulib/uniwidth/cjk.h b/grub-core/gnulib/uniwidth/cjk.h deleted file mode 100644 index 11b14dfec..000000000 --- a/grub-core/gnulib/uniwidth/cjk.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Test for CJK encoding. - Copyright (C) 2001-2002, 2005-2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2002. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include "streq.h" - -static int -is_cjk_encoding (const char *encoding) -{ - if (0 - /* Legacy Japanese encodings */ - || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0) - /* Legacy Chinese encodings */ - || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) - || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0) - || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0) - || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0) - /* Legacy Korean encodings */ - || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0) - || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0)) - return 1; - return 0; -} diff --git a/grub-core/gnulib/uniwidth/width.c b/grub-core/gnulib/uniwidth/width.c deleted file mode 100644 index 173d0872c..000000000 --- a/grub-core/gnulib/uniwidth/width.c +++ /dev/null @@ -1,368 +0,0 @@ -/* Determine display width of Unicode character. - Copyright (C) 2001-2002, 2006-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2002. - - This program 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. - - 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include "uniwidth.h" - -#include "cjk.h" - -/* - * Non-spacing attribute table. - * Consists of: - * - Non-spacing characters; generated from PropList.txt or - * "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt" - * - Format control characters; generated from - * "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt" - * - Zero width characters; generated from - * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt" - */ -static const unsigned char nonspacing_table_data[27*64] = { - /* 0x0000-0x01ff */ - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */ - 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */ - /* 0x0200-0x03ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */ - /* 0x0400-0x05ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */ - 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */ - 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */ - 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */ - /* 0x0600-0x07ff */ - 0x0f, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ - 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */ - 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ - 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */ - 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */ - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x07c0-0x07ff */ - /* 0x0800-0x09ff */ - 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */ - 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08c0-0x08ff */ - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */ - 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */ - 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x09c0-0x09ff */ - /* 0x0a00-0x0bff */ - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */ - 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */ - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */ - 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0ac0-0x0aff */ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */ - 0x1e, 0x20, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */ - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */ - 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */ - /* 0x0c00-0x0dff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */ - 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */ - 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */ - 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */ - 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */ - /* 0x0e00-0x0fff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */ - 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1b, /* 0x0e80-0x0ebf */ - 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */ - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */ - 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */ - 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */ - /* 0x1000-0x11ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */ - 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */ - 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1180-0x11bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c0-0x11ff */ - /* 0x1200-0x13ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */ - 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */ - /* 0x1600-0x17ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */ - 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, /* 0x1700-0x173f */ - 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */ - 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */ - /* 0x1800-0x19ff */ - 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */ - 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */ - /* 0x1a00-0x1bff */ - 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ - 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1a80-0x1abf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */ - 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */ - 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */ - 0x03, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, /* 0x1b80-0x1bbf */ - 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */ - /* 0x1c00-0x1dff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */ - 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x00, 0x00, /* 0x1cc0-0x1cff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, /* 0x1dc0-0x1dff */ - /* 0x2000-0x21ff */ - 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */ - 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, /* 0x2040-0x207f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */ - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */ - /* 0x2c00-0x2dff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */ - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */ - /* 0x3000-0x31ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, /* 0x3000-0x303f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */ - 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */ - /* 0xa600-0xa7ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x30, /* 0xa640-0xa67f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */ - /* 0xa800-0xa9ff */ - 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */ - 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */ - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */ - 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */ - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ - /* 0xaa00-0xabff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */ - 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaa40-0xaa7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaac0-0xaaff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */ - 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */ - /* 0xfa00-0xfbff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */ - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */ - /* 0xfe00-0xffff */ - 0xff, 0xff, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, /* 0xfe00-0xfe3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */ - /* 0x10000-0x101ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */ - /* 0x10a00-0x10bff */ - 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */ - /* 0x11000-0x111ff */ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */ - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11040-0x1107f */ - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11100-0x1113f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11140-0x1117f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11180-0x111bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ - /* 0x1d000-0x1d1ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */ - 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */ - /* 0x1d200-0x1d3ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */ - 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1d3c0-0x1d3ff */ -}; -static const signed char nonspacing_table_ind[240] = { - 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */ - 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */ - 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */ - 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */ - -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */ - -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */ - 22, -1, -1, -1, -1, 23, -1, -1, /* 0x10000-0x10fff */ - 24, -1, -1, -1, -1, -1, -1, -1, /* 0x11000-0x11fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x16000-0x16fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1b000-0x1bfff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */ - 25, 26, -1, -1, -1, -1, -1, -1 /* 0x1d000-0x1dfff */ -}; - -/* Determine number of column positions required for UC. */ -int -uc_width (ucs4_t uc, const char *encoding) -{ - /* Test for non-spacing or control character. */ - if ((uc >> 9) < 240) - { - int ind = nonspacing_table_ind[uc >> 9]; - if (ind >= 0) - if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1) - { - if (uc > 0 && uc < 0xa0) - return -1; - else - return 0; - } - } - else if ((uc >> 9) == (0xe0000 >> 9)) - { - if (uc >= 0xe0100) - { - if (uc <= 0xe01ef) - return 0; - } - else - { - if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001) - return 0; - } - } - /* Test for double-width character. - * Generated from "grep '^[^;]\{4,5\};[WF]' EastAsianWidth.txt" - * and "grep '^[^;]\{4,5\};[^WF]' EastAsianWidth.txt" - */ - if (uc >= 0x1100 - && ((uc < 0x1160) /* Hangul Jamo */ - || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */ - || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */ - && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00)) - || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */ - || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */ - || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */ - || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */ - || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */ - || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */ - || (uc >= 0x20000 && uc <= 0x2ffff) /* Supplementary Ideographic Plane */ - || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */ - ) ) - return 2; - /* In ancient CJK encodings, Cyrillic and most other characters are - double-width as well. */ - if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9 - && is_cjk_encoding (encoding)) - return 2; - return 1; -} diff --git a/grub-core/gnulib/vasnprintf.c b/grub-core/gnulib/vasnprintf.c deleted file mode 100644 index 8fdab32ea..000000000 --- a/grub-core/gnulib/vasnprintf.c +++ /dev/null @@ -1,5606 +0,0 @@ -/* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -/* This file can be parametrized with the following macros: - VASNPRINTF The name of the function being defined. - FCHAR_T The element type of the format string. - DCHAR_T The element type of the destination (result) string. - FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters - in the format string are ASCII. MUST be set if - FCHAR_T and DCHAR_T are not the same type. - DIRECTIVE Structure denoting a format directive. - Depends on FCHAR_T. - DIRECTIVES Structure denoting the set of format directives of a - format string. Depends on FCHAR_T. - PRINTF_PARSE Function that parses a format string. - Depends on FCHAR_T. - DCHAR_CPY memcpy like function for DCHAR_T[] arrays. - DCHAR_SET memset like function for DCHAR_T[] arrays. - DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays. - SNPRINTF The system's snprintf (or similar) function. - This may be either snprintf or swprintf. - TCHAR_T The element type of the argument and result string - of the said SNPRINTF function. This may be either - char or wchar_t. The code exploits that - sizeof (TCHAR_T) | sizeof (DCHAR_T) and - alignof (TCHAR_T) <= alignof (DCHAR_T). - DCHAR_IS_TCHAR Set to 1 if DCHAR_T and TCHAR_T are the same type. - DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. - DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. - DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. - DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ - -/* Tell glibc's to provide a prototype for snprintf(). - This must come before because may include - , and once has been included, it's too late. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -#ifndef VASNPRINTF -# include -#endif -#ifndef IN_LIBINTL -# include -#endif - -/* Specification. */ -#ifndef VASNPRINTF -# if WIDE_CHAR_VERSION -# include "vasnwprintf.h" -# else -# include "vasnprintf.h" -# endif -#endif - -#include /* localeconv() */ -#include /* snprintf(), sprintf() */ -#include /* abort(), malloc(), realloc(), free() */ -#include /* memcpy(), strlen() */ -#include /* errno */ -#include /* CHAR_BIT */ -#include /* DBL_MAX_EXP, LDBL_MAX_EXP */ -#if HAVE_NL_LANGINFO -# include -#endif -#ifndef VASNPRINTF -# if WIDE_CHAR_VERSION -# include "wprintf-parse.h" -# else -# include "printf-parse.h" -# endif -#endif - -/* Checked size_t computations. */ -#include "xsize.h" - -#include "verify.h" - -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL -# include -# include "float+.h" -#endif - -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL -# include -# include "isnand-nolibm.h" -#endif - -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL -# include -# include "isnanl-nolibm.h" -# include "fpucw.h" -#endif - -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL -# include -# include "isnand-nolibm.h" -# include "printf-frexp.h" -#endif - -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL -# include -# include "isnanl-nolibm.h" -# include "printf-frexpl.h" -# include "fpucw.h" -#endif - -/* Default parameters. */ -#ifndef VASNPRINTF -# if WIDE_CHAR_VERSION -# define VASNPRINTF vasnwprintf -# define FCHAR_T wchar_t -# define DCHAR_T wchar_t -# define TCHAR_T wchar_t -# define DCHAR_IS_TCHAR 1 -# define DIRECTIVE wchar_t_directive -# define DIRECTIVES wchar_t_directives -# define PRINTF_PARSE wprintf_parse -# define DCHAR_CPY wmemcpy -# define DCHAR_SET wmemset -# else -# define VASNPRINTF vasnprintf -# define FCHAR_T char -# define DCHAR_T char -# define TCHAR_T char -# define DCHAR_IS_TCHAR 1 -# define DIRECTIVE char_directive -# define DIRECTIVES char_directives -# define PRINTF_PARSE printf_parse -# define DCHAR_CPY memcpy -# define DCHAR_SET memset -# endif -#endif -#if WIDE_CHAR_VERSION - /* TCHAR_T is wchar_t. */ -# define USE_SNPRINTF 1 -# if HAVE_DECL__SNWPRINTF - /* On Windows, the function swprintf() has a different signature than - on Unix; we use the function _snwprintf() or - on mingw - snwprintf() - instead. The mingw function snwprintf() has fewer bugs than the - MSVCRT function _snwprintf(), so prefer that. */ -# if defined __MINGW32__ -# define SNPRINTF snwprintf -# else -# define SNPRINTF _snwprintf -# endif -# else - /* Unix. */ -# define SNPRINTF swprintf -# endif -#else - /* TCHAR_T is char. */ - /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. - But don't use it on BeOS, since BeOS snprintf produces no output if the - size argument is >= 0x3000000. - Also don't use it on Linux libc5, since there snprintf with size = 1 - writes any output without bounds, like sprintf. */ -# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1) -# define USE_SNPRINTF 1 -# else -# define USE_SNPRINTF 0 -# endif -# if HAVE_DECL__SNPRINTF - /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT - function _snprintf(), so prefer that. */ -# if defined __MINGW32__ -# define SNPRINTF snprintf - /* Here we need to call the native snprintf, not rpl_snprintf. */ -# undef snprintf -# else -# define SNPRINTF _snprintf -# endif -# else - /* Unix. */ -# define SNPRINTF snprintf - /* Here we need to call the native snprintf, not rpl_snprintf. */ -# undef snprintf -# endif -#endif -/* Here we need to call the native sprintf, not rpl_sprintf. */ -#undef sprintf - -/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" - warnings in this file. Use -Dlint to suppress them. */ -#ifdef lint -# define IF_LINT(Code) Code -#else -# define IF_LINT(Code) /* empty */ -#endif - -/* Avoid some warnings from "gcc -Wshadow". - This file doesn't use the exp() and remainder() functions. */ -#undef exp -#define exp expo -#undef remainder -#define remainder rem - -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION -# if (HAVE_STRNLEN && !defined _AIX) -# define local_strnlen strnlen -# else -# ifndef local_strnlen_defined -# define local_strnlen_defined 1 -static size_t -local_strnlen (const char *string, size_t maxlen) -{ - const char *end = memchr (string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; -} -# endif -# endif -#endif - -#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T -# if HAVE_WCSLEN -# define local_wcslen wcslen -# else - /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid - a dependency towards this library, here is a local substitute. - Define this substitute only once, even if this file is included - twice in the same compilation unit. */ -# ifndef local_wcslen_defined -# define local_wcslen_defined 1 -static size_t -local_wcslen (const wchar_t *s) -{ - const wchar_t *ptr; - - for (ptr = s; *ptr != (wchar_t) 0; ptr++) - ; - return ptr - s; -} -# endif -# endif -#endif - -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION -# if HAVE_WCSNLEN -# define local_wcsnlen wcsnlen -# else -# ifndef local_wcsnlen_defined -# define local_wcsnlen_defined 1 -static size_t -local_wcsnlen (const wchar_t *s, size_t maxlen) -{ - const wchar_t *ptr; - - for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--) - ; - return ptr - s; -} -# endif -# endif -#endif - -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL -/* Determine the decimal-point character according to the current locale. */ -# ifndef decimal_point_char_defined -# define decimal_point_char_defined 1 -static char -decimal_point_char (void) -{ - const char *point; - /* Determine it in a multithread-safe way. We know nl_langinfo is - multithread-safe on glibc systems and Mac OS X systems, but is not required - to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. - localeconv() is rarely multithread-safe. */ -# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__)) - point = nl_langinfo (RADIXCHAR); -# elif 1 - char pointbuf[5]; - sprintf (pointbuf, "%#.0f", 1.0); - point = &pointbuf[1]; -# else - point = localeconv () -> decimal_point; -# endif - /* The decimal point is always a single byte: either '.' or ','. */ - return (point[0] != '\0' ? point[0] : '.'); -} -# endif -#endif - -#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL - -/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ -static int -is_infinite_or_zero (double x) -{ - return isnand (x) || x + x == x; -} - -#endif - -#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL - -/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ -static int -is_infinite_or_zerol (long double x) -{ - return isnanl (x) || x + x == x; -} - -#endif - -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL - -/* Converting 'long double' to decimal without rare rounding bugs requires - real bignums. We use the naming conventions of GNU gmp, but vastly simpler - (and slower) algorithms. */ - -typedef unsigned int mp_limb_t; -# define GMP_LIMB_BITS 32 -verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); - -typedef unsigned long long mp_twolimb_t; -# define GMP_TWOLIMB_BITS 64 -verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); - -/* Representation of a bignum >= 0. */ -typedef struct -{ - size_t nlimbs; - mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc(). */ -} mpn_t; - -/* Compute the product of two bignums >= 0. - Return the allocated memory in case of success, NULL in case of memory - allocation failure. */ -static void * -multiply (mpn_t src1, mpn_t src2, mpn_t *dest) -{ - const mp_limb_t *p1; - const mp_limb_t *p2; - size_t len1; - size_t len2; - - if (src1.nlimbs <= src2.nlimbs) - { - len1 = src1.nlimbs; - p1 = src1.limbs; - len2 = src2.nlimbs; - p2 = src2.limbs; - } - else - { - len1 = src2.nlimbs; - p1 = src2.limbs; - len2 = src1.nlimbs; - p2 = src1.limbs; - } - /* Now 0 <= len1 <= len2. */ - if (len1 == 0) - { - /* src1 or src2 is zero. */ - dest->nlimbs = 0; - dest->limbs = (mp_limb_t *) malloc (1); - } - else - { - /* Here 1 <= len1 <= len2. */ - size_t dlen; - mp_limb_t *dp; - size_t k, i, j; - - dlen = len1 + len2; - dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); - if (dp == NULL) - return NULL; - for (k = len2; k > 0; ) - dp[--k] = 0; - for (i = 0; i < len1; i++) - { - mp_limb_t digit1 = p1[i]; - mp_twolimb_t carry = 0; - for (j = 0; j < len2; j++) - { - mp_limb_t digit2 = p2[j]; - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; - carry += dp[i + j]; - dp[i + j] = (mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; - } - dp[i + len2] = (mp_limb_t) carry; - } - /* Normalise. */ - while (dlen > 0 && dp[dlen - 1] == 0) - dlen--; - dest->nlimbs = dlen; - dest->limbs = dp; - } - return dest->limbs; -} - -/* Compute the quotient of a bignum a >= 0 and a bignum b > 0. - a is written as a = q * b + r with 0 <= r < b. q is the quotient, r - the remainder. - Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd, - q is incremented. - Return the allocated memory in case of success, NULL in case of memory - allocation failure. */ -static void * -divide (mpn_t a, mpn_t b, mpn_t *q) -{ - /* Algorithm: - First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]] - with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS). - If m=n=1, perform a single-precision division: - r:=0, j:=m, - while j>0 do - {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j = - = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r=n>1, perform a multiple-precision division: - We have a/b < beta^(m-n+1). - s:=intDsize-1-(highest bit in b[n-1]), 0<=s=beta/2. - For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).} - Compute q* : - q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]). - In case of overflow (q* >= beta) set q* := beta-1. - Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2] - and c3 := b[n-2] * q*. - {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow - occurred. Furthermore 0 <= c3 < beta^2. - If there was overflow and - r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2, - the next test can be skipped.} - While c3 > c2, {Here 0 <= c2 < c3 < beta^2} - Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2]. - If q* > 0: - Put r := r - b * q* * beta^j. In detail: - [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]]. - hence: u:=0, for i:=0 to n-1 do - u := u + q* * b[i], - r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry), - u:=u div beta (+ 1, if carry in subtraction) - r[n+j]:=r[n+j]-u. - {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1 - < q* + 1 <= beta, - the carry u does not overflow.} - If a negative carry occurs, put q* := q* - 1 - and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]]. - Set q[j] := q*. - Normalise [q[m-n],..,q[0]]; this yields the quotient q. - Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the - rest r. - The room for q[j] can be allocated at the memory location of r[n+j]. - Finally, round-to-even: - Shift r left by 1 bit. - If r > b or if r = b and q[0] is odd, q := q+1. - */ - const mp_limb_t *a_ptr = a.limbs; - size_t a_len = a.nlimbs; - const mp_limb_t *b_ptr = b.limbs; - size_t b_len = b.nlimbs; - mp_limb_t *roomptr; - mp_limb_t *tmp_roomptr = NULL; - mp_limb_t *q_ptr; - size_t q_len; - mp_limb_t *r_ptr; - size_t r_len; - - /* Allocate room for a_len+2 digits. - (Need a_len+1 digits for the real division and 1 more digit for the - final rounding of q.) */ - roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t)); - if (roomptr == NULL) - return NULL; - - /* Normalise a. */ - while (a_len > 0 && a_ptr[a_len - 1] == 0) - a_len--; - - /* Normalise b. */ - for (;;) - { - if (b_len == 0) - /* Division by zero. */ - abort (); - if (b_ptr[b_len - 1] == 0) - b_len--; - else - break; - } - - /* Here m = a_len >= 0 and n = b_len > 0. */ - - if (a_len < b_len) - { - /* m beta^(m-2) <= a/b < beta^m */ - r_ptr = roomptr; - q_ptr = roomptr + 1; - { - mp_limb_t den = b_ptr[0]; - mp_limb_t remainder = 0; - const mp_limb_t *sourceptr = a_ptr + a_len; - mp_limb_t *destptr = q_ptr + a_len; - size_t count; - for (count = a_len; count > 0; count--) - { - mp_twolimb_t num = - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; - *--destptr = num / den; - remainder = num % den; - } - /* Normalise and store r. */ - if (remainder > 0) - { - r_ptr[0] = remainder; - r_len = 1; - } - else - r_len = 0; - /* Normalise q. */ - q_len = a_len; - if (q_ptr[q_len - 1] == 0) - q_len--; - } - } - else - { - /* n>1: multiple precision division. - beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> - beta^(m-n-1) <= a/b < beta^(m-n+1). */ - /* Determine s. */ - size_t s; - { - mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ - /* Determine s = GMP_LIMB_BITS - integer_length (msd). - Code copied from gnulib's integer_length.c. */ -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - s = __builtin_clz (msd); -# else -# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT - if (GMP_LIMB_BITS <= DBL_MANT_BIT) - { - /* Use 'double' operations. - Assumes an IEEE 754 'double' implementation. */ -# define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) -# define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1) -# define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - union { double value; unsigned int word[NWORDS]; } m; - - /* Use a single integer to floating-point conversion. */ - m.value = msd; - - s = GMP_LIMB_BITS - - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK) - - DBL_EXP_BIAS); - } - else -# undef NWORDS -# endif - { - s = 31; - if (msd >= 0x10000) - { - msd = msd >> 16; - s -= 16; - } - if (msd >= 0x100) - { - msd = msd >> 8; - s -= 8; - } - if (msd >= 0x10) - { - msd = msd >> 4; - s -= 4; - } - if (msd >= 0x4) - { - msd = msd >> 2; - s -= 2; - } - if (msd >= 0x2) - { - msd = msd >> 1; - s -= 1; - } - } -# endif - } - /* 0 <= s < GMP_LIMB_BITS. - Copy b, shifting it left by s bits. */ - if (s > 0) - { - tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); - if (tmp_roomptr == NULL) - { - free (roomptr); - return NULL; - } - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = tmp_roomptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - /* accu must be zero, since that was how s was determined. */ - if (accu != 0) - abort (); - } - b_ptr = tmp_roomptr; - } - /* Copy a, shifting it left by s bits, yields r. - Memory layout: - At the beginning: r = roomptr[0..a_len], - at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ - r_ptr = roomptr; - if (s == 0) - { - memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); - r_ptr[a_len] = 0; - } - else - { - const mp_limb_t *sourceptr = a_ptr; - mp_limb_t *destptr = r_ptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = a_len; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - *destptr++ = (mp_limb_t) accu; - } - q_ptr = roomptr + b_len; - q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */ - { - size_t j = a_len - b_len; /* m-n */ - mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ - mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ - mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ - ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; - /* Division loop, traversed m-n+1 times. - j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ - for (;;) - { - mp_limb_t q_star; - mp_limb_t c1; - if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ - { - /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ - mp_twolimb_t num = - ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) - | r_ptr[j + b_len - 1]; - q_star = num / b_msd; - c1 = num % b_msd; - } - else - { - /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ - q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ - /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta - <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta - <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) - {<= beta !}. - If yes, jump directly to the subtraction loop. - (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta - <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ - if (r_ptr[j + b_len] > b_msd - || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) - /* r[j+n] >= b[n-1]+1 or - r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a - carry. */ - goto subtract; - } - /* q_star = q*, - c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, 0, decrease it by - b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 - this can happen only twice. */ - if (c3 > c2) - { - q_star = q_star - 1; /* q* := q* - 1 */ - if (c3 - c2 > b_msdd) - q_star = q_star - 1; /* q* := q* - 1 */ - } - } - if (q_star > 0) - subtract: - { - /* Subtract r := r - b * q* * beta^j. */ - mp_limb_t cr; - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = r_ptr + j; - mp_twolimb_t carry = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - /* Here 0 <= carry <= q*. */ - carry = - carry - + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ - + (mp_limb_t) ~(*destptr); - /* Here 0 <= carry <= beta*q* + beta-1. */ - *destptr++ = ~(mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; /* <= q* */ - } - cr = (mp_limb_t) carry; - } - /* Subtract cr from r_ptr[j + b_len], then forget about - r_ptr[j + b_len]. */ - if (cr > r_ptr[j + b_len]) - { - /* Subtraction gave a carry. */ - q_star = q_star - 1; /* q* := q* - 1 */ - /* Add b back. */ - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = r_ptr + j; - mp_limb_t carry = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - mp_limb_t source1 = *sourceptr++; - mp_limb_t source2 = *destptr; - *destptr++ = source1 + source2 + carry; - carry = - (carry - ? source1 >= (mp_limb_t) ~source2 - : source1 > (mp_limb_t) ~source2); - } - } - /* Forget about the carry and about r[j+n]. */ - } - } - /* q* is determined. Store it as q[j]. */ - q_ptr[j] = q_star; - if (j == 0) - break; - j--; - } - } - r_len = b_len; - /* Normalise q. */ - if (q_ptr[q_len - 1] == 0) - q_len--; -# if 0 /* Not needed here, since we need r only to compare it with b/2, and - b is shifted left by s bits. */ - /* Shift r right by s bits. */ - if (s > 0) - { - mp_limb_t ptr = r_ptr + r_len; - mp_twolimb_t accu = 0; - size_t count; - for (count = r_len; count > 0; count--) - { - accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; - accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); - *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); - } - } -# endif - /* Normalise r. */ - while (r_len > 0 && r_ptr[r_len - 1] == 0) - r_len--; - } - /* Compare r << 1 with b. */ - if (r_len > b_len) - goto increment_q; - { - size_t i; - for (i = b_len;;) - { - mp_limb_t r_i = - (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) - | (i < r_len ? r_ptr[i] << 1 : 0); - mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); - if (r_i > b_i) - goto increment_q; - if (r_i < b_i) - goto keep_q; - if (i == 0) - break; - i--; - } - } - if (q_len > 0 && ((q_ptr[0] & 1) != 0)) - /* q is odd. */ - increment_q: - { - size_t i; - for (i = 0; i < q_len; i++) - if (++(q_ptr[i]) != 0) - goto keep_q; - q_ptr[q_len++] = 1; - } - keep_q: - if (tmp_roomptr != NULL) - free (tmp_roomptr); - q->limbs = q_ptr; - q->nlimbs = q_len; - return roomptr; -} - -/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal - representation. - Destroys the contents of a. - Return the allocated memory - containing the decimal digits in low-to-high - order, terminated with a NUL character - in case of success, NULL in case - of memory allocation failure. */ -static char * -convert_to_decimal (mpn_t a, size_t extra_zeroes) -{ - mp_limb_t *a_ptr = a.limbs; - size_t a_len = a.nlimbs; - /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ - size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); - char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes)); - if (c_ptr != NULL) - { - char *d_ptr = c_ptr; - for (; extra_zeroes > 0; extra_zeroes--) - *d_ptr++ = '0'; - while (a_len > 0) - { - /* Divide a by 10^9, in-place. */ - mp_limb_t remainder = 0; - mp_limb_t *ptr = a_ptr + a_len; - size_t count; - for (count = a_len; count > 0; count--) - { - mp_twolimb_t num = - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; - *ptr = num / 1000000000; - remainder = num % 1000000000; - } - /* Store the remainder as 9 decimal digits. */ - for (count = 9; count > 0; count--) - { - *d_ptr++ = '0' + (remainder % 10); - remainder = remainder / 10; - } - /* Normalize a. */ - if (a_ptr[a_len - 1] == 0) - a_len--; - } - /* Remove leading zeroes. */ - while (d_ptr > c_ptr && d_ptr[-1] == '0') - d_ptr--; - /* But keep at least one zero. */ - if (d_ptr == c_ptr) - *d_ptr++ = '0'; - /* Terminate the string. */ - *d_ptr = '\0'; - } - return c_ptr; -} - -# if NEED_PRINTF_LONG_DOUBLE - -/* Assuming x is finite and >= 0: - write x as x = 2^e * m, where m is a bignum. - Return the allocated memory in case of success, NULL in case of memory - allocation failure. */ -static void * -decode_long_double (long double x, int *ep, mpn_t *mp) -{ - mpn_t m; - int exp; - long double y; - size_t i; - - /* Allocate memory for result. */ - m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; - m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); - if (m.limbs == NULL) - return NULL; - /* Split into exponential part and mantissa. */ - y = frexpl (x, &exp); - if (!(y >= 0.0L && y < 1.0L)) - abort (); - /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the - latter is an integer. */ - /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs. - I'm not sure whether it's safe to cast a 'long double' value between - 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only - 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int', - doesn't matter). */ -# if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0 -# if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 - { - mp_limb_t hi, lo; - y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2)); - hi = (int) y; - y -= hi; - if (!(y >= 0.0L && y < 1.0L)) - abort (); - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - lo = (int) y; - y -= lo; - if (!(y >= 0.0L && y < 1.0L)) - abort (); - m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; - } -# else - { - mp_limb_t d; - y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS); - d = (int) y; - y -= d; - if (!(y >= 0.0L && y < 1.0L)) - abort (); - m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d; - } -# endif -# endif - for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) - { - mp_limb_t hi, lo; - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - hi = (int) y; - y -= hi; - if (!(y >= 0.0L && y < 1.0L)) - abort (); - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - lo = (int) y; - y -= lo; - if (!(y >= 0.0L && y < 1.0L)) - abort (); - m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; - } -# if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess - precision. */ - if (!(y == 0.0L)) - abort (); -# endif - /* Normalise. */ - while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) - m.nlimbs--; - *mp = m; - *ep = exp - LDBL_MANT_BIT; - return m.limbs; -} - -# endif - -# if NEED_PRINTF_DOUBLE - -/* Assuming x is finite and >= 0: - write x as x = 2^e * m, where m is a bignum. - Return the allocated memory in case of success, NULL in case of memory - allocation failure. */ -static void * -decode_double (double x, int *ep, mpn_t *mp) -{ - mpn_t m; - int exp; - double y; - size_t i; - - /* Allocate memory for result. */ - m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; - m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); - if (m.limbs == NULL) - return NULL; - /* Split into exponential part and mantissa. */ - y = frexp (x, &exp); - if (!(y >= 0.0 && y < 1.0)) - abort (); - /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the - latter is an integer. */ - /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs. - I'm not sure whether it's safe to cast a 'double' value between - 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only - 'double' values between 0 and 2^16 (to 'unsigned int' or 'int', - doesn't matter). */ -# if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0 -# if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 - { - mp_limb_t hi, lo; - y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2)); - hi = (int) y; - y -= hi; - if (!(y >= 0.0 && y < 1.0)) - abort (); - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - lo = (int) y; - y -= lo; - if (!(y >= 0.0 && y < 1.0)) - abort (); - m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; - } -# else - { - mp_limb_t d; - y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS); - d = (int) y; - y -= d; - if (!(y >= 0.0 && y < 1.0)) - abort (); - m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d; - } -# endif -# endif - for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) - { - mp_limb_t hi, lo; - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - hi = (int) y; - y -= hi; - if (!(y >= 0.0 && y < 1.0)) - abort (); - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); - lo = (int) y; - y -= lo; - if (!(y >= 0.0 && y < 1.0)) - abort (); - m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; - } - if (!(y == 0.0)) - abort (); - /* Normalise. */ - while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) - m.nlimbs--; - *mp = m; - *ep = exp - DBL_MANT_BIT; - return m.limbs; -} - -# endif - -/* Assuming x = 2^e * m is finite and >= 0, and n is an integer: - Returns the decimal representation of round (x * 10^n). - Return the allocated memory - containing the decimal digits in low-to-high - order, terminated with a NUL character - in case of success, NULL in case - of memory allocation failure. */ -static char * -scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) -{ - int s; - size_t extra_zeroes; - unsigned int abs_n; - unsigned int abs_s; - mp_limb_t *pow5_ptr; - size_t pow5_len; - unsigned int s_limbs; - unsigned int s_bits; - mpn_t pow5; - mpn_t z; - void *z_memory; - char *digits; - - if (memory == NULL) - return NULL; - /* x = 2^e * m, hence - y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) - = round (2^s * 5^n * m). */ - s = e + n; - extra_zeroes = 0; - /* Factor out a common power of 10 if possible. */ - if (s > 0 && n > 0) - { - extra_zeroes = (s < n ? s : n); - s -= extra_zeroes; - n -= extra_zeroes; - } - /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes. - Before converting to decimal, we need to compute - z = round (2^s * 5^n * m). */ - /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same - sign. 2.322 is slightly larger than log(5)/log(2). */ - abs_n = (n >= 0 ? n : -n); - abs_s = (s >= 0 ? s : -s); - pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 - + abs_s / GMP_LIMB_BITS + 1) - * sizeof (mp_limb_t)); - if (pow5_ptr == NULL) - { - free (memory); - return NULL; - } - /* Initialize with 1. */ - pow5_ptr[0] = 1; - pow5_len = 1; - /* Multiply with 5^|n|. */ - if (abs_n > 0) - { - static mp_limb_t const small_pow5[13 + 1] = - { - 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, - 48828125, 244140625, 1220703125 - }; - unsigned int n13; - for (n13 = 0; n13 <= abs_n; n13 += 13) - { - mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; - size_t j; - mp_twolimb_t carry = 0; - for (j = 0; j < pow5_len; j++) - { - mp_limb_t digit2 = pow5_ptr[j]; - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; - pow5_ptr[j] = (mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; - } - if (carry > 0) - pow5_ptr[pow5_len++] = (mp_limb_t) carry; - } - } - s_limbs = abs_s / GMP_LIMB_BITS; - s_bits = abs_s % GMP_LIMB_BITS; - if (n >= 0 ? s >= 0 : s <= 0) - { - /* Multiply with 2^|s|. */ - if (s_bits > 0) - { - mp_limb_t *ptr = pow5_ptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = pow5_len; count > 0; count--) - { - accu += (mp_twolimb_t) *ptr << s_bits; - *ptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - if (accu > 0) - { - *ptr = (mp_limb_t) accu; - pow5_len++; - } - } - if (s_limbs > 0) - { - size_t count; - for (count = pow5_len; count > 0;) - { - count--; - pow5_ptr[s_limbs + count] = pow5_ptr[count]; - } - for (count = s_limbs; count > 0;) - { - count--; - pow5_ptr[count] = 0; - } - pow5_len += s_limbs; - } - pow5.limbs = pow5_ptr; - pow5.nlimbs = pow5_len; - if (n >= 0) - { - /* Multiply m with pow5. No division needed. */ - z_memory = multiply (m, pow5, &z); - } - else - { - /* Divide m by pow5 and round. */ - z_memory = divide (m, pow5, &z); - } - } - else - { - pow5.limbs = pow5_ptr; - pow5.nlimbs = pow5_len; - if (n >= 0) - { - /* n >= 0, s < 0. - Multiply m with pow5, then divide by 2^|s|. */ - mpn_t numerator; - mpn_t denominator; - void *tmp_memory; - tmp_memory = multiply (m, pow5, &numerator); - if (tmp_memory == NULL) - { - free (pow5_ptr); - free (memory); - return NULL; - } - /* Construct 2^|s|. */ - { - mp_limb_t *ptr = pow5_ptr + pow5_len; - size_t i; - for (i = 0; i < s_limbs; i++) - ptr[i] = 0; - ptr[s_limbs] = (mp_limb_t) 1 << s_bits; - denominator.limbs = ptr; - denominator.nlimbs = s_limbs + 1; - } - z_memory = divide (numerator, denominator, &z); - free (tmp_memory); - } - else - { - /* n < 0, s > 0. - Multiply m with 2^s, then divide by pow5. */ - mpn_t numerator; - mp_limb_t *num_ptr; - num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) - * sizeof (mp_limb_t)); - if (num_ptr == NULL) - { - free (pow5_ptr); - free (memory); - return NULL; - } - { - mp_limb_t *destptr = num_ptr; - { - size_t i; - for (i = 0; i < s_limbs; i++) - *destptr++ = 0; - } - if (s_bits > 0) - { - const mp_limb_t *sourceptr = m.limbs; - mp_twolimb_t accu = 0; - size_t count; - for (count = m.nlimbs; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s_bits; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - if (accu > 0) - *destptr++ = (mp_limb_t) accu; - } - else - { - const mp_limb_t *sourceptr = m.limbs; - size_t count; - for (count = m.nlimbs; count > 0; count--) - *destptr++ = *sourceptr++; - } - numerator.limbs = num_ptr; - numerator.nlimbs = destptr - num_ptr; - } - z_memory = divide (numerator, pow5, &z); - free (num_ptr); - } - } - free (pow5_ptr); - free (memory); - - /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */ - - if (z_memory == NULL) - return NULL; - digits = convert_to_decimal (z, extra_zeroes); - free (z_memory); - return digits; -} - -# if NEED_PRINTF_LONG_DOUBLE - -/* Assuming x is finite and >= 0, and n is an integer: - Returns the decimal representation of round (x * 10^n). - Return the allocated memory - containing the decimal digits in low-to-high - order, terminated with a NUL character - in case of success, NULL in case - of memory allocation failure. */ -static char * -scale10_round_decimal_long_double (long double x, int n) -{ - int e IF_LINT(= 0); - mpn_t m; - void *memory = decode_long_double (x, &e, &m); - return scale10_round_decimal_decoded (e, m, memory, n); -} - -# endif - -# if NEED_PRINTF_DOUBLE - -/* Assuming x is finite and >= 0, and n is an integer: - Returns the decimal representation of round (x * 10^n). - Return the allocated memory - containing the decimal digits in low-to-high - order, terminated with a NUL character - in case of success, NULL in case - of memory allocation failure. */ -static char * -scale10_round_decimal_double (double x, int n) -{ - int e IF_LINT(= 0); - mpn_t m; - void *memory = decode_double (x, &e, &m); - return scale10_round_decimal_decoded (e, m, memory, n); -} - -# endif - -# if NEED_PRINTF_LONG_DOUBLE - -/* Assuming x is finite and > 0: - Return an approximation for n with 10^n <= x < 10^(n+1). - The approximation is usually the right n, but may be off by 1 sometimes. */ -static int -floorlog10l (long double x) -{ - int exp; - long double y; - double z; - double l; - - /* Split into exponential part and mantissa. */ - y = frexpl (x, &exp); - if (!(y >= 0.0L && y < 1.0L)) - abort (); - if (y == 0.0L) - return INT_MIN; - if (y < 0.5L) - { - while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) - { - y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); - exp -= GMP_LIMB_BITS; - } - if (y < (1.0L / (1 << 16))) - { - y *= 1.0L * (1 << 16); - exp -= 16; - } - if (y < (1.0L / (1 << 8))) - { - y *= 1.0L * (1 << 8); - exp -= 8; - } - if (y < (1.0L / (1 << 4))) - { - y *= 1.0L * (1 << 4); - exp -= 4; - } - if (y < (1.0L / (1 << 2))) - { - y *= 1.0L * (1 << 2); - exp -= 2; - } - if (y < (1.0L / (1 << 1))) - { - y *= 1.0L * (1 << 1); - exp -= 1; - } - } - if (!(y >= 0.5L && y < 1.0L)) - abort (); - /* Compute an approximation for l = log2(x) = exp + log2(y). */ - l = exp; - z = y; - if (z < 0.70710678118654752444) - { - z *= 1.4142135623730950488; - l -= 0.5; - } - if (z < 0.8408964152537145431) - { - z *= 1.1892071150027210667; - l -= 0.25; - } - if (z < 0.91700404320467123175) - { - z *= 1.0905077326652576592; - l -= 0.125; - } - if (z < 0.9576032806985736469) - { - z *= 1.0442737824274138403; - l -= 0.0625; - } - /* Now 0.95 <= z <= 1.01. */ - z = 1 - z; - /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) - Four terms are enough to get an approximation with error < 10^-7. */ - l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); - /* Finally multiply with log(2)/log(10), yields an approximation for - log10(x). */ - l *= 0.30102999566398119523; - /* Round down to the next integer. */ - return (int) l + (l < 0 ? -1 : 0); -} - -# endif - -# if NEED_PRINTF_DOUBLE - -/* Assuming x is finite and > 0: - Return an approximation for n with 10^n <= x < 10^(n+1). - The approximation is usually the right n, but may be off by 1 sometimes. */ -static int -floorlog10 (double x) -{ - int exp; - double y; - double z; - double l; - - /* Split into exponential part and mantissa. */ - y = frexp (x, &exp); - if (!(y >= 0.0 && y < 1.0)) - abort (); - if (y == 0.0) - return INT_MIN; - if (y < 0.5) - { - while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) - { - y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); - exp -= GMP_LIMB_BITS; - } - if (y < (1.0 / (1 << 16))) - { - y *= 1.0 * (1 << 16); - exp -= 16; - } - if (y < (1.0 / (1 << 8))) - { - y *= 1.0 * (1 << 8); - exp -= 8; - } - if (y < (1.0 / (1 << 4))) - { - y *= 1.0 * (1 << 4); - exp -= 4; - } - if (y < (1.0 / (1 << 2))) - { - y *= 1.0 * (1 << 2); - exp -= 2; - } - if (y < (1.0 / (1 << 1))) - { - y *= 1.0 * (1 << 1); - exp -= 1; - } - } - if (!(y >= 0.5 && y < 1.0)) - abort (); - /* Compute an approximation for l = log2(x) = exp + log2(y). */ - l = exp; - z = y; - if (z < 0.70710678118654752444) - { - z *= 1.4142135623730950488; - l -= 0.5; - } - if (z < 0.8408964152537145431) - { - z *= 1.1892071150027210667; - l -= 0.25; - } - if (z < 0.91700404320467123175) - { - z *= 1.0905077326652576592; - l -= 0.125; - } - if (z < 0.9576032806985736469) - { - z *= 1.0442737824274138403; - l -= 0.0625; - } - /* Now 0.95 <= z <= 1.01. */ - z = 1 - z; - /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) - Four terms are enough to get an approximation with error < 10^-7. */ - l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); - /* Finally multiply with log(2)/log(10), yields an approximation for - log10(x). */ - l *= 0.30102999566398119523; - /* Round down to the next integer. */ - return (int) l + (l < 0 ? -1 : 0); -} - -# endif - -/* Tests whether a string of digits consists of exactly PRECISION zeroes and - a single '1' digit. */ -static int -is_borderline (const char *digits, size_t precision) -{ - for (; precision > 0; precision--, digits++) - if (*digits != '0') - return 0; - if (*digits != '1') - return 0; - digits++; - return *digits == '\0'; -} - -#endif - -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 - -/* Use a different function name, to make it possible that the 'wchar_t' - parametrization and the 'char' parametrization get compiled in the same - translation unit. */ -# if WIDE_CHAR_VERSION -# define MAX_ROOM_NEEDED wmax_room_needed -# else -# define MAX_ROOM_NEEDED max_room_needed -# endif - -/* Returns the number of TCHAR_T units needed as temporary space for the result - of sprintf or SNPRINTF of a single conversion directive. */ -static size_t -MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, - arg_type type, int flags, size_t width, int has_precision, - size_t precision, int pad_ourselves) -{ - size_t tmp_length; - - switch (conversion) - { - case 'd': case 'i': case 'u': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Multiply by 2, as an estimate for FLAG_GROUP. */ - tmp_length = xsum (tmp_length, tmp_length); - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; - - case 'o': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; - - case 'x': case 'X': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ - tmp_length = xsum (tmp_length, 2); - break; - - case 'f': case 'F': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - else - tmp_length = - (unsigned int) (DBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - tmp_length = xsum (tmp_length, precision); - break; - - case 'e': case 'E': case 'g': case 'G': - tmp_length = - 12; /* sign, decimal point, exponent etc. */ - tmp_length = xsum (tmp_length, precision); - break; - - case 'a': case 'A': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (DBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); - break; - - case 'c': -# if HAVE_WINT_T && !WIDE_CHAR_VERSION - if (type == TYPE_WIDE_CHAR) - tmp_length = MB_CUR_MAX; - else -# endif - tmp_length = 1; - break; - - case 's': -# if HAVE_WCHAR_T - if (type == TYPE_WIDE_STRING) - { -# if WIDE_CHAR_VERSION - /* ISO C says about %ls in fwprintf: - "If the precision is not specified or is greater than the size - of the array, the array shall contain a null wide character." - So if there is a precision, we must not use wcslen. */ - const wchar_t *arg = ap->arg[arg_index].a.a_wide_string; - - if (has_precision) - tmp_length = local_wcsnlen (arg, precision); - else - tmp_length = local_wcslen (arg); -# else - /* ISO C says about %ls in fprintf: - "If a precision is specified, no more than that many bytes are - written (including shift sequences, if any), and the array - shall contain a null wide character if, to equal the multibyte - character sequence length given by the precision, the function - would need to access a wide character one past the end of the - array." - So if there is a precision, we must not use wcslen. */ - /* This case has already been handled separately in VASNPRINTF. */ - abort (); -# endif - } - else -# endif - { -# if WIDE_CHAR_VERSION - /* ISO C says about %s in fwprintf: - "If the precision is not specified or is greater than the size - of the converted array, the converted array shall contain a - null wide character." - So if there is a precision, we must not use strlen. */ - /* This case has already been handled separately in VASNPRINTF. */ - abort (); -# else - /* ISO C says about %s in fprintf: - "If the precision is not specified or greater than the size of - the array, the array shall contain a null character." - So if there is a precision, we must not use strlen. */ - const char *arg = ap->arg[arg_index].a.a_string; - - if (has_precision) - tmp_length = local_strnlen (arg, precision); - else - tmp_length = strlen (arg); -# endif - } - break; - - case 'p': - tmp_length = - (unsigned int) (sizeof (void *) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading 0x */ - break; - - default: - abort (); - } - - if (!pad_ourselves) - { -# if ENABLE_UNISTDIO - /* Padding considers the number of characters, therefore the number of - elements after padding may be - > max (tmp_length, width) - but is certainly - <= tmp_length + width. */ - tmp_length = xsum (tmp_length, width); -# else - /* Padding considers the number of elements, says POSIX. */ - if (tmp_length < width) - tmp_length = width; -# endif - } - - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - - return tmp_length; -} - -#endif - -DCHAR_T * -VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, - const FCHAR_T *format, va_list args) -{ - DIRECTIVES d; - arguments a; - - if (PRINTF_PARSE (format, &d, &a) < 0) - /* errno is already set. */ - return NULL; - -#define CLEANUP() \ - if (d.dir != d.direct_alloc_dir) \ - free (d.dir); \ - if (a.arg != a.direct_alloc_arg) \ - free (a.arg); - - if (PRINTF_FETCHARGS (args, &a) < 0) - { - CLEANUP (); - errno = EINVAL; - return NULL; - } - - { - size_t buf_neededlength; - TCHAR_T *buf; - TCHAR_T *buf_malloced; - const FCHAR_T *cp; - size_t i; - DIRECTIVE *dp; - /* Output string accumulator. */ - DCHAR_T *result; - size_t allocated; - size_t length; - - /* Allocate a small buffer that will hold a directive passed to - sprintf or snprintf. */ - buf_neededlength = - xsum4 (7, d.max_width_length, d.max_precision_length, 6); -#if HAVE_ALLOCA - if (buf_neededlength < 4000 / sizeof (TCHAR_T)) - { - buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); - buf_malloced = NULL; - } - else -#endif - { - size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); - if (size_overflow_p (buf_memsize)) - goto out_of_memory_1; - buf = (TCHAR_T *) malloc (buf_memsize); - if (buf == NULL) - goto out_of_memory_1; - buf_malloced = buf; - } - - if (resultbuf != NULL) - { - result = resultbuf; - allocated = *lengthp; - } - else - { - result = NULL; - allocated = 0; - } - length = 0; - /* Invariants: - result is either == resultbuf or == NULL or malloc-allocated. - If length > 0, then result != NULL. */ - - /* Ensures that allocated >= needed. Aborts through a jump to - out_of_memory if needed is SIZE_MAX or otherwise too big. */ -#define ENSURE_ALLOCATION(needed) \ - if ((needed) > allocated) \ - { \ - size_t memory_size; \ - DCHAR_T *memory; \ - \ - allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ - if ((needed) > allocated) \ - allocated = (needed); \ - memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ - if (size_overflow_p (memory_size)) \ - goto out_of_memory; \ - if (result == resultbuf || result == NULL) \ - memory = (DCHAR_T *) malloc (memory_size); \ - else \ - memory = (DCHAR_T *) realloc (result, memory_size); \ - if (memory == NULL) \ - goto out_of_memory; \ - if (result == resultbuf && length > 0) \ - DCHAR_CPY (memory, result, length); \ - result = memory; \ - } - - for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) - { - if (cp != dp->dir_start) - { - size_t n = dp->dir_start - cp; - size_t augmented_length = xsum (length, n); - - ENSURE_ALLOCATION (augmented_length); - /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we - need that the format string contains only ASCII characters - if FCHAR_T and DCHAR_T are not the same type. */ - if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) - { - DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); - length = augmented_length; - } - else - { - do - result[length++] = (unsigned char) *cp++; - while (--n > 0); - } - } - if (i == d.count) - break; - - /* Execute a single directive. */ - if (dp->conversion == '%') - { - size_t augmented_length; - - if (!(dp->arg_index == ARG_NONE)) - abort (); - augmented_length = xsum (length, 1); - ENSURE_ALLOCATION (augmented_length); - result[length] = '%'; - length = augmented_length; - } - else - { - if (!(dp->arg_index != ARG_NONE)) - abort (); - - if (dp->conversion == 'n') - { - switch (a.arg[dp->arg_index].type) - { - case TYPE_COUNT_SCHAR_POINTER: - *a.arg[dp->arg_index].a.a_count_schar_pointer = length; - break; - case TYPE_COUNT_SHORT_POINTER: - *a.arg[dp->arg_index].a.a_count_short_pointer = length; - break; - case TYPE_COUNT_INT_POINTER: - *a.arg[dp->arg_index].a.a_count_int_pointer = length; - break; - case TYPE_COUNT_LONGINT_POINTER: - *a.arg[dp->arg_index].a.a_count_longint_pointer = length; - break; -#if HAVE_LONG_LONG_INT - case TYPE_COUNT_LONGLONGINT_POINTER: - *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; - break; -#endif - default: - abort (); - } - } -#if ENABLE_UNISTDIO - /* The unistdio extensions. */ - else if (dp->conversion == 'U') - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; - - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } - - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; - - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } - - switch (type) - { - case TYPE_U8_STRING: - { - const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; - const uint8_t *arg_end; - size_t characters; - - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u8_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u8_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u8_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } - - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - -# if DCHAR_IS_UINT8_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } -# else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; -# if DCHAR_IS_TCHAR - /* Convert from UTF-8 to locale encoding. */ - converted = - u8_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); -# else - /* Convert from UTF-8 to UTF-16/UTF-32. */ - converted = - U8_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); -# endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } -# endif - - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; - - case TYPE_U16_STRING: - { - const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; - const uint16_t *arg_end; - size_t characters; - - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u16_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u16_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u16_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } - - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - -# if DCHAR_IS_UINT16_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } -# else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; -# if DCHAR_IS_TCHAR - /* Convert from UTF-16 to locale encoding. */ - converted = - u16_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); -# else - /* Convert from UTF-16 to UTF-8/UTF-32. */ - converted = - U16_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); -# endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } -# endif - - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; - - case TYPE_U32_STRING: - { - const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; - const uint32_t *arg_end; - size_t characters; - - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u32_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u32_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u32_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } - - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - -# if DCHAR_IS_UINT32_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } -# else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; -# if DCHAR_IS_TCHAR - /* Convert from UTF-32 to locale encoding. */ - converted = - u32_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); -# else - /* Convert from UTF-32 to UTF-8/UTF-16. */ - converted = - U32_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); -# endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } -# endif - - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; - - default: - abort (); - } - } -#endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T - else if (dp->conversion == 's' -# if WIDE_CHAR_VERSION - && a.arg[dp->arg_index].type != TYPE_WIDE_STRING -# else - && a.arg[dp->arg_index].type == TYPE_WIDE_STRING -# endif - ) - { - /* The normal handling of the 's' directive below requires - allocating a temporary buffer. The determination of its - length (tmp_length), in the case when a precision is - specified, below requires a conversion between a char[] - string and a wchar_t[] wide string. It could be done, but - we have no guarantee that the implementation of sprintf will - use the exactly same algorithm. Without this guarantee, it - is possible to have buffer overrun bugs. In order to avoid - such bugs, we implement the entire processing of the 's' - directive ourselves. */ - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; - - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } - - has_precision = 0; - precision = 6; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; - - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } - -# if WIDE_CHAR_VERSION - /* %s in vasnwprintf. See the specification of fwprintf. */ - { - const char *arg = a.arg[dp->arg_index].a.a_string; - const char *arg_end; - size_t characters; - - if (has_precision) - { - /* Use only as many bytes as needed to produce PRECISION - wide characters, from the left. */ -# if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count; -# if HAVE_MBRTOWC - count = mbrlen (arg_end, MB_CUR_MAX, &state); -# else - count = mblen (arg_end, MB_CUR_MAX); -# endif - if (count == 0) - /* Found the terminating NUL. */ - break; - if (count < 0) - { - /* Invalid or incomplete multibyte character. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of wide - characters. */ -# if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - arg_end = arg; - characters = 0; - for (;;) - { - int count; -# if HAVE_MBRTOWC - count = mbrlen (arg_end, MB_CUR_MAX, &state); -# else - count = mblen (arg_end, MB_CUR_MAX); -# endif - if (count == 0) - /* Found the terminating NUL. */ - break; - if (count < 0) - { - /* Invalid or incomplete multibyte character. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } - - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - - if (has_precision || has_width) - { - /* We know the number of wide characters in advance. */ - size_t remaining; -# if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - ENSURE_ALLOCATION (xsum (length, characters)); - for (remaining = characters; remaining > 0; remaining--) - { - wchar_t wc; - int count; -# if HAVE_MBRTOWC - count = mbrtowc (&wc, arg, arg_end - arg, &state); -# else - count = mbtowc (&wc, arg, arg_end - arg); -# endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ - abort (); - result[length++] = wc; - arg += count; - } - if (!(arg == arg_end)) - abort (); - } - else - { -# if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - while (arg < arg_end) - { - wchar_t wc; - int count; -# if HAVE_MBRTOWC - count = mbrtowc (&wc, arg, arg_end - arg, &state); -# else - count = mbtowc (&wc, arg, arg_end - arg); -# endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ - abort (); - ENSURE_ALLOCATION (xsum (length, 1)); - result[length++] = wc; - arg += count; - } - } - - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } -# else - /* %ls in vasnprintf. See the specification of fprintf. */ - { - const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; - const wchar_t *arg_end; - size_t characters; -# if !DCHAR_IS_TCHAR - /* This code assumes that TCHAR_T is 'char'. */ - verify (sizeof (TCHAR_T) == 1); - TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t tmpdst_len; -# endif - size_t w; - - if (has_precision) - { - /* Use only as many wide characters as needed to produce - at most PRECISION bytes, from the left. */ -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - arg_end = arg; - characters = 0; - while (precision > 0) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; - - if (*arg_end == 0) - /* Found the terminating null wide character. */ - break; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg_end, &state); -# else - count = wctomb (cbuf, *arg_end); -# endif - if (count < 0) - { - /* Cannot convert. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - if (precision < count) - break; - arg_end++; - characters += count; - precision -= count; - } - } -# if DCHAR_IS_TCHAR - else if (has_width) -# else - else -# endif - { - /* Use the entire string, and count the number of - bytes. */ -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - arg_end = arg; - characters = 0; - for (;;) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; - - if (*arg_end == 0) - /* Found the terminating null wide character. */ - break; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg_end, &state); -# else - count = wctomb (cbuf, *arg_end); -# endif - if (count < 0) - { - /* Cannot convert. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end++; - characters += count; - } - } -# if DCHAR_IS_TCHAR - else - { - /* Use the entire string. */ - arg_end = arg + local_wcslen (arg); - /* The number of bytes doesn't matter. */ - characters = 0; - } -# endif - -# if !DCHAR_IS_TCHAR - /* Convert the string into a piece of temporary memory. */ - tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T)); - if (tmpsrc == NULL) - goto out_of_memory; - { - TCHAR_T *tmpptr = tmpsrc; - size_t remaining; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - for (remaining = characters; remaining > 0; ) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; - - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif - if (count <= 0) - /* Inconsistency. */ - abort (); - memcpy (tmpptr, cbuf, count); - tmpptr += count; - arg++; - remaining -= count; - } - if (!(arg == arg_end)) - abort (); - } - - /* Convert from TCHAR_T[] to DCHAR_T[]. */ - tmpdst = - DCHAR_CONV_FROM_ENCODING (locale_charset (), - iconveh_question_mark, - tmpsrc, characters, - NULL, - NULL, &tmpdst_len); - if (tmpdst == NULL) - { - int saved_errno = errno; - free (tmpsrc); - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - free (tmpsrc); -# endif - - if (has_width) - { -# if ENABLE_UNISTDIO - /* Outside POSIX, it's preferable to compare the width - against the number of _characters_ of the converted - value. */ - w = DCHAR_MBSNLEN (result + length, characters); -# else - /* The width is compared against the number of _bytes_ - of the converted value, says POSIX. */ - w = characters; -# endif - } - else - /* w doesn't matter. */ - w = 0; - - if (has_width && width > w - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - w; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - -# if DCHAR_IS_TCHAR - if (has_precision || has_width) - { - /* We know the number of bytes in advance. */ - size_t remaining; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - ENSURE_ALLOCATION (xsum (length, characters)); - for (remaining = characters; remaining > 0; ) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; - - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif - if (count <= 0) - /* Inconsistency. */ - abort (); - memcpy (result + length, cbuf, count); - length += count; - arg++; - remaining -= count; - } - if (!(arg == arg_end)) - abort (); - } - else - { -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); -# endif - while (arg < arg_end) - { - char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; - - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif - if (count <= 0) - { - /* Cannot convert. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - ENSURE_ALLOCATION (xsum (length, count)); - memcpy (result + length, cbuf, count); - length += count; - arg++; - } - } -# else - ENSURE_ALLOCATION (xsum (length, tmpdst_len)); - DCHAR_CPY (result + length, tmpdst, tmpdst_len); - free (tmpdst); - length += tmpdst_len; -# endif - - if (has_width && width > w - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - w; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } -# endif - } -#endif -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL - else if ((dp->conversion == 'a' || dp->conversion == 'A') -# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) - && (0 -# if NEED_PRINTF_DOUBLE - || a.arg[dp->arg_index].type == TYPE_DOUBLE -# endif -# if NEED_PRINTF_LONG_DOUBLE - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE -# endif - ) -# endif - ) - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - size_t tmp_length; - DCHAR_T tmpbuf[700]; - DCHAR_T *tmp; - DCHAR_T *pad_ptr; - DCHAR_T *p; - - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; - - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } - - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; - - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } - - /* Allocate a temporary buffer of sufficient size. */ - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) ((LDBL_DIG + 1) - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) ((DBL_DIG + 1) - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); - - if (tmp_length < width) - tmp_length = width; - - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); - - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (DCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } - - pad_ptr = NULL; - p = tmp; - if (type == TYPE_LONGDOUBLE) - { -# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE - long double arg = a.arg[dp->arg_index].a.a_longdouble; - - if (isnanl (arg)) - { - if (dp->conversion == 'A') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - DECL_LONG_DOUBLE_ROUNDING - - BEGIN_LONG_DOUBLE_ROUNDING (); - - if (signbit (arg)) /* arg < 0.0L or negative zero */ - { - sign = -1; - arg = -arg; - } - - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; - - if (arg > 0.0L && arg + arg == arg) - { - if (dp->conversion == 'A') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { - int exponent; - long double mantissa; - - if (arg > 0.0L) - mantissa = printf_frexpl (arg, &exponent); - else - { - exponent = 0; - mantissa = 0.0L; - } - - if (has_precision - && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) - { - /* Round the mantissa. */ - long double tail = mantissa; - size_t q; - - for (q = precision; ; q--) - { - int digit = (int) tail; - tail -= digit; - if (q == 0) - { - if (digit & 1 ? tail >= 0.5L : tail > 0.5L) - tail = 1 - tail; - else - tail = - tail; - break; - } - tail *= 16.0L; - } - if (tail != 0.0L) - for (q = precision; q > 0; q--) - tail *= 0.0625L; - mantissa += tail; - } - - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - { - int digit; - - digit = (int) mantissa; - mantissa -= digit; - *p++ = '0' + digit; - if ((flags & FLAG_ALT) - || mantissa > 0.0L || precision > 0) - { - *p++ = decimal_point_char (); - /* This loop terminates because we assume - that FLT_RADIX is a power of 2. */ - while (mantissa > 0.0L) - { - mantissa *= 16.0L; - digit = (int) mantissa; - mantissa -= digit; - *p++ = digit - + (digit < 10 - ? '0' - : dp->conversion - 10); - if (precision > 0) - precision--; - } - while (precision > 0) - { - *p++ = '0'; - precision--; - } - } - } - *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } -# endif - } - - END_LONG_DOUBLE_ROUNDING (); - } -# else - abort (); -# endif - } - else - { -# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE - double arg = a.arg[dp->arg_index].a.a_double; - - if (isnand (arg)) - { - if (dp->conversion == 'A') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - - if (signbit (arg)) /* arg < 0.0 or negative zero */ - { - sign = -1; - arg = -arg; - } - - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; - - if (arg > 0.0 && arg + arg == arg) - { - if (dp->conversion == 'A') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { - int exponent; - double mantissa; - - if (arg > 0.0) - mantissa = printf_frexp (arg, &exponent); - else - { - exponent = 0; - mantissa = 0.0; - } - - if (has_precision - && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) - { - /* Round the mantissa. */ - double tail = mantissa; - size_t q; - - for (q = precision; ; q--) - { - int digit = (int) tail; - tail -= digit; - if (q == 0) - { - if (digit & 1 ? tail >= 0.5 : tail > 0.5) - tail = 1 - tail; - else - tail = - tail; - break; - } - tail *= 16.0; - } - if (tail != 0.0) - for (q = precision; q > 0; q--) - tail *= 0.0625; - mantissa += tail; - } - - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - { - int digit; - - digit = (int) mantissa; - mantissa -= digit; - *p++ = '0' + digit; - if ((flags & FLAG_ALT) - || mantissa > 0.0 || precision > 0) - { - *p++ = decimal_point_char (); - /* This loop terminates because we assume - that FLT_RADIX is a power of 2. */ - while (mantissa > 0.0) - { - mantissa *= 16.0; - digit = (int) mantissa; - mantissa -= digit; - *p++ = digit - + (digit < 10 - ? '0' - : dp->conversion - 10); - if (precision > 0) - precision--; - } - while (precision > 0) - { - *p++ = '0'; - precision--; - } - } - } - *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } -# endif - } - } -# else - abort (); -# endif - } - /* The generated string now extends from tmp to p, with the - zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) - { - size_t pad = width - (p - tmp); - DCHAR_T *end = p + pad; - - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; - - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; - - while (p > tmp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } - - p = end; - } - - { - size_t count = p - tmp; - - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); - - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); - - ENSURE_ALLOCATION (n); - } - - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } - } -#endif -#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL - else if ((dp->conversion == 'f' || dp->conversion == 'F' - || dp->conversion == 'e' || dp->conversion == 'E' - || dp->conversion == 'g' || dp->conversion == 'G' - || dp->conversion == 'a' || dp->conversion == 'A') - && (0 -# if NEED_PRINTF_DOUBLE - || a.arg[dp->arg_index].type == TYPE_DOUBLE -# elif NEED_PRINTF_INFINITE_DOUBLE - || (a.arg[dp->arg_index].type == TYPE_DOUBLE - /* The systems (mingw) which produce wrong output - for Inf, -Inf, and NaN also do so for -0.0. - Therefore we treat this case here as well. */ - && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) -# endif -# if NEED_PRINTF_LONG_DOUBLE - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE -# elif NEED_PRINTF_INFINITE_LONG_DOUBLE - || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE - /* Some systems produce wrong output for Inf, - -Inf, and NaN. Some systems in this category - (IRIX 5.3) also do so for -0.0. Therefore we - treat this case here as well. */ - && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) -# endif - )) - { -# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) - arg_type type = a.arg[dp->arg_index].type; -# endif - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - size_t tmp_length; - DCHAR_T tmpbuf[700]; - DCHAR_T *tmp; - DCHAR_T *pad_ptr; - DCHAR_T *p; - - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; - - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } - - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; - - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } - - /* POSIX specifies the default precision to be 6 for %f, %F, - %e, %E, but not for %g, %G. Implementations appear to use - the same default precision also for %g, %G. But for %a, %A, - the default precision is 0. */ - if (!has_precision) - if (!(dp->conversion == 'a' || dp->conversion == 'A')) - precision = 6; - - /* Allocate a temporary buffer of sufficient size. */ -# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); -# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); -# elif NEED_PRINTF_LONG_DOUBLE - tmp_length = LDBL_DIG + 1; -# elif NEED_PRINTF_DOUBLE - tmp_length = DBL_DIG + 1; -# else - tmp_length = 0; -# endif - if (tmp_length < precision) - tmp_length = precision; -# if NEED_PRINTF_LONG_DOUBLE -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - if (type == TYPE_LONGDOUBLE) -# endif - if (dp->conversion == 'f' || dp->conversion == 'F') - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; - if (!(isnanl (arg) || arg + arg == arg)) - { - /* arg is finite and nonzero. */ - int exponent = floorlog10l (arg < 0 ? -arg : arg); - if (exponent >= 0 && tmp_length < exponent + precision) - tmp_length = exponent + precision; - } - } -# endif -# if NEED_PRINTF_DOUBLE -# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE - if (type == TYPE_DOUBLE) -# endif - if (dp->conversion == 'f' || dp->conversion == 'F') - { - double arg = a.arg[dp->arg_index].a.a_double; - if (!(isnand (arg) || arg + arg == arg)) - { - /* arg is finite and nonzero. */ - int exponent = floorlog10 (arg < 0 ? -arg : arg); - if (exponent >= 0 && tmp_length < exponent + precision) - tmp_length = exponent + precision; - } - } -# endif - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); - - if (tmp_length < width) - tmp_length = width; - - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); - - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (DCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } - - pad_ptr = NULL; - p = tmp; - -# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - if (type == TYPE_LONGDOUBLE) -# endif - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; - - if (isnanl (arg)) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - DECL_LONG_DOUBLE_ROUNDING - - BEGIN_LONG_DOUBLE_ROUNDING (); - - if (signbit (arg)) /* arg < 0.0L or negative zero */ - { - sign = -1; - arg = -arg; - } - - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; - - if (arg > 0.0L && arg + arg == arg) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { -# if NEED_PRINTF_LONG_DOUBLE - pad_ptr = p; - - if (dp->conversion == 'f' || dp->conversion == 'F') - { - char *digits; - size_t ndigits; - - digits = - scale10_round_decimal_long_double (arg, precision); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); - - if (ndigits > precision) - do - { - --ndigits; - *p++ = digits[ndigits]; - } - while (ndigits > precision); - else - *p++ = '0'; - /* Here ndigits <= precision. */ - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > ndigits; precision--) - *p++ = '0'; - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - - free (digits); - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - int exponent; - - if (arg == 0.0L) - { - exponent = 0; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else - { - /* arg > 0.0L. */ - int adjusted; - char *digits; - size_t ndigits; - - exponent = floorlog10l (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_long_double (arg, - (int)precision - exponent); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); - - if (ndigits == precision + 1) - break; - if (ndigits < precision - || ndigits > precision + 2) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits == precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision+1. */ - if (is_borderline (digits, precision)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_long_double (arg, - (int)precision - exponent + 1); - if (digits2 == NULL) - { - free (digits); - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - if (strlen (digits2) == precision + 1) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision+1. */ - - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - - free (digits); - } - - *p++ = dp->conversion; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', '.', '2', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+.2d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+.2d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } -# endif - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - if (precision == 0) - precision = 1; - /* precision >= 1. */ - - if (arg == 0.0L) - /* The exponent is 0, >= -4, < precision. - Use fixed-point notation. */ - { - size_t ndigits = precision; - /* Number of trailing zeroes that have to be - dropped. */ - size_t nzeroes = - (flags & FLAG_ALT ? 0 : precision - 1); - - --ndigits; - *p++ = '0'; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = '0'; - } - } - } - else - { - /* arg > 0.0L. */ - int exponent; - int adjusted; - char *digits; - size_t ndigits; - size_t nzeroes; - - exponent = floorlog10l (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_long_double (arg, - (int)(precision - 1) - exponent); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); - - if (ndigits == precision) - break; - if (ndigits < precision - 1 - || ndigits > precision + 1) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits < precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision. */ - if (is_borderline (digits, precision - 1)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_long_double (arg, - (int)(precision - 1) - exponent + 1); - if (digits2 == NULL) - { - free (digits); - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - if (strlen (digits2) == precision) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision. */ - - /* Determine the number of trailing zeroes - that have to be dropped. */ - nzeroes = 0; - if ((flags & FLAG_ALT) == 0) - while (nzeroes < ndigits - && digits[nzeroes] == '0') - nzeroes++; - - /* The exponent is now determined. */ - if (exponent >= -4 - && exponent < (long)precision) - { - /* Fixed-point notation: - max(exponent,0)+1 digits, then the - decimal point, then the remaining - digits without trailing zeroes. */ - if (exponent >= 0) - { - size_t count = exponent + 1; - /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - size_t count = -exponent - 1; - *p++ = '0'; - *p++ = decimal_point_char (); - for (; count > 0; count--) - *p++ = '0'; - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - /* Exponential notation. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', '.', '2', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+.2d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+.2d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } -# endif - } - - free (digits); - } - } - else - abort (); -# else - /* arg is finite. */ - if (!(arg == 0.0L)) - abort (); - - pad_ptr = p; - - if (dp->conversion == 'f' || dp->conversion == 'F') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion; /* 'e' or 'E' */ - *p++ = '+'; - *p++ = '0'; - *p++ = '0'; - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - *p++ = '0'; - if (flags & FLAG_ALT) - { - size_t ndigits = - (precision > 0 ? precision - 1 : 0); - *p++ = decimal_point_char (); - for (; ndigits > 0; --ndigits) - *p++ = '0'; - } - } - else if (dp->conversion == 'a' || dp->conversion == 'A') - { - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion - 'A' + 'P'; - *p++ = '+'; - *p++ = '0'; - } - else - abort (); -# endif - } - - END_LONG_DOUBLE_ROUNDING (); - } - } -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - else -# endif -# endif -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - { - double arg = a.arg[dp->arg_index].a.a_double; - - if (isnand (arg)) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - - if (signbit (arg)) /* arg < 0.0 or negative zero */ - { - sign = -1; - arg = -arg; - } - - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; - - if (arg > 0.0 && arg + arg == arg) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { -# if NEED_PRINTF_DOUBLE - pad_ptr = p; - - if (dp->conversion == 'f' || dp->conversion == 'F') - { - char *digits; - size_t ndigits; - - digits = - scale10_round_decimal_double (arg, precision); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); - - if (ndigits > precision) - do - { - --ndigits; - *p++ = digits[ndigits]; - } - while (ndigits > precision); - else - *p++ = '0'; - /* Here ndigits <= precision. */ - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > ndigits; precision--) - *p++ = '0'; - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - - free (digits); - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - int exponent; - - if (arg == 0.0) - { - exponent = 0; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else - { - /* arg > 0.0. */ - int adjusted; - char *digits; - size_t ndigits; - - exponent = floorlog10 (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_double (arg, - (int)precision - exponent); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); - - if (ndigits == precision + 1) - break; - if (ndigits < precision - || ndigits > precision + 2) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits == precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision+1. */ - if (is_borderline (digits, precision)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_double (arg, - (int)precision - exponent + 1); - if (digits2 == NULL) - { - free (digits); - goto out_of_memory; - } - if (strlen (digits2) == precision + 1) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision+1. */ - - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - - free (digits); - } - - *p++ = dp->conversion; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - { '%', '+', '.', '3', 'd', '\0' }; -# else - { '%', '+', '.', '2', 'd', '\0' }; -# endif - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - { - static const char decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - "%+.3d"; -# else - "%+.2d"; -# endif - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, decimal_format, exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, decimal_format, exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } - } -# endif - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - if (precision == 0) - precision = 1; - /* precision >= 1. */ - - if (arg == 0.0) - /* The exponent is 0, >= -4, < precision. - Use fixed-point notation. */ - { - size_t ndigits = precision; - /* Number of trailing zeroes that have to be - dropped. */ - size_t nzeroes = - (flags & FLAG_ALT ? 0 : precision - 1); - - --ndigits; - *p++ = '0'; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = '0'; - } - } - } - else - { - /* arg > 0.0. */ - int exponent; - int adjusted; - char *digits; - size_t ndigits; - size_t nzeroes; - - exponent = floorlog10 (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_double (arg, - (int)(precision - 1) - exponent); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); - - if (ndigits == precision) - break; - if (ndigits < precision - 1 - || ndigits > precision + 1) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits < precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision. */ - if (is_borderline (digits, precision - 1)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_double (arg, - (int)(precision - 1) - exponent + 1); - if (digits2 == NULL) - { - free (digits); - goto out_of_memory; - } - if (strlen (digits2) == precision) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision. */ - - /* Determine the number of trailing zeroes - that have to be dropped. */ - nzeroes = 0; - if ((flags & FLAG_ALT) == 0) - while (nzeroes < ndigits - && digits[nzeroes] == '0') - nzeroes++; - - /* The exponent is now determined. */ - if (exponent >= -4 - && exponent < (long)precision) - { - /* Fixed-point notation: - max(exponent,0)+1 digits, then the - decimal point, then the remaining - digits without trailing zeroes. */ - if (exponent >= 0) - { - size_t count = exponent + 1; - /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - size_t count = -exponent - 1; - *p++ = '0'; - *p++ = decimal_point_char (); - for (; count > 0; count--) - *p++ = '0'; - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - /* Exponential notation. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - { '%', '+', '.', '3', 'd', '\0' }; -# else - { '%', '+', '.', '2', 'd', '\0' }; -# endif - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; -# else - { - static const char decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - "%+.3d"; -# else - "%+.2d"; -# endif - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, decimal_format, exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, decimal_format, exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } - } -# endif - } - - free (digits); - } - } - else - abort (); -# else - /* arg is finite. */ - if (!(arg == 0.0)) - abort (); - - pad_ptr = p; - - if (dp->conversion == 'f' || dp->conversion == 'F') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion; /* 'e' or 'E' */ - *p++ = '+'; - /* Produce the same number of exponent digits as - the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - *p++ = '0'; -# endif - *p++ = '0'; - *p++ = '0'; - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - *p++ = '0'; - if (flags & FLAG_ALT) - { - size_t ndigits = - (precision > 0 ? precision - 1 : 0); - *p++ = decimal_point_char (); - for (; ndigits > 0; --ndigits) - *p++ = '0'; - } - } - else - abort (); -# endif - } - } - } -# endif - - /* The generated string now extends from tmp to p, with the - zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) - { - size_t pad = width - (p - tmp); - DCHAR_T *end = p + pad; - - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; - - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; - - while (p > tmp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } - - p = end; - } - - { - size_t count = p - tmp; - - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); - - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); - - ENSURE_ALLOCATION (n); - } - - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } - } -#endif - else - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - int has_width; - size_t width; -#endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION - int has_precision; - size_t precision; -#endif -#if NEED_PRINTF_UNBOUNDED_PRECISION - int prec_ourselves; -#else -# define prec_ourselves 0 -#endif -#if NEED_PRINTF_FLAG_LEFTADJUST -# define pad_ourselves 1 -#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - int pad_ourselves; -#else -# define pad_ourselves 0 -#endif - TCHAR_T *fbp; - unsigned int prefix_count; - int prefixes[2] IF_LINT (= { 0 }); - int orig_errno; -#if !USE_SNPRINTF - size_t tmp_length; - TCHAR_T tmpbuf[700]; - TCHAR_T *tmp; -#endif - -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; - - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } -#endif - -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION - has_precision = 0; - precision = 6; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; - - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; - - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } -#endif - - /* Decide whether to handle the precision ourselves. */ -#if NEED_PRINTF_UNBOUNDED_PRECISION - switch (dp->conversion) - { - case 'd': case 'i': case 'u': - case 'o': - case 'x': case 'X': case 'p': - prec_ourselves = has_precision && (precision > 0); - break; - default: - prec_ourselves = 0; - break; - } -#endif - - /* Decide whether to perform the padding ourselves. */ -#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) - switch (dp->conversion) - { -# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO - /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need - to perform the padding after this conversion. Functions - with unistdio extensions perform the padding based on - character count rather than element count. */ - case 'c': case 's': -# endif -# if NEED_PRINTF_FLAG_ZERO - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': -# endif - pad_ourselves = 1; - break; - default: - pad_ourselves = prec_ourselves; - break; - } -#endif - -#if !USE_SNPRINTF - /* Allocate a temporary buffer of sufficient size for calling - sprintf. */ - tmp_length = - MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, - flags, width, has_precision, precision, - pad_ourselves); - - if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); - - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (TCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } -#endif - - /* Construct the format string for calling snprintf or - sprintf. */ - fbp = buf; - *fbp++ = '%'; -#if NEED_PRINTF_FLAG_GROUPING - /* The underlying implementation doesn't support the ' flag. - Produce no grouping characters in this case; this is - acceptable because the grouping is locale dependent. */ -#else - if (flags & FLAG_GROUP) - *fbp++ = '\''; -#endif - if (flags & FLAG_LEFT) - *fbp++ = '-'; - if (flags & FLAG_SHOWSIGN) - *fbp++ = '+'; - if (flags & FLAG_SPACE) - *fbp++ = ' '; - if (flags & FLAG_ALT) - *fbp++ = '#'; -#if __GLIBC__ >= 2 && !defined __UCLIBC__ - if (flags & FLAG_LOCALIZED) - *fbp++ = 'I'; -#endif - if (!pad_ourselves) - { - if (flags & FLAG_ZERO) - *fbp++ = '0'; - if (dp->width_start != dp->width_end) - { - size_t n = dp->width_end - dp->width_start; - /* The width specification is known to consist only - of standard ASCII characters. */ - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) - { - memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); - fbp += n; - } - else - { - const FCHAR_T *mp = dp->width_start; - do - *fbp++ = (unsigned char) *mp++; - while (--n > 0); - } - } - } - if (!prec_ourselves) - { - if (dp->precision_start != dp->precision_end) - { - size_t n = dp->precision_end - dp->precision_start; - /* The precision specification is known to consist only - of standard ASCII characters. */ - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) - { - memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); - fbp += n; - } - else - { - const FCHAR_T *mp = dp->precision_start; - do - *fbp++ = (unsigned char) *mp++; - while (--n > 0); - } - } - } - - switch (type) - { -#if HAVE_LONG_LONG_INT - case TYPE_LONGLONGINT: - case TYPE_ULONGLONGINT: -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - *fbp++ = 'I'; - *fbp++ = '6'; - *fbp++ = '4'; - break; -# else - *fbp++ = 'l'; - /*FALLTHROUGH*/ -# endif -#endif - case TYPE_LONGINT: - case TYPE_ULONGINT: -#if HAVE_WINT_T - case TYPE_WIDE_CHAR: -#endif -#if HAVE_WCHAR_T - case TYPE_WIDE_STRING: -#endif - *fbp++ = 'l'; - break; - case TYPE_LONGDOUBLE: - *fbp++ = 'L'; - break; - default: - break; - } -#if NEED_PRINTF_DIRECTIVE_F - if (dp->conversion == 'F') - *fbp = 'f'; - else -#endif - *fbp = dp->conversion; -#if USE_SNPRINTF -# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) - fbp[1] = '%'; - fbp[2] = 'n'; - fbp[3] = '\0'; -# else - /* On glibc2 systems from glibc >= 2.3 - probably also older - ones - we know that snprintf's return value conforms to - ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and - gl_SNPRINTF_TRUNCATION_C99 pass. - Therefore we can avoid using %n in this situation. - On glibc2 systems from 2004-10-18 or newer, the use of %n - in format strings in writable memory may crash the program - (if compiled with _FORTIFY_SOURCE=2), so we should avoid it - in this situation. */ - /* On native Windows systems (such as mingw), we can avoid using - %n because: - - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, - snprintf does not write more than the specified number - of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes - '4', '5', '6' into buf, not '4', '5', '\0'.) - - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf - allows us to recognize the case of an insufficient - buffer size: it returns -1 in this case. - On native Windows systems (such as mingw) where the OS is - Windows Vista, the use of %n in format strings by default - crashes the program. See - and - - So we should avoid %n in this situation. */ - fbp[1] = '\0'; -# endif -#else - fbp[1] = '\0'; -#endif - - /* Construct the arguments for calling snprintf or sprintf. */ - prefix_count = 0; - if (!pad_ourselves && dp->width_arg_index != ARG_NONE) - { - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; - } - if (!prec_ourselves && dp->precision_arg_index != ARG_NONE) - { - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; - } - -#if USE_SNPRINTF - /* The SNPRINTF result is appended after result[0..length]. - The latter is an array of DCHAR_T; SNPRINTF appends an - array of TCHAR_T to it. This is possible because - sizeof (TCHAR_T) divides sizeof (DCHAR_T) and - alignof (TCHAR_T) <= alignof (DCHAR_T). */ -# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T)) - /* Ensure that maxlen below will be >= 2. Needed on BeOS, - where an snprintf() with maxlen==1 acts like sprintf(). */ - ENSURE_ALLOCATION (xsum (length, - (2 + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR)); - /* Prepare checking whether snprintf returns the count - via %n. */ - *(TCHAR_T *) (result + length) = '\0'; -#endif - - orig_errno = errno; - - for (;;) - { - int count = -1; - -#if USE_SNPRINTF - int retcount = 0; - size_t maxlen = allocated - length; - /* SNPRINTF can fail if its second argument is - > INT_MAX. */ - if (maxlen > INT_MAX / TCHARS_PER_DCHAR) - maxlen = INT_MAX / TCHARS_PER_DCHAR; - maxlen = maxlen * TCHARS_PER_DCHAR; -# define SNPRINTF_BUF(arg) \ - switch (prefix_count) \ - { \ - case 0: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - arg, &count); \ - break; \ - case 1: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - prefixes[0], arg, &count); \ - break; \ - case 2: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - prefixes[0], prefixes[1], arg, \ - &count); \ - break; \ - default: \ - abort (); \ - } -#else -# define SNPRINTF_BUF(arg) \ - switch (prefix_count) \ - { \ - case 0: \ - count = sprintf (tmp, buf, arg); \ - break; \ - case 1: \ - count = sprintf (tmp, buf, prefixes[0], arg); \ - break; \ - case 2: \ - count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ - arg); \ - break; \ - default: \ - abort (); \ - } -#endif - - errno = 0; - switch (type) - { - case TYPE_SCHAR: - { - int arg = a.arg[dp->arg_index].a.a_schar; - SNPRINTF_BUF (arg); - } - break; - case TYPE_UCHAR: - { - unsigned int arg = a.arg[dp->arg_index].a.a_uchar; - SNPRINTF_BUF (arg); - } - break; - case TYPE_SHORT: - { - int arg = a.arg[dp->arg_index].a.a_short; - SNPRINTF_BUF (arg); - } - break; - case TYPE_USHORT: - { - unsigned int arg = a.arg[dp->arg_index].a.a_ushort; - SNPRINTF_BUF (arg); - } - break; - case TYPE_INT: - { - int arg = a.arg[dp->arg_index].a.a_int; - SNPRINTF_BUF (arg); - } - break; - case TYPE_UINT: - { - unsigned int arg = a.arg[dp->arg_index].a.a_uint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_LONGINT: - { - long int arg = a.arg[dp->arg_index].a.a_longint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_ULONGINT: - { - unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; - SNPRINTF_BUF (arg); - } - break; -#if HAVE_LONG_LONG_INT - case TYPE_LONGLONGINT: - { - long long int arg = a.arg[dp->arg_index].a.a_longlongint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_ULONGLONGINT: - { - unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; - SNPRINTF_BUF (arg); - } - break; -#endif - case TYPE_DOUBLE: - { - double arg = a.arg[dp->arg_index].a.a_double; - SNPRINTF_BUF (arg); - } - break; - case TYPE_LONGDOUBLE: - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; - SNPRINTF_BUF (arg); - } - break; - case TYPE_CHAR: - { - int arg = a.arg[dp->arg_index].a.a_char; - SNPRINTF_BUF (arg); - } - break; -#if HAVE_WINT_T - case TYPE_WIDE_CHAR: - { - wint_t arg = a.arg[dp->arg_index].a.a_wide_char; - SNPRINTF_BUF (arg); - } - break; -#endif - case TYPE_STRING: - { - const char *arg = a.arg[dp->arg_index].a.a_string; - SNPRINTF_BUF (arg); - } - break; -#if HAVE_WCHAR_T - case TYPE_WIDE_STRING: - { - const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; - SNPRINTF_BUF (arg); - } - break; -#endif - case TYPE_POINTER: - { - void *arg = a.arg[dp->arg_index].a.a_pointer; - SNPRINTF_BUF (arg); - } - break; - default: - abort (); - } - -#if USE_SNPRINTF - /* Portability: Not all implementations of snprintf() - are ISO C 99 compliant. Determine the number of - bytes that snprintf() has produced or would have - produced. */ - if (count >= 0) - { - /* Verify that snprintf() has NUL-terminated its - result. */ - if (count < maxlen - && ((TCHAR_T *) (result + length)) [count] != '\0') - abort (); - /* Portability hack. */ - if (retcount > count) - count = retcount; - } - else - { - /* snprintf() doesn't understand the '%n' - directive. */ - if (fbp[1] != '\0') - { - /* Don't use the '%n' directive; instead, look - at the snprintf() return value. */ - fbp[1] = '\0'; - continue; - } - else - { - /* Look at the snprintf() return value. */ - if (retcount < 0) - { -# if !HAVE_SNPRINTF_RETVAL_C99 - /* HP-UX 10.20 snprintf() is doubly deficient: - It doesn't understand the '%n' directive, - *and* it returns -1 (rather than the length - that would have been required) when the - buffer is too small. - But a failure at this point can also come - from other reasons than a too small buffer, - such as an invalid wide string argument to - the %ls directive, or possibly an invalid - floating-point argument. */ - size_t tmp_length = - MAX_ROOM_NEEDED (&a, dp->arg_index, - dp->conversion, type, flags, - width, has_precision, - precision, pad_ourselves); - - if (maxlen < tmp_length) - { - /* Make more room. But try to do through - this reallocation only once. */ - size_t bigger_need = - xsum (length, - xsum (tmp_length, - TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR); - /* And always grow proportionally. - (There may be several arguments, each - needing a little more room than the - previous one.) */ - size_t bigger_need2 = - xsum (xtimes (allocated, 2), 12); - if (bigger_need < bigger_need2) - bigger_need = bigger_need2; - ENSURE_ALLOCATION (bigger_need); - continue; - } -# endif - } - else - count = retcount; - } - } -#endif - - /* Attempt to handle failure. */ - if (count < 0) - { - /* SNPRINTF or sprintf failed. Save and use the errno - that it has set, if any. */ - int saved_errno = errno; - - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = - (saved_errno != 0 - ? saved_errno - : (dp->conversion == 'c' || dp->conversion == 's' - ? EILSEQ - : EINVAL)); - return NULL; - } - -#if USE_SNPRINTF - /* Handle overflow of the allocated buffer. - If such an overflow occurs, a C99 compliant snprintf() - returns a count >= maxlen. However, a non-compliant - snprintf() function returns only count = maxlen - 1. To - cover both cases, test whether count >= maxlen - 1. */ - if ((unsigned int) count + 1 >= maxlen) - { - /* If maxlen already has attained its allowed maximum, - allocating more memory will not increase maxlen. - Instead of looping, bail out. */ - if (maxlen == INT_MAX / TCHARS_PER_DCHAR) - goto overflow; - else - { - /* Need at least (count + 1) * sizeof (TCHAR_T) - bytes. (The +1 is for the trailing NUL.) - But ask for (count + 2) * sizeof (TCHAR_T) - bytes, so that in the next round, we likely get - maxlen > (unsigned int) count + 1 - and so we don't get here again. - And allocate proportionally, to avoid looping - eternally if snprintf() reports a too small - count. */ - size_t n = - xmax (xsum (length, - ((unsigned int) count + 2 - + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR), - xtimes (allocated, 2)); - - ENSURE_ALLOCATION (n); - continue; - } - } -#endif - -#if NEED_PRINTF_UNBOUNDED_PRECISION - if (prec_ourselves) - { - /* Handle the precision. */ - TCHAR_T *prec_ptr = -# if USE_SNPRINTF - (TCHAR_T *) (result + length); -# else - tmp; -# endif - size_t prefix_count; - size_t move; - - prefix_count = 0; - /* Put the additional zeroes after the sign. */ - if (count >= 1 - && (*prec_ptr == '-' || *prec_ptr == '+' - || *prec_ptr == ' ')) - prefix_count = 1; - /* Put the additional zeroes after the 0x prefix if - (flags & FLAG_ALT) || (dp->conversion == 'p'). */ - else if (count >= 2 - && prec_ptr[0] == '0' - && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) - prefix_count = 2; - - move = count - prefix_count; - if (precision > move) - { - /* Insert zeroes. */ - size_t insert = precision - move; - TCHAR_T *prec_end; - -# if USE_SNPRINTF - size_t n = - xsum (length, - (count + insert + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR); - length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; - ENSURE_ALLOCATION (n); - length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; - prec_ptr = (TCHAR_T *) (result + length); -# endif - - prec_end = prec_ptr + count; - prec_ptr += prefix_count; - - while (prec_end > prec_ptr) - { - prec_end--; - prec_end[insert] = prec_end[0]; - } - - prec_end += insert; - do - *--prec_end = '0'; - while (prec_end > prec_ptr); - - count += insert; - } - } -#endif - -#if !USE_SNPRINTF - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); -#endif - -#if !DCHAR_IS_TCHAR - /* Convert from TCHAR_T[] to DCHAR_T[]. */ - if (dp->conversion == 'c' || dp->conversion == 's') - { - /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING - TYPE_WIDE_STRING. - The result string is not certainly ASCII. */ - const TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t tmpdst_len; - /* This code assumes that TCHAR_T is 'char'. */ - verify (sizeof (TCHAR_T) == 1); -# if USE_SNPRINTF - tmpsrc = (TCHAR_T *) (result + length); -# else - tmpsrc = tmp; -# endif - tmpdst = - DCHAR_CONV_FROM_ENCODING (locale_charset (), - iconveh_question_mark, - tmpsrc, count, - NULL, - NULL, &tmpdst_len); - if (tmpdst == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - ENSURE_ALLOCATION (xsum (length, tmpdst_len)); - DCHAR_CPY (result + length, tmpdst, tmpdst_len); - free (tmpdst); - count = tmpdst_len; - } - else - { - /* The result string is ASCII. - Simple 1:1 conversion. */ -# if USE_SNPRINTF - /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a - no-op conversion, in-place on the array starting - at (result + length). */ - if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) -# endif - { - const TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t n; - -# if USE_SNPRINTF - if (result == resultbuf) - { - tmpsrc = (TCHAR_T *) (result + length); - /* ENSURE_ALLOCATION will not move tmpsrc - (because it's part of resultbuf). */ - ENSURE_ALLOCATION (xsum (length, count)); - } - else - { - /* ENSURE_ALLOCATION will move the array - (because it uses realloc(). */ - ENSURE_ALLOCATION (xsum (length, count)); - tmpsrc = (TCHAR_T *) (result + length); - } -# else - tmpsrc = tmp; - ENSURE_ALLOCATION (xsum (length, count)); -# endif - tmpdst = result + length; - /* Copy backwards, because of overlapping. */ - tmpsrc += count; - tmpdst += count; - for (n = count; n > 0; n--) - *--tmpdst = (unsigned char) *--tmpsrc; - } - } -#endif - -#if DCHAR_IS_TCHAR && !USE_SNPRINTF - /* Make room for the result. */ - if (count > allocated - length) - { - /* Need at least count elements. But allocate - proportionally. */ - size_t n = - xmax (xsum (length, count), xtimes (allocated, 2)); - - ENSURE_ALLOCATION (n); - } -#endif - - /* Here count <= allocated - length. */ - - /* Perform padding. */ -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - if (pad_ourselves && has_width) - { - size_t w; -# if ENABLE_UNISTDIO - /* Outside POSIX, it's preferable to compare the width - against the number of _characters_ of the converted - value. */ - w = DCHAR_MBSNLEN (result + length, count); -# else - /* The width is compared against the number of _bytes_ - of the converted value, says POSIX. */ - w = count; -# endif - if (w < width) - { - size_t pad = width - w; - - /* Make room for the result. */ - if (xsum (count, pad) > allocated - length) - { - /* Need at least count + pad elements. But - allocate proportionally. */ - size_t n = - xmax (xsum3 (length, count, pad), - xtimes (allocated, 2)); - -# if USE_SNPRINTF - length += count; - ENSURE_ALLOCATION (n); - length -= count; -# else - ENSURE_ALLOCATION (n); -# endif - } - /* Here count + pad <= allocated - length. */ - - { -# if !DCHAR_IS_TCHAR || USE_SNPRINTF - DCHAR_T * const rp = result + length; -# else - DCHAR_T * const rp = tmp; -# endif - DCHAR_T *p = rp + count; - DCHAR_T *end = p + pad; - DCHAR_T *pad_ptr; -# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO - if (dp->conversion == 'c' - || dp->conversion == 's') - /* No zero-padding for string directives. */ - pad_ptr = NULL; - else -# endif - { - pad_ptr = (*rp == '-' ? rp + 1 : rp); - /* No zero-padding of "inf" and "nan". */ - if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') - || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) - pad_ptr = NULL; - } - /* The generated string now extends from rp to p, - with the zero padding insertion point being at - pad_ptr. */ - - count = count + pad; /* = end - rp */ - - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; - - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; - - while (p > rp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } - } - } - } -#endif - - /* Here still count <= allocated - length. */ - -#if !DCHAR_IS_TCHAR || USE_SNPRINTF - /* The snprintf() result did fit. */ -#else - /* Append the sprintf() result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); -#endif -#if !USE_SNPRINTF - if (tmp != tmpbuf) - free (tmp); -#endif - -#if NEED_PRINTF_DIRECTIVE_F - if (dp->conversion == 'F') - { - /* Convert the %f result to upper case for %F. */ - DCHAR_T *rp = result + length; - size_t rc; - for (rc = count; rc > 0; rc--, rp++) - if (*rp >= 'a' && *rp <= 'z') - *rp = *rp - 'a' + 'A'; - } -#endif - - length += count; - break; - } - errno = orig_errno; -#undef pad_ourselves -#undef prec_ourselves - } - } - } - - /* Add the final NUL. */ - ENSURE_ALLOCATION (xsum (length, 1)); - result[length] = '\0'; - - if (result != resultbuf && length + 1 < allocated) - { - /* Shrink the allocated memory if possible. */ - DCHAR_T *memory; - - memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); - if (memory != NULL) - result = memory; - } - - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - *lengthp = length; - /* Note that we can produce a big string of a length > INT_MAX. POSIX - says that snprintf() fails with errno = EOVERFLOW in this case, but - that's only because snprintf() returns an 'int'. This function does - not have this limitation. */ - return result; - -#if USE_SNPRINTF - overflow: - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EOVERFLOW; - return NULL; -#endif - - out_of_memory: - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - out_of_memory_1: - CLEANUP (); - errno = ENOMEM; - return NULL; - } -} - -#undef MAX_ROOM_NEEDED -#undef TCHARS_PER_DCHAR -#undef SNPRINTF -#undef USE_SNPRINTF -#undef DCHAR_SET -#undef DCHAR_CPY -#undef PRINTF_PARSE -#undef DIRECTIVES -#undef DIRECTIVE -#undef DCHAR_IS_TCHAR -#undef TCHAR_T -#undef DCHAR_T -#undef FCHAR_T -#undef VASNPRINTF diff --git a/grub-core/gnulib/vasnprintf.h b/grub-core/gnulib/vasnprintf.h deleted file mode 100644 index 7658f505e..000000000 --- a/grub-core/gnulib/vasnprintf.h +++ /dev/null @@ -1,79 +0,0 @@ -/* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifndef _VASNPRINTF_H -#define _VASNPRINTF_H - -/* Get va_list. */ -#include - -/* Get size_t. */ -#include - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Write formatted output to a string dynamically allocated with malloc(). - You can pass a preallocated buffer for the result in RESULTBUF and its - size in *LENGTHP; otherwise you pass RESULTBUF = NULL. - If successful, return the address of the string (this may be = RESULTBUF - if no dynamic memory allocation was necessary) and set *LENGTHP to the - number of resulting bytes, excluding the trailing NUL. Upon error, set - errno and return NULL. - - When dynamic memory allocation occurs, the preallocated buffer is left - alone (with possibly modified contents). This makes it possible to use - a statically allocated or stack-allocated buffer, like this: - - char buf[100]; - size_t len = sizeof (buf); - char *output = vasnprintf (buf, &len, format, args); - if (output == NULL) - ... error handling ...; - else - { - ... use the output string ...; - if (output != buf) - free (output); - } - */ -#if REPLACE_VASNPRINTF -# define asnprintf rpl_asnprintf -# define vasnprintf rpl_vasnprintf -#endif -extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); -extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0)); - -#ifdef __cplusplus -} -#endif - -#endif /* _VASNPRINTF_H */ diff --git a/grub-core/gnulib/verify.h b/grub-core/gnulib/verify.h deleted file mode 100644 index cb8e90b54..000000000 --- a/grub-core/gnulib/verify.h +++ /dev/null @@ -1,245 +0,0 @@ -/* Compile-time assert-like macros. - - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ - -#ifndef _GL_VERIFY_H -# define _GL_VERIFY_H - - -/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. - This is supported by GCC 4.6.0 and later, in C mode, and its use - here generates easier-to-read diagnostics when verify (R) fails. - - Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. - This will likely be supported by future GCC versions, in C++ mode. - - Use this only with GCC. If we were willing to slow 'configure' - down we could also use it with other compilers, but since this - affects only the quality of diagnostics, why bother? */ -# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus -# define _GL_HAVE__STATIC_ASSERT 1 -# endif -/* The condition (99 < __GNUC__) is temporary, until we know about the - first G++ release that supports static_assert. */ -# if (99 < __GNUC__) && defined __cplusplus -# define _GL_HAVE_STATIC_ASSERT 1 -# endif - -/* Each of these macros verifies that its argument R is nonzero. To - be portable, R should be an integer constant expression. Unlike - assert (R), there is no run-time overhead. - - If _Static_assert works, verify (R) uses it directly. Similarly, - _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct - that is an operand of sizeof. - - The code below uses several ideas for C++ compilers, and for C - compilers that do not support _Static_assert: - - * The first step is ((R) ? 1 : -1). Given an expression R, of - integral or boolean or floating-point type, this yields an - expression of integral type, whose value is later verified to be - constant and nonnegative. - - * Next this expression W is wrapped in a type - struct _gl_verify_type { - unsigned int _gl_verify_error_if_negative: W; - }. - If W is negative, this yields a compile-time error. No compiler can - deal with a bit-field of negative size. - - One might think that an array size check would have the same - effect, that is, that the type struct { unsigned int dummy[W]; } - would work as well. However, inside a function, some compilers - (such as C++ compilers and GNU C) allow local parameters and - variables inside array size expressions. With these compilers, - an array size check would not properly diagnose this misuse of - the verify macro: - - void function (int n) { verify (n < 0); } - - * For the verify macro, the struct _gl_verify_type will need to - somehow be embedded into a declaration. To be portable, this - declaration must declare an object, a constant, a function, or a - typedef name. If the declared entity uses the type directly, - such as in - - struct dummy {...}; - typedef struct {...} dummy; - extern struct {...} *dummy; - extern void dummy (struct {...} *); - extern struct {...} *dummy (void); - - two uses of the verify macro would yield colliding declarations - if the entity names are not disambiguated. A workaround is to - attach the current line number to the entity name: - - #define _GL_CONCAT0(x, y) x##y - #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) - extern struct {...} * _GL_CONCAT (dummy, __LINE__); - - But this has the problem that two invocations of verify from - within the same macro would collide, since the __LINE__ value - would be the same for both invocations. (The GCC __COUNTER__ - macro solves this problem, but is not portable.) - - A solution is to use the sizeof operator. It yields a number, - getting rid of the identity of the type. Declarations like - - extern int dummy [sizeof (struct {...})]; - extern void dummy (int [sizeof (struct {...})]); - extern int (*dummy (void)) [sizeof (struct {...})]; - - can be repeated. - - * Should the implementation use a named struct or an unnamed struct? - Which of the following alternatives can be used? - - extern int dummy [sizeof (struct {...})]; - extern int dummy [sizeof (struct _gl_verify_type {...})]; - extern void dummy (int [sizeof (struct {...})]); - extern void dummy (int [sizeof (struct _gl_verify_type {...})]); - extern int (*dummy (void)) [sizeof (struct {...})]; - extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})]; - - In the second and sixth case, the struct type is exported to the - outer scope; two such declarations therefore collide. GCC warns - about the first, third, and fourth cases. So the only remaining - possibility is the fifth case: - - extern int (*dummy (void)) [sizeof (struct {...})]; - - * GCC warns about duplicate declarations of the dummy function if - -Wredundant-decls is used. GCC 4.3 and later have a builtin - __COUNTER__ macro that can let us generate unique identifiers for - each dummy function, to suppress this warning. - - * This implementation exploits the fact that older versions of GCC, - which do not support _Static_assert, also do not warn about the - last declaration mentioned above. - - * GCC warns if -Wnested-externs is enabled and verify() is used - within a function body; but inside a function, you can always - arrange to use verify_expr() instead. - - * In C++, any struct definition inside sizeof is invalid. - Use a template type to work around the problem. */ - -/* Concatenate two preprocessor tokens. */ -# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) -# define _GL_CONCAT0(x, y) x##y - -/* _GL_COUNTER is an integer, preferably one that changes each time we - use it. Use __COUNTER__ if it works, falling back on __LINE__ - otherwise. __LINE__ isn't perfect, but it's better than a - constant. */ -# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ -# define _GL_COUNTER __COUNTER__ -# else -# define _GL_COUNTER __LINE__ -# endif - -/* Generate a symbol with the given prefix, making it unique if - possible. */ -# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) - -/* Verify requirement R at compile-time, as an integer constant expression - that returns 1. If R is false, fail at compile-time, preferably - with a diagnostic that includes the string-literal DIAGNOSTIC. */ - -# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ - (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) - -# ifdef __cplusplus -# if !GNULIB_defined_struct__gl_verify_type -template - struct _gl_verify_type { - unsigned int _gl_verify_error_if_negative: w; - }; -# define GNULIB_defined_struct__gl_verify_type 1 -# endif -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - _gl_verify_type<(R) ? 1 : -1> -# elif defined _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - struct { \ - _Static_assert (R, DIAGNOSTIC); \ - int _gl_dummy; \ - } -# else -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } -# endif - -/* Verify requirement R at compile-time, as a declaration without a - trailing ';'. If R is false, fail at compile-time, preferably - with a diagnostic that includes the string-literal DIAGNOSTIC. - - Unfortunately, unlike C11, this implementation must appear as an - ordinary declaration, and cannot appear inside struct { ... }. */ - -# ifdef _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY _Static_assert -# else -# define _GL_VERIFY(R, DIAGNOSTIC) \ - extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ - [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] -# endif - -/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ -# ifdef _GL_STATIC_ASSERT_H -# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert -# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) -# endif -# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert -# define static_assert _Static_assert /* C11 requires this #define. */ -# endif -# endif - -/* @assert.h omit start@ */ - -/* Each of these macros verifies that its argument R is nonzero. To - be portable, R should be an integer constant expression. Unlike - assert (R), there is no run-time overhead. - - There are two macros, since no single macro can be used in all - contexts in C. verify_true (R) is for scalar contexts, including - integer constant expression contexts. verify (R) is for declaration - contexts, e.g., the top level. */ - -/* Verify requirement R at compile-time, as an integer constant expression. - Return 1. This is equivalent to verify_expr (R, 1). - - verify_true is obsolescent; please use verify_expr instead. */ - -# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") - -/* Verify requirement R at compile-time. Return the value of the - expression E. */ - -# define verify_expr(R, E) \ - (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) - -/* Verify requirement R at compile-time, as a declaration without a - trailing ';'. */ - -# define verify(R) _GL_VERIFY (R, "verify (" #R ")") - -/* @assert.h omit end@ */ - -#endif diff --git a/grub-core/gnulib/vsnprintf.c b/grub-core/gnulib/vsnprintf.c deleted file mode 100644 index 7d4dfbed9..000000000 --- a/grub-core/gnulib/vsnprintf.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. - Written by Simon Josefsson and Yoann Vandoorselaere . - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -/* Specification. */ -#include - -#include -#include -#include -#include -#include - -#include "vasnprintf.h" - -/* Print formatted output to string STR. Similar to vsprintf, but - additional length SIZE limit how much is written into STR. Returns - string length of formatted string (which may be larger than SIZE). - STR may be NULL, in which case nothing will be written. On error, - return a negative value. */ -int -vsnprintf (char *str, size_t size, const char *format, va_list args) -{ - char *output; - size_t len; - size_t lenbuf = size; - - output = vasnprintf (str, &lenbuf, format, args); - len = lenbuf; - - if (!output) - return -1; - - if (output != str) - { - if (size) - { - size_t pruned_len = (len < size ? len : size - 1); - memcpy (str, output, pruned_len); - str[pruned_len] = '\0'; - } - - free (output); - } - - if (len > INT_MAX) - { - errno = EOVERFLOW; - return -1; - } - - return len; -} diff --git a/grub-core/gnulib/wchar.in.h b/grub-core/gnulib/wchar.in.h deleted file mode 100644 index b6e436279..000000000 --- a/grub-core/gnulib/wchar.in.h +++ /dev/null @@ -1,1028 +0,0 @@ -/* A substitute for ISO C99 , for platforms that have issues. - - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Written by Eric Blake. */ - -/* - * ISO C 99 for platforms that have issues. - * - * - * For now, this just ensures proper prerequisite inclusion order and - * the declaration of wcwidth(). - */ - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H -/* Special invocation convention: - - Inside glibc and uClibc header files. - - On HP-UX 11.00 we have a sequence of nested includes - -> -> , and the latter includes , - once indirectly -> -> -> - and once directly. In both situations 'wint_t' is not yet defined, - therefore we cannot provide the function overrides; instead include only - the system's . - - On IRIX 6.5, similarly, we have an include -> , and - the latter includes . But here, we have no way to detect whether - is completely included or is still being included. */ - -#@INCLUDE_NEXT@ @NEXT_WCHAR_H@ - -#else -/* Normal invocation convention. */ - -#ifndef _@GUARD_PREFIX@_WCHAR_H - -#define _GL_ALREADY_INCLUDING_WCHAR_H - -#if @HAVE_FEATURES_H@ -# include /* for __GLIBC__ */ -#endif - -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . - In some builds of uClibc, is nonexistent and wchar_t is defined - by . - But avoid namespace pollution on glibc systems. */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -#endif -#ifndef __GLIBC__ -# include -# include -#endif - -/* Include the original if it exists. - Some builds of uClibc lack it. */ -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_WCHAR_H@ -# @INCLUDE_NEXT@ @NEXT_WCHAR_H@ -#endif - -#undef _GL_ALREADY_INCLUDING_WCHAR_H - -#ifndef _@GUARD_PREFIX@_WCHAR_H -#define _@GUARD_PREFIX@_WCHAR_H - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The attribute __pure__ was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - - -/* Define wint_t and WEOF. (Also done in wctype.in.h.) */ -#if !@HAVE_WINT_T@ && !defined wint_t -# define wint_t int -# ifndef WEOF -# define WEOF -1 -# endif -#else -/* MSVC defines wint_t as 'unsigned short' in . - This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be - "unchanged by default argument promotions". Override it. */ -# if defined _MSC_VER -# if !GNULIB_defined_wint_t -# include -typedef unsigned int rpl_wint_t; -# undef wint_t -# define wint_t rpl_wint_t -# define GNULIB_defined_wint_t 1 -# endif -# endif -# ifndef WEOF -# define WEOF ((wint_t) -1) -# endif -#endif - - -/* Override mbstate_t if it is too small. - On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for - implementing mbrtowc for encodings like UTF-8. */ -#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ -# if !GNULIB_defined_mbstate_t -typedef int rpl_mbstate_t; -# undef mbstate_t -# define mbstate_t rpl_mbstate_t -# define GNULIB_defined_mbstate_t 1 -# endif -#endif - - -/* Convert a single-byte character to a wide character. */ -#if @GNULIB_BTOWC@ -# if @REPLACE_BTOWC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef btowc -# define btowc rpl_btowc -# endif -_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); -_GL_CXXALIAS_RPL (btowc, wint_t, (int c)); -# else -# if !@HAVE_BTOWC@ -_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (btowc, wint_t, (int c)); -# endif -_GL_CXXALIASWARN (btowc); -#elif defined GNULIB_POSIXCHECK -# undef btowc -# if HAVE_RAW_DECL_BTOWC -_GL_WARN_ON_USE (btowc, "btowc is unportable - " - "use gnulib module btowc for portability"); -# endif -#endif - - -/* Convert a wide character to a single-byte character. */ -#if @GNULIB_WCTOB@ -# if @REPLACE_WCTOB@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wctob -# define wctob rpl_wctob -# endif -_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); -_GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); -# else -# if !defined wctob && !@HAVE_DECL_WCTOB@ -/* wctob is provided by gnulib, or wctob exists but is not declared. */ -_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); -# endif -_GL_CXXALIASWARN (wctob); -#elif defined GNULIB_POSIXCHECK -# undef wctob -# if HAVE_RAW_DECL_WCTOB -_GL_WARN_ON_USE (wctob, "wctob is unportable - " - "use gnulib module wctob for portability"); -# endif -#endif - - -/* Test whether *PS is in the initial state. */ -#if @GNULIB_MBSINIT@ -# if @REPLACE_MBSINIT@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbsinit -# define mbsinit rpl_mbsinit -# endif -_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); -_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); -# else -# if !@HAVE_MBSINIT@ -_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); -# endif -_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (mbsinit); -#elif defined GNULIB_POSIXCHECK -# undef mbsinit -# if HAVE_RAW_DECL_MBSINIT -_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " - "use gnulib module mbsinit for portability"); -# endif -#endif - - -/* Convert a multibyte character to a wide character. */ -#if @GNULIB_MBRTOWC@ -# if @REPLACE_MBRTOWC@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbrtowc -# define mbrtowc rpl_mbrtowc -# endif -_GL_FUNCDECL_RPL (mbrtowc, size_t, - (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); -_GL_CXXALIAS_RPL (mbrtowc, size_t, - (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); -# else -# if !@HAVE_MBRTOWC@ -_GL_FUNCDECL_SYS (mbrtowc, size_t, - (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); -# endif -_GL_CXXALIAS_SYS (mbrtowc, size_t, - (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (mbrtowc); -#elif defined GNULIB_POSIXCHECK -# undef mbrtowc -# if HAVE_RAW_DECL_MBRTOWC -_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " - "use gnulib module mbrtowc for portability"); -# endif -#endif - - -/* Recognize a multibyte character. */ -#if @GNULIB_MBRLEN@ -# if @REPLACE_MBRLEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbrlen -# define mbrlen rpl_mbrlen -# endif -_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); -_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); -# else -# if !@HAVE_MBRLEN@ -_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); -# endif -_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (mbrlen); -#elif defined GNULIB_POSIXCHECK -# undef mbrlen -# if HAVE_RAW_DECL_MBRLEN -_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " - "use gnulib module mbrlen for portability"); -# endif -#endif - - -/* Convert a string to a wide string. */ -#if @GNULIB_MBSRTOWCS@ -# if @REPLACE_MBSRTOWCS@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbsrtowcs -# define mbsrtowcs rpl_mbsrtowcs -# endif -_GL_FUNCDECL_RPL (mbsrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (mbsrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t len, - mbstate_t *ps)); -# else -# if !@HAVE_MBSRTOWCS@ -_GL_FUNCDECL_SYS (mbsrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (mbsrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t len, - mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (mbsrtowcs); -#elif defined GNULIB_POSIXCHECK -# undef mbsrtowcs -# if HAVE_RAW_DECL_MBSRTOWCS -_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " - "use gnulib module mbsrtowcs for portability"); -# endif -#endif - - -/* Convert a string to a wide string. */ -#if @GNULIB_MBSNRTOWCS@ -# if @REPLACE_MBSNRTOWCS@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef mbsnrtowcs -# define mbsnrtowcs rpl_mbsnrtowcs -# endif -_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t srclen, size_t len, - mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t srclen, size_t len, - mbstate_t *ps)); -# else -# if !@HAVE_MBSNRTOWCS@ -_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t srclen, size_t len, - mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, - (wchar_t *dest, const char **srcp, size_t srclen, size_t len, - mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (mbsnrtowcs); -#elif defined GNULIB_POSIXCHECK -# undef mbsnrtowcs -# if HAVE_RAW_DECL_MBSNRTOWCS -_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " - "use gnulib module mbsnrtowcs for portability"); -# endif -#endif - - -/* Convert a wide character to a multibyte character. */ -#if @GNULIB_WCRTOMB@ -# if @REPLACE_WCRTOMB@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wcrtomb -# define wcrtomb rpl_wcrtomb -# endif -_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); -_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); -# else -# if !@HAVE_WCRTOMB@ -_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); -# endif -_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (wcrtomb); -#elif defined GNULIB_POSIXCHECK -# undef wcrtomb -# if HAVE_RAW_DECL_WCRTOMB -_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " - "use gnulib module wcrtomb for portability"); -# endif -#endif - - -/* Convert a wide string to a string. */ -#if @GNULIB_WCSRTOMBS@ -# if @REPLACE_WCSRTOMBS@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wcsrtombs -# define wcsrtombs rpl_wcsrtombs -# endif -_GL_FUNCDECL_RPL (wcsrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (wcsrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t len, - mbstate_t *ps)); -# else -# if !@HAVE_WCSRTOMBS@ -_GL_FUNCDECL_SYS (wcsrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (wcsrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t len, - mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (wcsrtombs); -#elif defined GNULIB_POSIXCHECK -# undef wcsrtombs -# if HAVE_RAW_DECL_WCSRTOMBS -_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " - "use gnulib module wcsrtombs for portability"); -# endif -#endif - - -/* Convert a wide string to a string. */ -#if @GNULIB_WCSNRTOMBS@ -# if @REPLACE_WCSNRTOMBS@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wcsnrtombs -# define wcsnrtombs rpl_wcsnrtombs -# endif -_GL_FUNCDECL_RPL (wcsnrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t srclen, size_t len, - mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (wcsnrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t srclen, size_t len, - mbstate_t *ps)); -# else -# if !@HAVE_WCSNRTOMBS@ -_GL_FUNCDECL_SYS (wcsnrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t srclen, size_t len, - mbstate_t *ps) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (wcsnrtombs, size_t, - (char *dest, const wchar_t **srcp, size_t srclen, size_t len, - mbstate_t *ps)); -# endif -_GL_CXXALIASWARN (wcsnrtombs); -#elif defined GNULIB_POSIXCHECK -# undef wcsnrtombs -# if HAVE_RAW_DECL_WCSNRTOMBS -_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " - "use gnulib module wcsnrtombs for portability"); -# endif -#endif - - -/* Return the number of screen columns needed for WC. */ -#if @GNULIB_WCWIDTH@ -# if @REPLACE_WCWIDTH@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wcwidth -# define wcwidth rpl_wcwidth -# endif -_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); -_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); -# else -# if !@HAVE_DECL_WCWIDTH@ -/* wcwidth exists but is not declared. */ -_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); -# endif -_GL_CXXALIASWARN (wcwidth); -#elif defined GNULIB_POSIXCHECK -# undef wcwidth -# if HAVE_RAW_DECL_WCWIDTH -_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " - "use gnulib module wcwidth for portability"); -# endif -#endif - - -/* Search N wide characters of S for C. */ -#if @GNULIB_WMEMCHR@ -# if !@HAVE_WMEMCHR@ -_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) - _GL_ATTRIBUTE_PURE); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { - const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t); - wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t); - } */ -_GL_CXXALIAS_SYS_CAST2 (wmemchr, - wchar_t *, (const wchar_t *, wchar_t, size_t), - const wchar_t *, (const wchar_t *, wchar_t, size_t)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); -_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, - (const wchar_t *s, wchar_t c, size_t n)); -# else -_GL_CXXALIASWARN (wmemchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef wmemchr -# if HAVE_RAW_DECL_WMEMCHR -_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " - "use gnulib module wmemchr for portability"); -# endif -#endif - - -/* Compare N wide characters of S1 and S2. */ -#if @GNULIB_WMEMCMP@ -# if !@HAVE_WMEMCMP@ -_GL_FUNCDECL_SYS (wmemcmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wmemcmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n)); -_GL_CXXALIASWARN (wmemcmp); -#elif defined GNULIB_POSIXCHECK -# undef wmemcmp -# if HAVE_RAW_DECL_WMEMCMP -_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " - "use gnulib module wmemcmp for portability"); -# endif -#endif - - -/* Copy N wide characters of SRC to DEST. */ -#if @GNULIB_WMEMCPY@ -# if !@HAVE_WMEMCPY@ -_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -# endif -_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -_GL_CXXALIASWARN (wmemcpy); -#elif defined GNULIB_POSIXCHECK -# undef wmemcpy -# if HAVE_RAW_DECL_WMEMCPY -_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " - "use gnulib module wmemcpy for portability"); -# endif -#endif - - -/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for - overlapping memory areas. */ -#if @GNULIB_WMEMMOVE@ -# if !@HAVE_WMEMMOVE@ -_GL_FUNCDECL_SYS (wmemmove, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -# endif -_GL_CXXALIAS_SYS (wmemmove, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -_GL_CXXALIASWARN (wmemmove); -#elif defined GNULIB_POSIXCHECK -# undef wmemmove -# if HAVE_RAW_DECL_WMEMMOVE -_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " - "use gnulib module wmemmove for portability"); -# endif -#endif - - -/* Set N wide characters of S to C. */ -#if @GNULIB_WMEMSET@ -# if !@HAVE_WMEMSET@ -_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); -# endif -_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); -_GL_CXXALIASWARN (wmemset); -#elif defined GNULIB_POSIXCHECK -# undef wmemset -# if HAVE_RAW_DECL_WMEMSET -_GL_WARN_ON_USE (wmemset, "wmemset is unportable - " - "use gnulib module wmemset for portability"); -# endif -#endif - - -/* Return the number of wide characters in S. */ -#if @GNULIB_WCSLEN@ -# if !@HAVE_WCSLEN@ -_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); -_GL_CXXALIASWARN (wcslen); -#elif defined GNULIB_POSIXCHECK -# undef wcslen -# if HAVE_RAW_DECL_WCSLEN -_GL_WARN_ON_USE (wcslen, "wcslen is unportable - " - "use gnulib module wcslen for portability"); -# endif -#endif - - -/* Return the number of wide characters in S, but at most MAXLEN. */ -#if @GNULIB_WCSNLEN@ -# if !@HAVE_WCSNLEN@ -_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); -_GL_CXXALIASWARN (wcsnlen); -#elif defined GNULIB_POSIXCHECK -# undef wcsnlen -# if HAVE_RAW_DECL_WCSNLEN -_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - " - "use gnulib module wcsnlen for portability"); -# endif -#endif - - -/* Copy SRC to DEST. */ -#if @GNULIB_WCSCPY@ -# if !@HAVE_WCSCPY@ -_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); -# endif -_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); -_GL_CXXALIASWARN (wcscpy); -#elif defined GNULIB_POSIXCHECK -# undef wcscpy -# if HAVE_RAW_DECL_WCSCPY -_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - " - "use gnulib module wcscpy for portability"); -# endif -#endif - - -/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ -#if @GNULIB_WCPCPY@ -# if !@HAVE_WCPCPY@ -_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); -# endif -_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); -_GL_CXXALIASWARN (wcpcpy); -#elif defined GNULIB_POSIXCHECK -# undef wcpcpy -# if HAVE_RAW_DECL_WCPCPY -_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - " - "use gnulib module wcpcpy for portability"); -# endif -#endif - - -/* Copy no more than N wide characters of SRC to DEST. */ -#if @GNULIB_WCSNCPY@ -# if !@HAVE_WCSNCPY@ -_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -# endif -_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -_GL_CXXALIASWARN (wcsncpy); -#elif defined GNULIB_POSIXCHECK -# undef wcsncpy -# if HAVE_RAW_DECL_WCSNCPY -_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - " - "use gnulib module wcsncpy for portability"); -# endif -#endif - - -/* Copy no more than N characters of SRC to DEST, returning the address of - the last character written into DEST. */ -#if @GNULIB_WCPNCPY@ -# if !@HAVE_WCPNCPY@ -_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -# endif -_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -_GL_CXXALIASWARN (wcpncpy); -#elif defined GNULIB_POSIXCHECK -# undef wcpncpy -# if HAVE_RAW_DECL_WCPNCPY -_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - " - "use gnulib module wcpncpy for portability"); -# endif -#endif - - -/* Append SRC onto DEST. */ -#if @GNULIB_WCSCAT@ -# if !@HAVE_WCSCAT@ -_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); -# endif -_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); -_GL_CXXALIASWARN (wcscat); -#elif defined GNULIB_POSIXCHECK -# undef wcscat -# if HAVE_RAW_DECL_WCSCAT -_GL_WARN_ON_USE (wcscat, "wcscat is unportable - " - "use gnulib module wcscat for portability"); -# endif -#endif - - -/* Append no more than N wide characters of SRC onto DEST. */ -#if @GNULIB_WCSNCAT@ -# if !@HAVE_WCSNCAT@ -_GL_FUNCDECL_SYS (wcsncat, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -# endif -_GL_CXXALIAS_SYS (wcsncat, wchar_t *, - (wchar_t *dest, const wchar_t *src, size_t n)); -_GL_CXXALIASWARN (wcsncat); -#elif defined GNULIB_POSIXCHECK -# undef wcsncat -# if HAVE_RAW_DECL_WCSNCAT -_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " - "use gnulib module wcsncat for portability"); -# endif -#endif - - -/* Compare S1 and S2. */ -#if @GNULIB_WCSCMP@ -# if !@HAVE_WCSCMP@ -_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); -_GL_CXXALIASWARN (wcscmp); -#elif defined GNULIB_POSIXCHECK -# undef wcscmp -# if HAVE_RAW_DECL_WCSCMP -_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " - "use gnulib module wcscmp for portability"); -# endif -#endif - - -/* Compare no more than N wide characters of S1 and S2. */ -#if @GNULIB_WCSNCMP@ -# if !@HAVE_WCSNCMP@ -_GL_FUNCDECL_SYS (wcsncmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcsncmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n)); -_GL_CXXALIASWARN (wcsncmp); -#elif defined GNULIB_POSIXCHECK -# undef wcsncmp -# if HAVE_RAW_DECL_WCSNCMP -_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - " - "use gnulib module wcsncmp for portability"); -# endif -#endif - - -/* Compare S1 and S2, ignoring case. */ -#if @GNULIB_WCSCASECMP@ -# if !@HAVE_WCSCASECMP@ -_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); -_GL_CXXALIASWARN (wcscasecmp); -#elif defined GNULIB_POSIXCHECK -# undef wcscasecmp -# if HAVE_RAW_DECL_WCSCASECMP -_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - " - "use gnulib module wcscasecmp for portability"); -# endif -#endif - - -/* Compare no more than N chars of S1 and S2, ignoring case. */ -#if @GNULIB_WCSNCASECMP@ -# if !@HAVE_WCSNCASECMP@ -_GL_FUNCDECL_SYS (wcsncasecmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcsncasecmp, int, - (const wchar_t *s1, const wchar_t *s2, size_t n)); -_GL_CXXALIASWARN (wcsncasecmp); -#elif defined GNULIB_POSIXCHECK -# undef wcsncasecmp -# if HAVE_RAW_DECL_WCSNCASECMP -_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - " - "use gnulib module wcsncasecmp for portability"); -# endif -#endif - - -/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE - category of the current locale. */ -#if @GNULIB_WCSCOLL@ -# if !@HAVE_WCSCOLL@ -_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); -# endif -_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); -_GL_CXXALIASWARN (wcscoll); -#elif defined GNULIB_POSIXCHECK -# undef wcscoll -# if HAVE_RAW_DECL_WCSCOLL -_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - " - "use gnulib module wcscoll for portability"); -# endif -#endif - - -/* Transform S2 into array pointed to by S1 such that if wcscmp is applied - to two transformed strings the result is the as applying 'wcscoll' to the - original strings. */ -#if @GNULIB_WCSXFRM@ -# if !@HAVE_WCSXFRM@ -_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); -# endif -_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); -_GL_CXXALIASWARN (wcsxfrm); -#elif defined GNULIB_POSIXCHECK -# undef wcsxfrm -# if HAVE_RAW_DECL_WCSXFRM -_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " - "use gnulib module wcsxfrm for portability"); -# endif -#endif - - -/* Duplicate S, returning an identical malloc'd string. */ -#if @GNULIB_WCSDUP@ -# if !@HAVE_WCSDUP@ -_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); -# endif -_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); -_GL_CXXALIASWARN (wcsdup); -#elif defined GNULIB_POSIXCHECK -# undef wcsdup -# if HAVE_RAW_DECL_WCSDUP -_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " - "use gnulib module wcsdup for portability"); -# endif -#endif - - -/* Find the first occurrence of WC in WCS. */ -#if @GNULIB_WCSCHR@ -# if !@HAVE_WCSCHR@ -_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) - _GL_ATTRIBUTE_PURE); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { - const wchar_t * std::wcschr (const wchar_t *, wchar_t); - wchar_t * std::wcschr (wchar_t *, wchar_t); - } */ -_GL_CXXALIAS_SYS_CAST2 (wcschr, - wchar_t *, (const wchar_t *, wchar_t), - const wchar_t *, (const wchar_t *, wchar_t)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); -_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); -# else -_GL_CXXALIASWARN (wcschr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef wcschr -# if HAVE_RAW_DECL_WCSCHR -_GL_WARN_ON_USE (wcschr, "wcschr is unportable - " - "use gnulib module wcschr for portability"); -# endif -#endif - - -/* Find the last occurrence of WC in WCS. */ -#if @GNULIB_WCSRCHR@ -# if !@HAVE_WCSRCHR@ -_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) - _GL_ATTRIBUTE_PURE); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { - const wchar_t * std::wcsrchr (const wchar_t *, wchar_t); - wchar_t * std::wcsrchr (wchar_t *, wchar_t); - } */ -_GL_CXXALIAS_SYS_CAST2 (wcsrchr, - wchar_t *, (const wchar_t *, wchar_t), - const wchar_t *, (const wchar_t *, wchar_t)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); -_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); -# else -_GL_CXXALIASWARN (wcsrchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef wcsrchr -# if HAVE_RAW_DECL_WCSRCHR -_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " - "use gnulib module wcsrchr for portability"); -# endif -#endif - - -/* Return the length of the initial segmet of WCS which consists entirely - of wide characters not in REJECT. */ -#if @GNULIB_WCSCSPN@ -# if !@HAVE_WCSCSPN@ -_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); -_GL_CXXALIASWARN (wcscspn); -#elif defined GNULIB_POSIXCHECK -# undef wcscspn -# if HAVE_RAW_DECL_WCSCSPN -_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " - "use gnulib module wcscspn for portability"); -# endif -#endif - - -/* Return the length of the initial segmet of WCS which consists entirely - of wide characters in ACCEPT. */ -#if @GNULIB_WCSSPN@ -# if !@HAVE_WCSSPN@ -_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); -_GL_CXXALIASWARN (wcsspn); -#elif defined GNULIB_POSIXCHECK -# undef wcsspn -# if HAVE_RAW_DECL_WCSSPN -_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - " - "use gnulib module wcsspn for portability"); -# endif -#endif - - -/* Find the first occurrence in WCS of any character in ACCEPT. */ -#if @GNULIB_WCSPBRK@ -# if !@HAVE_WCSPBRK@ -_GL_FUNCDECL_SYS (wcspbrk, wchar_t *, - (const wchar_t *wcs, const wchar_t *accept) - _GL_ATTRIBUTE_PURE); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { - const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *); - wchar_t * std::wcspbrk (wchar_t *, const wchar_t *); - } */ -_GL_CXXALIAS_SYS_CAST2 (wcspbrk, - wchar_t *, (const wchar_t *, const wchar_t *), - const wchar_t *, (const wchar_t *, const wchar_t *)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (wcspbrk, wchar_t *, - (wchar_t *wcs, const wchar_t *accept)); -_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, - (const wchar_t *wcs, const wchar_t *accept)); -# else -_GL_CXXALIASWARN (wcspbrk); -# endif -#elif defined GNULIB_POSIXCHECK -# undef wcspbrk -# if HAVE_RAW_DECL_WCSPBRK -_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " - "use gnulib module wcspbrk for portability"); -# endif -#endif - - -/* Find the first occurrence of NEEDLE in HAYSTACK. */ -#if @GNULIB_WCSSTR@ -# if !@HAVE_WCSSTR@ -_GL_FUNCDECL_SYS (wcsstr, wchar_t *, - (const wchar_t *haystack, const wchar_t *needle) - _GL_ATTRIBUTE_PURE); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { - const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); - wchar_t * std::wcsstr (wchar_t *, const wchar_t *); - } */ -_GL_CXXALIAS_SYS_CAST2 (wcsstr, - wchar_t *, (const wchar_t *, const wchar_t *), - const wchar_t *, (const wchar_t *, const wchar_t *)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (wcsstr, wchar_t *, - (wchar_t *haystack, const wchar_t *needle)); -_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, - (const wchar_t *haystack, const wchar_t *needle)); -# else -_GL_CXXALIASWARN (wcsstr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef wcsstr -# if HAVE_RAW_DECL_WCSSTR -_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - " - "use gnulib module wcsstr for portability"); -# endif -#endif - - -/* Divide WCS into tokens separated by characters in DELIM. */ -#if @GNULIB_WCSTOK@ -# if !@HAVE_WCSTOK@ -_GL_FUNCDECL_SYS (wcstok, wchar_t *, - (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); -# endif -_GL_CXXALIAS_SYS (wcstok, wchar_t *, - (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); -_GL_CXXALIASWARN (wcstok); -#elif defined GNULIB_POSIXCHECK -# undef wcstok -# if HAVE_RAW_DECL_WCSTOK -_GL_WARN_ON_USE (wcstok, "wcstok is unportable - " - "use gnulib module wcstok for portability"); -# endif -#endif - - -/* Determine number of column positions required for first N wide - characters (or fewer if S ends before this) in S. */ -#if @GNULIB_WCSWIDTH@ -# if @REPLACE_WCSWIDTH@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef wcswidth -# define wcswidth rpl_wcswidth -# endif -_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) - _GL_ATTRIBUTE_PURE); -_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); -# else -# if !@HAVE_WCSWIDTH@ -_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) - _GL_ATTRIBUTE_PURE); -# endif -_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); -# endif -_GL_CXXALIASWARN (wcswidth); -#elif defined GNULIB_POSIXCHECK -# undef wcswidth -# if HAVE_RAW_DECL_WCSWIDTH -_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - " - "use gnulib module wcswidth for portability"); -# endif -#endif - - -#endif /* _@GUARD_PREFIX@_WCHAR_H */ -#endif /* _@GUARD_PREFIX@_WCHAR_H */ -#endif diff --git a/grub-core/gnulib/wcrtomb.c b/grub-core/gnulib/wcrtomb.c deleted file mode 100644 index da42809bc..000000000 --- a/grub-core/gnulib/wcrtomb.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Convert wide character to multibyte character. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - - -size_t -wcrtomb (char *s, wchar_t wc, mbstate_t *ps) -{ - /* This implementation of wcrtomb on top of wctomb() supports only - stateless encodings. ps must be in the initial state. */ - if (ps != NULL && !mbsinit (ps)) - { - errno = EINVAL; - return (size_t)(-1); - } - - if (s == NULL) - /* We know the NUL wide character corresponds to the NUL character. */ - return 1; - else - { - int ret = wctomb (s, wc); - - if (ret >= 0) - return ret; - else - { - errno = EILSEQ; - return (size_t)(-1); - } - } -} diff --git a/grub-core/gnulib/wctype-h.c b/grub-core/gnulib/wctype-h.c deleted file mode 100644 index bb5f847e3..000000000 --- a/grub-core/gnulib/wctype-h.c +++ /dev/null @@ -1,4 +0,0 @@ -/* Normally this would be wctype.c, but that name's already taken. */ -#include -#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE -#include "wctype.h" diff --git a/grub-core/gnulib/wctype.in.h b/grub-core/gnulib/wctype.in.h deleted file mode 100644 index 0cd02d5a3..000000000 --- a/grub-core/gnulib/wctype.in.h +++ /dev/null @@ -1,504 +0,0 @@ -/* A substitute for ISO C99 , for platforms that lack it. - - Copyright (C) 2006-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -/* Written by Bruno Haible and Paul Eggert. */ - -/* - * ISO C 99 for platforms that lack it. - * - * - * iswctype, towctrans, towlower, towupper, wctrans, wctype, - * wctrans_t, and wctype_t are not yet implemented. - */ - -#ifndef _@GUARD_PREFIX@_WCTYPE_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -#if @HAVE_WINT_T@ -/* Solaris 2.5 has a bug: must be included before . - Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -# include -# include -# include -# include -#endif - -/* Include the original if it exists. - BeOS 5 has the functions but no . */ -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_WCTYPE_H@ -# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ -#endif - -#ifndef _@GUARD_PREFIX@_WCTYPE_H -#define _@GUARD_PREFIX@_WCTYPE_H - -_GL_INLINE_HEADER_BEGIN -#ifndef _GL_WCTYPE_INLINE -# define _GL_WCTYPE_INLINE _GL_INLINE -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -/* Solaris 2.6 includes which includes which - #defines a number of identifiers in the application namespace. Revert - these #defines. */ -#ifdef __sun -# undef multibyte -# undef eucw1 -# undef eucw2 -# undef eucw3 -# undef scrw1 -# undef scrw2 -# undef scrw3 -#endif - -/* Define wint_t and WEOF. (Also done in wchar.in.h.) */ -#if !@HAVE_WINT_T@ && !defined wint_t -# define wint_t int -# ifndef WEOF -# define WEOF -1 -# endif -#else -/* MSVC defines wint_t as 'unsigned short' in . - This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be - "unchanged by default argument promotions". Override it. */ -# if defined _MSC_VER -# if !GNULIB_defined_wint_t -# include -typedef unsigned int rpl_wint_t; -# undef wint_t -# define wint_t rpl_wint_t -# define GNULIB_defined_wint_t 1 -# endif -# endif -# ifndef WEOF -# define WEOF ((wint_t) -1) -# endif -#endif - - -#if !GNULIB_defined_wctype_functions - -/* FreeBSD 4.4 to 4.11 has but lacks the functions. - Linux libc5 has and the functions but they are broken. - Assume all 11 functions (all isw* except iswblank) are implemented the - same way, or not at all. */ -# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ - -/* IRIX 5.3 has macros but no functions, its isw* macros refer to an - undefined variable _ctmp_ and to macros like _P, and they - refer to system functions like _iswctype that are not in the - standard C library. Rather than try to get ancient buggy - implementations like this to work, just disable them. */ -# undef iswalnum -# undef iswalpha -# undef iswblank -# undef iswcntrl -# undef iswdigit -# undef iswgraph -# undef iswlower -# undef iswprint -# undef iswpunct -# undef iswspace -# undef iswupper -# undef iswxdigit -# undef towlower -# undef towupper - -/* Linux libc5 has and the functions but they are broken. */ -# if @REPLACE_ISWCNTRL@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define iswalnum rpl_iswalnum -# define iswalpha rpl_iswalpha -# define iswblank rpl_iswblank -# define iswcntrl rpl_iswcntrl -# define iswdigit rpl_iswdigit -# define iswgraph rpl_iswgraph -# define iswlower rpl_iswlower -# define iswprint rpl_iswprint -# define iswpunct rpl_iswpunct -# define iswspace rpl_iswspace -# define iswupper rpl_iswupper -# define iswxdigit rpl_iswxdigit -# endif -# endif -# if @REPLACE_TOWLOWER@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define towlower rpl_towlower -# define towupper rpl_towupper -# endif -# endif - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswalnum -# else -iswalnum -# endif - (wint_t wc) -{ - return ((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswalpha -# else -iswalpha -# endif - (wint_t wc) -{ - return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswblank -# else -iswblank -# endif - (wint_t wc) -{ - return wc == ' ' || wc == '\t'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswcntrl -# else -iswcntrl -# endif - (wint_t wc) -{ - return (wc & ~0x1f) == 0 || wc == 0x7f; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswdigit -# else -iswdigit -# endif - (wint_t wc) -{ - return wc >= '0' && wc <= '9'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswgraph -# else -iswgraph -# endif - (wint_t wc) -{ - return wc >= '!' && wc <= '~'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswlower -# else -iswlower -# endif - (wint_t wc) -{ - return wc >= 'a' && wc <= 'z'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswprint -# else -iswprint -# endif - (wint_t wc) -{ - return wc >= ' ' && wc <= '~'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswpunct -# else -iswpunct -# endif - (wint_t wc) -{ - return (wc >= '!' && wc <= '~' - && !((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswspace -# else -iswspace -# endif - (wint_t wc) -{ - return (wc == ' ' || wc == '\t' - || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswupper -# else -iswupper -# endif - (wint_t wc) -{ - return wc >= 'A' && wc <= 'Z'; -} - -_GL_WCTYPE_INLINE int -# if @REPLACE_ISWCNTRL@ -rpl_iswxdigit -# else -iswxdigit -# endif - (wint_t wc) -{ - return ((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); -} - -_GL_WCTYPE_INLINE wint_t -# if @REPLACE_TOWLOWER@ -rpl_towlower -# else -towlower -# endif - (wint_t wc) -{ - return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); -} - -_GL_WCTYPE_INLINE wint_t -# if @REPLACE_TOWLOWER@ -rpl_towupper -# else -towupper -# endif - (wint_t wc) -{ - return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); -} - -# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) -/* Only the iswblank function is missing. */ - -# if @REPLACE_ISWBLANK@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define iswblank rpl_iswblank -# endif -_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); -# else -_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); -# endif - -# endif - -# if defined __MINGW32__ - -/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. - The functions towlower and towupper are implemented in the MSVCRT library - to take a wchar_t argument and return a wchar_t result. mingw declares - these functions to take a wint_t argument and return a wint_t result. - This means that: - 1. When the user passes an argument outside the range 0x0000..0xFFFF, the - function will look only at the lower 16 bits. This is allowed according - to POSIX. - 2. The return value is returned in the lower 16 bits of the result register. - The upper 16 bits are random: whatever happened to be in that part of the - result register. We need to fix this by adding a zero-extend from - wchar_t to wint_t after the call. */ - -_GL_WCTYPE_INLINE wint_t -rpl_towlower (wint_t wc) -{ - return (wint_t) (wchar_t) towlower (wc); -} -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define towlower rpl_towlower -# endif - -_GL_WCTYPE_INLINE wint_t -rpl_towupper (wint_t wc) -{ - return (wint_t) (wchar_t) towupper (wc); -} -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define towupper rpl_towupper -# endif - -# endif /* __MINGW32__ */ - -# define GNULIB_defined_wctype_functions 1 -#endif - -#if @REPLACE_ISWCNTRL@ -_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); -_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); -#else -_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); -_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); -#endif -_GL_CXXALIASWARN (iswalnum); -_GL_CXXALIASWARN (iswalpha); -_GL_CXXALIASWARN (iswcntrl); -_GL_CXXALIASWARN (iswdigit); -_GL_CXXALIASWARN (iswgraph); -_GL_CXXALIASWARN (iswlower); -_GL_CXXALIASWARN (iswprint); -_GL_CXXALIASWARN (iswpunct); -_GL_CXXALIASWARN (iswspace); -_GL_CXXALIASWARN (iswupper); -_GL_CXXALIASWARN (iswxdigit); - -#if @GNULIB_ISWBLANK@ -# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ -_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); -# else -_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); -# endif -_GL_CXXALIASWARN (iswblank); -#endif - -#if !@HAVE_WCTYPE_T@ -# if !GNULIB_defined_wctype_t -typedef void * wctype_t; -# define GNULIB_defined_wctype_t 1 -# endif -#endif - -/* Get a descriptor for a wide character property. */ -#if @GNULIB_WCTYPE@ -# if !@HAVE_WCTYPE_T@ -_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); -# endif -_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); -_GL_CXXALIASWARN (wctype); -#elif defined GNULIB_POSIXCHECK -# undef wctype -# if HAVE_RAW_DECL_WCTYPE -_GL_WARN_ON_USE (wctype, "wctype is unportable - " - "use gnulib module wctype for portability"); -# endif -#endif - -/* Test whether a wide character has a given property. - The argument WC must be either a wchar_t value or WEOF. - The argument DESC must have been returned by the wctype() function. */ -#if @GNULIB_ISWCTYPE@ -# if !@HAVE_WCTYPE_T@ -_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); -# endif -_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); -_GL_CXXALIASWARN (iswctype); -#elif defined GNULIB_POSIXCHECK -# undef iswctype -# if HAVE_RAW_DECL_ISWCTYPE -_GL_WARN_ON_USE (iswctype, "iswctype is unportable - " - "use gnulib module iswctype for portability"); -# endif -#endif - -#if @REPLACE_TOWLOWER@ || defined __MINGW32__ -_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); -_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); -#else -_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); -_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); -#endif -_GL_CXXALIASWARN (towlower); -_GL_CXXALIASWARN (towupper); - -#if !@HAVE_WCTRANS_T@ -# if !GNULIB_defined_wctrans_t -typedef void * wctrans_t; -# define GNULIB_defined_wctrans_t 1 -# endif -#endif - -/* Get a descriptor for a wide character case conversion. */ -#if @GNULIB_WCTRANS@ -# if !@HAVE_WCTRANS_T@ -_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); -# endif -_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); -_GL_CXXALIASWARN (wctrans); -#elif defined GNULIB_POSIXCHECK -# undef wctrans -# if HAVE_RAW_DECL_WCTRANS -_GL_WARN_ON_USE (wctrans, "wctrans is unportable - " - "use gnulib module wctrans for portability"); -# endif -#endif - -/* Perform a given case conversion on a wide character. - The argument WC must be either a wchar_t value or WEOF. - The argument DESC must have been returned by the wctrans() function. */ -#if @GNULIB_TOWCTRANS@ -# if !@HAVE_WCTRANS_T@ -_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); -# endif -_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); -_GL_CXXALIASWARN (towctrans); -#elif defined GNULIB_POSIXCHECK -# undef towctrans -# if HAVE_RAW_DECL_TOWCTRANS -_GL_WARN_ON_USE (towctrans, "towctrans is unportable - " - "use gnulib module towctrans for portability"); -# endif -#endif - -_GL_INLINE_HEADER_END - -#endif /* _@GUARD_PREFIX@_WCTYPE_H */ -#endif /* _@GUARD_PREFIX@_WCTYPE_H */ diff --git a/grub-core/gnulib/wcwidth.c b/grub-core/gnulib/wcwidth.c deleted file mode 100644 index 253fcaa65..000000000 --- a/grub-core/gnulib/wcwidth.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Determine the number of screen columns needed for a character. - Copyright (C) 2006-2007, 2010-2013 Free Software Foundation, Inc. - - This program 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. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -/* Get iswprint. */ -#include - -#include "localcharset.h" -#include "streq.h" -#include "uniwidth.h" - -int -wcwidth (wchar_t wc) -#undef wcwidth -{ - /* In UTF-8 locales, use a Unicode aware width function. */ - const char *encoding = locale_charset (); - if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0)) - { - /* We assume that in a UTF-8 locale, a wide character is the same as a - Unicode character. */ - return uc_width (wc, encoding); - } - else - { - /* Otherwise, fall back to the system's wcwidth function. */ -#if HAVE_WCWIDTH - return wcwidth (wc); -#else - return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; -#endif - } -} diff --git a/grub-core/gnulib/xsize.c b/grub-core/gnulib/xsize.c deleted file mode 100644 index 4b4914c2c..000000000 --- a/grub-core/gnulib/xsize.c +++ /dev/null @@ -1,3 +0,0 @@ -#include -#define XSIZE_INLINE _GL_EXTERN_INLINE -#include "xsize.h" diff --git a/grub-core/gnulib/xsize.h b/grub-core/gnulib/xsize.h deleted file mode 100644 index 2922f3530..000000000 --- a/grub-core/gnulib/xsize.h +++ /dev/null @@ -1,114 +0,0 @@ -/* xsize.h -- Checked size_t computations. - - Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. - - This program 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, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _XSIZE_H -#define _XSIZE_H - -/* Get size_t. */ -#include - -/* Get SIZE_MAX. */ -#include -#if HAVE_STDINT_H -# include -#endif - -_GL_INLINE_HEADER_BEGIN -#ifndef XSIZE_INLINE -# define XSIZE_INLINE _GL_INLINE -#endif - -/* The size of memory objects is often computed through expressions of - type size_t. Example: - void* p = malloc (header_size + n * element_size). - These computations can lead to overflow. When this happens, malloc() - returns a piece of memory that is way too small, and the program then - crashes while attempting to fill the memory. - To avoid this, the functions and macros in this file check for overflow. - The convention is that SIZE_MAX represents overflow. - malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc - implementation that uses mmap --, it's recommended to use size_overflow_p() - or size_in_bounds_p() before invoking malloc(). - The example thus becomes: - size_t size = xsum (header_size, xtimes (n, element_size)); - void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); -*/ - -/* Convert an arbitrary value >= 0 to type size_t. */ -#define xcast_size_t(N) \ - ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) - -/* Sum of two sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif -xsum (size_t size1, size_t size2) -{ - size_t sum = size1 + size2; - return (sum >= size1 ? sum : SIZE_MAX); -} - -/* Sum of three sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif -xsum3 (size_t size1, size_t size2, size_t size3) -{ - return xsum (xsum (size1, size2), size3); -} - -/* Sum of four sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif -xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) -{ - return xsum (xsum (xsum (size1, size2), size3), size4); -} - -/* Maximum of two sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif -xmax (size_t size1, size_t size2) -{ - /* No explicit check is needed here, because for any n: - max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */ - return (size1 >= size2 ? size1 : size2); -} - -/* Multiplication of a count with an element size, with overflow check. - The count must be >= 0 and the element size must be > 0. - This is a macro, not a function, so that it works correctly even - when N is of a wider type and N > SIZE_MAX. */ -#define xtimes(N, ELSIZE) \ - ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) - -/* Check for overflow. */ -#define size_overflow_p(SIZE) \ - ((SIZE) == SIZE_MAX) -/* Check against overflow. */ -#define size_in_bounds_p(SIZE) \ - ((SIZE) != SIZE_MAX) - -_GL_INLINE_HEADER_END - -#endif /* _XSIZE_H */ diff --git a/grub-core/gnulib-fix-null-deref.diff b/grub-core/lib/gnulib-patches/fix-null-deref.patch similarity index 52% rename from grub-core/gnulib-fix-null-deref.diff rename to grub-core/lib/gnulib-patches/fix-null-deref.patch index a2fba8c3b..8fafa153a 100644 --- a/grub-core/gnulib-fix-null-deref.diff +++ b/grub-core/lib/gnulib-patches/fix-null-deref.patch @@ -1,7 +1,8 @@ -=== modified file 'grub-core/gnulib/argp-parse.c' ---- grub-core/gnulib/argp-parse.c 2010-04-02 22:45:01 +0000 -+++ grub-core/gnulib/argp-parse.c 2011-04-10 13:25:52 +0000 -@@ -935,7 +935,7 @@ +diff --git a/lib/argp-parse.c b/lib/argp-parse.c +index 6dec57310..900adad54 100644 +--- a/lib/argp-parse.c ++++ b/lib/argp-parse.c +@@ -940,7 +940,7 @@ weak_alias (__argp_parse, argp_parse) void * __argp_input (const struct argp *argp, const struct argp_state *state) { @@ -10,4 +11,3 @@ { struct group *group; struct parser *parser = state->pstate; - diff --git a/grub-core/gnulib-fix-width.diff b/grub-core/lib/gnulib-patches/fix-width.patch similarity index 75% rename from grub-core/gnulib-fix-width.diff rename to grub-core/lib/gnulib-patches/fix-width.patch index ae77af6c9..0a208ad08 100644 --- a/grub-core/gnulib-fix-width.diff +++ b/grub-core/lib/gnulib-patches/fix-width.patch @@ -1,8 +1,8 @@ diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c -index 7aa317c..02406ff 100644 +index ba6a407f7..d0685b3d4 100644 --- a/lib/argp-fmtstream.c +++ b/lib/argp-fmtstream.c -@@ -29,9 +29,11 @@ +@@ -28,9 +28,11 @@ #include #include #include @@ -14,7 +14,7 @@ index 7aa317c..02406ff 100644 #ifndef ARGP_FMTSTREAM_USE_LINEWRAP -@@ -116,6 +118,51 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free) +@@ -115,6 +117,51 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free) #endif #endif @@ -66,12 +66,12 @@ index 7aa317c..02406ff 100644 /* Process FS's buffer so that line wrapping is done from POINT_OFFS to the end of its buffer. This code is mostly from glibc stdio/linewrap.c. */ void -@@ -168,14 +215,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs) - +@@ -168,13 +215,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs) if (!nl) { -+ size_t display_width = mbsnwidth (buf, fs->p - buf, MBSW_STOP_AT_NUL); /* The buffer ends in a partial line. */ ++ size_t display_width = mbsnwidth (buf, fs->p - buf, ++ MBSW_STOP_AT_NUL); - if (fs->point_col + len < fs->rmargin) + if (fs->point_col + display_width < fs->rmargin) @@ -84,7 +84,7 @@ index 7aa317c..02406ff 100644 break; } else -@@ -183,14 +231,18 @@ __argp_fmtstream_update (argp_fmtstream_t fs) +@@ -182,14 +231,18 @@ __argp_fmtstream_update (argp_fmtstream_t fs) the end of the buffer. */ nl = fs->p; } @@ -111,16 +111,16 @@ index 7aa317c..02406ff 100644 /* This line is too long. */ r = fs->rmargin - 1; -@@ -226,7 +278,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) +@@ -225,7 +278,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) char *p, *nextline; int i; - p = buf + (r + 1 - fs->point_col); -+ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col)); ++ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col)); while (p >= buf && !isblank ((unsigned char) *p)) --p; nextline = p + 1; /* This will begin the next line. */ -@@ -244,7 +296,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) +@@ -243,7 +296,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) { /* A single word that is greater than the maximum line width. Oh well. Put it on an overlong line by itself. */ @@ -129,21 +129,21 @@ index 7aa317c..02406ff 100644 /* Find the end of the long word. */ if (p < nl) do -@@ -278,7 +330,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs) +@@ -277,7 +330,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs) && fs->p > nextline) { /* The margin needs more blanks than we removed. */ - if (fs->end - fs->p > fs->wmargin + 1) + if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL) -+ > fs->wmargin + 1) ++ > fs->wmargin + 1) /* Make some space for them. */ { size_t mv = fs->p - nextline; diff --git a/lib/argp-help.c b/lib/argp-help.c -index 354f1e2..2914f47 100644 +index e5375a0f0..5d8f451ec 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c -@@ -50,6 +50,7 @@ +@@ -51,6 +51,7 @@ #include "argp.h" #include "argp-fmtstream.h" #include "argp-namefrob.h" @@ -151,7 +151,7 @@ index 354f1e2..2914f47 100644 #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) -@@ -1452,7 +1453,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state, +@@ -1432,7 +1433,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state, /* Manually do line wrapping so that it (probably) won't get wrapped at any embedded spaces. */ @@ -161,71 +161,57 @@ index 354f1e2..2914f47 100644 __argp_fmtstream_write (stream, cp, nl - cp); } diff --git a/lib/mbswidth.c b/lib/mbswidth.c -index 7c2dfce..baa4f27 100644 +index 408a15e34..b3fb7f83a 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c -@@ -90,6 +90,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags) +@@ -38,6 +38,14 @@ + /* Get INT_MAX. */ + #include + ++#ifndef FALLTHROUGH ++# if __GNUC__ < 7 ++# define FALLTHROUGH ((void) 0) ++# else ++# define FALLTHROUGH __attribute__ ((__fallthrough__)) ++# endif ++#endif ++ + /* Returns the number of columns needed to represent the multibyte + character string pointed to by STRING. If a non-printable character + occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. +@@ -90,6 +98,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags) p++; width++; break; -+ case '\0': -+ if (flags & MBSW_STOP_AT_NUL) -+ return width; ++ case '\0': ++ if (flags & MBSW_STOP_AT_NUL) ++ return width; ++ FALLTHROUGH; default: /* If we have a multibyte sequence, scan it up to its end. */ { -@@ -168,6 +171,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags) +@@ -168,6 +180,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags) { unsigned char c = (unsigned char) *p++; + if (c == 0 && (flags & MBSW_STOP_AT_NUL)) -+ return width; ++ return width; + if (isprint (c)) { if (width == INT_MAX) diff --git a/lib/mbswidth.h b/lib/mbswidth.h -index e9c0b03..d7207c5 100644 +index 2b5c53c37..45a123e63 100644 --- a/lib/mbswidth.h +++ b/lib/mbswidth.h -@@ -45,6 +45,9 @@ extern "C" { +@@ -45,6 +45,10 @@ extern "C" { control characters and 1 otherwise. */ #define MBSW_REJECT_UNPRINTABLE 2 +/* If this bit is set \0 is treated as the end of string. + Otherwise it's treated as a normal one column width character. */ +#define MBSW_STOP_AT_NUL 4 ++ /* Returns the number of screen columns needed for STRING. */ #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ -diff --git a/modules/argp b/modules/argp -index 125046a..6f14d10 100644 ---- a/modules/argp -+++ b/modules/argp -@@ -40,6 +40,7 @@ stdalign - strerror - memchr - memmove -+mbswidth - - configure.ac: - gl_ARGP -diff --git a/modules/argp-tests b/modules/argp-tests -index 8f92a4d..0463927 100644 ---- a/modules/argp-tests -+++ b/modules/argp-tests -@@ -1,11 +1,13 @@ - Files: - tests/test-argp.c - tests/test-argp-2.sh -+tests/test-argp-2-utf.sh - - Depends-on: - progname - - Makefile.am: - TESTS += test-argp test-argp-2.sh --check_PROGRAMS += test-argp -+TESTS += test-argp test-argp-2.sh test-argp-2-utf.sh -+check_PROGRAMS += test-argp test-argp-utf8 - test_argp_LDADD = $(LDADD) @LIBINTL@ diff --git a/grub-core/lib/gnulib-patches/no-abort.patch b/grub-core/lib/gnulib-patches/no-abort.patch new file mode 100644 index 000000000..e469c4762 --- /dev/null +++ b/grub-core/lib/gnulib-patches/no-abort.patch @@ -0,0 +1,26 @@ +diff --git a/lib/regcomp.c b/lib/regcomp.c +index cc85f35ac..de45ebb5c 100644 +--- a/lib/regcomp.c ++++ b/lib/regcomp.c +@@ -528,9 +528,9 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf, + to this routine. If we are given anything else, or if other regex + code generates an invalid error code, then the program has a bug. + Dump core so we can fix it. */ +- abort (); +- +- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); ++ msg = gettext ("unknown regexp error"); ++ else ++ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); + + msg_size = strlen (msg) + 1; /* Includes the null. */ + +@@ -1136,7 +1136,7 @@ optimize_utf8 (re_dfa_t *dfa) + } + break; + default: +- abort (); ++ break; + } + + if (mb_chars || has_period) diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 deleted file mode 100644 index d4ad759fd..000000000 --- a/m4/00gnulib.m4 +++ /dev/null @@ -1,30 +0,0 @@ -# 00gnulib.m4 serial 2 -dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This file must be named something that sorts before all other -dnl gnulib-provided .m4 files. It is needed until such time as we can -dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. - -# AC_DEFUN_ONCE([NAME], VALUE) -# ---------------------------- -# Define NAME to expand to VALUE on the first use (whether by direct -# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. -# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This -# definition is slower than the version in Autoconf 2.64, because it -# can only use interfaces that existed since 2.59; but it achieves the -# same effect. Quoting is necessary to avoid confusing Automake. -m4_version_prereq([2.63.263], [], -[m4_define([AC][_DEFUN_ONCE], - [AC][_DEFUN([$1], - [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], - [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl -[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) - -# gl_00GNULIB -# ----------- -# Witness macro that this file has been included. Needed to force -# Automake to include this file prior to all other gnulib .m4 files. -AC_DEFUN([gl_00GNULIB]) diff --git a/m4/alloca.m4 b/m4/alloca.m4 deleted file mode 100644 index 270abd0cd..000000000 --- a/m4/alloca.m4 +++ /dev/null @@ -1,121 +0,0 @@ -# alloca.m4 serial 14 -dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_ALLOCA], -[ - AC_REQUIRE([AC_FUNC_ALLOCA]) - if test $ac_cv_func_alloca_works = no; then - gl_PREREQ_ALLOCA - fi - - # Define an additional variable used in the Makefile substitution. - if test $ac_cv_working_alloca_h = yes; then - AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [ - AC_EGREP_CPP([Need own alloca], [ -#if defined __GNUC__ || defined _AIX || defined _MSC_VER - Need own alloca -#endif - ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no]) - ]) - if test $gl_cv_rpl_alloca = yes; then - dnl OK, alloca can be implemented through a compiler built-in. - AC_DEFINE([HAVE_ALLOCA], [1], - [Define to 1 if you have 'alloca' after including , - a header that may be supplied by this distribution.]) - ALLOCA_H=alloca.h - else - dnl alloca exists as a library function, i.e. it is slow and probably - dnl a memory leak. Don't define HAVE_ALLOCA in this case. - ALLOCA_H= - fi - else - ALLOCA_H=alloca.h - fi - AC_SUBST([ALLOCA_H]) - AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"]) -]) - -# Prerequisites of lib/alloca.c. -# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. -AC_DEFUN([gl_PREREQ_ALLOCA], [:]) - -# This works around a bug in autoconf <= 2.68. -# See . - -m4_version_prereq([2.69], [] ,[ - -# This is taken from the following Autoconf patch: -# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497 - -# _AC_LIBOBJ_ALLOCA -# ----------------- -# Set up the LIBOBJ replacement of 'alloca'. Well, not exactly -# AC_LIBOBJ since we actually set the output variable 'ALLOCA'. -# Nevertheless, for Automake, AC_LIBSOURCES it. -m4_define([_AC_LIBOBJ_ALLOCA], -[# The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. -AC_LIBSOURCES(alloca.c) -AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl -AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.]) - -AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray, -[AC_EGREP_CPP(webecray, -[#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif -], ac_cv_os_cray=yes, ac_cv_os_cray=no)]) -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - AC_CHECK_FUNC($ac_func, - [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func, - [Define to one of '_getb67', 'GETB67', - 'getb67' for Cray-2 and Cray-YMP - systems. This function is required for - 'alloca.c' support on those systems.]) - break]) - done -fi - -AC_CACHE_CHECK([stack direction for C alloca], - [ac_cv_c_stack_direction], -[AC_RUN_IFELSE([AC_LANG_SOURCE( -[AC_INCLUDES_DEFAULT -int -find_stack_direction (int *addr, int depth) -{ - int dir, dummy = 0; - if (! addr) - addr = &dummy; - *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; - dir = depth ? find_stack_direction (addr, depth - 1) : 0; - return dir + dummy; -} - -int -main (int argc, char **argv) -{ - return find_stack_direction (0, argc + !argv + 20) < 0; -}])], - [ac_cv_c_stack_direction=1], - [ac_cv_c_stack_direction=-1], - [ac_cv_c_stack_direction=0])]) -AH_VERBATIM([STACK_DIRECTION], -[/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -@%:@undef STACK_DIRECTION])dnl -AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) -])# _AC_LIBOBJ_ALLOCA -]) diff --git a/m4/argp.m4 b/m4/argp.m4 deleted file mode 100644 index 4445d8e6c..000000000 --- a/m4/argp.m4 +++ /dev/null @@ -1,61 +0,0 @@ -# argp.m4 serial 14 -dnl Copyright (C) 2003-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_ARGP], -[ - AC_REQUIRE([AC_C_INLINE]) - AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS([program_invocation_name], [], - [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_NAME], [1], - [Define to 1 to add extern declaration of program_invocation_name to argp.h])], - [[#include ]]) - AC_CHECK_DECLS([program_invocation_short_name], [], - [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_SHORT_NAME], [1], - [Define to 1 to add extern declaration of program_invocation_short_name to argp.h])], - [[#include ]]) - - # Check if program_invocation_name and program_invocation_short_name - # are defined elsewhere. It is improbable that only one of them will - # be defined and other not, I prefer to stay on the safe side and to - # test each one separately. - AC_MSG_CHECKING([whether program_invocation_name is defined]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[program_invocation_name = "test";]])], - [AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1], - [Define if program_invocation_name is defined]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - - AC_MSG_CHECKING([whether program_invocation_short_name is defined]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[program_invocation_short_name = "test";]])], - [AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1], - [Define if program_invocation_short_name is defined]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - - AC_CHECK_DECLS_ONCE([clearerr_unlocked]) - AC_CHECK_DECLS_ONCE([feof_unlocked]) - AC_CHECK_DECLS_ONCE([ferror_unlocked]) - AC_CHECK_DECLS_ONCE([fflush_unlocked]) - AC_CHECK_DECLS_ONCE([fgets_unlocked]) - AC_CHECK_DECLS_ONCE([fputc_unlocked]) - AC_CHECK_DECLS_ONCE([fputs_unlocked]) - AC_CHECK_DECLS_ONCE([fread_unlocked]) - AC_CHECK_DECLS_ONCE([fwrite_unlocked]) - AC_CHECK_DECLS_ONCE([getc_unlocked]) - AC_CHECK_DECLS_ONCE([getchar_unlocked]) - AC_CHECK_DECLS_ONCE([putc_unlocked]) - AC_CHECK_DECLS_ONCE([putchar_unlocked]) - AC_CHECK_FUNCS_ONCE([flockfile funlockfile]) - AC_CHECK_HEADERS_ONCE([features.h linewrap.h]) -]) - -dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt -dnl always. -AC_DEFUN([gl_REPLACE_GETOPT_ALWAYS], []) diff --git a/m4/btowc.m4 b/m4/btowc.m4 deleted file mode 100644 index 978a06e9a..000000000 --- a/m4/btowc.m4 +++ /dev/null @@ -1,116 +0,0 @@ -# btowc.m4 serial 10 -dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_BTOWC], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - - dnl Check whether is usable at all, first. Otherwise the test - dnl program below may lead to an endless loop. See - dnl . - AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) - - AC_CHECK_FUNCS_ONCE([btowc]) - if test $ac_cv_func_btowc = no; then - HAVE_BTOWC=0 - else - - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0. - AC_CACHE_CHECK([whether btowc(0) is correct], - [gl_cv_func_btowc_nul], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - if (btowc ('\0') != 0) - return 1; - return 0; -}]])], - [gl_cv_func_btowc_nul=yes], - [gl_cv_func_btowc_nul=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess no on Cygwin. - cygwin*) gl_cv_func_btowc_nul="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_btowc_nul="guessing yes" ;; - esac -changequote([,])dnl - ]) - ]) - - dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF. - AC_CACHE_CHECK([whether btowc(EOF) is correct], - [gl_cv_func_btowc_eof], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on IRIX. - irix*) gl_cv_func_btowc_eof="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_btowc_eof="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) - { - if (btowc (EOF) != WEOF) - return 1; - } - return 0; -}]])], - [gl_cv_func_btowc_eof=yes], - [gl_cv_func_btowc_eof=no], - [:]) - fi - ]) - - case "$gl_cv_func_btowc_nul" in - *yes) ;; - *) REPLACE_BTOWC=1 ;; - esac - case "$gl_cv_func_btowc_eof" in - *yes) ;; - *) REPLACE_BTOWC=1 ;; - esac - fi -]) - -# Prerequisites of lib/btowc.c. -AC_DEFUN([gl_PREREQ_BTOWC], [ - : -]) diff --git a/m4/codeset.m4 b/m4/codeset.m4 deleted file mode 100644 index c2761be2a..000000000 --- a/m4/codeset.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# codeset.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_LANGINFO_CODESET], -[ - AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[char* cs = nl_langinfo(CODESET); return !cs;]])], - [am_cv_langinfo_codeset=yes], - [am_cv_langinfo_codeset=no]) - ]) - if test $am_cv_langinfo_codeset = yes; then - AC_DEFINE([HAVE_LANGINFO_CODESET], [1], - [Define if you have and nl_langinfo(CODESET).]) - fi -]) diff --git a/m4/configmake.m4 b/m4/configmake.m4 deleted file mode 100644 index 823ffc0dd..000000000 --- a/m4/configmake.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# configmake.m4 serial 1 -dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# gl_CONFIGMAKE_PREP -# ------------------ -# Guarantee all of the standard directory variables, even when used with -# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake -# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.). -AC_DEFUN([gl_CONFIGMAKE_PREP], -[ - dnl Technically, datadir should default to datarootdir. But if - dnl autoconf is too old to provide datarootdir, then reversing the - dnl definition is a reasonable compromise. Only AC_SUBST a variable - dnl if it was not already defined earlier by autoconf. - if test "x$datarootdir" = x; then - AC_SUBST([datarootdir], ['${datadir}']) - fi - dnl Copy the approach used in autoconf 2.60. - if test "x$docdir" = x; then - AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME], - ['${datarootdir}/doc/${PACKAGE_TARNAME}'], - ['${datarootdir}/doc/${PACKAGE}'])]) - fi - dnl The remaining variables missing from autoconf 2.59 are easier. - if test "x$htmldir" = x; then - AC_SUBST([htmldir], ['${docdir}']) - fi - if test "x$dvidir" = x; then - AC_SUBST([dvidir], ['${docdir}']) - fi - if test "x$pdfdir" = x; then - AC_SUBST([pdfdir], ['${docdir}']) - fi - if test "x$psdir" = x; then - AC_SUBST([psdir], ['${docdir}']) - fi - if test "x$lispdir" = x; then - AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp']) - fi - if test "x$localedir" = x; then - AC_SUBST([localedir], ['${datarootdir}/locale']) - fi - - dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely - dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe. - AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}']) -]) diff --git a/m4/dirname.m4 b/m4/dirname.m4 deleted file mode 100644 index 5897a2a8b..000000000 --- a/m4/dirname.m4 +++ /dev/null @@ -1,19 +0,0 @@ -#serial 10 -*- autoconf -*- -dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_DIRNAME], -[ - AC_REQUIRE([gl_DIRNAME_LGPL]) -]) - -AC_DEFUN([gl_DIRNAME_LGPL], -[ - dnl Prerequisites of lib/dirname.h. - AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) - - dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c, - dnl lib/stripslash.c. -]) diff --git a/m4/double-slash-root.m4 b/m4/double-slash-root.m4 deleted file mode 100644 index bd6f86714..000000000 --- a/m4/double-slash-root.m4 +++ /dev/null @@ -1,38 +0,0 @@ -# double-slash-root.m4 serial 4 -*- Autoconf -*- -dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_DOUBLE_SLASH_ROOT], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root], - [ if test x"$cross_compiling" = xyes ; then - # When cross-compiling, there is no way to tell whether // is special - # short of a list of hosts. However, the only known hosts to date - # that have a distinct // are Apollo DomainOS (too old to port to), - # Cygwin, and z/OS. If anyone knows of another system for which // has - # special semantics and is distinct from /, please report it to - # . - case $host in - *-cygwin | i370-ibm-openedition) - gl_cv_double_slash_root=yes ;; - *) - # Be optimistic and assume that / and // are the same when we - # don't know. - gl_cv_double_slash_root='unknown, assuming no' ;; - esac - else - set x `ls -di / // 2>/dev/null` - if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then - gl_cv_double_slash_root=no - else - gl_cv_double_slash_root=yes - fi - fi]) - if test "$gl_cv_double_slash_root" = yes; then - AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1], - [Define to 1 if // is a file system root distinct from /.]) - fi -]) diff --git a/m4/eealloc.m4 b/m4/eealloc.m4 deleted file mode 100644 index c640ec129..000000000 --- a/m4/eealloc.m4 +++ /dev/null @@ -1,31 +0,0 @@ -# eealloc.m4 serial 3 -dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_EEALLOC], -[ - AC_REQUIRE([gl_EEMALLOC]) - AC_REQUIRE([gl_EEREALLOC]) -]) - -AC_DEFUN([gl_EEMALLOC], -[ - _AC_FUNC_MALLOC_IF( - [gl_cv_func_malloc_0_nonnull=1], - [gl_cv_func_malloc_0_nonnull=0]) - AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull], - [If malloc(0) is != NULL, define this to 1. Otherwise define this - to 0.]) -]) - -AC_DEFUN([gl_EEREALLOC], -[ - _AC_FUNC_REALLOC_IF( - [gl_cv_func_realloc_0_nonnull=1], - [gl_cv_func_realloc_0_nonnull=0]) - AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull], - [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this - to 0.]) -]) diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 deleted file mode 100644 index c813ea583..000000000 --- a/m4/errno_h.m4 +++ /dev/null @@ -1,137 +0,0 @@ -# errno_h.m4 serial 12 -dnl Copyright (C) 2004, 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ - AC_EGREP_CPP([booboo],[ -#include -#if !defined ETXTBSY -booboo -#endif -#if !defined ENOMSG -booboo -#endif -#if !defined EIDRM -booboo -#endif -#if !defined ENOLINK -booboo -#endif -#if !defined EPROTO -booboo -#endif -#if !defined EMULTIHOP -booboo -#endif -#if !defined EBADMSG -booboo -#endif -#if !defined EOVERFLOW -booboo -#endif -#if !defined ENOTSUP -booboo -#endif -#if !defined ENETRESET -booboo -#endif -#if !defined ECONNABORTED -booboo -#endif -#if !defined ESTALE -booboo -#endif -#if !defined EDQUOT -booboo -#endif -#if !defined ECANCELED -booboo -#endif -#if !defined EOWNERDEAD -booboo -#endif -#if !defined ENOTRECOVERABLE -booboo -#endif -#if !defined EILSEQ -booboo -#endif - ], - [gl_cv_header_errno_h_complete=no], - [gl_cv_header_errno_h_complete=yes]) - ]) - if test $gl_cv_header_errno_h_complete = yes; then - ERRNO_H='' - else - gl_NEXT_HEADERS([errno.h]) - ERRNO_H='errno.h' - fi - AC_SUBST([ERRNO_H]) - AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"]) - gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) - gl_REPLACE_ERRNO_VALUE([ENOLINK]) - gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) -]) - -# Assuming $1 = EOVERFLOW. -# The EOVERFLOW errno value ought to be defined in , according to -# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and -# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined. -# Check for the value of EOVERFLOW. -# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. -AC_DEFUN([gl_REPLACE_ERRNO_VALUE], -[ - if test -n "$ERRNO_H"; then - AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ - AC_EGREP_CPP([yes],[ -#include -#ifdef ]$1[ -yes -#endif - ], - [gl_cv_header_errno_h_]$1[=yes], - [gl_cv_header_errno_h_]$1[=no]) - if test $gl_cv_header_errno_h_]$1[ = no; then - AC_EGREP_CPP([yes],[ -#define _XOPEN_SOURCE_EXTENDED 1 -#include -#ifdef ]$1[ -yes -#endif - ], [gl_cv_header_errno_h_]$1[=hidden]) - if test $gl_cv_header_errno_h_]$1[ = hidden; then - dnl The macro exists but is hidden. - dnl Define it to the same value. - AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [ -#define _XOPEN_SOURCE_EXTENDED 1 -#include -/* The following two lines are a workaround against an autoconf-2.52 bug. */ -#include -#include -]) - fi - fi - ]) - case $gl_cv_header_errno_h_]$1[ in - yes | no) - ]$1[_HIDDEN=0; ]$1[_VALUE= - ;; - *) - ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1[" - ;; - esac - AC_SUBST($1[_HIDDEN]) - AC_SUBST($1[_VALUE]) - fi -]) - -dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. -dnl Remove this when we can assume autoconf >= 2.61. -m4_ifdef([AC_COMPUTE_INT], [], [ - AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) -]) diff --git a/m4/error.m4 b/m4/error.m4 deleted file mode 100644 index 29e6fdc9c..000000000 --- a/m4/error.m4 +++ /dev/null @@ -1,27 +0,0 @@ -#serial 14 - -# Copyright (C) 1996-1998, 2001-2004, 2009-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_ERROR], -[ - dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer - dnl maintained in Autoconf and because it invokes AC_LIBOBJ. - AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[error_at_line (0, 0, "", 0, "an error occurred");]])], - [ac_cv_lib_error_at_line=yes], - [ac_cv_lib_error_at_line=no])]) -]) - -# Prerequisites of lib/error.c. -AC_DEFUN([gl_PREREQ_ERROR], -[ - AC_REQUIRE([AC_FUNC_STRERROR_R]) - : -]) diff --git a/m4/exponentd.m4 b/m4/exponentd.m4 deleted file mode 100644 index 09df468c9..000000000 --- a/m4/exponentd.m4 +++ /dev/null @@ -1,116 +0,0 @@ -# exponentd.m4 serial 3 -dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], -[ - AC_CACHE_CHECK([where to find the exponent in a 'double'], - [gl_cv_cc_double_expbit0], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -#include -#define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) -typedef union { double value; unsigned int word[NWORDS]; } memory_double; -static unsigned int ored_words[NWORDS]; -static unsigned int anded_words[NWORDS]; -static void add_to_ored_words (double x) -{ - memory_double m; - size_t i; - /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ - memset (&m, 0, sizeof (memory_double)); - m.value = x; - for (i = 0; i < NWORDS; i++) - { - ored_words[i] |= m.word[i]; - anded_words[i] &= m.word[i]; - } -} -int main () -{ - size_t j; - FILE *fp = fopen ("conftest.out", "w"); - if (fp == NULL) - return 1; - for (j = 0; j < NWORDS; j++) - anded_words[j] = ~ (unsigned int) 0; - add_to_ored_words (0.25); - add_to_ored_words (0.5); - add_to_ored_words (1.0); - add_to_ored_words (2.0); - add_to_ored_words (4.0); - /* Remove bits that are common (e.g. if representation of the first mantissa - bit is explicit). */ - for (j = 0; j < NWORDS; j++) - ored_words[j] &= ~anded_words[j]; - /* Now find the nonzero word. */ - for (j = 0; j < NWORDS; j++) - if (ored_words[j] != 0) - break; - if (j < NWORDS) - { - size_t i; - for (i = j + 1; i < NWORDS; i++) - if (ored_words[i] != 0) - { - fprintf (fp, "unknown"); - return (fclose (fp) != 0); - } - for (i = 0; ; i++) - if ((ored_words[j] >> i) & 1) - { - fprintf (fp, "word %d bit %d", (int) j, (int) i); - return (fclose (fp) != 0); - } - } - fprintf (fp, "unknown"); - return (fclose (fp) != 0); -} - ]])], - [gl_cv_cc_double_expbit0=`cat conftest.out`], - [gl_cv_cc_double_expbit0="unknown"], - [ - dnl On ARM, there are two 'double' floating-point formats, used by - dnl different sets of instructions: The older FPA instructions assume - dnl that they are stored in big-endian word order, while the words - dnl (like integer types) are stored in little-endian byte order. - dnl The newer VFP instructions assume little-endian order - dnl consistently. - AC_EGREP_CPP([mixed_endianness], [ -#if defined arm || defined __arm || defined __arm__ - mixed_endianness -#endif - ], - [gl_cv_cc_double_expbit0="unknown"], - [ - pushdef([AC_MSG_CHECKING],[:])dnl - pushdef([AC_MSG_RESULT],[:])dnl - pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl - AC_C_BIGENDIAN( - [gl_cv_cc_double_expbit0="word 0 bit 20"], - [gl_cv_cc_double_expbit0="word 1 bit 20"], - [gl_cv_cc_double_expbit0="unknown"]) - popdef([AC_MSG_RESULT_UNQUOTED])dnl - popdef([AC_MSG_RESULT])dnl - popdef([AC_MSG_CHECKING])dnl - ]) - ]) - rm -f conftest.out - ]) - case "$gl_cv_cc_double_expbit0" in - word*bit*) - word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` - bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` - AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word], - [Define as the word index where to find the exponent of 'double'.]) - AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit], - [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.]) - ;; - esac -]) diff --git a/m4/extensions.m4 b/m4/extensions.m4 deleted file mode 100644 index 07ba376c0..000000000 --- a/m4/extensions.m4 +++ /dev/null @@ -1,138 +0,0 @@ -# serial 13 -*- Autoconf -*- -# Enable extensions on systems that normally disable them. - -# Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS -# Autoconf. Perhaps we can remove this once we can assume Autoconf -# 2.70 or later everywhere, but since Autoconf mutates rapidly -# enough in this area it's likely we'll need to redefine -# AC_USE_SYSTEM_EXTENSIONS for quite some time. - -# If autoconf reports a warning -# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS -# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS -# the fix is -# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked -# but always AC_REQUIREd, -# 2) to ensure that for each occurrence of -# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) -# or -# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) -# the corresponding gnulib module description has 'extensions' among -# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS -# invocation occurs in gl_EARLY, not in gl_INIT. - -# AC_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -# -# Remember that #undef in AH_VERBATIM gets replaced with #define by -# AC_DEFINE. The goal here is to define all known feature-enabling -# macros, then, if reports of conflicts are made, disable macros that -# cause problems on some platforms (such as __EXTENSIONS__). -AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], -[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl -AC_BEFORE([$0], [AC_RUN_IFELSE])dnl - - AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) - if test "$MINIX" = yes; then - AC_DEFINE([_POSIX_SOURCE], [1], - [Define to 1 if you need to in order for 'stat' and other - things to work.]) - AC_DEFINE([_POSIX_1_SOURCE], [2], - [Define to 2 if the system does not provide POSIX.1 features - except with this defined.]) - AC_DEFINE([_MINIX], [1], - [Define to 1 if on MINIX.]) - AC_DEFINE([_NETBSD_SOURCE], [1], - [Define to 1 to make NetBSD features available. MINIX 3 needs this.]) - fi - -dnl Use a different key than __EXTENSIONS__, as that name broke existing -dnl configure.ac when using autoheader 2.62. - AH_VERBATIM([USE_SYSTEM_EXTENSIONS], -[/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable general extensions on OS X. */ -#ifndef _DARWIN_C_SOURCE -# undef _DARWIN_C_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable X/Open extensions if necessary. HP-UX 11.11 defines - mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of - whether compiling with -Ae or -D_HPUX_SOURCE=1. */ -#ifndef _XOPEN_SOURCE -# undef _XOPEN_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif -]) - AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], - [ac_cv_safe_to_define___extensions__], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -# define __EXTENSIONS__ 1 - ]AC_INCLUDES_DEFAULT])], - [ac_cv_safe_to_define___extensions__=yes], - [ac_cv_safe_to_define___extensions__=no])]) - test $ac_cv_safe_to_define___extensions__ = yes && - AC_DEFINE([__EXTENSIONS__]) - AC_DEFINE([_ALL_SOURCE]) - AC_DEFINE([_DARWIN_C_SOURCE]) - AC_DEFINE([_GNU_SOURCE]) - AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) - AC_DEFINE([_TANDEM_SOURCE]) - AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], - [ac_cv_should_define__xopen_source], - [ac_cv_should_define__xopen_source=no - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #include - mbstate_t x;]])], - [], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #define _XOPEN_SOURCE 500 - #include - mbstate_t x;]])], - [ac_cv_should_define__xopen_source=yes])])]) - test $ac_cv_should_define__xopen_source = yes && - AC_DEFINE([_XOPEN_SOURCE], [500]) -])# AC_USE_SYSTEM_EXTENSIONS - -# gl_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], -[ - dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS. - dnl gnulib does not need it. But if it gets required by third-party macros - dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a - dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". - dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE, - dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck. - AC_REQUIRE([AC_GNU_SOURCE]) - - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) -]) diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 deleted file mode 100644 index e74339a16..000000000 --- a/m4/extern-inline.m4 +++ /dev/null @@ -1,100 +0,0 @@ -dnl 'extern inline' a la ISO C99. - -dnl Copyright 2012-2015 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_EXTERN_INLINE], -[ - AH_VERBATIM([extern_inline], -[/* Please see the Gnulib manual for how to use these macros. - - Suppress extern inline with HP-UX cc, as it appears to be broken; see - . - - Suppress extern inline with Sun C in standards-conformance mode, as it - mishandles inline functions that call each other. E.g., for 'inline void f - (void) { } inline void g (void) { f (); }', c99 incorrectly complains - 'reference to static identifier "f" in extern inline function'. - This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. - - Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) - on configurations that mistakenly use 'static inline' to implement - functions or macros in standard C headers like . For example, - if isdigit is mistakenly implemented via a static inline function, - a program containing an extern inline function that calls isdigit - may not work since the C standard prohibits extern inline functions - from calling static functions. This bug is known to occur on: - - OS X 10.8 and earlier; see: - http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html - - DragonFly; see - http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log - - FreeBSD; see: - http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html - - OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and - for clang but remains for g++; see . - Assume DragonFly and FreeBSD will be similar. */ -#if (((defined __APPLE__ && defined __MACH__) \ - || defined __DragonFly__ || defined __FreeBSD__) \ - && (defined __header_inline \ - ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ - && ! defined __clang__) \ - : ((! defined _DONT_USE_CTYPE_INLINE_ \ - && (defined __GNUC__ || defined __cplusplus)) \ - || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ - && defined __GNUC__ && ! defined __cplusplus)))) -# define _GL_EXTERN_INLINE_STDHEADER_BUG -#endif -#if ((__GNUC__ \ - ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ - : (199901L <= __STDC_VERSION__ \ - && !defined __HP_cc \ - && !(defined __SUNPRO_C && __STDC__))) \ - && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) -# define _GL_INLINE inline -# define _GL_EXTERN_INLINE extern inline -# define _GL_EXTERN_INLINE_IN_USE -#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ - && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) -# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ - /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ -# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) -# else -# define _GL_INLINE extern inline -# endif -# define _GL_EXTERN_INLINE extern -# define _GL_EXTERN_INLINE_IN_USE -#else -# define _GL_INLINE static _GL_UNUSED -# define _GL_EXTERN_INLINE static _GL_UNUSED -#endif - -/* In GCC, suppress bogus "no previous prototype for 'FOO'" - and "no previous declaration for 'FOO'" diagnostics, - when FOO is an inline function in the header; see - and - . */ -#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) -# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ -# define _GL_INLINE_HEADER_CONST_PRAGMA -# else -# define _GL_INLINE_HEADER_CONST_PRAGMA \ - _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") -# endif -# define _GL_INLINE_HEADER_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ - _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ - _GL_INLINE_HEADER_CONST_PRAGMA -# define _GL_INLINE_HEADER_END \ - _Pragma ("GCC diagnostic pop") -#else -# define _GL_INLINE_HEADER_BEGIN -# define _GL_INLINE_HEADER_END -#endif]) -]) diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4 deleted file mode 100644 index 87cc4bd2d..000000000 --- a/m4/fcntl-o.m4 +++ /dev/null @@ -1,134 +0,0 @@ -# fcntl-o.m4 serial 4 -dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Paul Eggert. - -# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. -# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. -# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. -AC_DEFUN([gl_FCNTL_O_FLAGS], -[ - dnl Persuade glibc to define O_NOATIME and O_NOFOLLOW. - dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes - dnl AC_GNU_SOURCE. - m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], - [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], - [AC_REQUIRE([AC_GNU_SOURCE])]) - - AC_CHECK_HEADERS_ONCE([unistd.h]) - AC_CHECK_FUNCS_ONCE([symlink]) - AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include - #if HAVE_UNISTD_H - # include - #else /* on Windows with MSVC */ - # include - # include - # defined sleep(n) _sleep ((n) * 1000) - #endif - #include - #ifndef O_NOATIME - #define O_NOATIME 0 - #endif - #ifndef O_NOFOLLOW - #define O_NOFOLLOW 0 - #endif - static int const constants[] = - { - O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, - O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY - }; - ]], - [[ - int result = !constants; - #if HAVE_SYMLINK - { - static char const sym[] = "conftest.sym"; - if (symlink ("/dev/null", sym) != 0) - result |= 2; - else - { - int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); - if (fd >= 0) - { - close (fd); - result |= 4; - } - } - if (unlink (sym) != 0 || symlink (".", sym) != 0) - result |= 2; - else - { - int fd = open (sym, O_RDONLY | O_NOFOLLOW); - if (fd >= 0) - { - close (fd); - result |= 4; - } - } - unlink (sym); - } - #endif - { - static char const file[] = "confdefs.h"; - int fd = open (file, O_RDONLY | O_NOATIME); - if (fd < 0) - result |= 8; - else - { - struct stat st0; - if (fstat (fd, &st0) != 0) - result |= 16; - else - { - char c; - sleep (1); - if (read (fd, &c, 1) != 1) - result |= 24; - else - { - if (close (fd) != 0) - result |= 32; - else - { - struct stat st1; - if (stat (file, &st1) != 0) - result |= 40; - else - if (st0.st_atime != st1.st_atime) - result |= 64; - } - } - } - } - } - return result;]])], - [gl_cv_header_working_fcntl_h=yes], - [case $? in #( - 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( - 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( - 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( - *) gl_cv_header_working_fcntl_h='no';; - esac], - [gl_cv_header_working_fcntl_h=cross-compiling])]) - - case $gl_cv_header_working_fcntl_h in #( - *O_NOATIME* | no | cross-compiling) ac_val=0;; #( - *) ac_val=1;; - esac - AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], - [Define to 1 if O_NOATIME works.]) - - case $gl_cv_header_working_fcntl_h in #( - *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( - *) ac_val=1;; - esac - AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], - [Define to 1 if O_NOFOLLOW works.]) -]) diff --git a/m4/float_h.m4 b/m4/float_h.m4 deleted file mode 100644 index 397f2d1fa..000000000 --- a/m4/float_h.m4 +++ /dev/null @@ -1,98 +0,0 @@ -# float_h.m4 serial 9 -dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FLOAT_H], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - FLOAT_H= - REPLACE_FLOAT_LDBL=0 - case "$host_os" in - aix* | beos* | openbsd* | mirbsd* | irix*) - FLOAT_H=float.h - ;; - freebsd*) - case "$host_cpu" in -changequote(,)dnl - i[34567]86 ) -changequote([,])dnl - FLOAT_H=float.h - ;; - x86_64 ) - # On x86_64 systems, the C compiler may still be generating - # 32-bit code. - AC_EGREP_CPP([yes], - [#if defined __LP64__ || defined __x86_64__ || defined __amd64__ - yes - #endif], - [], - [FLOAT_H=float.h]) - ;; - esac - ;; - linux*) - case "$host_cpu" in - powerpc*) - FLOAT_H=float.h - ;; - esac - ;; - esac - case "$host_os" in - aix* | freebsd* | linux*) - if test -n "$FLOAT_H"; then - REPLACE_FLOAT_LDBL=1 - fi - ;; - esac - - dnl Test against glibc-2.7 Linux/SPARC64 bug. - REPLACE_ITOLD=0 - AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works], - [gl_cv_func_itold_works], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -int i = -1; -volatile long double ld; -int main () -{ - ld += i * 1.0L; - if (ld > 0) - return 1; - return 0; -}]])], - [gl_cv_func_itold_works=yes], - [gl_cv_func_itold_works=no], - [case "$host" in - sparc*-*-linux*) - AC_EGREP_CPP([yes], - [#if defined __LP64__ || defined __arch64__ - yes - #endif], - [gl_cv_func_itold_works="guessing no"], - [gl_cv_func_itold_works="guessing yes"]) - ;; - *) gl_cv_func_itold_works="guessing yes" ;; - esac - ]) - ]) - case "$gl_cv_func_itold_works" in - *no) - REPLACE_ITOLD=1 - dnl We add the workaround to but also to , - dnl to increase the chances that the fix function gets pulled in. - FLOAT_H=float.h - ;; - esac - - if test -n "$FLOAT_H"; then - gl_NEXT_HEADERS([float.h]) - fi - AC_SUBST([FLOAT_H]) - AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"]) - AC_SUBST([REPLACE_ITOLD]) -]) diff --git a/m4/fnmatch.m4 b/m4/fnmatch.m4 deleted file mode 100644 index fa0ba4d22..000000000 --- a/m4/fnmatch.m4 +++ /dev/null @@ -1,156 +0,0 @@ -# Check for fnmatch - serial 9. - -# Copyright (C) 2000-2007, 2009-2013 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent. -# New applications should use the macros below instead. - -# Request a POSIX compliant fnmatch function. -AC_DEFUN([gl_FUNC_FNMATCH_POSIX], -[ - m4_divert_text([DEFAULTS], [gl_fnmatch_required=POSIX]) - - dnl Persuade glibc to declare FNM_CASEFOLD etc. - dnl This is only needed if gl_fnmatch_required = GNU. It would be possible - dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting - dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file. - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - FNMATCH_H= - gl_fnmatch_required_lowercase=` - echo $gl_fnmatch_required | LC_ALL=C tr '[[A-Z]]' '[[a-z]]' - ` - gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}" - AC_CACHE_CHECK([for working $gl_fnmatch_required fnmatch], - [$gl_fnmatch_cache_var], - [dnl Some versions of Solaris, SCO, and the GNU C Library - dnl have a broken or incompatible fnmatch. - dnl So we run a test program. If we are cross-compiling, take no chance. - dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this - dnl test. - if test $gl_fnmatch_required = GNU; then - gl_fnmatch_gnu_start= - gl_fnmatch_gnu_end= - else - gl_fnmatch_gnu_start='#if 0' - gl_fnmatch_gnu_end='#endif' - fi - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - static int - y (char const *pattern, char const *string, int flags) - { - return fnmatch (pattern, string, flags) == 0; - } - static int - n (char const *pattern, char const *string, int flags) - { - return fnmatch (pattern, string, flags) == FNM_NOMATCH; - } - ]], - [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]"; - char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]"; - static char const A_1[] = { 'A' - 1, 0 }; - static char const A01[] = { 'A' + 1, 0 }; - static char const a_1[] = { 'a' - 1, 0 }; - static char const a01[] = { 'a' + 1, 0 }; - static char const bs_1[] = { '\\\\' - 1, 0 }; - static char const bs01[] = { '\\\\' + 1, 0 }; - int result = 0; - if (!n ("a*", "", 0)) - return 1; - if (!y ("a*", "abc", 0)) - return 1; - if (!y ("[/b", "[/b", 0)) /*"]]"*/ /* glibc Bugzilla bug 12378 */ - return 1; - if (!n ("d*/*1", "d/s/1", FNM_PATHNAME)) - return 2; - if (!y ("a\\\\bc", "abc", 0)) - return 3; - if (!n ("a\\\\bc", "abc", FNM_NOESCAPE)) - return 3; - if (!y ("*x", ".x", 0)) - return 4; - if (!n ("*x", ".x", FNM_PERIOD)) - return 4; - if (!y (Apat, "\\\\", 0)) - return 5; - if (!y (Apat, "A", 0)) - return 5; - if (!y (apat, "\\\\", 0)) - return 5; - if (!y (apat, "a", 0)) - return 5; - if (!(n (Apat, A_1, 0) == ('A' < '\\\\'))) - return 5; - if (!(n (apat, a_1, 0) == ('a' < '\\\\'))) - return 5; - if (!(y (Apat, A01, 0) == ('A' < '\\\\'))) - return 5; - if (!(y (apat, a01, 0) == ('a' < '\\\\'))) - return 5; - if (!(y (Apat, bs_1, 0) == ('A' < '\\\\'))) - return 5; - if (!(y (apat, bs_1, 0) == ('a' < '\\\\'))) - return 5; - if (!(n (Apat, bs01, 0) == ('A' < '\\\\'))) - return 5; - if (!(n (apat, bs01, 0) == ('a' < '\\\\'))) - return 5; - $gl_fnmatch_gnu_start - if (!y ("xxXX", "xXxX", FNM_CASEFOLD)) - result |= 8; - if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)) - result |= 16; - if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME)) - result |= 32; - if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)) - result |= 64; - if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)) - result |= 64; - if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)) - result |= 64; - $gl_fnmatch_gnu_end - return result; - ]])], - [eval "$gl_fnmatch_cache_var=yes"], - [eval "$gl_fnmatch_cache_var=no"], - [eval "$gl_fnmatch_cache_var=\"guessing no\""]) - ]) - eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\"" - if test "$gl_fnmatch_result" = yes; then - dnl Not strictly necessary. Only to avoid spurious leftover files if people - dnl don't do "make distclean". - rm -f "$gl_source_base/fnmatch.h" - else - FNMATCH_H=fnmatch.h - fi - AC_SUBST([FNMATCH_H]) - AM_CONDITIONAL([GL_GENERATE_FNMATCH_H], [test -n "$FNMATCH_H"]) -]) - -# Request a POSIX compliant fnmatch function with GNU extensions. -AC_DEFUN([gl_FUNC_FNMATCH_GNU], -[ - m4_divert_text([INIT_PREPARE], [gl_fnmatch_required=GNU]) - - AC_REQUIRE([gl_FUNC_FNMATCH_POSIX]) -]) - -AC_DEFUN([gl_PREREQ_FNMATCH], -[ - dnl We must choose a different name for our function, since on ELF systems - dnl a broken fnmatch() in libc.so would override our fnmatch() if it is - dnl compiled into a shared library. - AC_DEFINE_UNQUOTED([fnmatch], [${gl_fnmatch_required_lowercase}_fnmatch], - [Define to a replacement function name for fnmatch().]) - dnl Prerequisites of lib/fnmatch.c. - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - AC_CHECK_DECLS([isblank], [], [], [[#include ]]) - AC_CHECK_FUNCS_ONCE([btowc isblank iswctype mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) - AC_CHECK_HEADERS_ONCE([wctype.h]) -]) diff --git a/m4/getdelim.m4 b/m4/getdelim.m4 deleted file mode 100644 index 36f66a108..000000000 --- a/m4/getdelim.m4 +++ /dev/null @@ -1,88 +0,0 @@ -# getdelim.m4 serial 10 - -dnl Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. -dnl -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_PREREQ([2.59]) - -AC_DEFUN([gl_FUNC_GETDELIM], -[ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - - dnl Persuade glibc to declare getdelim(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS_ONCE([getdelim]) - - AC_CHECK_FUNCS_ONCE([getdelim]) - if test $ac_cv_func_getdelim = yes; then - HAVE_GETDELIM=1 - dnl Found it in some library. Verify that it works. - AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim], - [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -# include -# include -# include - int main () - { - FILE *in = fopen ("./conftest.data", "r"); - if (!in) - return 1; - { - /* Test result for a NULL buffer and a zero size. - Based on a test program from Karl Heuer. */ - char *line = NULL; - size_t siz = 0; - int len = getdelim (&line, &siz, '\n', in); - if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) - return 2; - } - { - /* Test result for a NULL buffer and a non-zero size. - This crashes on FreeBSD 8.0. */ - char *line = NULL; - size_t siz = (size_t)(~0) / 4; - if (getdelim (&line, &siz, '\n', in) == -1) - return 3; - } - return 0; - } - ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works. - , [gl_cv_func_working_getdelim=no] dnl The library version does NOT work. - , dnl We're cross compiling. Assume it works on glibc2 systems. - [AC_EGREP_CPP([Lucky GNU user], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) && !defined __UCLIBC__ - Lucky GNU user - #endif -#endif - ], - [gl_cv_func_working_getdelim="guessing yes"], - [gl_cv_func_working_getdelim="guessing no"])] - )]) - case "$gl_cv_func_working_getdelim" in - *no) - REPLACE_GETDELIM=1 - ;; - esac - else - HAVE_GETDELIM=0 - fi - - if test $ac_cv_have_decl_getdelim = no; then - HAVE_DECL_GETDELIM=0 - fi -]) - -# Prerequisites of lib/getdelim.c. -AC_DEFUN([gl_PREREQ_GETDELIM], -[ - AC_CHECK_FUNCS([flockfile funlockfile]) - AC_CHECK_DECLS([getc_unlocked]) -]) diff --git a/m4/getline.m4 b/m4/getline.m4 deleted file mode 100644 index 342bc9905..000000000 --- a/m4/getline.m4 +++ /dev/null @@ -1,96 +0,0 @@ -# getline.m4 serial 26 - -dnl Copyright (C) 1998-2003, 2005-2007, 2009-2013 Free Software Foundation, -dnl Inc. -dnl -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_PREREQ([2.59]) - -dnl See if there's a working, system-supplied version of the getline function. -dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems -dnl have a function by that name in -linet that doesn't have anything -dnl to do with the function we need. -AC_DEFUN([gl_FUNC_GETLINE], -[ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - - dnl Persuade glibc to declare getline(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS_ONCE([getline]) - - gl_getline_needs_run_time_check=no - AC_CHECK_FUNC([getline], - [dnl Found it in some library. Verify that it works. - gl_getline_needs_run_time_check=yes], - [am_cv_func_working_getline=no]) - if test $gl_getline_needs_run_time_check = yes; then - AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline], - [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -# include -# include -# include - int main () - { - FILE *in = fopen ("./conftest.data", "r"); - if (!in) - return 1; - { - /* Test result for a NULL buffer and a zero size. - Based on a test program from Karl Heuer. */ - char *line = NULL; - size_t siz = 0; - int len = getline (&line, &siz, in); - if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) - return 2; - } - { - /* Test result for a NULL buffer and a non-zero size. - This crashes on FreeBSD 8.0. */ - char *line = NULL; - size_t siz = (size_t)(~0) / 4; - if (getline (&line, &siz, in) == -1) - return 3; - } - return 0; - } - ]])], [am_cv_func_working_getline=yes] dnl The library version works. - , [am_cv_func_working_getline=no] dnl The library version does NOT work. - , dnl We're cross compiling. Assume it works on glibc2 systems. - [AC_EGREP_CPP([Lucky GNU user], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) && !defined __UCLIBC__ - Lucky GNU user - #endif -#endif - ], - [am_cv_func_working_getline="guessing yes"], - [am_cv_func_working_getline="guessing no"])] - )]) - fi - - if test $ac_cv_have_decl_getline = no; then - HAVE_DECL_GETLINE=0 - fi - - case "$am_cv_func_working_getline" in - *no) - dnl Set REPLACE_GETLINE always: Even if we have not found the broken - dnl getline function among $LIBS, it may exist in libinet and the - dnl executable may be linked with -linet. - REPLACE_GETLINE=1 - ;; - esac -]) - -# Prerequisites of lib/getline.c. -AC_DEFUN([gl_PREREQ_GETLINE], -[ - : -]) diff --git a/m4/getopt.m4 b/m4/getopt.m4 deleted file mode 100644 index 50f450919..000000000 --- a/m4/getopt.m4 +++ /dev/null @@ -1,368 +0,0 @@ -# getopt.m4 serial 44 -dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Request a POSIX compliant getopt function. -AC_DEFUN([gl_FUNC_GETOPT_POSIX], -[ - m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX]) - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) - dnl Other modules can request the gnulib implementation of the getopt - dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS. - dnl argp.m4 does this. - m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [ - REPLACE_GETOPT=1 - ], [ - REPLACE_GETOPT=0 - if test -n "$gl_replace_getopt"; then - REPLACE_GETOPT=1 - fi - ]) - if test $REPLACE_GETOPT = 1; then - dnl Arrange for getopt.h to be created. - gl_GETOPT_SUBSTITUTE_HEADER - fi -]) - -# Request a POSIX compliant getopt function with GNU extensions (such as -# options with optional arguments) and the functions getopt_long, -# getopt_long_only. -AC_DEFUN([gl_FUNC_GETOPT_GNU], -[ - m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) - - AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) -]) - -# Determine whether to replace the entire getopt facility. -AC_DEFUN([gl_GETOPT_CHECK_HEADERS], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON - - dnl Persuade Solaris to declare optarg, optind, opterr, optopt. - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - gl_CHECK_NEXT_HEADERS([getopt.h]) - if test $ac_cv_header_getopt_h = yes; then - HAVE_GETOPT_H=1 - else - HAVE_GETOPT_H=0 - fi - AC_SUBST([HAVE_GETOPT_H]) - - gl_replace_getopt= - - dnl Test whether is available. - if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then - AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes]) - fi - - dnl Test whether the function getopt_long is available. - if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then - AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) - fi - - dnl POSIX 2008 does not specify leading '+' behavior, but see - dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on - dnl the next version of POSIX. For now, we only guarantee leading '+' - dnl behavior with getopt-gnu. - if test -z "$gl_replace_getopt"; then - AC_CACHE_CHECK([whether getopt is POSIX compatible], - [gl_cv_func_getopt_posix], - [ - dnl Merging these three different test programs into a single one - dnl would require a reset mechanism. On BSD systems, it can be done - dnl through 'optreset'; on some others (glibc), it can be done by - dnl setting 'optind' to 0; on others again (HP-UX, IRIX, OSF/1, - dnl Solaris 9, musl libc), there is no such mechanism. - if test $cross_compiling = no; then - dnl Sanity check. Succeeds everywhere (except on MSVC, - dnl which lacks and getopt() entirely). - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include - -int -main () -{ - static char program[] = "program"; - static char a[] = "-a"; - static char foo[] = "foo"; - static char bar[] = "bar"; - char *argv[] = { program, a, foo, bar, NULL }; - int c; - - c = getopt (4, argv, "ab"); - if (!(c == 'a')) - return 1; - c = getopt (4, argv, "ab"); - if (!(c == -1)) - return 2; - if (!(optind == 2)) - return 3; - return 0; -} -]])], - [gl_cv_func_getopt_posix=maybe], - [gl_cv_func_getopt_posix=no]) - if test $gl_cv_func_getopt_posix = maybe; then - dnl Sanity check with '+'. Succeeds everywhere (except on MSVC, - dnl which lacks and getopt() entirely). - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include - -int -main () -{ - static char program[] = "program"; - static char donald[] = "donald"; - static char p[] = "-p"; - static char billy[] = "billy"; - static char duck[] = "duck"; - static char a[] = "-a"; - static char bar[] = "bar"; - char *argv[] = { program, donald, p, billy, duck, a, bar, NULL }; - int c; - - c = getopt (7, argv, "+abp:q:"); - if (!(c == -1)) - return 4; - if (!(strcmp (argv[0], "program") == 0)) - return 5; - if (!(strcmp (argv[1], "donald") == 0)) - return 6; - if (!(strcmp (argv[2], "-p") == 0)) - return 7; - if (!(strcmp (argv[3], "billy") == 0)) - return 8; - if (!(strcmp (argv[4], "duck") == 0)) - return 9; - if (!(strcmp (argv[5], "-a") == 0)) - return 10; - if (!(strcmp (argv[6], "bar") == 0)) - return 11; - if (!(optind == 1)) - return 12; - return 0; -} -]])], - [gl_cv_func_getopt_posix=maybe], - [gl_cv_func_getopt_posix=no]) - fi - if test $gl_cv_func_getopt_posix = maybe; then - dnl Detect Mac OS X 10.5, AIX 7.1, mingw bug. - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include - -int -main () -{ - static char program[] = "program"; - static char ab[] = "-ab"; - char *argv[3] = { program, ab, NULL }; - if (getopt (2, argv, "ab:") != 'a') - return 13; - if (getopt (2, argv, "ab:") != '?') - return 14; - if (optopt != 'b') - return 15; - if (optind != 2) - return 16; - return 0; -} -]])], - [gl_cv_func_getopt_posix=yes], - [gl_cv_func_getopt_posix=no]) - fi - else - case "$host_os" in - darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";; - *) gl_cv_func_getopt_posix="guessing yes";; - esac - fi - ]) - case "$gl_cv_func_getopt_posix" in - *no) gl_replace_getopt=yes ;; - esac - fi - - if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then - AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu], - [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the - # optstring is necessary for programs like m4 that have POSIX-mandated - # semantics for supporting options interspersed with files. - # Also, since getopt_long is a GNU extension, we require optind=0. - # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT; - # so take care to revert to the correct (non-)export state. -dnl GNU Coding Standards currently allow awk but not env; besides, env -dnl is ambiguous with environment values that contain newlines. - gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' - case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" - #include - #include - ]GL_NOCRASH[ - ]], [[ - int result = 0; - - nocrash_init(); - - /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, - and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, - OSF/1 5.1, Solaris 10. */ - { - static char conftest[] = "conftest"; - static char plus[] = "-+"; - char *argv[3] = { conftest, plus, NULL }; - opterr = 0; - if (getopt (2, argv, "+a") != '?') - result |= 1; - } - /* This code succeeds on glibc 2.8, mingw, - and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, - IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ - { - static char program[] = "program"; - static char p[] = "-p"; - static char foo[] = "foo"; - static char bar[] = "bar"; - char *argv[] = { program, p, foo, bar, NULL }; - - optind = 1; - if (getopt (4, argv, "p::") != 'p') - result |= 2; - else if (optarg != NULL) - result |= 4; - else if (getopt (4, argv, "p::") != -1) - result |= 6; - else if (optind != 2) - result |= 8; - } - /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ - { - static char program[] = "program"; - static char foo[] = "foo"; - static char p[] = "-p"; - char *argv[] = { program, foo, p, NULL }; - optind = 0; - if (getopt (3, argv, "-p") != 1) - result |= 16; - else if (getopt (3, argv, "-p") != 'p') - result |= 16; - } - /* This code fails on glibc 2.11. */ - { - static char program[] = "program"; - static char b[] = "-b"; - static char a[] = "-a"; - char *argv[] = { program, b, a, NULL }; - optind = opterr = 0; - if (getopt (3, argv, "+:a:b") != 'b') - result |= 32; - else if (getopt (3, argv, "+:a:b") != ':') - result |= 32; - } - /* This code dumps core on glibc 2.14. */ - { - static char program[] = "program"; - static char w[] = "-W"; - static char dummy[] = "dummy"; - char *argv[] = { program, w, dummy, NULL }; - optind = opterr = 1; - if (getopt (3, argv, "W;") != 'W') - result |= 64; - } - return result; - ]])], - [gl_cv_func_getopt_gnu=yes], - [gl_cv_func_getopt_gnu=no], - [dnl Cross compiling. Assume the worst, even on glibc platforms. - gl_cv_func_getopt_gnu="guessing no" - ]) - case $gl_had_POSIXLY_CORRECT in - exported) ;; - yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;; - *) AS_UNSET([POSIXLY_CORRECT]) ;; - esac - ]) - if test "$gl_cv_func_getopt_gnu" != yes; then - gl_replace_getopt=yes - else - AC_CACHE_CHECK([for working GNU getopt_long function], - [gl_cv_func_getopt_long_gnu], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include - #include - ]], - [[static const struct option long_options[] = - { - { "xtremely-",no_argument, NULL, 1003 }, - { "xtra", no_argument, NULL, 1001 }, - { "xtreme", no_argument, NULL, 1002 }, - { "xtremely", no_argument, NULL, 1003 }, - { NULL, 0, NULL, 0 } - }; - /* This code fails on OpenBSD 5.0. */ - { - static char program[] = "program"; - static char xtremel[] = "--xtremel"; - char *argv[] = { program, xtremel, NULL }; - int option_index; - optind = 1; opterr = 0; - if (getopt_long (2, argv, "", long_options, &option_index) != 1003) - return 1; - } - return 0; - ]])], - [gl_cv_func_getopt_long_gnu=yes], - [gl_cv_func_getopt_long_gnu=no], - [dnl Cross compiling. Guess no on OpenBSD, yes otherwise. - case "$host_os" in - openbsd*) gl_cv_func_getopt_long_gnu="guessing no";; - *) gl_cv_func_getopt_long_gnu="guessing yes";; - esac - ]) - ]) - case "$gl_cv_func_getopt_long_gnu" in - *yes) ;; - *) gl_replace_getopt=yes ;; - esac - fi - fi -]) - -AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], -[ - GETOPT_H=getopt.h - AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], - [Define to rpl_ if the getopt replacement functions and variables - should be used.]) - AC_SUBST([GETOPT_H]) -]) - -# Prerequisites of lib/getopt*. -AC_DEFUN([gl_PREREQ_GETOPT], -[ - AC_CHECK_DECLS_ONCE([getenv]) -]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 deleted file mode 100644 index 8d1f0665c..000000000 --- a/m4/gettext.m4 +++ /dev/null @@ -1,401 +0,0 @@ -# gettext.m4 serial 66 (gettext-0.18.2) -dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2006, 2008-2010. - -dnl Macro to add for using GNU gettext. - -dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). -dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The -dnl default (if it is not specified or empty) is 'no-libtool'. -dnl INTLSYMBOL should be 'external' for packages with no intl directory, -dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. -dnl If INTLSYMBOL is 'use-libtool', then a libtool library -dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, -dnl depending on --{enable,disable}-{shared,static} and on the presence of -dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library -dnl $(top_builddir)/intl/libintl.a will be created. -dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext -dnl implementations (in libc or libintl) without the ngettext() function -dnl will be ignored. If NEEDSYMBOL is specified and is -dnl 'need-formatstring-macros', then GNU gettext implementations that don't -dnl support the ISO C 99 formatstring macros will be ignored. -dnl INTLDIR is used to find the intl libraries. If empty, -dnl the value '$(top_builddir)/intl/' is used. -dnl -dnl The result of the configuration is one of three cases: -dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled -dnl and used. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 2) GNU gettext has been found in the system's C library. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 3) No internationalization, always use English msgid. -dnl Catalog format: none -dnl Catalog extension: none -dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. -dnl The use of .gmo is historical (it was needed to avoid overwriting the -dnl GNU format catalogs when building on a platform with an X/Open gettext), -dnl but we keep it in order not to force irrelevant filename changes on the -dnl maintainers. -dnl -AC_DEFUN([AM_GNU_GETTEXT], -[ - dnl Argument checking. - ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , - [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT -])])])])]) - ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], - [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) - ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , - [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT -])])])]) - define([gt_included_intl], - ifelse([$1], [external], - ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), - [yes])) - define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) - gt_NEEDS_INIT - AM_GNU_GETTEXT_NEED([$2]) - - AC_REQUIRE([AM_PO_SUBDIRS])dnl - ifelse(gt_included_intl, yes, [ - AC_REQUIRE([AM_INTL_SUBDIR])dnl - ]) - - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Sometimes libintl requires libiconv, so first search for libiconv. - dnl Ideally we would do this search only after the - dnl if test "$USE_NLS" = "yes"; then - dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT - dnl the configure script would need to contain the same shell code - dnl again, outside any 'if'. There are two solutions: - dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. - dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. - dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not - dnl documented, we avoid it. - ifelse(gt_included_intl, yes, , [ - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - ]) - - dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. - gt_INTL_MACOSX - - dnl Set USE_NLS. - AC_REQUIRE([AM_NLS]) - - ifelse(gt_included_intl, yes, [ - BUILD_INCLUDED_LIBINTL=no - USE_INCLUDED_LIBINTL=no - ]) - LIBINTL= - LTLIBINTL= - POSUB= - - dnl Add a version number to the cache macros. - case " $gt_needs " in - *" need-formatstring-macros "*) gt_api_version=3 ;; - *" need-ngettext "*) gt_api_version=2 ;; - *) gt_api_version=1 ;; - esac - gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" - gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" - - dnl If we use NLS figure out what method - if test "$USE_NLS" = "yes"; then - gt_use_preinstalled_gnugettext=no - ifelse(gt_included_intl, yes, [ - AC_MSG_CHECKING([whether included gettext is requested]) - AC_ARG_WITH([included-gettext], - [ --with-included-gettext use the GNU gettext library included here], - nls_cv_force_use_gnu_gettext=$withval, - nls_cv_force_use_gnu_gettext=no) - AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) - - nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" - if test "$nls_cv_force_use_gnu_gettext" != "yes"; then - ]) - dnl User does not insist on using GNU NLS library. Figure out what - dnl to use. If GNU gettext is available we use this. Else we have - dnl to fall back to GNU NLS library. - - if test $gt_api_version -ge 3; then - gt_revision_test_code=' -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -#endif -changequote(,)dnl -typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -changequote([,])dnl -' - else - gt_revision_test_code= - fi - if test $gt_api_version -ge 2; then - gt_expression_test_code=' + * ngettext ("", "", 0)' - else - gt_expression_test_code= - fi - - AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings; - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings - ]])], - [eval "$gt_func_gnugettext_libc=yes"], - [eval "$gt_func_gnugettext_libc=no"])]) - - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl Sometimes libintl requires libiconv, so first search for libiconv. - ifelse(gt_included_intl, yes, , [ - AM_ICONV_LINK - ]) - dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL - dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) - dnl because that would add "-liconv" to LIBINTL and LTLIBINTL - dnl even if libiconv doesn't exist. - AC_LIB_LINKFLAGS_BODY([intl]) - AC_CACHE_CHECK([for GNU gettext in libintl], - [$gt_func_gnugettext_libintl], - [gt_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $INCINTL" - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - dnl Now see whether libintl exists and does not depend on libiconv. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ]])], - [eval "$gt_func_gnugettext_libintl=yes"], - [eval "$gt_func_gnugettext_libintl=no"]) - dnl Now see whether libintl exists and depends on libiconv. - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ]])], - [LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - ]) - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS"]) - fi - - dnl If an already present or preinstalled GNU gettext() is found, - dnl use it. But if this macro is used in GNU gettext, and GNU - dnl gettext is already preinstalled in libintl, we update this - dnl libintl. (Cf. the install rule in intl/Makefile.in.) - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ - || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ - && test "$PACKAGE" != gettext-runtime \ - && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes - else - dnl Reset the values set by searching for libintl. - LIBINTL= - LTLIBINTL= - INCINTL= - fi - - ifelse(gt_included_intl, yes, [ - if test "$gt_use_preinstalled_gnugettext" != "yes"; then - dnl GNU gettext is not found in the C library. - dnl Fall back on included GNU gettext library. - nls_cv_use_gnu_gettext=yes - fi - fi - - if test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions used to generate GNU NLS library. - BUILD_INCLUDED_LIBINTL=yes - USE_INCLUDED_LIBINTL=yes - LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" - LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" - LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` - fi - - CATOBJEXT= - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions to use GNU gettext tools. - CATOBJEXT=.gmo - fi - ]) - - if test -n "$INTL_MACOSX_LIBS"; then - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Some extra flags are needed during linking. - LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" - LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" - fi - fi - - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - AC_DEFINE([ENABLE_NLS], [1], - [Define to 1 if translation of program messages to the user's native language - is requested.]) - else - USE_NLS=no - fi - fi - - AC_MSG_CHECKING([whether to use NLS]) - AC_MSG_RESULT([$USE_NLS]) - if test "$USE_NLS" = "yes"; then - AC_MSG_CHECKING([where the gettext function comes from]) - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - gt_source="external libintl" - else - gt_source="libc" - fi - else - gt_source="included intl directory" - fi - AC_MSG_RESULT([$gt_source]) - fi - - if test "$USE_NLS" = "yes"; then - - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - AC_MSG_CHECKING([how to link with libintl]) - AC_MSG_RESULT([$LIBINTL]) - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) - fi - - dnl For backward compatibility. Some packages may be using this. - AC_DEFINE([HAVE_GETTEXT], [1], - [Define if the GNU gettext() function is already present or preinstalled.]) - AC_DEFINE([HAVE_DCGETTEXT], [1], - [Define if the GNU dcgettext() function is already present or preinstalled.]) - fi - - dnl We need to process the po/ directory. - POSUB=po - fi - - ifelse(gt_included_intl, yes, [ - dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL - dnl to 'yes' because some of the testsuite requires it. - if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then - BUILD_INCLUDED_LIBINTL=yes - fi - - dnl Make all variables we use known to autoconf. - AC_SUBST([BUILD_INCLUDED_LIBINTL]) - AC_SUBST([USE_INCLUDED_LIBINTL]) - AC_SUBST([CATOBJEXT]) - - dnl For backward compatibility. Some configure.ins may be using this. - nls_cv_header_intl= - nls_cv_header_libgt= - - dnl For backward compatibility. Some Makefiles may be using this. - DATADIRNAME=share - AC_SUBST([DATADIRNAME]) - - dnl For backward compatibility. Some Makefiles may be using this. - INSTOBJEXT=.mo - AC_SUBST([INSTOBJEXT]) - - dnl For backward compatibility. Some Makefiles may be using this. - GENCAT=gencat - AC_SUBST([GENCAT]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLOBJS= - if test "$USE_INCLUDED_LIBINTL" = yes; then - INTLOBJS="\$(GETTOBJS)" - fi - AC_SUBST([INTLOBJS]) - - dnl Enable libtool support if the surrounding package wishes it. - INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix - AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) - ]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLLIBS="$LIBINTL" - AC_SUBST([INTLLIBS]) - - dnl Make all documented variables known to autoconf. - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) - AC_SUBST([POSUB]) -]) - - -dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. -m4_define([gt_NEEDS_INIT], -[ - m4_divert_text([DEFAULTS], [gt_needs=]) - m4_define([gt_NEEDS_INIT], []) -]) - - -dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) -AC_DEFUN([AM_GNU_GETTEXT_NEED], -[ - m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) -]) - - -dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) -AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/m4/glibc2.m4 b/m4/glibc2.m4 deleted file mode 100644 index 0e5068266..000000000 --- a/m4/glibc2.m4 +++ /dev/null @@ -1,31 +0,0 @@ -# glibc2.m4 serial 3 -dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Test for the GNU C Library, version 2.0 or newer. -# From Bruno Haible. - -AC_DEFUN([gt_GLIBC2], - [ - AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer], - [ac_cv_gnu_library_2], - [AC_EGREP_CPP([Lucky GNU user], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) && !defined __UCLIBC__ - Lucky GNU user - #endif -#endif - ], - [ac_cv_gnu_library_2=yes], - [ac_cv_gnu_library_2=no]) - ] - ) - AC_SUBST([GLIBC2]) - GLIBC2="$ac_cv_gnu_library_2" - ] -) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 deleted file mode 100644 index 613fb2a41..000000000 --- a/m4/glibc21.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# glibc21.m4 serial 5 -dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Test for the GNU C Library, version 2.1 or newer, or uClibc. -# From Bruno Haible. - -AC_DEFUN([gl_GLIBC21], - [ - AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], - [ac_cv_gnu_library_2_1], - [AC_EGREP_CPP([Lucky], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) - Lucky GNU user - #endif -#endif -#ifdef __UCLIBC__ - Lucky user -#endif - ], - [ac_cv_gnu_library_2_1=yes], - [ac_cv_gnu_library_2_1=no]) - ] - ) - AC_SUBST([GLIBC21]) - GLIBC21="$ac_cv_gnu_library_2_1" - ] -) diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 deleted file mode 100644 index 408918440..000000000 --- a/m4/gnulib-cache.m4 +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2002-2013 Free Software Foundation, Inc. -# -# This file 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. -# -# This file 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 this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# -# This file represents the specification of how gnulib-tool is used. -# It acts as a cache: It is written and read by gnulib-tool. -# In projects that use version control, this file is meant to be put under -# version control, like the configure.ac and various Makefile.am files. - - -# Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex - -# Specification in the form of a few gnulib-tool.m4 macro invocations: -gl_LOCAL_DIR([]) -gl_MODULES([ - argp - error - fnmatch - getdelim - getline - gettext - progname - regex -]) -gl_AVOID([]) -gl_SOURCE_BASE([grub-core/gnulib]) -gl_M4_BASE([m4]) -gl_PO_BASE([]) -gl_DOC_BASE([doc]) -gl_TESTS_BASE([tests]) -gl_LIB([libgnu]) -gl_MAKEFILE_NAME([]) -gl_MACRO_PREFIX([gl]) -gl_PO_DOMAIN([]) -gl_WITNESS_C_MACRO([]) -gl_VC_FILES([false]) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 deleted file mode 100644 index 0ae5a9ec6..000000000 --- a/m4/gnulib-common.m4 +++ /dev/null @@ -1,377 +0,0 @@ -# gnulib-common.m4 serial 33 -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# gl_COMMON -# is expanded unconditionally through gnulib-tool magic. -AC_DEFUN([gl_COMMON], [ - dnl Use AC_REQUIRE here, so that the code is expanded once only. - AC_REQUIRE([gl_00GNULIB]) - AC_REQUIRE([gl_COMMON_BODY]) -]) -AC_DEFUN([gl_COMMON_BODY], [ - AH_VERBATIM([_Noreturn], -[/* The _Noreturn keyword of C11. */ -#if ! (defined _Noreturn \ - || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) -# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ - || 0x5110 <= __SUNPRO_C) -# define _Noreturn __attribute__ ((__noreturn__)) -# elif defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn -# endif -#endif -]) - AH_VERBATIM([isoc99_inline], -[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports - the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of - earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. - __APPLE__ && __MACH__ test for Mac OS X. - __APPLE_CC__ tests for the Apple compiler and its version. - __STDC_VERSION__ tests for the C99 mode. */ -#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ -# define __GNUC_STDC_INLINE__ 1 -#endif]) - AH_VERBATIM([unused_parameter], -[/* Define as a marker that can be attached to declarations that might not - be used. This helps to reduce warnings, such as from - GCC -Wunused-parameter. */ -#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_UNUSED __attribute__ ((__unused__)) -#else -# define _GL_UNUSED -#endif -/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name - is a misnomer outside of parameter lists. */ -#define _UNUSED_PARAMETER_ _GL_UNUSED - -/* The __pure__ attribute was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* The __const__ attribute was added in gcc 2.95. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) -#else -# define _GL_ATTRIBUTE_CONST /* empty */ -#endif -]) - dnl Preparation for running test programs: - dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not - dnl to /dev/tty, so they can be redirected to log files. Such diagnostics - dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. - LIBC_FATAL_STDERR_=1 - export LIBC_FATAL_STDERR_ -]) - -# gl_MODULE_INDICATOR_CONDITION -# expands to a C preprocessor expression that evaluates to 1 or 0, depending -# whether a gnulib module that has been requested shall be considered present -# or not. -m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) - -# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) -# sets the shell variable that indicates the presence of the given module to -# a C preprocessor expression that will evaluate to 1. -AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], -[ - gl_MODULE_INDICATOR_SET_VARIABLE_AUX( - [GNULIB_[]m4_translit([[$1]], - [abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], - [gl_MODULE_INDICATOR_CONDITION]) -]) - -# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable]) -# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION. -# The shell variable's value is a C preprocessor expression that evaluates -# to 0 or 1. -AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], -[ - m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], - [ - dnl Simplify the expression VALUE || 1 to 1. - $1=1 - ], - [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], - [gl_MODULE_INDICATOR_CONDITION])]) -]) - -# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition]) -# modifies the shell variable to include the given condition. The shell -# variable's value is a C preprocessor expression that evaluates to 0 or 1. -AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], -[ - dnl Simplify the expression 1 || CONDITION to 1. - if test "$[]$1" != 1; then - dnl Simplify the expression 0 || CONDITION to CONDITION. - if test "$[]$1" = 0; then - $1=$2 - else - $1="($[]$1 || $2)" - fi - fi -]) - -# gl_MODULE_INDICATOR([modulename]) -# defines a C macro indicating the presence of the given module -# in a location where it can be used. -# | Value | Value | -# | in lib/ | in tests/ | -# --------------------------------------------+---------+-----------+ -# Module present among main modules: | 1 | 1 | -# --------------------------------------------+---------+-----------+ -# Module present among tests-related modules: | 0 | 1 | -# --------------------------------------------+---------+-----------+ -# Module not present at all: | 0 | 0 | -# --------------------------------------------+---------+-----------+ -AC_DEFUN([gl_MODULE_INDICATOR], -[ - AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], - [abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), - [gl_MODULE_INDICATOR_CONDITION], - [Define to a C preprocessor expression that evaluates to 1 or 0, - depending whether the gnulib module $1 shall be considered present.]) -]) - -# gl_MODULE_INDICATOR_FOR_TESTS([modulename]) -# defines a C macro indicating the presence of the given module -# in lib or tests. This is useful to determine whether the module -# should be tested. -# | Value | Value | -# | in lib/ | in tests/ | -# --------------------------------------------+---------+-----------+ -# Module present among main modules: | 1 | 1 | -# --------------------------------------------+---------+-----------+ -# Module present among tests-related modules: | 1 | 1 | -# --------------------------------------------+---------+-----------+ -# Module not present at all: | 0 | 0 | -# --------------------------------------------+---------+-----------+ -AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], -[ - AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], - [abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], - [Define to 1 when the gnulib module $1 should be tested.]) -]) - -# gl_ASSERT_NO_GNULIB_POSIXCHECK -# asserts that there will never be a need to #define GNULIB_POSIXCHECK. -# and thereby enables an optimization of configure and config.h. -# Used by Emacs. -AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], -[ - dnl Override gl_WARN_ON_USE_PREPARE. - dnl But hide this definition from 'aclocal'. - AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], []) -]) - -# gl_ASSERT_NO_GNULIB_TESTS -# asserts that there will be no gnulib tests in the scope of the configure.ac -# and thereby enables an optimization of config.h. -# Used by Emacs. -AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], -[ - dnl Override gl_MODULE_INDICATOR_FOR_TESTS. - AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) -]) - -# Test whether exists. -# Set HAVE_FEATURES_H. -AC_DEFUN([gl_FEATURES_H], -[ - AC_CHECK_HEADERS_ONCE([features.h]) - if test $ac_cv_header_features_h = yes; then - HAVE_FEATURES_H=1 - else - HAVE_FEATURES_H=0 - fi - AC_SUBST([HAVE_FEATURES_H]) -]) - -# m4_foreach_w -# is a backport of autoconf-2.59c's m4_foreach_w. -# Remove this macro when we can assume autoconf >= 2.60. -m4_ifndef([m4_foreach_w], - [m4_define([m4_foreach_w], - [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) - -# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) -# ---------------------------------------------------- -# Backport of autoconf-2.63b's macro. -# Remove this macro when we can assume autoconf >= 2.64. -m4_ifndef([AS_VAR_IF], -[m4_define([AS_VAR_IF], -[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) - -# gl_PROG_CC_C99 -# Modifies the value of the shell variable CC in an attempt to make $CC -# understand ISO C99 source code. -# This is like AC_PROG_CC_C99, except that -# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60, -# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC -# , -# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99 -# . -# Remaining problems: -# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options -# to CC twice -# . -# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard. -AC_DEFUN([gl_PROG_CC_C99], -[ - dnl Change that version number to the minimum Autoconf version that supports - dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. - m4_version_prereq([9.0], - [AC_REQUIRE([AC_PROG_CC_C99])], - [AC_REQUIRE([AC_PROG_CC_STDC])]) -]) - -# gl_PROG_AR_RANLIB -# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler. -# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override -# the values. -AC_DEFUN([gl_PROG_AR_RANLIB], -[ - dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler - dnl as "cc", and GCC as "gcc". They have different object file formats and - dnl library formats. In particular, the GNU binutils programs ar, ranlib - dnl produce libraries that work only with gcc, not with cc. - AC_REQUIRE([AC_PROG_CC]) - AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], - [ - AC_EGREP_CPP([Amsterdam], - [ -#ifdef __ACK__ -Amsterdam -#endif - ], - [gl_cv_c_amsterdam_compiler=yes], - [gl_cv_c_amsterdam_compiler=no]) - ]) - if test -z "$AR"; then - if test $gl_cv_c_amsterdam_compiler = yes; then - AR='cc -c.a' - if test -z "$ARFLAGS"; then - ARFLAGS='-o' - fi - else - dnl Use the Automake-documented default values for AR and ARFLAGS, - dnl but prefer ${host}-ar over ar (useful for cross-compiling). - AC_CHECK_TOOL([AR], [ar], [ar]) - if test -z "$ARFLAGS"; then - ARFLAGS='cru' - fi - fi - else - if test -z "$ARFLAGS"; then - ARFLAGS='cru' - fi - fi - AC_SUBST([AR]) - AC_SUBST([ARFLAGS]) - if test -z "$RANLIB"; then - if test $gl_cv_c_amsterdam_compiler = yes; then - RANLIB=':' - else - dnl Use the ranlib program if it is available. - AC_PROG_RANLIB - fi - fi - AC_SUBST([RANLIB]) -]) - -# AC_PROG_MKDIR_P -# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix -# for interoperability with automake-1.9.6 from autoconf-2.62. -# Remove this macro when we can assume autoconf >= 2.62 or -# autoconf >= 2.60 && automake >= 1.10. -# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness. -m4_ifndef([AC_AUTOCONF_VERSION],[ -m4_ifdef([AC_PROG_MKDIR_P], [ - dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed. - m4_define([AC_PROG_MKDIR_P], - m4_defn([AC_PROG_MKDIR_P])[ - AC_SUBST([MKDIR_P])])], [ - dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P. - AC_DEFUN_ONCE([AC_PROG_MKDIR_P], - [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake - MKDIR_P='$(mkdir_p)' - AC_SUBST([MKDIR_P])])]) -]) - -# AC_C_RESTRICT -# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, -# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ -# works. -# This definition can be removed once autoconf >= 2.62 can be assumed. -# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness. -m4_ifndef([AC_AUTOCONF_VERSION],[ -AC_DEFUN([AC_C_RESTRICT], -[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], - [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; - }]], - [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t)]])], - [ac_cv_c_restrict=$ac_kw]) - test "$ac_cv_c_restrict" != no && break - done - ]) - AH_VERBATIM([restrict], -[/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#undef restrict -/* Work around a bug in Sun C++: it does not support _Restrict, even - though the corresponding Sun C compiler does, which causes - "#define restrict _Restrict" in the previous line. Perhaps some future - version of Sun C++ will work with _Restrict; if so, it'll probably - define __RESTRICT, just as Sun C does. */ -#if defined __SUNPRO_CC && !defined __RESTRICT -# define _Restrict -#endif]) - case $ac_cv_c_restrict in - restrict) ;; - no) AC_DEFINE([restrict], []) ;; - *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; - esac -]) -]) - -# gl_BIGENDIAN -# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. -# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some -# macros invoke AC_C_BIGENDIAN with arguments. -AC_DEFUN([gl_BIGENDIAN], -[ - AC_C_BIGENDIAN -]) - -# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) -# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not -# output a spurious "(cached)" mark in the midst of other configure output. -# This macro should be used instead of AC_CACHE_VAL when it is not surrounded -# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. -AC_DEFUN([gl_CACHE_VAL_SILENT], -[ - saved_as_echo_n="$as_echo_n" - as_echo_n=':' - AC_CACHE_VAL([$1], [$2]) - as_echo_n="$saved_as_echo_n" -]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 deleted file mode 100644 index 7a19f60d8..000000000 --- a/m4/gnulib-comp.m4 +++ /dev/null @@ -1,756 +0,0 @@ -# DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2013 Free Software Foundation, Inc. -# -# This file 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. -# -# This file 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 this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# -# This file represents the compiled summary of the specification in -# gnulib-cache.m4. It lists the computed macro invocations that need -# to be invoked from configure.ac. -# In projects that use version control, this file can be treated like -# other built files. - - -# This macro should be invoked from ./configure.ac, in the section -# "Checks for programs", right after AC_PROG_CC, and certainly before -# any checks for libraries, header files, types and library functions. -AC_DEFUN([gl_EARLY], -[ - m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace - m4_pattern_allow([^gl_ES$])dnl a valid locale name - m4_pattern_allow([^gl_LIBOBJS$])dnl a variable - m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable - AC_REQUIRE([gl_PROG_AR_RANLIB]) - AC_REQUIRE([AM_PROG_CC_C_O]) - # Code from module alloca: - # Code from module alloca-opt: - # Code from module argp: - # Code from module btowc: - # Code from module configmake: - # Code from module dirname-lgpl: - # Code from module dosname: - # Code from module double-slash-root: - # Code from module errno: - # Code from module error: - # Code from module extensions: - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - # Code from module extern-inline: - # Code from module float: - # Code from module fnmatch: - # Code from module getdelim: - # Code from module getline: - # Code from module getopt-gnu: - # Code from module getopt-posix: - # Code from module gettext: - # Code from module gettext-h: - # Code from module havelib: - # Code from module include_next: - # Code from module intprops: - # Code from module langinfo: - # Code from module localcharset: - # Code from module locale: - # Code from module localeconv: - # Code from module malloc-gnu: - # Code from module malloc-posix: - # Code from module mbrtowc: - # Code from module mbsinit: - # Code from module mbsrtowcs: - # Code from module mbswidth: - # Code from module mbtowc: - # Code from module memchr: - # Code from module mempcpy: - # Code from module msvc-inval: - # Code from module msvc-nothrow: - # Code from module multiarch: - # Code from module nl_langinfo: - # Code from module nocrash: - # Code from module progname: - # Code from module rawmemchr: - # Code from module realloc-posix: - # Code from module regex: - # Code from module size_max: - # Code from module sleep: - # Code from module snippet/_Noreturn: - # Code from module snippet/arg-nonnull: - # Code from module snippet/c++defs: - # Code from module snippet/warn-on-use: - # Code from module ssize_t: - # Code from module stdalign: - # Code from module stdbool: - # Code from module stddef: - # Code from module stdint: - # Code from module stdio: - # Code from module stdlib: - # Code from module strcase: - # Code from module strchrnul: - # Code from module streq: - # Code from module strerror: - # Code from module strerror-override: - # Code from module string: - # Code from module strings: - # Code from module strndup: - # Code from module strnlen: - # Code from module strnlen1: - # Code from module sys_types: - # Code from module sysexits: - # Code from module unistd: - # Code from module unitypes: - # Code from module uniwidth/base: - # Code from module uniwidth/width: - # Code from module vasnprintf: - # Code from module verify: - # Code from module vsnprintf: - # Code from module wchar: - # Code from module wcrtomb: - # Code from module wctype-h: - # Code from module wcwidth: - # Code from module xsize: -]) - -# This macro should be invoked from ./configure.ac, in the section -# "Check for header files, types and library functions". -AC_DEFUN([gl_INIT], -[ - AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) - gl_cond_libtool=false - gl_libdeps= - gl_ltlibdeps= - gl_m4_base='m4' - m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) - m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) - m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) - m4_pushdef([gl_LIBSOURCES_LIST], []) - m4_pushdef([gl_LIBSOURCES_DIR], []) - gl_COMMON - gl_source_base='grub-core/gnulib' - gl_FUNC_ALLOCA - gl_ARGP - m4_ifdef([AM_XGETTEXT_OPTION], - [AM_][XGETTEXT_OPTION([--flag=argp_error:2:c-format]) - AM_][XGETTEXT_OPTION([--flag=argp_failure:4:c-format])]) - gl_FUNC_BTOWC - if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then - AC_LIBOBJ([btowc]) - gl_PREREQ_BTOWC - fi - gl_WCHAR_MODULE_INDICATOR([btowc]) - gl_CONFIGMAKE_PREP - gl_DIRNAME_LGPL - gl_DOUBLE_SLASH_ROOT - gl_HEADER_ERRNO_H - gl_ERROR - if test $ac_cv_lib_error_at_line = no; then - AC_LIBOBJ([error]) - gl_PREREQ_ERROR - fi - m4_ifdef([AM_XGETTEXT_OPTION], - [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) - AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) - AC_REQUIRE([gl_EXTERN_INLINE]) - gl_FLOAT_H - if test $REPLACE_FLOAT_LDBL = 1; then - AC_LIBOBJ([float]) - fi - if test $REPLACE_ITOLD = 1; then - AC_LIBOBJ([itold]) - fi - gl_FUNC_FNMATCH_POSIX - if test -n "$FNMATCH_H"; then - AC_LIBOBJ([fnmatch]) - gl_PREREQ_FNMATCH - fi - gl_FUNC_GETDELIM - if test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1; then - AC_LIBOBJ([getdelim]) - gl_PREREQ_GETDELIM - fi - gl_STDIO_MODULE_INDICATOR([getdelim]) - gl_FUNC_GETLINE - if test $REPLACE_GETLINE = 1; then - AC_LIBOBJ([getline]) - gl_PREREQ_GETLINE - fi - gl_STDIO_MODULE_INDICATOR([getline]) - gl_FUNC_GETOPT_GNU - if test $REPLACE_GETOPT = 1; then - AC_LIBOBJ([getopt]) - AC_LIBOBJ([getopt1]) - gl_PREREQ_GETOPT - dnl Arrange for unistd.h to include getopt.h. - GNULIB_GL_UNISTD_H_GETOPT=1 - fi - AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) - gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu]) - gl_FUNC_GETOPT_POSIX - if test $REPLACE_GETOPT = 1; then - AC_LIBOBJ([getopt]) - AC_LIBOBJ([getopt1]) - gl_PREREQ_GETOPT - dnl Arrange for unistd.h to include getopt.h. - GNULIB_GL_UNISTD_H_GETOPT=1 - fi - AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) - dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. - AM_GNU_GETTEXT_VERSION([0.18.1]) - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) - gl_LANGINFO_H - gl_LOCALCHARSET - LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" - AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) - gl_LOCALE_H - gl_FUNC_LOCALECONV - if test $REPLACE_LOCALECONV = 1; then - AC_LIBOBJ([localeconv]) - gl_PREREQ_LOCALECONV - fi - gl_LOCALE_MODULE_INDICATOR([localeconv]) - gl_FUNC_MALLOC_GNU - if test $REPLACE_MALLOC = 1; then - AC_LIBOBJ([malloc]) - fi - gl_MODULE_INDICATOR([malloc-gnu]) - gl_FUNC_MALLOC_POSIX - if test $REPLACE_MALLOC = 1; then - AC_LIBOBJ([malloc]) - fi - gl_STDLIB_MODULE_INDICATOR([malloc-posix]) - gl_FUNC_MBRTOWC - if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then - AC_LIBOBJ([mbrtowc]) - gl_PREREQ_MBRTOWC - fi - gl_WCHAR_MODULE_INDICATOR([mbrtowc]) - gl_FUNC_MBSINIT - if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then - AC_LIBOBJ([mbsinit]) - gl_PREREQ_MBSINIT - fi - gl_WCHAR_MODULE_INDICATOR([mbsinit]) - gl_FUNC_MBSRTOWCS - if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then - AC_LIBOBJ([mbsrtowcs]) - AC_LIBOBJ([mbsrtowcs-state]) - gl_PREREQ_MBSRTOWCS - fi - gl_WCHAR_MODULE_INDICATOR([mbsrtowcs]) - gl_MBSWIDTH - gl_FUNC_MBTOWC - if test $REPLACE_MBTOWC = 1; then - AC_LIBOBJ([mbtowc]) - gl_PREREQ_MBTOWC - fi - gl_STDLIB_MODULE_INDICATOR([mbtowc]) - gl_FUNC_MEMCHR - if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then - AC_LIBOBJ([memchr]) - gl_PREREQ_MEMCHR - fi - gl_STRING_MODULE_INDICATOR([memchr]) - gl_FUNC_MEMPCPY - if test $HAVE_MEMPCPY = 0; then - AC_LIBOBJ([mempcpy]) - gl_PREREQ_MEMPCPY - fi - gl_STRING_MODULE_INDICATOR([mempcpy]) - gl_MSVC_INVAL - if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then - AC_LIBOBJ([msvc-inval]) - fi - gl_MSVC_NOTHROW - if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then - AC_LIBOBJ([msvc-nothrow]) - fi - gl_MULTIARCH - gl_FUNC_NL_LANGINFO - if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then - AC_LIBOBJ([nl_langinfo]) - fi - gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) - AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) - AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) - gl_FUNC_RAWMEMCHR - if test $HAVE_RAWMEMCHR = 0; then - AC_LIBOBJ([rawmemchr]) - gl_PREREQ_RAWMEMCHR - fi - gl_STRING_MODULE_INDICATOR([rawmemchr]) - gl_FUNC_REALLOC_POSIX - if test $REPLACE_REALLOC = 1; then - AC_LIBOBJ([realloc]) - fi - gl_STDLIB_MODULE_INDICATOR([realloc-posix]) - gl_REGEX - if test $ac_use_included_regex = yes; then - AC_LIBOBJ([regex]) - gl_PREREQ_REGEX - fi - gl_SIZE_MAX - gl_FUNC_SLEEP - if test $HAVE_SLEEP = 0 || test $REPLACE_SLEEP = 1; then - AC_LIBOBJ([sleep]) - fi - gl_UNISTD_MODULE_INDICATOR([sleep]) - gt_TYPE_SSIZE_T - gl_STDALIGN_H - AM_STDBOOL_H - gl_STDDEF_H - gl_STDINT_H - gl_STDIO_H - gl_STDLIB_H - gl_STRCASE - if test $HAVE_STRCASECMP = 0; then - AC_LIBOBJ([strcasecmp]) - gl_PREREQ_STRCASECMP - fi - if test $HAVE_STRNCASECMP = 0; then - AC_LIBOBJ([strncasecmp]) - gl_PREREQ_STRNCASECMP - fi - gl_FUNC_STRCHRNUL - if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then - AC_LIBOBJ([strchrnul]) - gl_PREREQ_STRCHRNUL - fi - gl_STRING_MODULE_INDICATOR([strchrnul]) - gl_FUNC_STRERROR - if test $REPLACE_STRERROR = 1; then - AC_LIBOBJ([strerror]) - fi - gl_MODULE_INDICATOR([strerror]) - gl_STRING_MODULE_INDICATOR([strerror]) - AC_REQUIRE([gl_HEADER_ERRNO_H]) - AC_REQUIRE([gl_FUNC_STRERROR_0]) - if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then - AC_LIBOBJ([strerror-override]) - gl_PREREQ_SYS_H_WINSOCK2 - fi - gl_HEADER_STRING_H - gl_HEADER_STRINGS_H - gl_FUNC_STRNDUP - if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then - AC_LIBOBJ([strndup]) - fi - gl_STRING_MODULE_INDICATOR([strndup]) - gl_FUNC_STRNLEN - if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then - AC_LIBOBJ([strnlen]) - gl_PREREQ_STRNLEN - fi - gl_STRING_MODULE_INDICATOR([strnlen]) - gl_SYS_TYPES_H - AC_PROG_MKDIR_P - gl_SYSEXITS - gl_UNISTD_H - gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h]) - gl_LIBUNISTRING_LIBHEADER([0.9], [uniwidth.h]) - gl_LIBUNISTRING_MODULE([0.9.4], [uniwidth/width]) - gl_FUNC_VASNPRINTF - gl_FUNC_VSNPRINTF - gl_STDIO_MODULE_INDICATOR([vsnprintf]) - gl_WCHAR_H - gl_FUNC_WCRTOMB - if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then - AC_LIBOBJ([wcrtomb]) - gl_PREREQ_WCRTOMB - fi - gl_WCHAR_MODULE_INDICATOR([wcrtomb]) - gl_WCTYPE_H - gl_FUNC_WCWIDTH - if test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1; then - AC_LIBOBJ([wcwidth]) - fi - gl_WCHAR_MODULE_INDICATOR([wcwidth]) - gl_XSIZE - # End of code from modules - m4_ifval(gl_LIBSOURCES_LIST, [ - m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || - for gl_file in ]gl_LIBSOURCES_LIST[ ; do - if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then - echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 - exit 1 - fi - done])dnl - m4_if(m4_sysval, [0], [], - [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) - ]) - m4_popdef([gl_LIBSOURCES_DIR]) - m4_popdef([gl_LIBSOURCES_LIST]) - m4_popdef([AC_LIBSOURCES]) - m4_popdef([AC_REPLACE_FUNCS]) - m4_popdef([AC_LIBOBJ]) - AC_CONFIG_COMMANDS_PRE([ - gl_libobjs= - gl_ltlibobjs= - if test -n "$gl_LIBOBJS"; then - # Remove the extension. - sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do - gl_libobjs="$gl_libobjs $i.$ac_objext" - gl_ltlibobjs="$gl_ltlibobjs $i.lo" - done - fi - AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) - AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) - ]) - gltests_libdeps= - gltests_ltlibdeps= - m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) - m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) - m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) - m4_pushdef([gltests_LIBSOURCES_LIST], []) - m4_pushdef([gltests_LIBSOURCES_DIR], []) - gl_COMMON - gl_source_base='tests' -changequote(,)dnl - gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS -changequote([, ])dnl - AC_SUBST([gltests_WITNESS]) - gl_module_indicator_condition=$gltests_WITNESS - m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) - m4_popdef([gl_MODULE_INDICATOR_CONDITION]) - m4_ifval(gltests_LIBSOURCES_LIST, [ - m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || - for gl_file in ]gltests_LIBSOURCES_LIST[ ; do - if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then - echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 - exit 1 - fi - done])dnl - m4_if(m4_sysval, [0], [], - [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) - ]) - m4_popdef([gltests_LIBSOURCES_DIR]) - m4_popdef([gltests_LIBSOURCES_LIST]) - m4_popdef([AC_LIBSOURCES]) - m4_popdef([AC_REPLACE_FUNCS]) - m4_popdef([AC_LIBOBJ]) - AC_CONFIG_COMMANDS_PRE([ - gltests_libobjs= - gltests_ltlibobjs= - if test -n "$gltests_LIBOBJS"; then - # Remove the extension. - sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do - gltests_libobjs="$gltests_libobjs $i.$ac_objext" - gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" - done - fi - AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) - AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) - ]) - LIBGNU_LIBDEPS="$gl_libdeps" - AC_SUBST([LIBGNU_LIBDEPS]) - LIBGNU_LTLIBDEPS="$gl_ltlibdeps" - AC_SUBST([LIBGNU_LTLIBDEPS]) -]) - -# Like AC_LIBOBJ, except that the module name goes -# into gl_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gl_LIBOBJ], [ - AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl - gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" -]) - -# Like AC_REPLACE_FUNCS, except that the module name goes -# into gl_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gl_REPLACE_FUNCS], [ - m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl - AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) -]) - -# Like AC_LIBSOURCES, except the directory where the source file is -# expected is derived from the gnulib-tool parameterization, -# and alloca is special cased (for the alloca-opt module). -# We could also entirely rely on EXTRA_lib..._SOURCES. -AC_DEFUN([gl_LIBSOURCES], [ - m4_foreach([_gl_NAME], [$1], [ - m4_if(_gl_NAME, [alloca.c], [], [ - m4_define([gl_LIBSOURCES_DIR], [grub-core/gnulib]) - m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) - ]) - ]) -]) - -# Like AC_LIBOBJ, except that the module name goes -# into gltests_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gltests_LIBOBJ], [ - AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl - gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" -]) - -# Like AC_REPLACE_FUNCS, except that the module name goes -# into gltests_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gltests_REPLACE_FUNCS], [ - m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl - AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) -]) - -# Like AC_LIBSOURCES, except the directory where the source file is -# expected is derived from the gnulib-tool parameterization, -# and alloca is special cased (for the alloca-opt module). -# We could also entirely rely on EXTRA_lib..._SOURCES. -AC_DEFUN([gltests_LIBSOURCES], [ - m4_foreach([_gl_NAME], [$1], [ - m4_if(_gl_NAME, [alloca.c], [], [ - m4_define([gltests_LIBSOURCES_DIR], [tests]) - m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) - ]) - ]) -]) - -# This macro records the list of files which have been installed by -# gnulib-tool and may be removed by future gnulib-tool invocations. -AC_DEFUN([gl_FILE_LIST], [ - build-aux/config.rpath - build-aux/snippet/_Noreturn.h - build-aux/snippet/arg-nonnull.h - build-aux/snippet/c++defs.h - build-aux/snippet/warn-on-use.h - lib/alloca.c - lib/alloca.in.h - lib/argp-ba.c - lib/argp-eexst.c - lib/argp-fmtstream.c - lib/argp-fmtstream.h - lib/argp-fs-xinl.c - lib/argp-help.c - lib/argp-namefrob.h - lib/argp-parse.c - lib/argp-pin.c - lib/argp-pv.c - lib/argp-pvh.c - lib/argp-xinl.c - lib/argp.h - lib/asnprintf.c - lib/basename-lgpl.c - lib/btowc.c - lib/config.charset - lib/dirname-lgpl.c - lib/dirname.h - lib/dosname.h - lib/errno.in.h - lib/error.c - lib/error.h - lib/float+.h - lib/float.c - lib/float.in.h - lib/fnmatch.c - lib/fnmatch.in.h - lib/fnmatch_loop.c - lib/getdelim.c - lib/getline.c - lib/getopt.c - lib/getopt.in.h - lib/getopt1.c - lib/getopt_int.h - lib/gettext.h - lib/intprops.h - lib/itold.c - lib/langinfo.in.h - lib/localcharset.c - lib/localcharset.h - lib/locale.in.h - lib/localeconv.c - lib/malloc.c - lib/mbrtowc.c - lib/mbsinit.c - lib/mbsrtowcs-impl.h - lib/mbsrtowcs-state.c - lib/mbsrtowcs.c - lib/mbswidth.c - lib/mbswidth.h - lib/mbtowc-impl.h - lib/mbtowc.c - lib/memchr.c - lib/memchr.valgrind - lib/mempcpy.c - lib/msvc-inval.c - lib/msvc-inval.h - lib/msvc-nothrow.c - lib/msvc-nothrow.h - lib/nl_langinfo.c - lib/printf-args.c - lib/printf-args.h - lib/printf-parse.c - lib/printf-parse.h - lib/progname.c - lib/progname.h - lib/rawmemchr.c - lib/rawmemchr.valgrind - lib/realloc.c - lib/ref-add.sin - lib/ref-del.sin - lib/regcomp.c - lib/regex.c - lib/regex.h - lib/regex_internal.c - lib/regex_internal.h - lib/regexec.c - lib/size_max.h - lib/sleep.c - lib/stdalign.in.h - lib/stdbool.in.h - lib/stddef.in.h - lib/stdint.in.h - lib/stdio.in.h - lib/stdlib.in.h - lib/strcasecmp.c - lib/strchrnul.c - lib/strchrnul.valgrind - lib/streq.h - lib/strerror-override.c - lib/strerror-override.h - lib/strerror.c - lib/string.in.h - lib/strings.in.h - lib/stripslash.c - lib/strncasecmp.c - lib/strndup.c - lib/strnlen.c - lib/strnlen1.c - lib/strnlen1.h - lib/sys_types.in.h - lib/sysexits.in.h - lib/unistd.c - lib/unistd.in.h - lib/unitypes.in.h - lib/uniwidth.in.h - lib/uniwidth/cjk.h - lib/uniwidth/width.c - lib/vasnprintf.c - lib/vasnprintf.h - lib/verify.h - lib/vsnprintf.c - lib/wchar.in.h - lib/wcrtomb.c - lib/wctype-h.c - lib/wctype.in.h - lib/wcwidth.c - lib/xsize.c - lib/xsize.h - m4/00gnulib.m4 - m4/alloca.m4 - m4/argp.m4 - m4/btowc.m4 - m4/codeset.m4 - m4/configmake.m4 - m4/dirname.m4 - m4/double-slash-root.m4 - m4/eealloc.m4 - m4/errno_h.m4 - m4/error.m4 - m4/exponentd.m4 - m4/extensions.m4 - m4/extern-inline.m4 - m4/fcntl-o.m4 - m4/float_h.m4 - m4/fnmatch.m4 - m4/getdelim.m4 - m4/getline.m4 - m4/getopt.m4 - m4/gettext.m4 - m4/glibc2.m4 - m4/glibc21.m4 - m4/gnulib-common.m4 - m4/iconv.m4 - m4/include_next.m4 - m4/intdiv0.m4 - m4/intl.m4 - m4/intldir.m4 - m4/intlmacosx.m4 - m4/intmax.m4 - m4/intmax_t.m4 - m4/inttypes-pri.m4 - m4/inttypes_h.m4 - m4/langinfo_h.m4 - m4/lcmessage.m4 - m4/lib-ld.m4 - m4/lib-link.m4 - m4/lib-prefix.m4 - m4/libunistring-base.m4 - m4/localcharset.m4 - m4/locale-fr.m4 - m4/locale-ja.m4 - m4/locale-zh.m4 - m4/locale_h.m4 - m4/localeconv.m4 - m4/lock.m4 - m4/longlong.m4 - m4/malloc.m4 - m4/math_h.m4 - m4/mbrtowc.m4 - m4/mbsinit.m4 - m4/mbsrtowcs.m4 - m4/mbstate_t.m4 - m4/mbswidth.m4 - m4/mbtowc.m4 - m4/memchr.m4 - m4/mempcpy.m4 - m4/mmap-anon.m4 - m4/msvc-inval.m4 - m4/msvc-nothrow.m4 - m4/multiarch.m4 - m4/nl_langinfo.m4 - m4/nls.m4 - m4/nocrash.m4 - m4/off_t.m4 - m4/po.m4 - m4/printf-posix.m4 - m4/printf.m4 - m4/progtest.m4 - m4/rawmemchr.m4 - m4/realloc.m4 - m4/regex.m4 - m4/size_max.m4 - m4/sleep.m4 - m4/ssize_t.m4 - m4/stdalign.m4 - m4/stdbool.m4 - m4/stddef_h.m4 - m4/stdint.m4 - m4/stdint_h.m4 - m4/stdio_h.m4 - m4/stdlib_h.m4 - m4/strcase.m4 - m4/strchrnul.m4 - m4/strerror.m4 - m4/string_h.m4 - m4/strings_h.m4 - m4/strndup.m4 - m4/strnlen.m4 - m4/sys_socket_h.m4 - m4/sys_types_h.m4 - m4/sysexits.m4 - m4/threadlib.m4 - m4/uintmax_t.m4 - m4/unistd_h.m4 - m4/vasnprintf.m4 - m4/visibility.m4 - m4/vsnprintf.m4 - m4/warn-on-use.m4 - m4/wchar_h.m4 - m4/wchar_t.m4 - m4/wcrtomb.m4 - m4/wctype_h.m4 - m4/wcwidth.m4 - m4/wint_t.m4 - m4/xsize.m4 -]) diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4 deleted file mode 100644 index f3dea1a9f..000000000 --- a/m4/gnulib-tool.m4 +++ /dev/null @@ -1,57 +0,0 @@ -# gnulib-tool.m4 serial 2 -dnl Copyright (C) 2004-2005, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl The following macros need not be invoked explicitly. -dnl Invoking them does nothing except to declare default arguments -dnl for "gnulib-tool --import". - -dnl Usage: gl_LOCAL_DIR([DIR]) -AC_DEFUN([gl_LOCAL_DIR], []) - -dnl Usage: gl_MODULES([module1 module2 ...]) -AC_DEFUN([gl_MODULES], []) - -dnl Usage: gl_AVOID([module1 module2 ...]) -AC_DEFUN([gl_AVOID], []) - -dnl Usage: gl_SOURCE_BASE([DIR]) -AC_DEFUN([gl_SOURCE_BASE], []) - -dnl Usage: gl_M4_BASE([DIR]) -AC_DEFUN([gl_M4_BASE], []) - -dnl Usage: gl_PO_BASE([DIR]) -AC_DEFUN([gl_PO_BASE], []) - -dnl Usage: gl_DOC_BASE([DIR]) -AC_DEFUN([gl_DOC_BASE], []) - -dnl Usage: gl_TESTS_BASE([DIR]) -AC_DEFUN([gl_TESTS_BASE], []) - -dnl Usage: gl_WITH_TESTS -AC_DEFUN([gl_WITH_TESTS], []) - -dnl Usage: gl_LIB([LIBNAME]) -AC_DEFUN([gl_LIB], []) - -dnl Usage: gl_LGPL or gl_LGPL([VERSION]) -AC_DEFUN([gl_LGPL], []) - -dnl Usage: gl_MAKEFILE_NAME([FILENAME]) -AC_DEFUN([gl_MAKEFILE_NAME], []) - -dnl Usage: gl_LIBTOOL -AC_DEFUN([gl_LIBTOOL], []) - -dnl Usage: gl_MACRO_PREFIX([PREFIX]) -AC_DEFUN([gl_MACRO_PREFIX], []) - -dnl Usage: gl_PO_DOMAIN([DOMAIN]) -AC_DEFUN([gl_PO_DOMAIN], []) - -dnl Usage: gl_VC_FILES([BOOLEAN]) -AC_DEFUN([gl_VC_FILES], []) diff --git a/m4/iconv.m4 b/m4/iconv.m4 deleted file mode 100644 index a50364656..000000000 --- a/m4/iconv.m4 +++ /dev/null @@ -1,268 +0,0 @@ -# iconv.m4 serial 18 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], -[ - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([iconv]) -]) - -AC_DEFUN([AM_ICONV_LINK], -[ - dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and - dnl those with the standalone portable GNU libiconv installed). - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - - dnl Add $INCICONV to CPPFLAGS before performing the following checks, - dnl because if the user has installed libiconv and not disabled its use - dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. - am_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - - AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_func_iconv=yes]) - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_lib_iconv=yes] - [am_cv_func_iconv=yes]) - LIBS="$am_save_LIBS" - fi - ]) - if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, - dnl Solaris 10. - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -int main () -{ - int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\263"; - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - const char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; -}]])], - [am_cv_func_iconv_works=yes], - [am_cv_func_iconv_works=no], - [ -changequote(,)dnl - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -changequote([,])dnl - ]) - LIBS="$am_save_LIBS" - ]) - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - AC_DEFINE([HAVE_ICONV], [1], - [Define if you have the iconv() function and it works.]) - fi - if test "$am_cv_lib_iconv" = yes; then - AC_MSG_CHECKING([how to link with libiconv]) - AC_MSG_RESULT([$LIBICONV]) - else - dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV - dnl either. - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi - AC_SUBST([LIBICONV]) - AC_SUBST([LTLIBICONV]) -]) - -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like -dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [m4_ifdef([gl_00GNULIB], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])])) -gl_iconv_AC_DEFUN([AM_ICONV], -[ - AM_ICONV_LINK - if test "$am_cv_func_iconv" = yes; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif - ]], - [[]])], - [am_cv_proto_iconv_arg1=""], - [am_cv_proto_iconv_arg1="const"]) - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], - [Define as const if the declaration of iconv() needs const.]) - dnl Also substitute ICONV_CONST in the gnulib generated . - m4_ifdef([gl_ICONV_H_DEFAULTS], - [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - if test -n "$am_cv_proto_iconv_arg1"; then - ICONV_CONST="const" - fi - ]) - fi -]) diff --git a/m4/include_next.m4 b/m4/include_next.m4 deleted file mode 100644 index 108d94567..000000000 --- a/m4/include_next.m4 +++ /dev/null @@ -1,270 +0,0 @@ -# include_next.m4 serial 23 -dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert and Derek Price. - -dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. -dnl -dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to -dnl 'include' otherwise. -dnl -dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler -dnl supports it in the special case that it is the first include directive in -dnl the given file, or to 'include' otherwise. -dnl -dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next, -dnl so as to avoid GCC warnings when the gcc option -pedantic is used. -dnl '#pragma GCC system_header' has the same effect as if the file was found -dnl through the include search path specified with '-isystem' options (as -dnl opposed to the search path specified with '-I' options). Namely, gcc -dnl does not warn about some things, and on some systems (Solaris and Interix) -dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side -dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead -dnl of plain '__STDC__'. -dnl -dnl PRAGMA_COLUMNS can be used in files that override system header files, so -dnl as to avoid compilation errors on HP NonStop systems when the gnulib file -dnl is included by a system header file that does a "#pragma COLUMNS 80" (which -dnl has the effect of truncating the lines of that file and all files that it -dnl includes to 80 columns) and the gnulib file has lines longer than 80 -dnl columns. - -AC_DEFUN([gl_INCLUDE_NEXT], -[ - AC_LANG_PREPROC_REQUIRE() - AC_CACHE_CHECK([whether the preprocessor supports include_next], - [gl_cv_have_include_next], - [rm -rf conftestd1a conftestd1b conftestd2 - mkdir conftestd1a conftestd1b conftestd2 - dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on - dnl AIX 6.1 support include_next when used as first preprocessor directive - dnl in a file, but not when preceded by another include directive. Check - dnl for this bug by including . - dnl Additionally, with this same compiler, include_next is a no-op when - dnl used in a header file that was included by specifying its absolute - dnl file name. Despite these two bugs, include_next is used in the - dnl compiler's . By virtue of the second bug, we need to use - dnl include_next as well in this case. - cat < conftestd1a/conftest.h -#define DEFINED_IN_CONFTESTD1 -#include_next -#ifdef DEFINED_IN_CONFTESTD2 -int foo; -#else -#error "include_next doesn't work" -#endif -EOF - cat < conftestd1b/conftest.h -#define DEFINED_IN_CONFTESTD1 -#include -#include_next -#ifdef DEFINED_IN_CONFTESTD2 -int foo; -#else -#error "include_next doesn't work" -#endif -EOF - cat < conftestd2/conftest.h -#ifndef DEFINED_IN_CONFTESTD1 -#error "include_next test doesn't work" -#endif -#define DEFINED_IN_CONFTESTD2 -EOF - gl_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" -dnl We intentionally avoid using AC_LANG_SOURCE here. - AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], - [gl_cv_have_include_next=yes], - [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" - AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], - [gl_cv_have_include_next=buggy], - [gl_cv_have_include_next=no]) - ]) - CPPFLAGS="$gl_save_CPPFLAGS" - rm -rf conftestd1a conftestd1b conftestd2 - ]) - PRAGMA_SYSTEM_HEADER= - if test $gl_cv_have_include_next = yes; then - INCLUDE_NEXT=include_next - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next - if test -n "$GCC"; then - PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' - fi - else - if test $gl_cv_have_include_next = buggy; then - INCLUDE_NEXT=include - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next - else - INCLUDE_NEXT=include - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include - fi - fi - AC_SUBST([INCLUDE_NEXT]) - AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) - AC_SUBST([PRAGMA_SYSTEM_HEADER]) - AC_CACHE_CHECK([whether system header files limit the line length], - [gl_cv_pragma_columns], - [dnl HP NonStop systems, which define __TANDEM, have this misfeature. - AC_EGREP_CPP([choke me], - [ -#ifdef __TANDEM -choke me -#endif - ], - [gl_cv_pragma_columns=yes], - [gl_cv_pragma_columns=no]) - ]) - if test $gl_cv_pragma_columns = yes; then - PRAGMA_COLUMNS="#pragma COLUMNS 10000" - else - PRAGMA_COLUMNS= - fi - AC_SUBST([PRAGMA_COLUMNS]) -]) - -# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) -# ------------------------------------------ -# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be -# ''; otherwise define it to be -# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. -# Also, if #include_next works as first preprocessing directive in a file, -# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be ''; otherwise define it to -# be -# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. -# That way, a header file with the following line: -# #@INCLUDE_NEXT@ @NEXT_FOO_H@ -# or -# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ -# behaves (after sed substitution) as if it contained -# #include_next -# even if the compiler does not support include_next. -# The three "///" are to pacify Sun C 5.8, which otherwise would say -# "warning: #include of /usr/include/... may be non-portable". -# Use '""', not '<>', so that the /// cannot be confused with a C99 comment. -# Note: This macro assumes that the header file is not empty after -# preprocessing, i.e. it does not only define preprocessor macros but also -# provides some type/enum definitions or function/variable declarations. -# -# This macro also checks whether each header exists, by invoking -# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. -AC_DEFUN([gl_CHECK_NEXT_HEADERS], -[ - gl_NEXT_HEADERS_INTERNAL([$1], [check]) -]) - -# gl_NEXT_HEADERS(HEADER1 HEADER2 ...) -# ------------------------------------ -# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. -# This is suitable for headers like that are standardized by C89 -# and therefore can be assumed to exist. -AC_DEFUN([gl_NEXT_HEADERS], -[ - gl_NEXT_HEADERS_INTERNAL([$1], [assume]) -]) - -# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. -AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], -[ - AC_REQUIRE([gl_INCLUDE_NEXT]) - AC_REQUIRE([AC_CANONICAL_HOST]) - - m4_if([$2], [check], - [AC_CHECK_HEADERS_ONCE([$1]) - ]) - -dnl FIXME: gl_next_header and gl_header_exists must be used unquoted -dnl until we can assume autoconf 2.64 or newer. - m4_foreach_w([gl_HEADER_NAME], [$1], - [AS_VAR_PUSHDEF([gl_next_header], - [gl_cv_next_]m4_defn([gl_HEADER_NAME])) - if test $gl_cv_have_include_next = yes; then - AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) - else - AC_CACHE_CHECK( - [absolute name of <]m4_defn([gl_HEADER_NAME])[>], - m4_defn([gl_next_header]), - [m4_if([$2], [check], - [AS_VAR_PUSHDEF([gl_header_exists], - [ac_cv_header_]m4_defn([gl_HEADER_NAME])) - if test AS_VAR_GET(gl_header_exists) = yes; then - AS_VAR_POPDEF([gl_header_exists]) - ]) - AC_LANG_CONFTEST( - [AC_LANG_SOURCE( - [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] - )]) - dnl AIX "xlc -E" and "cc -E" omit #line directives for header - dnl files that contain only a #include of other header files and - dnl no non-comment tokens of their own. This leads to a failure - dnl to detect the absolute name of , , - dnl and others. The workaround is to force preservation - dnl of comments through option -C. This ensures all necessary - dnl #line directives are present. GCC supports option -C as well. - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac -changequote(,) - case "$host_os" in - mingw*) - dnl For the sake of native Windows compilers (excluding gcc), - dnl treat backslash as a directory separator, like /. - dnl Actually, these compilers use a double-backslash as - dnl directory separator, inside the - dnl # line "filename" - dnl directives. - gl_dirsep_regex='[/\\]' - ;; - *) - gl_dirsep_regex='\/' - ;; - esac - dnl A sed expression that turns a string into a basic regular - dnl expression, for use within "/.../". - gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' -changequote([,]) - gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \ - | sed -e "$gl_make_literal_regex_sed"` - gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ - s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ -changequote(,)dnl - s|^/[^/]|//&| -changequote([,])dnl - p - q - }' - dnl eval is necessary to expand gl_absname_cpp. - dnl Ultrix and Pyramid sh refuse to redirect output of eval, - dnl so use subshell. - AS_VAR_SET(gl_next_header, - ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | - sed -n "$gl_absolute_header_sed"`'"']) - m4_if([$2], [check], - [else - AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) - fi - ]) - ]) - fi - AC_SUBST( - AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), - [AS_VAR_GET(gl_next_header)]) - if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then - # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' - gl_next_as_first_directive='<'gl_HEADER_NAME'>' - else - # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' - gl_next_as_first_directive=AS_VAR_GET(gl_next_header) - fi - AC_SUBST( - AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), - [$gl_next_as_first_directive]) - AS_VAR_POPDEF([gl_next_header])]) -]) - -# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; -# this fallback is safe for all earlier autoconf versions. -m4_define_default([AC_LANG_DEFINES_PROVIDED]) diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 deleted file mode 100644 index 74d0e80d2..000000000 --- a/m4/intdiv0.m4 +++ /dev/null @@ -1,87 +0,0 @@ -# intdiv0.m4 serial 6 (gettext-0.18.2) -dnl Copyright (C) 2002, 2007-2008, 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([gt_INTDIV0], -[ - AC_REQUIRE([AC_PROG_CC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl - - AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], - gt_cv_int_divbyzero_sigfpe, - [ - gt_cv_int_divbyzero_sigfpe= -changequote(,)dnl - case "$host_os" in - macos* | darwin[6-9]* | darwin[1-9][0-9]*) - # On Mac OS X 10.2 or newer, just assume the same as when cross- - # compiling. If we were to perform the real test, 1 Crash Report - # dialog window would pop up. - case "$host_cpu" in - i[34567]86 | x86_64) - gt_cv_int_divbyzero_sigfpe="guessing yes" ;; - esac - ;; - esac -changequote([,])dnl - if test -z "$gt_cv_int_divbyzero_sigfpe"; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include - -static void -sigfpe_handler (int sig) -{ - /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ - exit (sig != SIGFPE); -} - -int x = 1; -int y = 0; -int z; -int nan; - -int main () -{ - signal (SIGFPE, sigfpe_handler); -/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ -#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) - signal (SIGTRAP, sigfpe_handler); -#endif -/* Linux/SPARC yields signal SIGILL. */ -#if defined (__sparc__) && defined (__linux__) - signal (SIGILL, sigfpe_handler); -#endif - - z = x / y; - nan = y / y; - exit (2); -} -]])], - [gt_cv_int_divbyzero_sigfpe=yes], - [gt_cv_int_divbyzero_sigfpe=no], - [ - # Guess based on the CPU. -changequote(,)dnl - case "$host_cpu" in - alpha* | i[34567]86 | x86_64 | m68k | s390*) - gt_cv_int_divbyzero_sigfpe="guessing yes";; - *) - gt_cv_int_divbyzero_sigfpe="guessing no";; - esac -changequote([,])dnl - ]) - fi - ]) - case "$gt_cv_int_divbyzero_sigfpe" in - *yes) value=1;; - *) value=0;; - esac - AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value], - [Define if integer division by zero raises signal SIGFPE.]) -]) diff --git a/m4/intl.m4 b/m4/intl.m4 deleted file mode 100644 index 486b5cc64..000000000 --- a/m4/intl.m4 +++ /dev/null @@ -1,300 +0,0 @@ -# intl.m4 serial 22 (gettext-0.18.2) -dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2009. - -AC_PREREQ([2.60]) - -dnl Checks for all prerequisites of the intl subdirectory, -dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, -dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. -AC_DEFUN([AM_INTL_SUBDIR], -[ - AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AC_PROG_MKDIR_P])dnl - AC_REQUIRE([AC_PROG_CC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl - AC_REQUIRE([gt_GLIBC2])dnl - AC_REQUIRE([AC_PROG_RANLIB])dnl - AC_REQUIRE([gl_VISIBILITY])dnl - AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl - AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl - AC_REQUIRE([gt_TYPE_WCHAR_T])dnl - AC_REQUIRE([gt_TYPE_WINT_T])dnl - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gt_TYPE_INTMAX_T]) - AC_REQUIRE([gt_PRINTF_POSIX]) - AC_REQUIRE([gl_GLIBC21])dnl - AC_REQUIRE([gl_XSIZE])dnl - AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl - AC_REQUIRE([gt_INTL_MACOSX])dnl - - dnl Support for automake's --enable-silent-rules. - case "$enable_silent_rules" in - yes) INTL_DEFAULT_VERBOSITY=0;; - no) INTL_DEFAULT_VERBOSITY=1;; - *) INTL_DEFAULT_VERBOSITY=1;; - esac - AC_SUBST([INTL_DEFAULT_VERBOSITY]) - - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], - [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) - ]) - AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h]) - AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ - snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) - - dnl Use the _snprintf function only if it is declared (because on NetBSD it - dnl is defined as a weak alias of snprintf; we prefer to use the latter). - gt_CHECK_DECL(_snprintf, [#include ]) - gt_CHECK_DECL(_snwprintf, [#include ]) - - dnl Use the *_unlocked functions only if they are declared. - dnl (because some of them were defined without being declared in Solaris - dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built - dnl on Solaris 2.5.1 to run on Solaris 2.6). - dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. - gt_CHECK_DECL(getc_unlocked, [#include ]) - - case $gt_cv_func_printf_posix in - *yes) HAVE_POSIX_PRINTF=1 ;; - *) HAVE_POSIX_PRINTF=0 ;; - esac - AC_SUBST([HAVE_POSIX_PRINTF]) - if test "$ac_cv_func_asprintf" = yes; then - HAVE_ASPRINTF=1 - else - HAVE_ASPRINTF=0 - fi - AC_SUBST([HAVE_ASPRINTF]) - if test "$ac_cv_func_snprintf" = yes; then - HAVE_SNPRINTF=1 - else - HAVE_SNPRINTF=0 - fi - AC_SUBST([HAVE_SNPRINTF]) - if test "$ac_cv_func_newlocale" = yes; then - HAVE_NEWLOCALE=1 - else - HAVE_NEWLOCALE=0 - fi - AC_SUBST([HAVE_NEWLOCALE]) - if test "$ac_cv_func_wprintf" = yes; then - HAVE_WPRINTF=1 - else - HAVE_WPRINTF=0 - fi - AC_SUBST([HAVE_WPRINTF]) - - AM_LANGINFO_CODESET - gt_LC_MESSAGES - - dnl Compilation on mingw and Cygwin needs special Makefile rules, because - dnl 1. when we install a shared library, we must arrange to export - dnl auxiliary pointer variables for every exported variable, - dnl 2. when we install a shared library and a static library simultaneously, - dnl the include file specifies __declspec(dllimport) and therefore we - dnl must arrange to define the auxiliary pointer variables for the - dnl exported variables _also_ in the static library. - if test "$enable_shared" = yes; then - case "$host_os" in - mingw* | cygwin*) is_woe32dll=yes ;; - *) is_woe32dll=no ;; - esac - else - is_woe32dll=no - fi - WOE32DLL=$is_woe32dll - AC_SUBST([WOE32DLL]) - - dnl On mingw and Cygwin, we can activate special Makefile rules which add - dnl version information to the shared libraries and executables. - case "$host_os" in - mingw* | cygwin*) is_woe32=yes ;; - *) is_woe32=no ;; - esac - WOE32=$is_woe32 - AC_SUBST([WOE32]) - if test $WOE32 = yes; then - dnl Check for a program that compiles Windows resource files. - AC_CHECK_TOOL([WINDRES], [windres]) - fi - - dnl Determine whether when creating a library, "-lc" should be passed to - dnl libtool or not. On many platforms, it is required for the libtool option - dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool - dnl in the *.la files - makes it impossible to create multithreaded programs, - dnl because libtool also reorders the -lc to come before the -pthread, and - dnl this disables pthread_create() . - case "$host_os" in - hpux*) LTLIBC="" ;; - *) LTLIBC="-lc" ;; - esac - AC_SUBST([LTLIBC]) - - dnl Rename some macros and functions used for locking. - AH_BOTTOM([ -#define __libc_lock_t gl_lock_t -#define __libc_lock_define gl_lock_define -#define __libc_lock_define_initialized gl_lock_define_initialized -#define __libc_lock_init gl_lock_init -#define __libc_lock_lock gl_lock_lock -#define __libc_lock_unlock gl_lock_unlock -#define __libc_lock_recursive_t gl_recursive_lock_t -#define __libc_lock_define_recursive gl_recursive_lock_define -#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized -#define __libc_lock_init_recursive gl_recursive_lock_init -#define __libc_lock_lock_recursive gl_recursive_lock_lock -#define __libc_lock_unlock_recursive gl_recursive_lock_unlock -#define glthread_in_use libintl_thread_in_use -#define glthread_lock_init_func libintl_lock_init_func -#define glthread_lock_lock_func libintl_lock_lock_func -#define glthread_lock_unlock_func libintl_lock_unlock_func -#define glthread_lock_destroy_func libintl_lock_destroy_func -#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded -#define glthread_rwlock_init_func libintl_rwlock_init_func -#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded -#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func -#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded -#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func -#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded -#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func -#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded -#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func -#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded -#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func -#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded -#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func -#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded -#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func -#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded -#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func -#define glthread_once_func libintl_once_func -#define glthread_once_singlethreaded libintl_once_singlethreaded -#define glthread_once_multithreaded libintl_once_multithreaded -]) -]) - - -dnl Checks for the core files of the intl subdirectory: -dnl dcigettext.c -dnl eval-plural.h -dnl explodename.c -dnl finddomain.c -dnl gettextP.h -dnl gmo.h -dnl hash-string.h hash-string.c -dnl l10nflist.c -dnl libgnuintl.h.in (except the *printf stuff) -dnl loadinfo.h -dnl loadmsgcat.c -dnl localealias.c -dnl log.c -dnl plural-exp.h plural-exp.c -dnl plural.y -dnl Used by libglocale. -AC_DEFUN([gt_INTL_SUBDIR_CORE], -[ - AC_REQUIRE([AC_C_INLINE])dnl - AC_REQUIRE([AC_TYPE_SIZE_T])dnl - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - AC_REQUIRE([AC_FUNC_ALLOCA])dnl - AC_REQUIRE([AC_FUNC_MMAP])dnl - AC_REQUIRE([gt_INTDIV0])dnl - AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl - AC_REQUIRE([gt_INTTYPES_PRI])dnl - AC_REQUIRE([gl_LOCK])dnl - - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]], - [[]])], - [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], - [Define to 1 if the compiler understands __builtin_expect.])]) - - AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) - AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ - stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \ - argz_stringify argz_next __fsetlocking]) - - dnl Use the *_unlocked functions only if they are declared. - dnl (because some of them were defined without being declared in Solaris - dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built - dnl on Solaris 2.5.1 to run on Solaris 2.6). - dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. - gt_CHECK_DECL([feof_unlocked], [#include ]) - gt_CHECK_DECL([fgets_unlocked], [#include ]) - - AM_ICONV - - dnl intl/plural.c is generated from intl/plural.y. It requires bison, - dnl because plural.y uses bison specific features. It requires at least - dnl bison-1.26 because earlier versions generate a plural.c that doesn't - dnl compile. - dnl bison is only needed for the maintainer (who touches plural.y). But in - dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put - dnl the rule in general Makefile. Now, some people carelessly touch the - dnl files or have a broken "make" program, hence the plural.c rule will - dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not - dnl present or too old. - AC_CHECK_PROGS([INTLBISON], [bison]) - if test -z "$INTLBISON"; then - ac_verc_fail=yes - else - dnl Found it, now check the version. - AC_MSG_CHECKING([version of bison]) -changequote(<<,>>)dnl - ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` - case $ac_prog_version in - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) -changequote([,])dnl - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; - esac - AC_MSG_RESULT([$ac_prog_version]) - fi - if test $ac_verc_fail = yes; then - INTLBISON=: - fi -]) - - -dnl gt_CHECK_DECL(FUNC, INCLUDES) -dnl Check whether a function is declared. -AC_DEFUN([gt_CHECK_DECL], -[ - AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[$2]], - [[ -#ifndef $1 - char *p = (char *) $1; -#endif - ]])], - [ac_cv_have_decl_$1=yes], - [ac_cv_have_decl_$1=no])]) - if test $ac_cv_have_decl_$1 = yes; then - gt_value=1 - else - gt_value=0 - fi - AC_DEFINE_UNQUOTED([HAVE_DECL_]m4_translit($1, [a-z], [A-Z]), [$gt_value], - [Define to 1 if you have the declaration of '$1', and to 0 if you don't.]) -]) diff --git a/m4/intldir.m4 b/m4/intldir.m4 deleted file mode 100644 index 388ecd6fd..000000000 --- a/m4/intldir.m4 +++ /dev/null @@ -1,19 +0,0 @@ -# intldir.m4 serial 2 (gettext-0.18) -dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -AC_PREREQ([2.52]) - -dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. -AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) diff --git a/m4/intlmacosx.m4 b/m4/intlmacosx.m4 deleted file mode 100644 index ab97d39f9..000000000 --- a/m4/intlmacosx.m4 +++ /dev/null @@ -1,56 +0,0 @@ -# intlmacosx.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2004-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Checks for special options needed on Mac OS X. -dnl Defines INTL_MACOSX_LIBS. -AC_DEFUN([gt_INTL_MACOSX], -[ - dnl Check for API introduced in Mac OS X 10.2. - AC_CACHE_CHECK([for CFPreferencesCopyAppValue], - [gt_cv_func_CFPreferencesCopyAppValue], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFPreferencesCopyAppValue(NULL, NULL)]])], - [gt_cv_func_CFPreferencesCopyAppValue=yes], - [gt_cv_func_CFPreferencesCopyAppValue=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], - [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) - fi - dnl Check for API introduced in Mac OS X 10.3. - AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[CFLocaleCopyCurrent();]])], - [gt_cv_func_CFLocaleCopyCurrent=yes], - [gt_cv_func_CFLocaleCopyCurrent=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], - [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - AC_SUBST([INTL_MACOSX_LIBS]) -]) diff --git a/m4/intmax.m4 b/m4/intmax.m4 deleted file mode 100644 index 18733a52e..000000000 --- a/m4/intmax.m4 +++ /dev/null @@ -1,36 +0,0 @@ -# intmax.m4 serial 6 (gettext-0.18.2) -dnl Copyright (C) 2002-2005, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. -dnl Test whether the system has the 'intmax_t' type, but don't attempt to -dnl find a replacement if it is lacking. - -AC_DEFUN([gt_TYPE_INTMAX_T], -[ - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -#if HAVE_STDINT_H_WITH_UINTMAX -#include -#endif -#if HAVE_INTTYPES_H_WITH_UINTMAX -#include -#endif - ]], - [[intmax_t x = -1; - return !x;]])], - [gt_cv_c_intmax_t=yes], - [gt_cv_c_intmax_t=no])]) - if test $gt_cv_c_intmax_t = yes; then - AC_DEFINE([HAVE_INTMAX_T], [1], - [Define if you have the 'intmax_t' type in or .]) - fi -]) diff --git a/m4/intmax_t.m4 b/m4/intmax_t.m4 deleted file mode 100644 index 6ea70531c..000000000 --- a/m4/intmax_t.m4 +++ /dev/null @@ -1,67 +0,0 @@ -# intmax_t.m4 serial 8 -dnl Copyright (C) 1997-2004, 2006-2007, 2009-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -AC_PREREQ([2.53]) - -# Define intmax_t to 'long' or 'long long' -# if it is not already defined in or . - -AC_DEFUN([gl_AC_TYPE_INTMAX_T], -[ - dnl For simplicity, we assume that a header file defines 'intmax_t' if and - dnl only if it defines 'uintmax_t'. - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - test $ac_cv_type_long_long_int = yes \ - && ac_type='long long' \ - || ac_type='long' - AC_DEFINE_UNQUOTED([intmax_t], [$ac_type], - [Define to long or long long if and don't define.]) - else - AC_DEFINE([HAVE_INTMAX_T], [1], - [Define if you have the 'intmax_t' type in or .]) - fi -]) - -dnl An alternative would be to explicitly test for 'intmax_t'. - -AC_DEFUN([gt_AC_TYPE_INTMAX_T], -[ - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -#if HAVE_STDINT_H_WITH_UINTMAX -#include -#endif -#if HAVE_INTTYPES_H_WITH_UINTMAX -#include -#endif - ]], - [[intmax_t x = -1; return !x;]])], - [gt_cv_c_intmax_t=yes], - [gt_cv_c_intmax_t=no])]) - if test $gt_cv_c_intmax_t = yes; then - AC_DEFINE([HAVE_INTMAX_T], [1], - [Define if you have the 'intmax_t' type in or .]) - else - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - test $ac_cv_type_long_long_int = yes \ - && ac_type='long long' \ - || ac_type='long' - AC_DEFINE_UNQUOTED([intmax_t], [$ac_type], - [Define to long or long long if and don't define.]) - fi -]) diff --git a/m4/inttypes-pri.m4 b/m4/inttypes-pri.m4 deleted file mode 100644 index e5a1e0571..000000000 --- a/m4/inttypes-pri.m4 +++ /dev/null @@ -1,42 +0,0 @@ -# inttypes-pri.m4 serial 7 (gettext-0.18.2) -dnl Copyright (C) 1997-2002, 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_PREREQ([2.53]) - -# Define PRI_MACROS_BROKEN if exists and defines the PRI* -# macros to non-string values. This is the case on AIX 4.3.3. - -AC_DEFUN([gt_INTTYPES_PRI], -[ - AC_CHECK_HEADERS([inttypes.h]) - if test $ac_cv_header_inttypes_h = yes; then - AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], - [gt_cv_inttypes_pri_broken], - [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#ifdef PRId32 -char *p = PRId32; -#endif - ]], - [[]])], - [gt_cv_inttypes_pri_broken=no], - [gt_cv_inttypes_pri_broken=yes]) - ]) - fi - if test "$gt_cv_inttypes_pri_broken" = yes; then - AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1], - [Define if exists and defines unusable PRI* macros.]) - PRI_MACROS_BROKEN=1 - else - PRI_MACROS_BROKEN=0 - fi - AC_SUBST([PRI_MACROS_BROKEN]) -]) diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 deleted file mode 100644 index 5f05ac58c..000000000 --- a/m4/inttypes_h.m4 +++ /dev/null @@ -1,29 +0,0 @@ -# inttypes_h.m4 serial 10 -dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, -# doesn't clash with , and declares uintmax_t. - -AC_DEFUN([gl_AC_HEADER_INTTYPES_H], -[ - AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[uintmax_t i = (uintmax_t) -1; return !i;]])], - [gl_cv_header_inttypes_h=yes], - [gl_cv_header_inttypes_h=no])]) - if test $gl_cv_header_inttypes_h = yes; then - AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], - [Define if exists, doesn't clash with , - and declares uintmax_t. ]) - fi -]) diff --git a/m4/langinfo_h.m4 b/m4/langinfo_h.m4 deleted file mode 100644 index 73bef8bce..000000000 --- a/m4/langinfo_h.m4 +++ /dev/null @@ -1,105 +0,0 @@ -# langinfo_h.m4 serial 7 -dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_LANGINFO_H], -[ - AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) - - dnl Persuade glibc-2.0.6 to define CODESET. - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - dnl is always overridden, because of GNULIB_POSIXCHECK. - gl_CHECK_NEXT_HEADERS([langinfo.h]) - - dnl Determine whether exists. It is missing on mingw and BeOS. - HAVE_LANGINFO_CODESET=0 - HAVE_LANGINFO_T_FMT_AMPM=0 - HAVE_LANGINFO_ERA=0 - HAVE_LANGINFO_YESEXPR=0 - AC_CHECK_HEADERS_ONCE([langinfo.h]) - if test $ac_cv_header_langinfo_h = yes; then - HAVE_LANGINFO_H=1 - dnl Determine what defines. CODESET and ERA etc. are missing - dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3. - AC_CACHE_CHECK([whether langinfo.h defines CODESET], - [gl_cv_header_langinfo_codeset], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include -int a = CODESET; -]])], - [gl_cv_header_langinfo_codeset=yes], - [gl_cv_header_langinfo_codeset=no]) - ]) - if test $gl_cv_header_langinfo_codeset = yes; then - HAVE_LANGINFO_CODESET=1 - fi - AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM], - [gl_cv_header_langinfo_t_fmt_ampm], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include -int a = T_FMT_AMPM; -]])], - [gl_cv_header_langinfo_t_fmt_ampm=yes], - [gl_cv_header_langinfo_t_fmt_ampm=no]) - ]) - if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then - HAVE_LANGINFO_T_FMT_AMPM=1 - fi - AC_CACHE_CHECK([whether langinfo.h defines ERA], - [gl_cv_header_langinfo_era], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include -int a = ERA; -]])], - [gl_cv_header_langinfo_era=yes], - [gl_cv_header_langinfo_era=no]) - ]) - if test $gl_cv_header_langinfo_era = yes; then - HAVE_LANGINFO_ERA=1 - fi - AC_CACHE_CHECK([whether langinfo.h defines YESEXPR], - [gl_cv_header_langinfo_yesexpr], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include -int a = YESEXPR; -]])], - [gl_cv_header_langinfo_yesexpr=yes], - [gl_cv_header_langinfo_yesexpr=no]) - ]) - if test $gl_cv_header_langinfo_yesexpr = yes; then - HAVE_LANGINFO_YESEXPR=1 - fi - else - HAVE_LANGINFO_H=0 - fi - AC_SUBST([HAVE_LANGINFO_H]) - AC_SUBST([HAVE_LANGINFO_CODESET]) - AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM]) - AC_SUBST([HAVE_LANGINFO_ERA]) - AC_SUBST([HAVE_LANGINFO_YESEXPR]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[#include - ]], [nl_langinfo]) -]) - -AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_LANGINFO_H_DEFAULTS], -[ - GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) - REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) -]) diff --git a/m4/lcmessage.m4 b/m4/lcmessage.m4 deleted file mode 100644 index d62a175fc..000000000 --- a/m4/lcmessage.m4 +++ /dev/null @@ -1,35 +0,0 @@ -# lcmessage.m4 serial 7 (gettext-0.18.2) -dnl Copyright (C) 1995-2002, 2004-2005, 2008-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995. - -# Check whether LC_MESSAGES is available in . - -AC_DEFUN([gt_LC_MESSAGES], -[ - AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[return LC_MESSAGES]])], - [gt_cv_val_LC_MESSAGES=yes], - [gt_cv_val_LC_MESSAGES=no])]) - if test $gt_cv_val_LC_MESSAGES = yes; then - AC_DEFINE([HAVE_LC_MESSAGES], [1], - [Define if your file defines LC_MESSAGES.]) - fi -]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 deleted file mode 100644 index c145e478e..000000000 --- a/m4/lib-ld.m4 +++ /dev/null @@ -1,119 +0,0 @@ -# lib-ld.m4 serial 6 -dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid -dnl collision with libtool.m4. - -dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], -[# I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 /dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL([acl_cv_path_LD], -[if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE([rpath], - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_FROMPACKAGE(name, package) -dnl declares that libname comes from the given package. The configure file -dnl will then not have a --with-libname-prefix option but a -dnl --with-package-prefix option. Several libraries can come from the same -dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar -dnl macro call that searches for libname. -AC_DEFUN([AC_LIB_FROMPACKAGE], -[ - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_frompackage_]NAME, [$2]) - popdef([NAME]) - pushdef([PACK],[$2]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) - popdef([PACKUP]) - popdef([PACK]) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found -dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) - dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_ARG_WITH(P_A_C_K[-prefix], -[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - LIB[]NAME[]_PREFIX= - dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been - dnl computed. So it has to be reset here. - HAVE_LIB[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - dnl The same code as in the loop below: - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$acl_hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi - popdef([P_A_C_K]) - popdef([PACKLIBS]) - popdef([PACKUP]) - popdef([PACK]) - popdef([NAME]) -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -dnl For those cases where a variable contains several -L and -l options -dnl referring to unknown libraries and directories, this macro determines the -dnl necessary additional linker options for the runtime path. -dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) -dnl sets LDADDVAR to linker options needed together with LIBSVALUE. -dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, -dnl otherwise linking without libtool is assumed. -AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], -[ - AC_REQUIRE([AC_LIB_RPATH]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - $1= - if test "$enable_rpath" != no; then - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode directories into the resulting - dnl binary. - rpathdirs= - next= - for opt in $2; do - if test -n "$next"; then - dir="$next" - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= - else - case $opt in - -L) next=yes ;; - -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= ;; - *) next= ;; - esac - fi - done - if test "X$rpathdirs" != "X"; then - if test -n ""$3""; then - dnl libtool is used for linking. Use -R options. - for dir in $rpathdirs; do - $1="${$1}${$1:+ }-R$dir" - done - else - dnl The linker is used for linking directly. - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user - dnl must pass all path elements in one option. - alldirs= - for dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="$flag" - else - dnl The -rpath options are cumulative. - for dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="${$1}${$1:+ }$flag" - done - fi - fi - fi - fi - fi - AC_SUBST([$1]) -]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 deleted file mode 100644 index 60908e8fb..000000000 --- a/m4/lib-prefix.m4 +++ /dev/null @@ -1,224 +0,0 @@ -# lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AC_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_PREPARE_MULTILIB creates -dnl - a variable acl_libdirstem, containing the basename of the libdir, either -dnl "lib" or "lib64" or "lib/64", -dnl - a variable acl_libdirstem2, as a secondary possible value for -dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or -dnl "lib/amd64". -AC_DEFUN([AC_LIB_PREPARE_MULTILIB], -[ - dnl There is no formal standard regarding lib and lib64. - dnl On glibc systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine - dnl the compiler's default mode by looking at the compiler's library search - dnl path. If at least one of its elements ends in /lib64 or points to a - dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. - dnl Otherwise we use the default, namely "lib". - dnl On Solaris systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or - dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. - AC_REQUIRE([AC_CANONICAL_HOST]) - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment - dnl . - dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." - dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the - dnl symlink is missing, so we set acl_libdirstem2 too. - AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], - [AC_EGREP_CPP([sixtyfour bits], [ -#ifdef _LP64 -sixtyfour bits -#endif - ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) - ]) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" -]) diff --git a/m4/libunistring-base.m4 b/m4/libunistring-base.m4 deleted file mode 100644 index d105c7217..000000000 --- a/m4/libunistring-base.m4 +++ /dev/null @@ -1,141 +0,0 @@ -# libunistring-base.m4 serial 5 -dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paolo Bonzini and Bruno Haible. - -dnl gl_LIBUNISTRING_MODULE([VERSION], [Module]) -dnl Declares that the source files of Module should be compiled, unless we -dnl are linking with libunistring and its version is >= the given VERSION. -dnl Defines an automake conditional LIBUNISTRING_COMPILE_$MODULE that is -dnl true if the source files of Module should be compiled. -dnl This macro is to be used for public libunistring API, not for -dnl undocumented API. -dnl -dnl You have to bump the VERSION argument to the next projected version -dnl number each time you make a change that affects the behaviour of the -dnl functions defined in Module (even if the sources of Module itself do not -dnl change). - -AC_DEFUN([gl_LIBUNISTRING_MODULE], -[ - AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) - dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from - dnl gl_LIBUNISTRING_CORE if that macro has been run. - AM_CONDITIONAL(AS_TR_CPP([LIBUNISTRING_COMPILE_$2]), - [gl_LIBUNISTRING_VERSION_CMP([$1])]) -]) - -dnl gl_LIBUNISTRING_LIBHEADER([VERSION], [HeaderFile]) -dnl Declares that HeaderFile should be created, unless we are linking -dnl with libunistring and its version is >= the given VERSION. -dnl HeaderFile should be relative to the lib directory and end in '.h'. -dnl Prepares for substituting LIBUNISTRING_HEADERFILE (to HeaderFile or empty). -dnl -dnl When we are linking with the already installed libunistring and its version -dnl is < VERSION, we create HeaderFile here, because we may compile functions -dnl (via gl_LIBUNISTRING_MODULE above) that are not contained in the installed -dnl version. -dnl When we are linking with the already installed libunistring and its version -dnl is > VERSION, we don't create HeaderFile here: it could cause compilation -dnl errors in other libunistring header files if some types are missing. -dnl -dnl You have to bump the VERSION argument to the next projected version -dnl number each time you make a non-comment change to the HeaderFile. - -AC_DEFUN([gl_LIBUNISTRING_LIBHEADER], -[ - AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) - dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from - dnl gl_LIBUNISTRING_CORE if that macro has been run. - if gl_LIBUNISTRING_VERSION_CMP([$1]); then - LIBUNISTRING_[]AS_TR_CPP([$2])='$2' - else - LIBUNISTRING_[]AS_TR_CPP([$2])= - fi - AC_SUBST([LIBUNISTRING_]AS_TR_CPP([$2])) -]) - -dnl Miscellaneous preparations/initializations. - -AC_DEFUN([gl_LIBUNISTRING_LIB_PREPARE], -[ - dnl Ensure that HAVE_LIBUNISTRING is fully determined at this point. - m4_ifdef([gl_LIBUNISTRING], [AC_REQUIRE([gl_LIBUNISTRING])]) - - AC_REQUIRE([AC_PROG_AWK]) - -dnl Sed expressions to extract the parts of a version number. -changequote(,) -gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} -i\ -0 -q -' -gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} -i\ -0 -q -' -gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;} -i\ -0 -q -' -changequote([,]) - - if test "$HAVE_LIBUNISTRING" = yes; then - LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"` - LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"` - LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"` - fi -]) - -dnl gl_LIBUNISTRING_VERSION_CMP([VERSION]) -dnl Expands to a shell statement that evaluates to true if LIBUNISTRING_VERSION -dnl is less than the VERSION argument. -AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP], -[ { test "$HAVE_LIBUNISTRING" != yes \ - || { - dnl AS_LITERAL_IF exists and works fine since autoconf-2.59 at least. - AS_LITERAL_IF([$1], - [dnl This is the optimized variant, that assumes the argument is a literal: - m4_pushdef([requested_version_major], - [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^\([0-9]*\).*], [\1]), [])]) - m4_pushdef([requested_version_minor], - [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) - m4_pushdef([requested_version_subminor], - [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.][0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) - test $LIBUNISTRING_VERSION_MAJOR -lt requested_version_major \ - || { test $LIBUNISTRING_VERSION_MAJOR -eq requested_version_major \ - && { test $LIBUNISTRING_VERSION_MINOR -lt requested_version_minor \ - || { test $LIBUNISTRING_VERSION_MINOR -eq requested_version_minor \ - && test $LIBUNISTRING_VERSION_SUBMINOR -lt requested_version_subminor - } - } - } - m4_popdef([requested_version_subminor]) - m4_popdef([requested_version_minor]) - m4_popdef([requested_version_major]) - ], - [dnl This is the unoptimized variant: - requested_version_major=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_major"` - requested_version_minor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_minor"` - requested_version_subminor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_subminor"` - test $LIBUNISTRING_VERSION_MAJOR -lt $requested_version_major \ - || { test $LIBUNISTRING_VERSION_MAJOR -eq $requested_version_major \ - && { test $LIBUNISTRING_VERSION_MINOR -lt $requested_version_minor \ - || { test $LIBUNISTRING_VERSION_MINOR -eq $requested_version_minor \ - && test $LIBUNISTRING_VERSION_SUBMINOR -lt $requested_version_subminor - } - } - } - ]) - } - }]) - -dnl gl_LIBUNISTRING_ARG_OR_ZERO([ARG], [ORIG]) expands to ARG if it is not the -dnl same as ORIG, otherwise to 0. -m4_define([gl_LIBUNISTRING_ARG_OR_ZERO], [m4_if([$1], [$2], [0], [$1])]) diff --git a/m4/localcharset.m4 b/m4/localcharset.m4 deleted file mode 100644 index 2e93e5818..000000000 --- a/m4/localcharset.m4 +++ /dev/null @@ -1,17 +0,0 @@ -# localcharset.m4 serial 7 -dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_LOCALCHARSET], -[ - dnl Prerequisites of lib/localcharset.c. - AC_REQUIRE([AM_LANGINFO_CODESET]) - AC_REQUIRE([gl_FCNTL_O_FLAGS]) - AC_CHECK_DECLS_ONCE([getc_unlocked]) - - dnl Prerequisites of the lib/Makefile.am snippet. - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([gl_GLIBC21]) -]) diff --git a/m4/locale-fr.m4 b/m4/locale-fr.m4 deleted file mode 100644 index ef199e397..000000000 --- a/m4/locale-fr.m4 +++ /dev/null @@ -1,250 +0,0 @@ -# locale-fr.m4 serial 17 -dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl Determine the name of a french locale with traditional encoding. -AC_DEFUN([gt_LOCALE_FR], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AM_LANGINFO_CODESET]) - AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ - AC_LANG_CONFTEST([AC_LANG_SOURCE([ -changequote(,)dnl -#include -#include -#if HAVE_LANGINFO_CODESET -# include -#endif -#include -#include -struct tm t; -char buf[16]; -int main () { - /* Check whether the given locale name is recognized by the system. */ -#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ - /* On native Windows, setlocale(category, "") looks at the system settings, - not at the environment variables. Also, when an encoding suffix such - as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE - category of the locale to "C". */ - if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL - || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) - return 1; -#else - if (setlocale (LC_ALL, "") == NULL) return 1; -#endif - /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". - On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) - is empty, and the behaviour of Tcl 8.4 in this locale is not useful. - On OpenBSD 4.0, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "646". In this situation, - some unit tests fail. - On MirBSD 10, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "UTF-8". */ -#if HAVE_LANGINFO_CODESET - { - const char *cs = nl_langinfo (CODESET); - if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 - || strcmp (cs, "UTF-8") == 0) - return 1; - } -#endif -#ifdef __CYGWIN__ - /* On Cygwin, avoid locale names without encoding suffix, because the - locale_charset() function relies on the encoding suffix. Note that - LC_ALL is set on the command line. */ - if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; -#endif - /* Check whether in the abbreviation of the second month, the second - character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only - one byte long. This excludes the UTF-8 encoding. */ - t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; - if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; -#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ - /* Check whether the decimal separator is a comma. - On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point - are nl_langinfo(RADIXCHAR) are both ".". */ - if (localeconv () ->decimal_point[0] != ',') return 1; -#endif - return 0; -} -changequote([,])dnl - ])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - case "$host_os" in - # Handle native Windows specially, because there setlocale() interprets - # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", - # "fr" or "fra" as "French" or "French_France.1252", - # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", - # "ja" as "Japanese" or "Japanese_Japan.932", - # and similar. - mingw*) - # Test for the native Windows locale name. - if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=French_France.1252 - else - # None found. - gt_cv_locale_fr=none - fi - ;; - *) - # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because - # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the - # configure script would override the LC_ALL setting. Likewise for - # LC_CTYPE, which is also set at the beginning of the configure script. - # Test for the usual locale name. - if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=fr_FR - else - # Test for the locale name with explicit encoding suffix. - if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=fr_FR.ISO-8859-1 - else - # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. - if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=fr_FR.ISO8859-1 - else - # Test for the HP-UX locale name. - if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=fr_FR.iso88591 - else - # Test for the Solaris 7 locale name. - if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr=fr - else - # None found. - gt_cv_locale_fr=none - fi - fi - fi - fi - fi - ;; - esac - fi - rm -fr conftest* - ]) - LOCALE_FR=$gt_cv_locale_fr - AC_SUBST([LOCALE_FR]) -]) - -dnl Determine the name of a french locale with UTF-8 encoding. -AC_DEFUN([gt_LOCALE_FR_UTF8], -[ - AC_REQUIRE([AM_LANGINFO_CODESET]) - AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ - AC_LANG_CONFTEST([AC_LANG_SOURCE([ -changequote(,)dnl -#include -#include -#if HAVE_LANGINFO_CODESET -# include -#endif -#include -#include -struct tm t; -char buf[16]; -int main () { - /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl - imitates locale dependent behaviour by looking at the environment - variables, and all locales use the UTF-8 encoding. */ -#if !(defined __BEOS__ || defined __HAIKU__) - /* Check whether the given locale name is recognized by the system. */ -# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ - /* On native Windows, setlocale(category, "") looks at the system settings, - not at the environment variables. Also, when an encoding suffix such - as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE - category of the locale to "C". */ - if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL - || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) - return 1; -# else - if (setlocale (LC_ALL, "") == NULL) return 1; -# endif - /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". - On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) - is empty, and the behaviour of Tcl 8.4 in this locale is not useful. - On OpenBSD 4.0, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "646". In this situation, - some unit tests fail. */ -# if HAVE_LANGINFO_CODESET - { - const char *cs = nl_langinfo (CODESET); - if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) - return 1; - } -# endif -# ifdef __CYGWIN__ - /* On Cygwin, avoid locale names without encoding suffix, because the - locale_charset() function relies on the encoding suffix. Note that - LC_ALL is set on the command line. */ - if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; -# endif - /* Check whether in the abbreviation of the second month, the second - character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is - two bytes long, with UTF-8 encoding. */ - t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; - if (strftime (buf, sizeof (buf), "%b", &t) < 4 - || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') - return 1; -#endif -#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ - /* Check whether the decimal separator is a comma. - On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point - are nl_langinfo(RADIXCHAR) are both ".". */ - if (localeconv () ->decimal_point[0] != ',') return 1; -#endif - return 0; -} -changequote([,])dnl - ])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - case "$host_os" in - # Handle native Windows specially, because there setlocale() interprets - # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", - # "fr" or "fra" as "French" or "French_France.1252", - # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", - # "ja" as "Japanese" or "Japanese_Japan.932", - # and similar. - mingw*) - # Test for the hypothetical native Windows locale name. - if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=French_France.65001 - else - # None found. - gt_cv_locale_fr_utf8=none - fi - ;; - *) - # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because - # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the - # configure script would override the LC_ALL setting. Likewise for - # LC_CTYPE, which is also set at the beginning of the configure script. - # Test for the usual locale name. - if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr_FR - else - # Test for the locale name with explicit encoding suffix. - if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr_FR.UTF-8 - else - # Test for the Solaris 7 locale name. - if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_fr_utf8=fr.UTF-8 - else - # None found. - gt_cv_locale_fr_utf8=none - fi - fi - fi - ;; - esac - fi - rm -fr conftest* - ]) - LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 - AC_SUBST([LOCALE_FR_UTF8]) -]) diff --git a/m4/locale-ja.m4 b/m4/locale-ja.m4 deleted file mode 100644 index 132a3e779..000000000 --- a/m4/locale-ja.m4 +++ /dev/null @@ -1,136 +0,0 @@ -# locale-ja.m4 serial 12 -dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl Determine the name of a japanese locale with EUC-JP encoding. -AC_DEFUN([gt_LOCALE_JA], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AM_LANGINFO_CODESET]) - AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [ - AC_LANG_CONFTEST([AC_LANG_SOURCE([ -changequote(,)dnl -#include -#include -#if HAVE_LANGINFO_CODESET -# include -#endif -#include -#include -struct tm t; -char buf[16]; -int main () -{ - const char *p; - /* Check whether the given locale name is recognized by the system. */ -#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ - /* On native Windows, setlocale(category, "") looks at the system settings, - not at the environment variables. Also, when an encoding suffix such - as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE - category of the locale to "C". */ - if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL - || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) - return 1; -#else - if (setlocale (LC_ALL, "") == NULL) return 1; -#endif - /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". - On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) - is empty, and the behaviour of Tcl 8.4 in this locale is not useful. - On OpenBSD 4.0, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "646". In this situation, - some unit tests fail. - On MirBSD 10, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "UTF-8". */ -#if HAVE_LANGINFO_CODESET - { - const char *cs = nl_langinfo (CODESET); - if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 - || strcmp (cs, "UTF-8") == 0) - return 1; - } -#endif -#ifdef __CYGWIN__ - /* On Cygwin, avoid locale names without encoding suffix, because the - locale_charset() function relies on the encoding suffix. Note that - LC_ALL is set on the command line. */ - if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; -#endif - /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales - on Cygwin 1.5.x. */ - if (MB_CUR_MAX == 1) - return 1; - /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. - This excludes the UTF-8 encoding (except on MirBSD). */ - t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; - if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; - for (p = buf; *p != '\0'; p++) - if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) - return 1; - return 0; -} -changequote([,])dnl - ])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - case "$host_os" in - # Handle native Windows specially, because there setlocale() interprets - # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", - # "fr" or "fra" as "French" or "French_France.1252", - # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", - # "ja" as "Japanese" or "Japanese_Japan.932", - # and similar. - mingw*) - # Note that on native Windows, the Japanese locale is - # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we - # cannot use it here. - gt_cv_locale_ja=none - ;; - *) - # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because - # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the - # configure script would override the LC_ALL setting. Likewise for - # LC_CTYPE, which is also set at the beginning of the configure script. - # Test for the AIX locale name. - if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_ja=ja_JP - else - # Test for the locale name with explicit encoding suffix. - if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_ja=ja_JP.EUC-JP - else - # Test for the HP-UX, OSF/1, NetBSD locale name. - if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_ja=ja_JP.eucJP - else - # Test for the IRIX, FreeBSD locale name. - if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_ja=ja_JP.EUC - else - # Test for the Solaris 7 locale name. - if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_ja=ja - else - # Special test for NetBSD 1.6. - if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then - gt_cv_locale_ja=ja_JP.eucJP - else - # None found. - gt_cv_locale_ja=none - fi - fi - fi - fi - fi - fi - ;; - esac - fi - rm -fr conftest* - ]) - LOCALE_JA=$gt_cv_locale_ja - AC_SUBST([LOCALE_JA]) -]) diff --git a/m4/locale-zh.m4 b/m4/locale-zh.m4 deleted file mode 100644 index 4eed73f40..000000000 --- a/m4/locale-zh.m4 +++ /dev/null @@ -1,130 +0,0 @@ -# locale-zh.m4 serial 12 -dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl Determine the name of a chinese locale with GB18030 encoding. -AC_DEFUN([gt_LOCALE_ZH_CN], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AM_LANGINFO_CODESET]) - AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [ - AC_LANG_CONFTEST([AC_LANG_SOURCE([ -changequote(,)dnl -#include -#include -#include -#if HAVE_LANGINFO_CODESET -# include -#endif -#include -#include -struct tm t; -char buf[16]; -int main () -{ - const char *p; - /* Check whether the given locale name is recognized by the system. */ -#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ - /* On native Windows, setlocale(category, "") looks at the system settings, - not at the environment variables. Also, when an encoding suffix such - as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE - category of the locale to "C". */ - if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL - || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) - return 1; -#else - if (setlocale (LC_ALL, "") == NULL) return 1; -#endif - /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". - On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) - is empty, and the behaviour of Tcl 8.4 in this locale is not useful. - On OpenBSD 4.0, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "646". In this situation, - some unit tests fail. - On MirBSD 10, when an unsupported locale is specified, setlocale() - succeeds but then nl_langinfo(CODESET) is "UTF-8". */ -#if HAVE_LANGINFO_CODESET - { - const char *cs = nl_langinfo (CODESET); - if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 - || strcmp (cs, "UTF-8") == 0) - return 1; - } -#endif -#ifdef __CYGWIN__ - /* On Cygwin, avoid locale names without encoding suffix, because the - locale_charset() function relies on the encoding suffix. Note that - LC_ALL is set on the command line. */ - if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; -#endif - /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. - This excludes the UTF-8 encoding (except on MirBSD). */ - t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; - if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; - for (p = buf; *p != '\0'; p++) - if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) - return 1; - /* Check whether a typical GB18030 multibyte sequence is recognized as a - single wide character. This excludes the GB2312 and GBK encodings. */ - if (mblen ("\203\062\332\066", 5) != 4) - return 1; - return 0; -} -changequote([,])dnl - ])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - case "$host_os" in - # Handle native Windows specially, because there setlocale() interprets - # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", - # "fr" or "fra" as "French" or "French_France.1252", - # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", - # "ja" as "Japanese" or "Japanese_Japan.932", - # and similar. - mingw*) - # Test for the hypothetical native Windows locale name. - if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_zh_CN=Chinese_China.54936 - else - # None found. - gt_cv_locale_zh_CN=none - fi - ;; - solaris2.8) - # On Solaris 8, the locales zh_CN.GB18030, zh_CN.GBK, zh.GBK are - # broken. One witness is the test case in gl_MBRTOWC_SANITYCHECK. - # Another witness is that "LC_ALL=zh_CN.GB18030 bash -c true" dumps core. - gt_cv_locale_zh_CN=none - ;; - *) - # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because - # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the - # configure script would override the LC_ALL setting. Likewise for - # LC_CTYPE, which is also set at the beginning of the configure script. - # Test for the locale name without encoding suffix. - if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_zh_CN=zh_CN - else - # Test for the locale name with explicit encoding suffix. - if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then - gt_cv_locale_zh_CN=zh_CN.GB18030 - else - # None found. - gt_cv_locale_zh_CN=none - fi - fi - ;; - esac - else - # If there was a link error, due to mblen(), the system is so old that - # it certainly doesn't have a chinese locale. - gt_cv_locale_zh_CN=none - fi - rm -fr conftest* - ]) - LOCALE_ZH_CN=$gt_cv_locale_zh_CN - AC_SUBST([LOCALE_ZH_CN]) -]) diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 deleted file mode 100644 index 8bd12e80e..000000000 --- a/m4/locale_h.m4 +++ /dev/null @@ -1,122 +0,0 @@ -# locale_h.m4 serial 19 -dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_LOCALE_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) - - dnl Persuade glibc to define locale_t and the int_p_*, int_n_* - dnl members of 'struct lconv'. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - dnl If is replaced, then must also be replaced. - AC_REQUIRE([gl_STDDEF_H]) - - dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv' - dnl only if _LCONV_C99 is defined. - AC_REQUIRE([AC_CANONICAL_HOST]) - case "$host_os" in - solaris*) - AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.]) - ;; - esac - - AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001], - [gl_cv_header_locale_h_posix2001], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - int x = LC_MESSAGES; - int y = sizeof (((struct lconv *) 0)->decimal_point);]], - [[]])], - [gl_cv_header_locale_h_posix2001=yes], - [gl_cv_header_locale_h_posix2001=no])]) - - dnl Check for . - AC_CHECK_HEADERS_ONCE([xlocale.h]) - if test $ac_cv_header_xlocale_h = yes; then - HAVE_XLOCALE_H=1 - dnl Check whether use of locale_t requires inclusion of , - dnl e.g. on Mac OS X 10.5. If does not define locale_t by - dnl itself, we assume that will do so. - AC_CACHE_CHECK([whether locale.h defines locale_t], - [gl_cv_header_locale_has_locale_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - locale_t x;]], - [[]])], - [gl_cv_header_locale_has_locale_t=yes], - [gl_cv_header_locale_has_locale_t=no]) - ]) - if test $gl_cv_header_locale_has_locale_t = yes; then - gl_cv_header_locale_h_needs_xlocale_h=no - else - gl_cv_header_locale_h_needs_xlocale_h=yes - fi - else - HAVE_XLOCALE_H=0 - gl_cv_header_locale_h_needs_xlocale_h=no - fi - AC_SUBST([HAVE_XLOCALE_H]) - - dnl Check whether 'struct lconv' is complete. - dnl Bionic libc's 'struct lconv' is just a dummy. - dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, - dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members. - AC_CACHE_CHECK([whether struct lconv is properly defined], - [gl_cv_sys_struct_lconv_ok], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - struct lconv l; - int x = sizeof (l.decimal_point); - int y = sizeof (l.int_p_cs_precedes);]], - [[]])], - [gl_cv_sys_struct_lconv_ok=yes], - [gl_cv_sys_struct_lconv_ok=no]) - ]) - if test $gl_cv_sys_struct_lconv_ok = no; then - REPLACE_STRUCT_LCONV=1 - fi - - dnl is always overridden, because of GNULIB_POSIXCHECK. - gl_NEXT_HEADERS([locale.h]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[#include -/* Some systems provide declarations in a non-standard header. */ -#if HAVE_XLOCALE_H -# include -#endif - ]], - [setlocale duplocale]) -]) - -AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_LOCALE_H_DEFAULTS], -[ - GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV]) - GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE]) - GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) - REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) - REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) - REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) - REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) -]) diff --git a/m4/localeconv.m4 b/m4/localeconv.m4 deleted file mode 100644 index b8bb5964b..000000000 --- a/m4/localeconv.m4 +++ /dev/null @@ -1,22 +0,0 @@ -# localeconv.m4 serial 1 -dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_LOCALECONV], -[ - AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) - AC_REQUIRE([gl_LOCALE_H]) - - if test $REPLACE_STRUCT_LCONV = 1; then - REPLACE_LOCALECONV=1 - fi -]) - -# Prerequisites of lib/localeconv.c. -AC_DEFUN([gl_PREREQ_LOCALECONV], -[ - AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [], - [[#include ]]) -]) diff --git a/m4/lock.m4 b/m4/lock.m4 deleted file mode 100644 index d3fc1eff0..000000000 --- a/m4/lock.m4 +++ /dev/null @@ -1,39 +0,0 @@ -# lock.m4 serial 13 (gettext-0.18.2) -dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([gl_LOCK], -[ - AC_REQUIRE([gl_THREADLIB]) - if test "$gl_threads_api" = posix; then - # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the - # pthread_rwlock_* functions. - AC_CHECK_TYPE([pthread_rwlock_t], - [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], - [Define if the POSIX multithreading library has read/write locks.])], - [], - [#include ]) - # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM( - [[#include ]], - [[ -#if __FreeBSD__ == 4 -error "No, in FreeBSD 4.0 recursive mutexes actually don't work." -#else -int x = (int)PTHREAD_MUTEX_RECURSIVE; -return !x; -#endif - ]])], - [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], - [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) - fi - gl_PREREQ_LOCK -]) - -# Prerequisites of lib/glthread/lock.c. -AC_DEFUN([gl_PREREQ_LOCK], [:]) diff --git a/m4/longlong.m4 b/m4/longlong.m4 deleted file mode 100644 index 3af6ab5aa..000000000 --- a/m4/longlong.m4 +++ /dev/null @@ -1,113 +0,0 @@ -# longlong.m4 serial 17 -dnl Copyright (C) 1999-2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -# Define HAVE_LONG_LONG_INT if 'long long int' works. -# This fixes a bug in Autoconf 2.61, and can be faster -# than what's in Autoconf 2.62 through 2.68. - -# Note: If the type 'long long int' exists but is only 32 bits large -# (as on some very old compilers), HAVE_LONG_LONG_INT will not be -# defined. In this case you can treat 'long long int' like 'long int'. - -AC_DEFUN([AC_TYPE_LONG_LONG_INT], -[ - AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], - [ac_cv_type_long_long_int=yes - if test "x${ac_cv_prog_cc_c99-no}" = xno; then - ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int - if test $ac_cv_type_long_long_int = yes; then - dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. - dnl If cross compiling, assume the bug is not important, since - dnl nobody cross compiles for this platform as far as we know. - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[@%:@include - @%:@ifndef LLONG_MAX - @%:@ define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - @%:@ define LLONG_MAX (HALF - 1 + HALF) - @%:@endif]], - [[long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0;]])], - [], - [ac_cv_type_long_long_int=no], - [:]) - fi - fi]) - if test $ac_cv_type_long_long_int = yes; then - AC_DEFINE([HAVE_LONG_LONG_INT], [1], - [Define to 1 if the system has the type 'long long int'.]) - fi -]) - -# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. -# This fixes a bug in Autoconf 2.61, and can be faster -# than what's in Autoconf 2.62 through 2.68. - -# Note: If the type 'unsigned long long int' exists but is only 32 bits -# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT -# will not be defined. In this case you can treat 'unsigned long long int' -# like 'unsigned long int'. - -AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], -[ - AC_CACHE_CHECK([for unsigned long long int], - [ac_cv_type_unsigned_long_long_int], - [ac_cv_type_unsigned_long_long_int=yes - if test "x${ac_cv_prog_cc_c99-no}" = xno; then - AC_LINK_IFELSE( - [_AC_TYPE_LONG_LONG_SNIPPET], - [], - [ac_cv_type_unsigned_long_long_int=no]) - fi]) - if test $ac_cv_type_unsigned_long_long_int = yes; then - AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], - [Define to 1 if the system has the type 'unsigned long long int'.]) - fi -]) - -# Expands to a C program that can be used to test for simultaneous support -# of 'long long' and 'unsigned long long'. We don't want to say that -# 'long long' is available if 'unsigned long long' is not, or vice versa, -# because too many programs rely on the symmetry between signed and unsigned -# integer types (excluding 'bool'). -AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], -[ - AC_LANG_PROGRAM( - [[/* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ - /* Test literals. */ - long long int ll = 9223372036854775807ll; - long long int nll = -9223372036854775807LL; - unsigned long long int ull = 18446744073709551615ULL; - /* Test constant expressions. */ - typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; - typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; - int i = 63;]], - [[/* Test availability of runtime routines for shift and division. */ - long long int llmax = 9223372036854775807ll; - unsigned long long int ullmax = 18446744073709551615ull; - return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull));]]) -]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 deleted file mode 100644 index 4b24a0b11..000000000 --- a/m4/malloc.m4 +++ /dev/null @@ -1,98 +0,0 @@ -# malloc.m4 serial 14 -dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -m4_version_prereq([2.70], [] ,[ - -# This is taken from the following Autoconf patch: -# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 -AC_DEFUN([_AC_FUNC_MALLOC_IF], -[ - AC_REQUIRE([AC_HEADER_STDC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles - AC_CHECK_HEADERS([stdlib.h]) - AC_CACHE_CHECK([for GNU libc compatible malloc], - [ac_cv_func_malloc_0_nonnull], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H - # include - #else - char *malloc (); - #endif - ]], - [[return ! malloc (0);]]) - ], - [ac_cv_func_malloc_0_nonnull=yes], - [ac_cv_func_malloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* \ - | hpux* | solaris* | cygwin* | mingw*) - ac_cv_func_malloc_0_nonnull=yes ;; - # If we don't know, assume the worst. - *) ac_cv_func_malloc_0_nonnull=no ;; - esac - ]) - ]) - AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2]) -])# _AC_FUNC_MALLOC_IF - -]) - -# gl_FUNC_MALLOC_GNU -# ------------------ -# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if -# it is not. -AC_DEFUN([gl_FUNC_MALLOC_GNU], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. - _AC_FUNC_MALLOC_IF( - [AC_DEFINE([HAVE_MALLOC_GNU], [1], - [Define to 1 if your system has a GNU libc compatible 'malloc' - function, and to 0 otherwise.])], - [AC_DEFINE([HAVE_MALLOC_GNU], [0]) - REPLACE_MALLOC=1 - ]) -]) - -# gl_FUNC_MALLOC_POSIX -# -------------------- -# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it -# fails), and replace malloc if it is not. -AC_DEFUN([gl_FUNC_MALLOC_POSIX], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) - if test $gl_cv_func_malloc_posix = yes; then - AC_DEFINE([HAVE_MALLOC_POSIX], [1], - [Define if the 'malloc' function is POSIX compliant.]) - else - REPLACE_MALLOC=1 - fi -]) - -# Test whether malloc, realloc, calloc are POSIX compliant, -# Set gl_cv_func_malloc_posix to yes or no accordingly. -AC_DEFUN([gl_CHECK_MALLOC_POSIX], -[ - AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant], - [gl_cv_func_malloc_posix], - [ - dnl It is too dangerous to try to allocate a large amount of memory: - dnl some systems go to their knees when you do that. So assume that - dnl all Unix implementations of the function are POSIX compliant. - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[]], - [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - choke me - #endif - ]])], - [gl_cv_func_malloc_posix=yes], - [gl_cv_func_malloc_posix=no]) - ]) -]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 deleted file mode 100644 index bf0845fd1..000000000 --- a/m4/math_h.m4 +++ /dev/null @@ -1,353 +0,0 @@ -# math_h.m4 serial 114 -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_MATH_H], -[ - AC_REQUIRE([gl_MATH_H_DEFAULTS]) - gl_CHECK_NEXT_HEADERS([math.h]) - - AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[/* Solaris 10 has a broken definition of NAN. Other platforms - fail to provide NAN, or provide it only in C99 mode; this - test only needs to fail when NAN is provided but wrong. */ - float f = 1.0f; -#ifdef NAN - f = NAN; -#endif - return f == 0;]])], - [gl_cv_header_math_nan_works=yes], - [gl_cv_header_math_nan_works=no])]) - if test $gl_cv_header_math_nan_works = no; then - REPLACE_NAN=1 - fi - AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[/* Solaris 10 has a broken definition of HUGE_VAL. */ - double d = HUGE_VAL; - return d == 0;]])], - [gl_cv_header_math_huge_val_works=yes], - [gl_cv_header_math_huge_val_works=no])]) - if test $gl_cv_header_math_huge_val_works = no; then - REPLACE_HUGE_VAL=1 - fi - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[#include ]], - [acosf acosl asinf asinl atanf atanl - cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf - expf expl exp2 exp2f exp2l expm1 expm1f expm1l - fabsf fabsl floorf floorl fma fmaf fmal - fmod fmodf fmodl frexpf frexpl hypotf hypotl - ilogb ilogbf ilogbl - ldexpf ldexpl - log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l - logb logbf logbl - modf modff modfl powf - remainder remainderf remainderl - rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl - tanf tanl tanhf trunc truncf truncl]) -]) - -AC_DEFUN([gl_MATH_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_MATH_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_MATH_H_DEFAULTS], -[ - GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF]) - GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL]) - GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF]) - GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL]) - GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF]) - GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL]) - GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F]) - GNULIB_CBRT=0; AC_SUBST([GNULIB_CBRT]) - GNULIB_CBRTF=0; AC_SUBST([GNULIB_CBRTF]) - GNULIB_CBRTL=0; AC_SUBST([GNULIB_CBRTL]) - GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL]) - GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF]) - GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL]) - GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN]) - GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF]) - GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL]) - GNULIB_COSF=0; AC_SUBST([GNULIB_COSF]) - GNULIB_COSL=0; AC_SUBST([GNULIB_COSL]) - GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF]) - GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF]) - GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL]) - GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2]) - GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F]) - GNULIB_EXP2L=0; AC_SUBST([GNULIB_EXP2L]) - GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1]) - GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F]) - GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L]) - GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF]) - GNULIB_FABSL=0; AC_SUBST([GNULIB_FABSL]) - GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR]) - GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF]) - GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL]) - GNULIB_FMA=0; AC_SUBST([GNULIB_FMA]) - GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF]) - GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL]) - GNULIB_FMOD=0; AC_SUBST([GNULIB_FMOD]) - GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF]) - GNULIB_FMODL=0; AC_SUBST([GNULIB_FMODL]) - GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF]) - GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) - GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) - GNULIB_HYPOT=0; AC_SUBST([GNULIB_HYPOT]) - GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF]) - GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL]) - GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB]) - GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF]) - GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL]) - GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE]) - GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF]) - GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN]) - GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF]) - GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND]) - GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL]) - GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF]) - GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) - GNULIB_LOG=0; AC_SUBST([GNULIB_LOG]) - GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF]) - GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL]) - GNULIB_LOG10=0; AC_SUBST([GNULIB_LOG10]) - GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F]) - GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L]) - GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P]) - GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF]) - GNULIB_LOG1PL=0; AC_SUBST([GNULIB_LOG1PL]) - GNULIB_LOG2=0; AC_SUBST([GNULIB_LOG2]) - GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F]) - GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L]) - GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB]) - GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF]) - GNULIB_LOGBL=0; AC_SUBST([GNULIB_LOGBL]) - GNULIB_MODF=0; AC_SUBST([GNULIB_MODF]) - GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF]) - GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL]) - GNULIB_POWF=0; AC_SUBST([GNULIB_POWF]) - GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER]) - GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF]) - GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL]) - GNULIB_RINT=0; AC_SUBST([GNULIB_RINT]) - GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF]) - GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL]) - GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) - GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) - GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) - GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) - GNULIB_SINF=0; AC_SUBST([GNULIB_SINF]) - GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) - GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF]) - GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF]) - GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) - GNULIB_TANF=0; AC_SUBST([GNULIB_TANF]) - GNULIB_TANL=0; AC_SUBST([GNULIB_TANL]) - GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF]) - GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) - GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) - GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF]) - HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) - HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) - HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) - HAVE_ATANF=1; AC_SUBST([HAVE_ATANF]) - HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) - HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F]) - HAVE_CBRT=1; AC_SUBST([HAVE_CBRT]) - HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) - HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) - HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) - HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) - HAVE_COSF=1; AC_SUBST([HAVE_COSF]) - HAVE_COSL=1; AC_SUBST([HAVE_COSL]) - HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) - HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) - HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) - HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) - HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) - HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) - HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) - HAVE_FMA=1; AC_SUBST([HAVE_FMA]) - HAVE_FMAF=1; AC_SUBST([HAVE_FMAF]) - HAVE_FMAL=1; AC_SUBST([HAVE_FMAL]) - HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) - HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) - HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) - HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) - HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) - HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) - HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF]) - HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL]) - HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) - HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) - HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) - HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) - HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) - HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) - HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) - HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) - HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) - HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) - HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) - HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) - HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) - HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) - HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) - HAVE_POWF=1; AC_SUBST([HAVE_POWF]) - HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) - HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) - HAVE_RINT=1; AC_SUBST([HAVE_RINT]) - HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) - HAVE_SINF=1; AC_SUBST([HAVE_SINF]) - HAVE_SINL=1; AC_SUBST([HAVE_SINL]) - HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) - HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) - HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) - HAVE_TANF=1; AC_SUBST([HAVE_TANF]) - HAVE_TANL=1; AC_SUBST([HAVE_TANL]) - HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) - HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) - HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) - HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) - HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF]) - HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL]) - HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) - HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) - HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF]) - HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) - HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) - HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) - HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) - HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L]) - HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) - HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) - HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) - HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) - HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) - HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) - HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) - HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2]) - HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F]) - HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L]) - HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) - HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) - HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL]) - HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF]) - HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) - HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) - HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) - HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) - HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) - HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) - HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) - HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) - HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) - REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) - REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) - REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) - REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) - REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) - REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) - REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) - REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) - REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L]) - REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) - REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) - REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) - REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) - REPLACE_FMA=0; AC_SUBST([REPLACE_FMA]) - REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF]) - REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL]) - REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD]) - REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF]) - REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL]) - REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) - REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) - REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) - REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) - REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) - REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) - REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL]) - REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB]) - REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF]) - REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) - REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) - REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) - REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) - REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) - REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) - REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) - REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10]) - REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F]) - REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L]) - REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) - REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) - REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) - REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2]) - REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F]) - REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L]) - REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB]) - REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF]) - REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL]) - REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) - REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) - REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) - REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) - REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) - REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) - REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) - REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) - REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) - REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) - REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) - REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) - REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) - REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) - REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) - REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) -]) - -# gl_LONG_DOUBLE_VS_DOUBLE -# determines whether 'long double' and 'double' have the same representation. -# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines -# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly. -# The currently known platforms where this is the case are: -# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9. -AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE], -[ - AC_CACHE_CHECK([whether long double and double are the same], - [gl_cv_long_double_equals_double], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[typedef int check[sizeof (long double) == sizeof (double) - && LDBL_MANT_DIG == DBL_MANT_DIG - && LDBL_MAX_EXP == DBL_MAX_EXP - && LDBL_MIN_EXP == DBL_MIN_EXP - ? 1 : -1]; - ]])], - [gl_cv_long_double_equals_double=yes], - [gl_cv_long_double_equals_double=no]) - ]) - if test $gl_cv_long_double_equals_double = yes; then - AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1], - [Define to 1 if 'long double' and 'double' have the same representation.]) - HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1 - else - HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0 - fi - AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]) -]) diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 deleted file mode 100644 index 4c9f38861..000000000 --- a/m4/mbrtowc.m4 +++ /dev/null @@ -1,572 +0,0 @@ -# mbrtowc.m4 serial 25 -dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_MBRTOWC], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - gl_MBSTATE_T_BROKEN - - AC_CHECK_FUNCS_ONCE([mbrtowc]) - if test $ac_cv_func_mbrtowc = no; then - HAVE_MBRTOWC=0 - AC_CHECK_DECLS([mbrtowc],,, [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -]]) - if test $ac_cv_have_decl_mbrtowc = yes; then - dnl On Minix 3.1.8, the system's declares mbrtowc() although - dnl it does not have the function. Avoid a collision with gnulib's - dnl replacement. - REPLACE_MBRTOWC=1 - fi - else - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_MBRTOWC=1 - else - gl_MBRTOWC_NULL_ARG1 - gl_MBRTOWC_NULL_ARG2 - gl_MBRTOWC_RETVAL - gl_MBRTOWC_NUL_RETVAL - case "$gl_cv_func_mbrtowc_null_arg1" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], - [Define if the mbrtowc function has the NULL pwc argument bug.]) - REPLACE_MBRTOWC=1 - ;; - esac - case "$gl_cv_func_mbrtowc_null_arg2" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1], - [Define if the mbrtowc function has the NULL string argument bug.]) - REPLACE_MBRTOWC=1 - ;; - esac - case "$gl_cv_func_mbrtowc_retval" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], - [Define if the mbrtowc function returns a wrong return value.]) - REPLACE_MBRTOWC=1 - ;; - esac - case "$gl_cv_func_mbrtowc_nul_retval" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1], - [Define if the mbrtowc function does not return 0 for a NUL character.]) - REPLACE_MBRTOWC=1 - ;; - esac - fi - fi -]) - -dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that -dnl redefines the semantics of the given mbstate_t type. -dnl Result is REPLACE_MBSTATE_T. -dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to -dnl avoid inconsistencies. - -AC_DEFUN([gl_MBSTATE_T_BROKEN], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - AC_CHECK_FUNCS_ONCE([mbsinit]) - AC_CHECK_FUNCS_ONCE([mbrtowc]) - if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then - gl_MBRTOWC_INCOMPLETE_STATE - gl_MBRTOWC_SANITYCHECK - REPLACE_MBSTATE_T=0 - case "$gl_cv_func_mbrtowc_incomplete_state" in - *yes) ;; - *) REPLACE_MBSTATE_T=1 ;; - esac - case "$gl_cv_func_mbrtowc_sanitycheck" in - *yes) ;; - *) REPLACE_MBSTATE_T=1 ;; - esac - else - REPLACE_MBSTATE_T=1 - fi -]) - -dnl Test whether mbrtowc puts the state into non-initial state when parsing an -dnl incomplete multibyte character. -dnl Result is gl_cv_func_mbrtowc_incomplete_state. - -AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_JA]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], - [gl_cv_func_mbrtowc_incomplete_state], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on AIX and OSF/1. - aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_JA != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) - { - const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) - if (mbsinit (&state)) - return 1; - } - return 0; -}]])], - [gl_cv_func_mbrtowc_incomplete_state=yes], - [gl_cv_func_mbrtowc_incomplete_state=no], - [:]) - fi - ]) -]) - -dnl Test whether mbrtowc works not worse than mbtowc. -dnl Result is gl_cv_func_mbrtowc_sanitycheck. - -AC_DEFUN([gl_MBRTOWC_SANITYCHECK], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_ZH_CN]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc], - [gl_cv_func_mbrtowc_sanitycheck], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on Solaris 8. - solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_ZH_CN != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - /* This fails on Solaris 8: - mbrtowc returns 2, and sets wc to 0x00F0. - mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ - if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) - { - char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 3, 6, &state) != 4 - && mbtowc (&wc, input + 3, 6) == 4) - return 1; - } - return 0; -}]])], - [gl_cv_func_mbrtowc_sanitycheck=yes], - [gl_cv_func_mbrtowc_sanitycheck=no], - [:]) - fi - ]) -]) - -dnl Test whether mbrtowc supports a NULL pwc argument correctly. -dnl Result is gl_cv_func_mbrtowc_null_arg1. - -AC_DEFUN([gl_MBRTOWC_NULL_ARG1], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], - [gl_cv_func_mbrtowc_null_arg1], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on Solaris. - solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR_UTF8 != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - int result = 0; - - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) - { - char input[] = "\303\237er"; - mbstate_t state; - wchar_t wc; - size_t ret; - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input, 5, &state); - if (ret != 2) - result |= 1; - if (!mbsinit (&state)) - result |= 2; - - memset (&state, '\0', sizeof (mbstate_t)); - ret = mbrtowc (NULL, input, 5, &state); - if (ret != 2) /* Solaris 7 fails here: ret is -1. */ - result |= 4; - if (!mbsinit (&state)) - result |= 8; - } - return result; -}]])], - [gl_cv_func_mbrtowc_null_arg1=yes], - [gl_cv_func_mbrtowc_null_arg1=no], - [:]) - fi - ]) -]) - -dnl Test whether mbrtowc supports a NULL string argument correctly. -dnl Result is gl_cv_func_mbrtowc_null_arg2. - -AC_DEFUN([gl_MBRTOWC_NULL_ARG2], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument], - [gl_cv_func_mbrtowc_null_arg2], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on OSF/1. - osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR_UTF8 != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) - { - mbstate_t state; - wchar_t wc; - int ret; - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - mbrtowc (&wc, NULL, 5, &state); - /* Check that wc was not modified. */ - if (wc != (wchar_t) 0xBADFACE) - return 1; - } - return 0; -}]])], - [gl_cv_func_mbrtowc_null_arg2=yes], - [gl_cv_func_mbrtowc_null_arg2=no], - [:]) - fi - ]) -]) - -dnl Test whether mbrtowc, when parsing the end of a multibyte character, -dnl correctly returns the number of bytes that were needed to complete the -dnl character (not the total number of bytes of the multibyte character). -dnl Result is gl_cv_func_mbrtowc_retval. - -AC_DEFUN([gl_MBRTOWC_RETVAL], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) - AC_REQUIRE([gt_LOCALE_JA]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CACHE_CHECK([whether mbrtowc has a correct return value], - [gl_cv_func_mbrtowc_retval], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on HP-UX, Solaris, native Windows. - hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_retval="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ - || { case "$host_os" in mingw*) true;; *) false;; esac; }; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - int result = 0; - int found_some_locale = 0; - /* This fails on Solaris. */ - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) - { - char input[] = "B\303\274\303\237er"; /* "Büßer" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) - { - input[1] = '\0'; - if (mbrtowc (&wc, input + 2, 5, &state) != 1) - result |= 1; - } - found_some_locale = 1; - } - /* This fails on HP-UX 11.11. */ - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) - { - char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) - { - input[1] = '\0'; - if (mbrtowc (&wc, input + 2, 5, &state) != 2) - result |= 2; - } - found_some_locale = 1; - } - /* This fails on native Windows. */ - if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) - { - char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) - { - input[3] = '\0'; - if (mbrtowc (&wc, input + 4, 4, &state) != 1) - result |= 4; - } - found_some_locale = 1; - } - if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) - { - char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) - { - input[3] = '\0'; - if (mbrtowc (&wc, input + 4, 4, &state) != 1) - result |= 8; - } - found_some_locale = 1; - } - if (setlocale (LC_ALL, "Chinese_China.936") != NULL) - { - char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) - { - input[3] = '\0'; - if (mbrtowc (&wc, input + 4, 4, &state) != 1) - result |= 16; - } - found_some_locale = 1; - } - return (found_some_locale ? result : 77); -}]])], - [gl_cv_func_mbrtowc_retval=yes], - [if test $? != 77; then - gl_cv_func_mbrtowc_retval=no - fi - ], - [:]) - fi - ]) -]) - -dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0. -dnl Result is gl_cv_func_mbrtowc_nul_retval. - -AC_DEFUN([gl_MBRTOWC_NUL_RETVAL], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_ZH_CN]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character], - [gl_cv_func_mbrtowc_nul_retval], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on Solaris 8 and 9. - solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_ZH_CN != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - /* This fails on Solaris 8 and 9. */ - if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) - { - mbstate_t state; - wchar_t wc; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (&wc, "", 1, &state) != 0) - return 1; - } - return 0; -}]])], - [gl_cv_func_mbrtowc_nul_retval=yes], - [gl_cv_func_mbrtowc_nul_retval=no], - [:]) - fi - ]) -]) - -# Prerequisites of lib/mbrtowc.c. -AC_DEFUN([gl_PREREQ_MBRTOWC], [ - : -]) - - -dnl From Paul Eggert - -dnl This is an override of an autoconf macro. - -AC_DEFUN([AC_FUNC_MBRTOWC], -[ - dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. - AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], - gl_cv_func_mbrtowc, - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[/* Tru64 with Desktop Toolkit C has a bug: must be - included before . - BSD/OS 4.0.1 has a bug: , and - must be included before . */ - #include - #include - #include - #include ]], - [[wchar_t wc; - char const s[] = ""; - size_t n = 1; - mbstate_t state; - return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], - gl_cv_func_mbrtowc=yes, - gl_cv_func_mbrtowc=no)]) - if test $gl_cv_func_mbrtowc = yes; then - AC_DEFINE([HAVE_MBRTOWC], [1], - [Define to 1 if mbrtowc and mbstate_t are properly declared.]) - fi -]) diff --git a/m4/mbsinit.m4 b/m4/mbsinit.m4 deleted file mode 100644 index 2e6d0921a..000000000 --- a/m4/mbsinit.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# mbsinit.m4 serial 8 -dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_MBSINIT], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) - - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - gl_MBSTATE_T_BROKEN - - AC_CHECK_FUNCS_ONCE([mbsinit]) - if test $ac_cv_func_mbsinit = no; then - HAVE_MBSINIT=0 - AC_CHECK_DECLS([mbsinit],,, [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -]]) - if test $ac_cv_have_decl_mbsinit = yes; then - dnl On Minix 3.1.8, the system's declares mbsinit() although - dnl it does not have the function. Avoid a collision with gnulib's - dnl replacement. - REPLACE_MBSINIT=1 - fi - else - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_MBSINIT=1 - else - dnl On mingw, mbsinit() always returns 1, which is inappropriate for - dnl states produced by mbrtowc() for an incomplete multibyte character - dnl in multibyte locales. - case "$host_os" in - mingw*) REPLACE_MBSINIT=1 ;; - esac - fi - fi -]) - -# Prerequisites of lib/mbsinit.c. -AC_DEFUN([gl_PREREQ_MBSINIT], [ - : -]) diff --git a/m4/mbsrtowcs.m4 b/m4/mbsrtowcs.m4 deleted file mode 100644 index c4934c281..000000000 --- a/m4/mbsrtowcs.m4 +++ /dev/null @@ -1,155 +0,0 @@ -# mbsrtowcs.m4 serial 13 -dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_MBSRTOWCS], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - gl_MBSTATE_T_BROKEN - - AC_CHECK_FUNCS_ONCE([mbsrtowcs]) - if test $ac_cv_func_mbsrtowcs = no; then - HAVE_MBSRTOWCS=0 - AC_CHECK_DECLS([mbsrtowcs],,, [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -]]) - if test $ac_cv_have_decl_mbsrtowcs = yes; then - dnl On Minix 3.1.8, the system's declares mbsrtowcs() although - dnl it does not have the function. Avoid a collision with gnulib's - dnl replacement. - REPLACE_MBSRTOWCS=1 - fi - else - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_MBSRTOWCS=1 - else - gl_MBSRTOWCS_WORKS - case "$gl_cv_func_mbsrtowcs_works" in - *yes) ;; - *) REPLACE_MBSRTOWCS=1 ;; - esac - fi - fi -]) - -dnl Test whether mbsrtowcs works. -dnl Result is gl_cv_func_mbsrtowcs_works. - -AC_DEFUN([gl_MBSRTOWCS_WORKS], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) - AC_REQUIRE([gt_LOCALE_JA]) - AC_REQUIRE([gt_LOCALE_ZH_CN]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether mbsrtowcs works], - [gl_cv_func_mbsrtowcs_works], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on HP-UX, Solaris, mingw. - hpux* | solaris* | mingw*) gl_cv_func_mbsrtowcs_works="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbsrtowcs_works="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - int result = 0; - /* Test whether the function supports a NULL destination argument. - This fails on native Windows. */ - if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) - { - const char input[] = "\337er"; - const char *src = input; - mbstate_t state; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbsrtowcs (NULL, &src, 1, &state) != 3 - || src != input) - result |= 1; - } - /* Test whether the function works when started with a conversion state - in non-initial state. This fails on HP-UX 11.11 and Solaris 10. */ - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) - { - const char input[] = "B\303\274\303\237er"; - mbstate_t state; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) - if (!mbsinit (&state)) - { - const char *src = input + 2; - if (mbsrtowcs (NULL, &src, 10, &state) != 4) - result |= 2; - } - } - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) - { - const char input[] = "<\306\374\313\334\270\354>"; - mbstate_t state; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2)) - if (!mbsinit (&state)) - { - const char *src = input + 4; - if (mbsrtowcs (NULL, &src, 10, &state) != 3) - result |= 4; - } - } - if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) - { - const char input[] = "B\250\271\201\060\211\070er"; - mbstate_t state; - - memset (&state, '\0', sizeof (mbstate_t)); - if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) - if (!mbsinit (&state)) - { - const char *src = input + 2; - if (mbsrtowcs (NULL, &src, 10, &state) != 4) - result |= 8; - } - } - return result; -}]])], - [gl_cv_func_mbsrtowcs_works=yes], - [gl_cv_func_mbsrtowcs_works=no], - [:]) - fi - ]) -]) - -# Prerequisites of lib/mbsrtowcs.c. -AC_DEFUN([gl_PREREQ_MBSRTOWCS], [ - : -]) diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4 deleted file mode 100644 index ed0011798..000000000 --- a/m4/mbstate_t.m4 +++ /dev/null @@ -1,41 +0,0 @@ -# mbstate_t.m4 serial 13 -dnl Copyright (C) 2000-2002, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# From Paul Eggert. - -# BeOS 5 has but does not define mbstate_t, -# so you can't declare an object of that type. -# Check for this incompatibility with Standard C. - -# AC_TYPE_MBSTATE_T -# ----------------- -AC_DEFUN([AC_TYPE_MBSTATE_T], -[ - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11 - - AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [AC_INCLUDES_DEFAULT[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include ]], - [[mbstate_t x; return sizeof x;]])], - [ac_cv_type_mbstate_t=yes], - [ac_cv_type_mbstate_t=no])]) - if test $ac_cv_type_mbstate_t = yes; then - AC_DEFINE([HAVE_MBSTATE_T], [1], - [Define to 1 if declares mbstate_t.]) - else - AC_DEFINE([mbstate_t], [int], - [Define to a type if does not define.]) - fi -]) diff --git a/m4/mbswidth.m4 b/m4/mbswidth.m4 deleted file mode 100644 index 39760fcd2..000000000 --- a/m4/mbswidth.m4 +++ /dev/null @@ -1,46 +0,0 @@ -# mbswidth.m4 serial 18 -dnl Copyright (C) 2000-2002, 2004, 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl autoconf tests required for use of mbswidth.c -dnl From Bruno Haible. - -AC_DEFUN([gl_MBSWIDTH], -[ - AC_CHECK_HEADERS_ONCE([wchar.h]) - AC_CHECK_FUNCS_ONCE([isascii mbsinit]) - - dnl UnixWare 7.1.1 has a declaration of a function mbswidth() - dnl that clashes with ours. - AC_CACHE_CHECK([whether mbswidth is declared in ], - [ac_cv_have_decl_mbswidth], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include -#include - ]], - [[ - char *p = (char *) mbswidth; - return !p; - ]])], - [ac_cv_have_decl_mbswidth=yes], - [ac_cv_have_decl_mbswidth=no])]) - if test $ac_cv_have_decl_mbswidth = yes; then - ac_val=1 - else - ac_val=0 - fi - AC_DEFINE_UNQUOTED([HAVE_DECL_MBSWIDTH_IN_WCHAR_H], [$ac_val], - [Define to 1 if you have a declaration of mbswidth() in , and to 0 otherwise.]) - - AC_TYPE_MBSTATE_T -]) diff --git a/m4/mbtowc.m4 b/m4/mbtowc.m4 deleted file mode 100644 index e47946196..000000000 --- a/m4/mbtowc.m4 +++ /dev/null @@ -1,19 +0,0 @@ -# mbtowc.m4 serial 2 -dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_MBTOWC], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - - if false; then - REPLACE_MBTOWC=1 - fi -]) - -# Prerequisites of lib/mbtowc.c. -AC_DEFUN([gl_PREREQ_MBTOWC], [ - : -]) diff --git a/m4/memchr.m4 b/m4/memchr.m4 deleted file mode 100644 index 2d8abe75d..000000000 --- a/m4/memchr.m4 +++ /dev/null @@ -1,88 +0,0 @@ -# memchr.m4 serial 12 -dnl Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN_ONCE([gl_FUNC_MEMCHR], -[ - dnl Check for prerequisites for memory fence checks. - gl_FUNC_MMAP_ANON - AC_CHECK_HEADERS_ONCE([sys/mman.h]) - AC_CHECK_FUNCS_ONCE([mprotect]) - - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ - dnl These days, we assume memchr is present. But if support for old - dnl platforms is desired: - AC_CHECK_FUNCS_ONCE([memchr]) - if test $ac_cv_func_memchr = no; then - HAVE_MEMCHR=0 - fi - ]) - if test $HAVE_MEMCHR = 1; then - # Detect platform-specific bugs in some versions of glibc: - # memchr should not dereference anything with length 0 - # http://bugzilla.redhat.com/499689 - # memchr should not dereference overestimated length after a match - # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 - # http://sourceware.org/bugzilla/show_bug.cgi?id=10162 - # Assume that memchr works on platforms that lack mprotect. - AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#if HAVE_SYS_MMAN_H -# include -# include -# include -# include -# ifndef MAP_FILE -# define MAP_FILE 0 -# endif -#endif -]], [[ - int result = 0; - char *fence = NULL; -#if HAVE_SYS_MMAN_H && HAVE_MPROTECT -# if HAVE_MAP_ANONYMOUS - const int flags = MAP_ANONYMOUS | MAP_PRIVATE; - const int fd = -1; -# else /* !HAVE_MAP_ANONYMOUS */ - const int flags = MAP_FILE | MAP_PRIVATE; - int fd = open ("/dev/zero", O_RDONLY, 0666); - if (fd >= 0) -# endif - { - int pagesize = getpagesize (); - char *two_pages = - (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, - flags, fd, 0); - if (two_pages != (char *)(-1) - && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) - fence = two_pages + pagesize; - } -#endif - if (fence) - { - if (memchr (fence, 0, 0)) - result |= 1; - strcpy (fence - 9, "12345678"); - if (memchr (fence - 9, 0, 79) != fence - 1) - result |= 2; - if (memchr (fence - 1, 0, 3) != fence - 1) - result |= 4; - } - return result; -]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], - [dnl Be pessimistic for now. - gl_cv_func_memchr_works="guessing no"])]) - if test "$gl_cv_func_memchr_works" != yes; then - REPLACE_MEMCHR=1 - fi - fi -]) - -# Prerequisites of lib/memchr.c. -AC_DEFUN([gl_PREREQ_MEMCHR], [ - AC_CHECK_HEADERS([bp-sym.h]) -]) diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 deleted file mode 100644 index a48f2d107..000000000 --- a/m4/mempcpy.m4 +++ /dev/null @@ -1,26 +0,0 @@ -# mempcpy.m4 serial 11 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_MEMPCPY], -[ - dnl Persuade glibc to declare mempcpy(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'. - AC_REQUIRE([AC_C_RESTRICT]) - - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_FUNCS([mempcpy]) - if test $ac_cv_func_mempcpy = no; then - HAVE_MEMPCPY=0 - fi -]) - -# Prerequisites of lib/mempcpy.c. -AC_DEFUN([gl_PREREQ_MEMPCPY], [ - : -]) diff --git a/m4/mmap-anon.m4 b/m4/mmap-anon.m4 deleted file mode 100644 index 9b60ddfa4..000000000 --- a/m4/mmap-anon.m4 +++ /dev/null @@ -1,55 +0,0 @@ -# mmap-anon.m4 serial 10 -dnl Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Detect how mmap can be used to create anonymous (not file-backed) memory -# mappings. -# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS -# and MAP_ANON exist and have the same value. -# - On HP-UX, only MAP_ANONYMOUS exists. -# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. -# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be -# used. - -AC_DEFUN([gl_FUNC_MMAP_ANON], -[ - dnl Persuade glibc to define MAP_ANONYMOUS. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it - # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is - # irrelevant for anonymous mappings. - AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no]) - - # Try to allow MAP_ANONYMOUS. - gl_have_mmap_anonymous=no - if test $gl_have_mmap = yes; then - AC_MSG_CHECKING([for MAP_ANONYMOUS]) - AC_EGREP_CPP([I cannot identify this map], [ -#include -#ifdef MAP_ANONYMOUS - I cannot identify this map -#endif -], - [gl_have_mmap_anonymous=yes]) - if test $gl_have_mmap_anonymous != yes; then - AC_EGREP_CPP([I cannot identify this map], [ -#include -#ifdef MAP_ANON - I cannot identify this map -#endif -], - [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON], - [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.]) - gl_have_mmap_anonymous=yes]) - fi - AC_MSG_RESULT([$gl_have_mmap_anonymous]) - if test $gl_have_mmap_anonymous = yes; then - AC_DEFINE([HAVE_MAP_ANONYMOUS], [1], - [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including - config.h and .]) - fi - fi -]) diff --git a/m4/msvc-inval.m4 b/m4/msvc-inval.m4 deleted file mode 100644 index 9a6a47a74..000000000 --- a/m4/msvc-inval.m4 +++ /dev/null @@ -1,19 +0,0 @@ -# msvc-inval.m4 serial 1 -dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_MSVC_INVAL], -[ - AC_CHECK_FUNCS_ONCE([_set_invalid_parameter_handler]) - if test $ac_cv_func__set_invalid_parameter_handler = yes; then - HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 - AC_DEFINE([HAVE_MSVC_INVALID_PARAMETER_HANDLER], [1], - [Define to 1 on MSVC platforms that have the "invalid parameter handler" - concept.]) - else - HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 - fi - AC_SUBST([HAVE_MSVC_INVALID_PARAMETER_HANDLER]) -]) diff --git a/m4/msvc-nothrow.m4 b/m4/msvc-nothrow.m4 deleted file mode 100644 index a39618a41..000000000 --- a/m4/msvc-nothrow.m4 +++ /dev/null @@ -1,10 +0,0 @@ -# msvc-nothrow.m4 serial 1 -dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_MSVC_NOTHROW], -[ - AC_REQUIRE([gl_MSVC_INVAL]) -]) diff --git a/m4/multiarch.m4 b/m4/multiarch.m4 deleted file mode 100644 index 552ec7e71..000000000 --- a/m4/multiarch.m4 +++ /dev/null @@ -1,62 +0,0 @@ -# multiarch.m4 serial 7 -dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Determine whether the compiler is or may be producing universal binaries. -# -# On Mac OS X 10.5 and later systems, the user can create libraries and -# executables that work on multiple system types--known as "fat" or -# "universal" binaries--by specifying multiple '-arch' options to the -# compiler but only a single '-arch' option to the preprocessor. Like -# this: -# -# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ -# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ -# CPP="gcc -E" CXXCPP="g++ -E" -# -# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly. - -AC_DEFUN_ONCE([gl_MULTIARCH], -[ - dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. - gl_cv_c_multiarch=no - AC_COMPILE_IFELSE( - [AC_LANG_SOURCE( - [[#ifndef __APPLE_CC__ - not a universal capable compiler - #endif - typedef int dummy; - ]])], - [ - dnl Check for potential -arch flags. It is not universal unless - dnl there are at least two -arch flags with different values. - arch= - prev= - for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do - if test -n "$prev"; then - case $word in - i?86 | x86_64 | ppc | ppc64) - if test -z "$arch" || test "$arch" = "$word"; then - arch="$word" - else - gl_cv_c_multiarch=yes - fi - ;; - esac - prev= - else - if test "x$word" = "x-arch"; then - prev=arch - fi - fi - done - ]) - if test $gl_cv_c_multiarch = yes; then - APPLE_UNIVERSAL_BUILD=1 - else - APPLE_UNIVERSAL_BUILD=0 - fi - AC_SUBST([APPLE_UNIVERSAL_BUILD]) -]) diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4 deleted file mode 100644 index 25e210155..000000000 --- a/m4/nl_langinfo.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# nl_langinfo.m4 serial 5 -dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_NL_LANGINFO], -[ - AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) - AC_REQUIRE([gl_LANGINFO_H]) - AC_CHECK_FUNCS_ONCE([nl_langinfo]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - if test $ac_cv_func_nl_langinfo = yes; then - # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. - AC_CACHE_CHECK([whether YESEXPR works], - [gl_cv_func_nl_langinfo_yesexpr_works], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[#include -]], [[return !*nl_langinfo(YESEXPR); -]])], - [gl_cv_func_nl_langinfo_yesexpr_works=yes], - [gl_cv_func_nl_langinfo_yesexpr_works=no], - [ - case "$host_os" in - # Guess no on irix systems. - irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";; - # Guess yes elsewhere. - *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";; - esac - ]) - ]) - case $gl_cv_func_nl_langinfo_yesexpr_works in - *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;; - *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;; - esac - AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], - [$FUNC_NL_LANGINFO_YESEXPR_WORKS], - [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) - if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ - && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then - : - else - REPLACE_NL_LANGINFO=1 - AC_DEFINE([REPLACE_NL_LANGINFO], [1], - [Define if nl_langinfo exists but is overridden by gnulib.]) - fi - else - HAVE_NL_LANGINFO=0 - fi -]) diff --git a/m4/nls.m4 b/m4/nls.m4 deleted file mode 100644 index 8f8a147be..000000000 --- a/m4/nls.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# nls.m4 serial 5 (gettext-0.18) -dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.50]) - -AC_DEFUN([AM_NLS], -[ - AC_MSG_CHECKING([whether NLS is requested]) - dnl Default is enabled NLS - AC_ARG_ENABLE([nls], - [ --disable-nls do not use Native Language Support], - USE_NLS=$enableval, USE_NLS=yes) - AC_MSG_RESULT([$USE_NLS]) - AC_SUBST([USE_NLS]) -]) diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 deleted file mode 100644 index 105b884f1..000000000 --- a/m4/nocrash.m4 +++ /dev/null @@ -1,130 +0,0 @@ -# nocrash.m4 serial 4 -dnl Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. - -AC_PREREQ([2.13]) - -dnl Expands to some code for use in .c programs that will cause the configure -dnl test to exit instead of crashing. This is useful to avoid triggering -dnl action from a background debugger and to avoid core dumps. -dnl Usage: ... -dnl ]GL_NOCRASH[ -dnl ... -dnl int main() { nocrash_init(); ... } -AC_DEFUN([GL_NOCRASH],[[ -#include -#if defined __MACH__ && defined __APPLE__ -/* Avoid a crash on Mac OS X. */ -#include -#include -#include -#include -#include -#include -/* The exception port on which our thread listens. */ -static mach_port_t our_exception_port; -/* The main function of the thread listening for exceptions of type - EXC_BAD_ACCESS. */ -static void * -mach_exception_thread (void *arg) -{ - /* Buffer for a message to be received. */ - struct { - mach_msg_header_t head; - mach_msg_body_t msgh_body; - char data[1024]; - } msg; - mach_msg_return_t retval; - /* Wait for a message on the exception port. */ - retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), - our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - if (retval != MACH_MSG_SUCCESS) - abort (); - exit (1); -} -static void -nocrash_init (void) -{ - mach_port_t self = mach_task_self (); - /* Allocate a port on which the thread shall listen for exceptions. */ - if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) - == KERN_SUCCESS) { - /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ - if (mach_port_insert_right (self, our_exception_port, our_exception_port, - MACH_MSG_TYPE_MAKE_SEND) - == KERN_SUCCESS) { - /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting - for us. */ - exception_mask_t mask = EXC_MASK_BAD_ACCESS; - /* Create the thread listening on the exception port. */ - pthread_attr_t attr; - pthread_t thread; - if (pthread_attr_init (&attr) == 0 - && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 - && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { - pthread_attr_destroy (&attr); - /* Replace the exception port info for these exceptions with our own. - Note that we replace the exception port for the entire task, not only - for a particular thread. This has the effect that when our exception - port gets the message, the thread specific exception port has already - been asked, and we don't need to bother about it. - See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ - task_set_exception_ports (self, mask, our_exception_port, - EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); - } - } - } -} -#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* Avoid a crash on native Windows. */ -#define WIN32_LEAN_AND_MEAN -#include -#include -static LONG WINAPI -exception_filter (EXCEPTION_POINTERS *ExceptionInfo) -{ - switch (ExceptionInfo->ExceptionRecord->ExceptionCode) - { - case EXCEPTION_ACCESS_VIOLATION: - case EXCEPTION_IN_PAGE_ERROR: - case EXCEPTION_STACK_OVERFLOW: - case EXCEPTION_GUARD_PAGE: - case EXCEPTION_PRIV_INSTRUCTION: - case EXCEPTION_ILLEGAL_INSTRUCTION: - case EXCEPTION_DATATYPE_MISALIGNMENT: - case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: - case EXCEPTION_NONCONTINUABLE_EXCEPTION: - exit (1); - } - return EXCEPTION_CONTINUE_SEARCH; -} -static void -nocrash_init (void) -{ - SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); -} -#else -/* Avoid a crash on POSIX systems. */ -#include -/* A POSIX signal handler. */ -static void -exception_handler (int sig) -{ - exit (1); -} -static void -nocrash_init (void) -{ -#ifdef SIGSEGV - signal (SIGSEGV, exception_handler); -#endif -#ifdef SIGBUS - signal (SIGBUS, exception_handler); -#endif -} -#endif -]]) diff --git a/m4/off_t.m4 b/m4/off_t.m4 deleted file mode 100644 index d355d0131..000000000 --- a/m4/off_t.m4 +++ /dev/null @@ -1,18 +0,0 @@ -# off_t.m4 serial 1 -dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Check whether to override the 'off_t' type. -dnl Set WINDOWS_64_BIT_OFF_T. - -AC_DEFUN([gl_TYPE_OFF_T], -[ - m4_ifdef([gl_LARGEFILE], [ - AC_REQUIRE([gl_LARGEFILE]) - ], [ - WINDOWS_64_BIT_OFF_T=0 - ]) - AC_SUBST([WINDOWS_64_BIT_OFF_T]) -]) diff --git a/m4/po.m4 b/m4/po.m4 deleted file mode 100644 index f39572343..000000000 --- a/m4/po.m4 +++ /dev/null @@ -1,452 +0,0 @@ -# po.m4 serial 20 (gettext-0.18.2) -dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.60]) - -dnl Checks for all prerequisites of the po subdirectory. -AC_DEFUN([AM_PO_SUBDIRS], -[ - AC_REQUIRE([AC_PROG_MAKE_SET])dnl - AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AC_PROG_MKDIR_P])dnl - AC_REQUIRE([AM_NLS])dnl - - dnl Release version of the gettext macros. This is used to ensure that - dnl the gettext macros and po/Makefile.in.in are in sync. - AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) - - dnl Perform the following tests also if --disable-nls has been given, - dnl because they are needed for "make dist" to work. - - dnl Search for GNU msgfmt in the PATH. - dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. - dnl The second test excludes FreeBSD msgfmt. - AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, - [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) - - dnl Test whether it is GNU msgfmt >= 0.15. -changequote(,)dnl - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([MSGFMT_015]) -changequote(,)dnl - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; - *) GMSGFMT_015=$GMSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([GMSGFMT_015]) - - dnl Search for GNU xgettext 0.12 or newer in the PATH. - dnl The first test excludes Solaris xgettext and early GNU xgettext versions. - dnl The second test excludes FreeBSD xgettext. - AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, - [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - dnl Remove leftover from FreeBSD xgettext call. - rm -f messages.po - - dnl Test whether it is GNU xgettext >= 0.15. -changequote(,)dnl - case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; - *) XGETTEXT_015=$XGETTEXT ;; - esac -changequote([,])dnl - AC_SUBST([XGETTEXT_015]) - - dnl Search for GNU msgmerge 0.11 or newer in the PATH. - AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, - [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) - - dnl Installation directories. - dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we - dnl have to define it here, so that it can be used in po/Makefile. - test -n "$localedir" || localedir='${datadir}/locale' - AC_SUBST([localedir]) - - dnl Support for AM_XGETTEXT_OPTION. - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) - - AC_CONFIG_COMMANDS([po-directories], [[ - for ac_file in $CONFIG_FILES; do - # Support "outfile[:infile[:infile...]]" - case "$ac_file" in - *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - esac - # PO directories have a Makefile.in generated from Makefile.in.in. - case "$ac_file" in */Makefile.in) - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - # Treat a directory as a PO directory if and only if it has a - # POTFILES.in file. This allows packages to have multiple PO - # directories under different names or in different locations. - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - gt_tab=`printf '\t'` - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" - POMAKEFILEDEPS="POTFILES.in" - # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. - if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" - fi - ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' - POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" - else - # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assignment from automake < 1.5. - eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi - # Compute POFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) - # Compute UPDATEPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) - # Compute DUMMYPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) - # Compute GMOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= - UPDATEPOFILES= - DUMMYPOFILES= - GMOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" - GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. - INST_LINGUAS= - if test -n "$ALL_LINGUAS"; then - for presentlang in $ALL_LINGUAS; do - useit=no - if test "%UNSET%" != "$LINGUAS"; then - desiredlanguages="$LINGUAS" - else - desiredlanguages="$ALL_LINGUAS" - fi - for desiredlang in $desiredlanguages; do - # Use the presentlang catalog if desiredlang is - # a. equal to presentlang, or - # b. a variant of presentlang (because in this case, - # presentlang can be used as a fallback for messages - # which are not translated in the desiredlang catalog). - case "$desiredlang" in - "$presentlang"*) useit=yes;; - esac - done - if test $useit = yes; then - INST_LINGUAS="$INST_LINGUAS $presentlang" - fi - done - fi - CATALOGS= - if test -n "$INST_LINGUAS"; then - for lang in $INST_LINGUAS; do - CATALOGS="$CATALOGS $lang.gmo" - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" - sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in - *.orig | *.bak | *~) ;; - *) cat "$f" >> "$ac_dir/Makefile" ;; - esac - fi - done - fi - ;; - esac - done]], - [# Capture the value of obsolete ALL_LINGUAS because we need it to compute - # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it - # from automake < 1.5. - eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - ]) -]) - -dnl Postprocesses a Makefile in a directory containing PO files. -AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], -[ - # When this code is run, in config.status, two variables have already been - # set: - # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, - # - LINGUAS is the value of the environment variable LINGUAS at configure - # time. - -changequote(,)dnl - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - # Find a way to echo strings without interpreting backslash. - if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='echo' - else - if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='printf %s\n' - else - echo_func () { - cat < "$ac_file.tmp" - tab=`printf '\t'` - if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` - cat >> "$ac_file.tmp" < /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` - cat >> "$ac_file.tmp" <> "$ac_file.tmp" < -#include -/* The string "%2$d %1$d", with dollar characters protected from the shell's - dollar expansion (possibly an autoconf bug). */ -static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; -static char buf[100]; -int main () -{ - sprintf (buf, format, 33, 55); - return (strcmp (buf, "55 33") != 0); -}]])], - [gt_cv_func_printf_posix=yes], - [gt_cv_func_printf_posix=no], - [ - AC_EGREP_CPP([notposix], [ -#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ - notposix -#endif - ], - [gt_cv_func_printf_posix="guessing no"], - [gt_cv_func_printf_posix="guessing yes"]) - ]) - ]) - case $gt_cv_func_printf_posix in - *yes) - AC_DEFINE([HAVE_POSIX_PRINTF], [1], - [Define if your printf() function supports format strings with positions.]) - ;; - esac -]) diff --git a/m4/printf.m4 b/m4/printf.m4 deleted file mode 100644 index ef44f7851..000000000 --- a/m4/printf.m4 +++ /dev/null @@ -1,1570 +0,0 @@ -# printf.m4 serial 50 -dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Test whether the *printf family of functions supports the 'j', 'z', 't', -dnl 'L' size specifiers. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_sizes_c99. - -AC_DEFUN([gl_PRINTF_SIZES_C99], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports size specifiers as in C99], - [gl_cv_func_printf_sizes_c99], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -#include -#if HAVE_STDINT_H_WITH_UINTMAX -# include -#endif -#if HAVE_INTTYPES_H_WITH_UINTMAX -# include -#endif -static char buf[100]; -int main () -{ - int result = 0; -#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX - buf[0] = '\0'; - if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 - || strcmp (buf, "12345671 33") != 0) - result |= 1; -#endif - buf[0] = '\0'; - if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 - || strcmp (buf, "12345672 33") != 0) - result |= 2; - buf[0] = '\0'; - if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 - || strcmp (buf, "12345673 33") != 0) - result |= 4; - buf[0] = '\0'; - if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 - || strcmp (buf, "1.5 33") != 0) - result |= 8; - return result; -}]])], - [gl_cv_func_printf_sizes_c99=yes], - [gl_cv_func_printf_sizes_c99=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; - darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_printf_sizes_c99="guessing no";; - openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; - solaris*) gl_cv_func_printf_sizes_c99="guessing no";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_sizes_c99="guessing no";; - netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_sizes_c99="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports 'long double' -dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_long_double. - -AC_DEFUN([gl_PRINTF_LONG_DOUBLE], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports 'long double' arguments], - [gl_cv_func_printf_long_double], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[10000]; -int main () -{ - int result = 0; - buf[0] = '\0'; - if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 - || strcmp (buf, "1.750000 33") != 0) - result |= 1; - buf[0] = '\0'; - if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 - || strcmp (buf, "1.750000e+00 33") != 0) - result |= 2; - buf[0] = '\0'; - if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 - || strcmp (buf, "1.75 33") != 0) - result |= 4; - return result; -}]])], - [gl_cv_func_printf_long_double=yes], - [gl_cv_func_printf_long_double=no], - [ -changequote(,)dnl - case "$host_os" in - beos*) gl_cv_func_printf_long_double="guessing no";; - mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; - *) gl_cv_func_printf_long_double="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports infinite and NaN -dnl 'double' arguments and negative zero arguments in the %f, %e, %g -dnl directives. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_infinite. - -AC_DEFUN([gl_PRINTF_INFINITE], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], - [gl_cv_func_printf_infinite], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static int -strisnan (const char *string, size_t start_index, size_t end_index) -{ - if (start_index < end_index) - { - if (string[start_index] == '-') - start_index++; - if (start_index + 3 <= end_index - && memcmp (string + start_index, "nan", 3) == 0) - { - start_index += 3; - if (start_index == end_index - || (string[start_index] == '(' && string[end_index - 1] == ')')) - return 1; - } - } - return 0; -} -static int -have_minus_zero () -{ - static double plus_zero = 0.0; - double minus_zero = - plus_zero; - return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; -} -static char buf[10000]; -static double zero = 0.0; -int main () -{ - int result = 0; - if (sprintf (buf, "%f", 1.0 / zero) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 1; - if (sprintf (buf, "%f", -1.0 / zero) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 1; - if (sprintf (buf, "%f", zero / zero) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - if (sprintf (buf, "%e", 1.0 / zero) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 4; - if (sprintf (buf, "%e", -1.0 / zero) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 4; - if (sprintf (buf, "%e", zero / zero) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 8; - if (sprintf (buf, "%g", 1.0 / zero) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 16; - if (sprintf (buf, "%g", -1.0 / zero) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 16; - if (sprintf (buf, "%g", zero / zero) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 32; - /* This test fails on HP-UX 10.20. */ - if (have_minus_zero ()) - if (sprintf (buf, "%g", - zero) < 0 - || strcmp (buf, "-0") != 0) - result |= 64; - return result; -}]])], - [gl_cv_func_printf_infinite=yes], - [gl_cv_func_printf_infinite=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; - darwin*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; - hpux*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite="guessing no";; - netbsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_infinite="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports infinite and NaN -dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_infinite_long_double. - -AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], -[ - AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gl_BIGENDIAN]) - AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - dnl The user can set or unset the variable gl_printf_safe to indicate - dnl that he wishes a safe handling of non-IEEE-754 'long double' values. - if test -n "$gl_printf_safe"; then - AC_DEFINE([CHECK_PRINTF_SAFE], [1], - [Define if you wish *printf() functions that have a safe handling of - non-IEEE-754 'long double' values.]) - fi - case "$gl_cv_func_printf_long_double" in - *yes) - AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], - [gl_cv_func_printf_infinite_long_double], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -]GL_NOCRASH[ -#include -#include -#include -static int -strisnan (const char *string, size_t start_index, size_t end_index) -{ - if (start_index < end_index) - { - if (string[start_index] == '-') - start_index++; - if (start_index + 3 <= end_index - && memcmp (string + start_index, "nan", 3) == 0) - { - start_index += 3; - if (start_index == end_index - || (string[start_index] == '(' && string[end_index - 1] == ')')) - return 1; - } - } - return 0; -} -static char buf[10000]; -static long double zeroL = 0.0L; -int main () -{ - int result = 0; - nocrash_init(); - if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 1; - if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Le", zeroL / zeroL) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 1; - if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 - || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 - || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) - result |= 1; - if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 1; -#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE -/* Representation of an 80-bit 'long double' as an initializer for a sequence - of 'unsigned int' words. */ -# ifdef WORDS_BIGENDIAN -# define LDBL80_WORDS(exponent,manthi,mantlo) \ - { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ - ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ - (unsigned int) (mantlo) << 16 \ - } -# else -# define LDBL80_WORDS(exponent,manthi,mantlo) \ - { mantlo, manthi, exponent } -# endif - { /* Quiet NaN. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - } - { - /* Signalling NaN. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 2; - } - { /* Pseudo-NaN. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 4; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 4; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 4; - } - { /* Pseudo-Infinity. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 8; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 8; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 8; - } - { /* Pseudo-Zero. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 16; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 16; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 16; - } - { /* Unnormalized number. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 32; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 32; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 32; - } - { /* Pseudo-Denormal. */ - static union { unsigned int word[4]; long double value; } x = - { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; - if (sprintf (buf, "%Lf", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 64; - if (sprintf (buf, "%Le", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 64; - if (sprintf (buf, "%Lg", x.value) < 0 - || !strisnan (buf, 0, strlen (buf))) - result |= 64; - } -#endif - return result; -}]])], - [gl_cv_func_printf_infinite_long_double=yes], - [gl_cv_func_printf_infinite_long_double=no], - [ -changequote(,)dnl - case "$host_cpu" in - # Guess no on ia64, x86_64, i386. - ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; - *) - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; - hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite_long_double="guessing no";; - esac - ;; - esac -changequote([,])dnl - ]) - ]) - ;; - *) - gl_cv_func_printf_infinite_long_double="irrelevant" - ;; - esac -]) - -dnl Test whether the *printf family of functions supports the 'a' and 'A' -dnl conversion specifier for hexadecimal output of floating-point numbers. -dnl (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_directive_a. - -AC_DEFUN([gl_PRINTF_DIRECTIVE_A], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], - [gl_cv_func_printf_directive_a], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[100]; -static double zero = 0.0; -int main () -{ - int result = 0; - if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 - || (strcmp (buf, "0x1.922p+1 33") != 0 - && strcmp (buf, "0x3.244p+0 33") != 0 - && strcmp (buf, "0x6.488p-1 33") != 0 - && strcmp (buf, "0xc.91p-2 33") != 0)) - result |= 1; - if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0 - || (strcmp (buf, "-0X1.922P+1 33") != 0 - && strcmp (buf, "-0X3.244P+0 33") != 0 - && strcmp (buf, "-0X6.488P-1 33") != 0 - && strcmp (buf, "-0XC.91P-2 33") != 0)) - result |= 2; - /* This catches a FreeBSD 6.1 bug: it doesn't round. */ - if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 - || (strcmp (buf, "0x1.83p+0 33") != 0 - && strcmp (buf, "0x3.05p-1 33") != 0 - && strcmp (buf, "0x6.0ap-2 33") != 0 - && strcmp (buf, "0xc.14p-3 33") != 0)) - result |= 4; - /* This catches a FreeBSD 6.1 bug. See - */ - if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 - || buf[0] == '0') - result |= 8; - /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ - if (sprintf (buf, "%.1a", 1.999) < 0 - || (strcmp (buf, "0x1.0p+1") != 0 - && strcmp (buf, "0x2.0p+0") != 0 - && strcmp (buf, "0x4.0p-1") != 0 - && strcmp (buf, "0x8.0p-2") != 0)) - result |= 16; - /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a - glibc 2.4 bug . */ - if (sprintf (buf, "%.1La", 1.999L) < 0 - || (strcmp (buf, "0x1.0p+1") != 0 - && strcmp (buf, "0x2.0p+0") != 0 - && strcmp (buf, "0x4.0p-1") != 0 - && strcmp (buf, "0x8.0p-2") != 0)) - result |= 32; - return result; -}]])], - [gl_cv_func_printf_directive_a=yes], - [gl_cv_func_printf_directive_a=no], - [ - case "$host_os" in - # Guess yes on glibc >= 2.5 systems. - *-gnu*) - AC_EGREP_CPP([BZ2908], [ - #include - #ifdef __GNU_LIBRARY__ - #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__ - BZ2908 - #endif - #endif - ], - [gl_cv_func_printf_directive_a="guessing yes"], - [gl_cv_func_printf_directive_a="guessing no"]) - ;; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_a="guessing no";; - esac - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports the %F format -dnl directive. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_directive_f. - -AC_DEFUN([gl_PRINTF_DIRECTIVE_F], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the 'F' directive], - [gl_cv_func_printf_directive_f], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[100]; -static double zero = 0.0; -int main () -{ - int result = 0; - if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 - || strcmp (buf, "1234567.000000 33") != 0) - result |= 1; - if (sprintf (buf, "%F", 1.0 / zero) < 0 - || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0)) - result |= 2; - /* This catches a Cygwin 1.5.x bug. */ - if (sprintf (buf, "%.F", 1234.0) < 0 - || strcmp (buf, "1234") != 0) - result |= 4; - return result; -}]])], - [gl_cv_func_printf_directive_f=yes], - [gl_cv_func_printf_directive_f=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; - darwin*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; - solaris*) gl_cv_func_printf_sizes_c99="guessing no";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_f="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports the %n format -dnl directive. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_printf_directive_n. - -AC_DEFUN([gl_PRINTF_DIRECTIVE_N], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the 'n' directive], - [gl_cv_func_printf_directive_n], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -#ifdef _MSC_VER -/* See page about "Parameter Validation" on msdn.microsoft.com. */ -static void cdecl -invalid_parameter_handler (const wchar_t *expression, - const wchar_t *function, - const wchar_t *file, unsigned int line, - uintptr_t dummy) -{ - exit (1); -} -#endif -static char fmtstring[10]; -static char buf[100]; -int main () -{ - int count = -1; -#ifdef _MSC_VER - _set_invalid_parameter_handler (invalid_parameter_handler); -#endif - /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) - support %n in format strings in read-only memory but not in writable - memory. */ - strcpy (fmtstring, "%d %n"); - if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 - || strcmp (buf, "123 ") != 0 - || count != 4) - return 1; - return 0; -}]])], - [gl_cv_func_printf_directive_n=yes], - [gl_cv_func_printf_directive_n=no], - [ -changequote(,)dnl - case "$host_os" in - mingw*) gl_cv_func_printf_directive_n="guessing no";; - *) gl_cv_func_printf_directive_n="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports the %ls format -dnl directive and in particular, when a precision is specified, whether -dnl the functions stop converting the wide string argument when the number -dnl of bytes that have been produced by this conversion equals or exceeds -dnl the precision. -dnl Result is gl_cv_func_printf_directive_ls. - -AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the 'ls' directive], - [gl_cv_func_printf_directive_ls], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -#include -int main () -{ - int result = 0; - char buf[100]; - /* Test whether %ls works at all. - This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on - Cygwin 1.5. */ - { - static const wchar_t wstring[] = { 'a', 'b', 'c', 0 }; - buf[0] = '\0'; - if (sprintf (buf, "%ls", wstring) < 0 - || strcmp (buf, "abc") != 0) - result |= 1; - } - /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an - assertion failure inside libc), but not on OpenBSD 4.0. */ - { - static const wchar_t wstring[] = { 'a', 0 }; - buf[0] = '\0'; - if (sprintf (buf, "%ls", wstring) < 0 - || strcmp (buf, "a") != 0) - result |= 2; - } - /* Test whether precisions in %ls are supported as specified in ISO C 99 - section 7.19.6.1: - "If a precision is specified, no more than that many bytes are written - (including shift sequences, if any), and the array shall contain a - null wide character if, to equal the multibyte character sequence - length given by the precision, the function would need to access a - wide character one past the end of the array." - This test fails on Solaris 10. */ - { - static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 }; - buf[0] = '\0'; - if (sprintf (buf, "%.2ls", wstring) < 0 - || strcmp (buf, "ab") != 0) - result |= 8; - } - return result; -}]])], - [gl_cv_func_printf_directive_ls=yes], - [gl_cv_func_printf_directive_ls=no], - [ -changequote(,)dnl - case "$host_os" in - openbsd*) gl_cv_func_printf_directive_ls="guessing no";; - irix*) gl_cv_func_printf_directive_ls="guessing no";; - solaris*) gl_cv_func_printf_directive_ls="guessing no";; - cygwin*) gl_cv_func_printf_directive_ls="guessing no";; - beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; - *) gl_cv_func_printf_directive_ls="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports POSIX/XSI format -dnl strings with positions. (POSIX:2001) -dnl Result is gl_cv_func_printf_positions. - -AC_DEFUN([gl_PRINTF_POSITIONS], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], - [gl_cv_func_printf_positions], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* The string "%2$d %1$d", with dollar characters protected from the shell's - dollar expansion (possibly an autoconf bug). */ -static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; -static char buf[100]; -int main () -{ - sprintf (buf, format, 33, 55); - return (strcmp (buf, "55 33") != 0); -}]])], - [gl_cv_func_printf_positions=yes], - [gl_cv_func_printf_positions=no], - [ -changequote(,)dnl - case "$host_os" in - netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) - gl_cv_func_printf_positions="guessing no";; - beos*) gl_cv_func_printf_positions="guessing no";; - mingw* | pw*) gl_cv_func_printf_positions="guessing no";; - *) gl_cv_func_printf_positions="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports POSIX/XSI format -dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001) -dnl Result is gl_cv_func_printf_flag_grouping. - -AC_DEFUN([gl_PRINTF_FLAG_GROUPING], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the grouping flag], - [gl_cv_func_printf_flag_grouping], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[100]; -int main () -{ - if (sprintf (buf, "%'d %d", 1234567, 99) < 0 - || buf[strlen (buf) - 1] != '9') - return 1; - return 0; -}]])], - [gl_cv_func_printf_flag_grouping=yes], - [gl_cv_func_printf_flag_grouping=no], - [ -changequote(,)dnl - case "$host_os" in - cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; - netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; - mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; - *) gl_cv_func_printf_flag_grouping="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports the - flag correctly. -dnl (ISO C99.) See -dnl -dnl Result is gl_cv_func_printf_flag_leftadjust. - -AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], - [gl_cv_func_printf_flag_leftadjust], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[100]; -int main () -{ - /* Check that a '-' flag is not annihilated by a negative width. */ - if (sprintf (buf, "a%-*sc", -3, "b") < 0 - || strcmp (buf, "ab c") != 0) - return 1; - return 0; -}]])], - [gl_cv_func_printf_flag_leftadjust=yes], - [gl_cv_func_printf_flag_leftadjust=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on HP-UX 11. - hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess no on HP-UX 10 and older. - hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; - # Guess yes otherwise. - *) gl_cv_func_printf_flag_leftadjust="guessing yes";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports padding of non-finite -dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See -dnl -dnl Result is gl_cv_func_printf_flag_zero. - -AC_DEFUN([gl_PRINTF_FLAG_ZERO], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports the zero flag correctly], - [gl_cv_func_printf_flag_zero], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[100]; -static double zero = 0.0; -int main () -{ - if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 - || (strcmp (buf, " inf") != 0 - && strcmp (buf, " infinity") != 0)) - return 1; - return 0; -}]])], - [gl_cv_func_printf_flag_zero=yes], - [gl_cv_func_printf_flag_zero=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_flag_zero="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_flag_zero="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions supports large precisions. -dnl On mingw, precisions larger than 512 are treated like 512, in integer, -dnl floating-point or pointer output. On Solaris 10/x86, precisions larger -dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC, -dnl precisions larger than 510 in floating-point output yield wrong results. -dnl On AIX 7.1, precisions larger than 998 in floating-point output yield -dnl wrong results. On BeOS, precisions larger than 1044 crash the program. -dnl Result is gl_cv_func_printf_precision. - -AC_DEFUN([gl_PRINTF_PRECISION], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf supports large precisions], - [gl_cv_func_printf_precision], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static char buf[5000]; -int main () -{ - int result = 0; -#ifdef __BEOS__ - /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ - return 1; -#endif - if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) - result |= 1; - if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5) - result |= 2; - if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5 - || buf[0] != '1') - result |= 4; - if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5 - || buf[0] != '1') - result |= 4; - return result; -}]])], - [gl_cv_func_printf_precision=yes], - [gl_cv_func_printf_precision=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess no only on Solaris, native Windows, and BeOS systems. - solaris*) gl_cv_func_printf_precision="guessing no" ;; - mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; - beos*) gl_cv_func_printf_precision="guessing no" ;; - *) gl_cv_func_printf_precision="guessing yes" ;; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the *printf family of functions recovers gracefully in case -dnl of an out-of-memory condition, or whether it crashes the entire program. -dnl Result is gl_cv_func_printf_enomem. - -AC_DEFUN([gl_PRINTF_ENOMEM], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gl_MULTIARCH]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether printf survives out-of-memory conditions], - [gl_cv_func_printf_enomem], - [ - gl_cv_func_printf_enomem="guessing no" - if test "$cross_compiling" = no; then - if test $APPLE_UNIVERSAL_BUILD = 0; then - AC_LANG_CONFTEST([AC_LANG_SOURCE([ -]GL_NOCRASH[ -changequote(,)dnl -#include -#include -#include -#include -#include -int main() -{ - struct rlimit limit; - int ret; - nocrash_init (); - /* Some printf implementations allocate temporary space with malloc. */ - /* On BSD systems, malloc() is limited by RLIMIT_DATA. */ -#ifdef RLIMIT_DATA - if (getrlimit (RLIMIT_DATA, &limit) < 0) - return 77; - if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) - limit.rlim_max = 5000000; - limit.rlim_cur = limit.rlim_max; - if (setrlimit (RLIMIT_DATA, &limit) < 0) - return 77; -#endif - /* On Linux systems, malloc() is limited by RLIMIT_AS. */ -#ifdef RLIMIT_AS - if (getrlimit (RLIMIT_AS, &limit) < 0) - return 77; - if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) - limit.rlim_max = 5000000; - limit.rlim_cur = limit.rlim_max; - if (setrlimit (RLIMIT_AS, &limit) < 0) - return 77; -#endif - /* Some printf implementations allocate temporary space on the stack. */ -#ifdef RLIMIT_STACK - if (getrlimit (RLIMIT_STACK, &limit) < 0) - return 77; - if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) - limit.rlim_max = 5000000; - limit.rlim_cur = limit.rlim_max; - if (setrlimit (RLIMIT_STACK, &limit) < 0) - return 77; -#endif - ret = printf ("%.5000000f", 1.0); - return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); -} -changequote([,])dnl - ])]) - if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then - (./conftest 2>&AS_MESSAGE_LOG_FD - result=$? - _AS_ECHO_LOG([\$? = $result]) - if test $result != 0 && test $result != 77; then result=1; fi - exit $result - ) >/dev/null 2>/dev/null - case $? in - 0) gl_cv_func_printf_enomem="yes" ;; - 77) gl_cv_func_printf_enomem="guessing no" ;; - *) gl_cv_func_printf_enomem="no" ;; - esac - else - gl_cv_func_printf_enomem="guessing no" - fi - rm -fr conftest* - else - dnl A universal build on Apple Mac OS X platforms. - dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode. - dnl But we need a configuration result that is valid in both modes. - gl_cv_func_printf_enomem="guessing no" - fi - fi - if test "$gl_cv_func_printf_enomem" = "guessing no"; then -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on Solaris. - solaris*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on AIX. - aix*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on HP-UX/hppa. - hpux*) case "$host_cpu" in - hppa*) gl_cv_func_printf_enomem="guessing yes";; - *) gl_cv_func_printf_enomem="guessing no";; - esac - ;; - # Guess yes on IRIX. - irix*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on OSF/1. - osf*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_enomem="guessing yes";; - # Guess yes on Haiku. - haiku*) gl_cv_func_printf_enomem="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_enomem="guessing no";; - esac -changequote([,])dnl - fi - ]) -]) - -dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) -dnl Result is ac_cv_func_snprintf. - -AC_DEFUN([gl_SNPRINTF_PRESENCE], -[ - AC_CHECK_FUNCS_ONCE([snprintf]) -]) - -dnl Test whether the string produced by the snprintf function is always NUL -dnl terminated. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_snprintf_truncation_c99. - -AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([gl_SNPRINTF_PRESENCE]) - AC_CACHE_CHECK([whether snprintf truncates the result as in C99], - [gl_cv_func_snprintf_truncation_c99], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#if HAVE_SNPRINTF -# define my_snprintf snprintf -#else -# include -static int my_snprintf (char *buf, int size, const char *format, ...) -{ - va_list args; - int ret; - va_start (args, format); - ret = vsnprintf (buf, size, format, args); - va_end (args); - return ret; -} -#endif -static char buf[100]; -int main () -{ - strcpy (buf, "ABCDEF"); - my_snprintf (buf, 3, "%d %d", 4567, 89); - if (memcmp (buf, "45\0DEF", 6) != 0) - return 1; - return 0; -}]])], - [gl_cv_func_snprintf_truncation_c99=yes], - [gl_cv_func_snprintf_truncation_c99=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; - darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5] | solaris2.[0-5].*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; - hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_truncation_c99="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the return value of the snprintf function is the number -dnl of bytes (excluding the terminating NUL) that would have been produced -dnl if the buffer had been large enough. (ISO C99, POSIX:2001) -dnl For example, this test program fails on IRIX 6.5: -dnl --------------------------------------------------------------------- -dnl #include -dnl int main() -dnl { -dnl static char buf[8]; -dnl int retval = snprintf (buf, 3, "%d", 12345); -dnl return retval >= 0 && retval < 3; -dnl } -dnl --------------------------------------------------------------------- -dnl Result is gl_cv_func_snprintf_retval_c99. - -AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([gl_SNPRINTF_PRESENCE]) - AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], - [gl_cv_func_snprintf_retval_c99], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#if HAVE_SNPRINTF -# define my_snprintf snprintf -#else -# include -static int my_snprintf (char *buf, int size, const char *format, ...) -{ - va_list args; - int ret; - va_start (args, format); - ret = vsnprintf (buf, size, format, args); - va_end (args); - return ret; -} -#endif -static char buf[100]; -int main () -{ - strcpy (buf, "ABCDEF"); - if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7) - return 1; - if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7) - return 2; - if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7) - return 3; - return 0; -}]])], - [gl_cv_func_snprintf_retval_c99=yes], - [gl_cv_func_snprintf_retval_c99=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; - darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_retval_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; - solaris*) gl_cv_func_printf_sizes_c99="guessing no";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; - aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_retval_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_retval_c99="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the snprintf function supports the %n format directive -dnl also in truncated portions of the format string. (ISO C99, POSIX:2001) -dnl Result is gl_cv_func_snprintf_directive_n. - -AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([gl_SNPRINTF_PRESENCE]) - AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], - [gl_cv_func_snprintf_directive_n], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#if HAVE_SNPRINTF -# define my_snprintf snprintf -#else -# include -static int my_snprintf (char *buf, int size, const char *format, ...) -{ - va_list args; - int ret; - va_start (args, format); - ret = vsnprintf (buf, size, format, args); - va_end (args); - return ret; -} -#endif -static char fmtstring[10]; -static char buf[100]; -int main () -{ - int count = -1; - /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) - support %n in format strings in read-only memory but not in writable - memory. */ - strcpy (fmtstring, "%d %n"); - my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); - if (count != 6) - return 1; - return 0; -}]])], - [gl_cv_func_snprintf_directive_n=yes], - [gl_cv_func_snprintf_directive_n=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; - darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5] | solaris2.[0-5].*) - gl_cv_func_snprintf_directive_n="guessing no";; - solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; - aix*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - osf*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_directive_n="guessing no";; - netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_directive_n="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_directive_n="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl Test whether the snprintf function, when passed a size = 1, writes any -dnl output without bounds in this case, behaving like sprintf. This is the -dnl case on Linux libc5. -dnl Result is gl_cv_func_snprintf_size1. - -AC_DEFUN([gl_SNPRINTF_SIZE1], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gl_SNPRINTF_PRESENCE]) - AC_CACHE_CHECK([whether snprintf respects a size of 1], - [gl_cv_func_snprintf_size1], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#if HAVE_SNPRINTF -# define my_snprintf snprintf -#else -# include -static int my_snprintf (char *buf, int size, const char *format, ...) -{ - va_list args; - int ret; - va_start (args, format); - ret = vsnprintf (buf, size, format, args); - va_end (args); - return ret; -} -#endif -int main() -{ - static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; - my_snprintf (buf, 1, "%d", 12345); - return buf[1] != 'E'; -}]])], - [gl_cv_func_snprintf_size1=yes], - [gl_cv_func_snprintf_size1=no], - [gl_cv_func_snprintf_size1="guessing yes"]) - ]) -]) - -dnl Test whether the vsnprintf function, when passed a zero size, produces no -dnl output. (ISO C99, POSIX:2001) -dnl For example, snprintf nevertheless writes a NUL byte in this case -dnl on OSF/1 5.1: -dnl --------------------------------------------------------------------- -dnl #include -dnl int main() -dnl { -dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; -dnl snprintf (buf, 0, "%d", 12345); -dnl return buf[0] != 'D'; -dnl } -dnl --------------------------------------------------------------------- -dnl And vsnprintf writes any output without bounds in this case, behaving like -dnl vsprintf, on HP-UX 11 and OSF/1 5.1: -dnl --------------------------------------------------------------------- -dnl #include -dnl #include -dnl static int my_snprintf (char *buf, int size, const char *format, ...) -dnl { -dnl va_list args; -dnl int ret; -dnl va_start (args, format); -dnl ret = vsnprintf (buf, size, format, args); -dnl va_end (args); -dnl return ret; -dnl } -dnl int main() -dnl { -dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; -dnl my_snprintf (buf, 0, "%d", 12345); -dnl return buf[0] != 'D'; -dnl } -dnl --------------------------------------------------------------------- -dnl Result is gl_cv_func_vsnprintf_zerosize_c99. - -AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], - [gl_cv_func_vsnprintf_zerosize_c99], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -static int my_snprintf (char *buf, int size, const char *format, ...) -{ - va_list args; - int ret; - va_start (args, format); - ret = vsnprintf (buf, size, format, args); - va_end (args); - return ret; -} -int main() -{ - static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; - my_snprintf (buf, 0, "%d", 12345); - return buf[0] != 'D'; -}]])], - [gl_cv_func_vsnprintf_zerosize_c99=yes], - [gl_cv_func_vsnprintf_zerosize_c99=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Cygwin. - cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5] | solaris2.[0-5].*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on mingw. - mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - esac -changequote([,])dnl - ]) - ]) -]) - -dnl The results of these tests on various platforms are: -dnl -dnl 1 = gl_PRINTF_SIZES_C99 -dnl 2 = gl_PRINTF_LONG_DOUBLE -dnl 3 = gl_PRINTF_INFINITE -dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE -dnl 5 = gl_PRINTF_DIRECTIVE_A -dnl 6 = gl_PRINTF_DIRECTIVE_F -dnl 7 = gl_PRINTF_DIRECTIVE_N -dnl 8 = gl_PRINTF_DIRECTIVE_LS -dnl 9 = gl_PRINTF_POSITIONS -dnl 10 = gl_PRINTF_FLAG_GROUPING -dnl 11 = gl_PRINTF_FLAG_LEFTADJUST -dnl 12 = gl_PRINTF_FLAG_ZERO -dnl 13 = gl_PRINTF_PRECISION -dnl 14 = gl_PRINTF_ENOMEM -dnl 15 = gl_SNPRINTF_PRESENCE -dnl 16 = gl_SNPRINTF_TRUNCATION_C99 -dnl 17 = gl_SNPRINTF_RETVAL_C99 -dnl 18 = gl_SNPRINTF_DIRECTIVE_N -dnl 19 = gl_SNPRINTF_SIZE1 -dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 -dnl -dnl 1 = checking whether printf supports size specifiers as in C99... -dnl 2 = checking whether printf supports 'long double' arguments... -dnl 3 = checking whether printf supports infinite 'double' arguments... -dnl 4 = checking whether printf supports infinite 'long double' arguments... -dnl 5 = checking whether printf supports the 'a' and 'A' directives... -dnl 6 = checking whether printf supports the 'F' directive... -dnl 7 = checking whether printf supports the 'n' directive... -dnl 8 = checking whether printf supports the 'ls' directive... -dnl 9 = checking whether printf supports POSIX/XSI format strings with positions... -dnl 10 = checking whether printf supports the grouping flag... -dnl 11 = checking whether printf supports the left-adjust flag correctly... -dnl 12 = checking whether printf supports the zero flag correctly... -dnl 13 = checking whether printf supports large precisions... -dnl 14 = checking whether printf survives out-of-memory conditions... -dnl 15 = checking for snprintf... -dnl 16 = checking whether snprintf truncates the result as in C99... -dnl 17 = checking whether snprintf returns a byte count as in C99... -dnl 18 = checking whether snprintf fully supports the 'n' directive... -dnl 19 = checking whether snprintf respects a size of 1... -dnl 20 = checking whether vsnprintf respects a zero size as in C99... -dnl -dnl . = yes, # = no. -dnl -dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . -dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . -dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . -dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . -dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . -dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . -dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . -dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . -dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . -dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . . -dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . -dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . -dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # -dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . -dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . -dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . . -dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . -dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # -dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # -dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . -dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # -dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # -dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . -dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? -dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . -dnl Haiku . . . # # # . # . . . . . ? . . ? . . . -dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . -dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . -dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . -dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . -dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . diff --git a/m4/progtest.m4 b/m4/progtest.m4 deleted file mode 100644 index 7b3912329..000000000 --- a/m4/progtest.m4 +++ /dev/null @@ -1,91 +0,0 @@ -# progtest.m4 serial 7 (gettext-0.18.2) -dnl Copyright (C) 1996-2003, 2005, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1996. - -AC_PREREQ([2.50]) - -# Search path for a program which passes the given test. - -dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, -dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -AC_DEFUN([AM_PATH_PROG_WITH_TEST], -[ -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "$2", so it can be a program name with args. -set dummy $2; ac_word=[$]2 -AC_MSG_CHECKING([for $ac_word]) -AC_CACHE_VAL([ac_cv_path_$1], -[case "[$]$1" in - [[\\/]]* | ?:[[\\/]]*) - ac_cv_path_$1="[$]$1" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in ifelse([$5], , $PATH, [$5]); do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD - if [$3]; then - ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" -dnl If no 4th arg is given, leave the cache variable unset, -dnl so AC_PATH_PROGS will keep looking. -ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" -])dnl - ;; -esac])dnl -$1="$ac_cv_path_$1" -if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then - AC_MSG_RESULT([$][$1]) -else - AC_MSG_RESULT([no]) -fi -AC_SUBST([$1])dnl -]) diff --git a/m4/rawmemchr.m4 b/m4/rawmemchr.m4 deleted file mode 100644 index 8c500547c..000000000 --- a/m4/rawmemchr.m4 +++ /dev/null @@ -1,20 +0,0 @@ -# rawmemchr.m4 serial 2 -dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_RAWMEMCHR], -[ - dnl Persuade glibc to declare rawmemchr(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_FUNCS([rawmemchr]) - if test $ac_cv_func_rawmemchr = no; then - HAVE_RAWMEMCHR=0 - fi -]) - -# Prerequisites of lib/strchrnul.c. -AC_DEFUN([gl_PREREQ_RAWMEMCHR], [:]) diff --git a/m4/realloc.m4 b/m4/realloc.m4 deleted file mode 100644 index d477fb470..000000000 --- a/m4/realloc.m4 +++ /dev/null @@ -1,76 +0,0 @@ -# realloc.m4 serial 13 -dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -m4_version_prereq([2.70], [] ,[ - -# This is taken from the following Autoconf patch: -# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 -AC_DEFUN([_AC_FUNC_REALLOC_IF], -[ - AC_REQUIRE([AC_HEADER_STDC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles - AC_CHECK_HEADERS([stdlib.h]) - AC_CACHE_CHECK([for GNU libc compatible realloc], - [ac_cv_func_realloc_0_nonnull], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H - # include - #else - char *realloc (); - #endif - ]], - [[return ! realloc (0, 0);]]) - ], - [ac_cv_func_realloc_0_nonnull=yes], - [ac_cv_func_realloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* \ - | hpux* | solaris* | cygwin* | mingw*) - ac_cv_func_realloc_0_nonnull=yes ;; - # If we don't know, assume the worst. - *) ac_cv_func_realloc_0_nonnull=no ;; - esac - ]) - ]) - AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2]) -])# AC_FUNC_REALLOC - -]) - -# gl_FUNC_REALLOC_GNU -# ------------------- -# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace -# realloc if it is not. -AC_DEFUN([gl_FUNC_REALLOC_GNU], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - dnl _AC_FUNC_REALLOC_IF is defined in Autoconf. - _AC_FUNC_REALLOC_IF( - [AC_DEFINE([HAVE_REALLOC_GNU], [1], - [Define to 1 if your system has a GNU libc compatible 'realloc' - function, and to 0 otherwise.])], - [AC_DEFINE([HAVE_REALLOC_GNU], [0]) - REPLACE_REALLOC=1 - ]) -])# gl_FUNC_REALLOC_GNU - -# gl_FUNC_REALLOC_POSIX -# --------------------- -# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it -# fails), and replace realloc if it is not. -AC_DEFUN([gl_FUNC_REALLOC_POSIX], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) - if test $gl_cv_func_malloc_posix = yes; then - AC_DEFINE([HAVE_REALLOC_POSIX], [1], - [Define if the 'realloc' function is POSIX compliant.]) - else - REPLACE_REALLOC=1 - fi -]) diff --git a/m4/regex.m4 b/m4/regex.m4 deleted file mode 100644 index 3334c1041..000000000 --- a/m4/regex.m4 +++ /dev/null @@ -1,261 +0,0 @@ -# serial 64 - -# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -dnl Initially derived from code in GNU grep. -dnl Mostly written by Jim Meyering. - -AC_PREREQ([2.50]) - -AC_DEFUN([gl_REGEX], -[ - AC_ARG_WITH([included-regex], - [AS_HELP_STRING([--without-included-regex], - [don't compile regex; this is the default on systems - with recent-enough versions of the GNU C Library - (use with caution on other systems).])]) - - case $with_included_regex in #( - yes|no) ac_use_included_regex=$with_included_regex - ;; - '') - # If the system regex support is good enough that it passes the - # following run test, then default to *not* using the included regex.c. - # If cross compiling, assume the test would fail and use the included - # regex.c. - AC_CHECK_DECLS_ONCE([alarm]) - AC_CACHE_CHECK([for working re_compile_pattern], - [gl_cv_func_re_compile_pattern_working], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - - #include - #include - #include - #if HAVE_DECL_ALARM - # include - # include - #endif - ]], - [[int result = 0; - static struct re_pattern_buffer regex; - unsigned char folded_chars[UCHAR_MAX + 1]; - int i; - const char *s; - struct re_registers regs; - -#if HAVE_DECL_ALARM - /* Some builds of glibc go into an infinite loop on this test. */ - signal (SIGALRM, SIG_DFL); - alarm (2); -#endif - if (setlocale (LC_ALL, "en_US.UTF-8")) - { - { - /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html - This test needs valgrind to catch the bug on Debian - GNU/Linux 3.1 x86, but it might catch the bug better - on other platforms and it shouldn't hurt to try the - test here. */ - static char const pat[] = "insert into"; - static char const data[] = - "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; - re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE - | RE_ICASE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern (pat, sizeof pat - 1, ®ex); - if (s) - result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, ®s) - != -1) - result |= 1; - } - - { - /* This test is from glibc bug 15078. - The test case is from Andreas Schwab in - . - */ - static char const pat[] = "[^x]x"; - static char const data[] = - "\xe1\x80\x80\xe1\x80\xbb\xe1\x80\xbd\xe1\x80\x94\xe1\x80" - "\xba\xe1\x80\xaf\xe1\x80\x95\xe1\x80\xbax"; - re_set_syntax (0); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern (pat, sizeof pat - 1, ®ex); - if (s) - result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, 0) - != 21) - result |= 1; - } - - if (! setlocale (LC_ALL, "C")) - return 1; - } - - /* This test is from glibc bug 3957, reported by Andrew Mackey. */ - re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("a[^x]b", 6, ®ex); - if (s) - result |= 2; - /* This should fail, but succeeds for glibc-2.5. */ - else if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) - result |= 2; - - /* This regular expression is from Spencer ere test number 75 - in grep-2.3. */ - re_set_syntax (RE_SYNTAX_POSIX_EGREP); - memset (®ex, 0, sizeof regex); - for (i = 0; i <= UCHAR_MAX; i++) - folded_chars[i] = i; - regex.translate = folded_chars; - s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); - /* This should fail with _Invalid character class name_ error. */ - if (!s) - result |= 4; - - /* Ensure that [b-a] is diagnosed as invalid, when - using RE_NO_EMPTY_RANGES. */ - re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("a[b-a]", 6, ®ex); - if (s == 0) - result |= 8; - - /* This should succeed, but does not for glibc-2.1.3. */ - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("{1", 2, ®ex); - if (s) - result |= 8; - - /* The following example is derived from a problem report - against gawk from Jorge Stolfi . */ - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("[an\371]*n", 7, ®ex); - if (s) - result |= 8; - /* This should match, but does not for glibc-2.2.1. */ - else if (re_match (®ex, "an", 2, 0, ®s) != 2) - result |= 8; - - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("x", 1, ®ex); - if (s) - result |= 8; - /* glibc-2.2.93 does not work with a negative RANGE argument. */ - else if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) - result |= 8; - - /* The version of regex.c in older versions of gnulib - ignored RE_ICASE. Detect that problem too. */ - re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("x", 1, ®ex); - if (s) - result |= 16; - else if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) - result |= 16; - - /* Catch a bug reported by Vin Shelton in - http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html - */ - re_set_syntax (RE_SYNTAX_POSIX_BASIC - & ~RE_CONTEXT_INVALID_DUP - & ~RE_NO_EMPTY_RANGES); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); - if (s) - result |= 32; - - /* REG_STARTEND was added to glibc on 2004-01-15. - Reject older versions. */ - if (! REG_STARTEND) - result |= 64; - -#if 0 - /* It would be nice to reject hosts whose regoff_t values are too - narrow (including glibc on hosts with 64-bit ptrdiff_t and - 32-bit int), but we should wait until glibc implements this - feature. Otherwise, support for equivalence classes and - multibyte collation symbols would always be broken except - when compiling --without-included-regex. */ - if (sizeof (regoff_t) < sizeof (ptrdiff_t) - || sizeof (regoff_t) < sizeof (ssize_t)) - result |= 64; -#endif - - return result; - ]])], - [gl_cv_func_re_compile_pattern_working=yes], - [gl_cv_func_re_compile_pattern_working=no], - dnl When crosscompiling, assume it is not working. - [gl_cv_func_re_compile_pattern_working=no])]) - case $gl_cv_func_re_compile_pattern_working in #( - yes) ac_use_included_regex=no;; #( - no) ac_use_included_regex=yes;; - esac - ;; - *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) - ;; - esac - - if test $ac_use_included_regex = yes; then - AC_DEFINE([_REGEX_INCLUDE_LIMITS_H], [1], - [Define if you want to include , so that it - consistently overrides 's RE_DUP_MAX.]) - AC_DEFINE([_REGEX_LARGE_OFFSETS], [1], - [Define if you want regoff_t to be at least as wide POSIX requires.]) - AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], - [Define to rpl_re_syntax_options if the replacement should be used.]) - AC_DEFINE([re_set_syntax], [rpl_re_set_syntax], - [Define to rpl_re_set_syntax if the replacement should be used.]) - AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern], - [Define to rpl_re_compile_pattern if the replacement should be used.]) - AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap], - [Define to rpl_re_compile_fastmap if the replacement should be used.]) - AC_DEFINE([re_search], [rpl_re_search], - [Define to rpl_re_search if the replacement should be used.]) - AC_DEFINE([re_search_2], [rpl_re_search_2], - [Define to rpl_re_search_2 if the replacement should be used.]) - AC_DEFINE([re_match], [rpl_re_match], - [Define to rpl_re_match if the replacement should be used.]) - AC_DEFINE([re_match_2], [rpl_re_match_2], - [Define to rpl_re_match_2 if the replacement should be used.]) - AC_DEFINE([re_set_registers], [rpl_re_set_registers], - [Define to rpl_re_set_registers if the replacement should be used.]) - AC_DEFINE([re_comp], [rpl_re_comp], - [Define to rpl_re_comp if the replacement should be used.]) - AC_DEFINE([re_exec], [rpl_re_exec], - [Define to rpl_re_exec if the replacement should be used.]) - AC_DEFINE([regcomp], [rpl_regcomp], - [Define to rpl_regcomp if the replacement should be used.]) - AC_DEFINE([regexec], [rpl_regexec], - [Define to rpl_regexec if the replacement should be used.]) - AC_DEFINE([regerror], [rpl_regerror], - [Define to rpl_regerror if the replacement should be used.]) - AC_DEFINE([regfree], [rpl_regfree], - [Define to rpl_regfree if the replacement should be used.]) - fi -]) - -# Prerequisites of lib/regex.c and lib/regex_internal.c. -AC_DEFUN([gl_PREREQ_REGEX], -[ - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([AC_C_INLINE]) - AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - AC_REQUIRE([gl_EEMALLOC]) - AC_CHECK_HEADERS([libintl.h]) - AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) - AC_CHECK_DECLS([isblank], [], [], [[#include ]]) -]) diff --git a/m4/size_max.m4 b/m4/size_max.m4 deleted file mode 100644 index 4b247abc0..000000000 --- a/m4/size_max.m4 +++ /dev/null @@ -1,79 +0,0 @@ -# size_max.m4 serial 10 -dnl Copyright (C) 2003, 2005-2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([gl_SIZE_MAX], -[ - AC_CHECK_HEADERS([stdint.h]) - dnl First test whether the system already has SIZE_MAX. - AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ - gl_cv_size_max= - AC_EGREP_CPP([Found it], [ -#include -#if HAVE_STDINT_H -#include -#endif -#ifdef SIZE_MAX -Found it -#endif -], [gl_cv_size_max=yes]) - if test -z "$gl_cv_size_max"; then - dnl Define it ourselves. Here we assume that the type 'size_t' is not wider - dnl than the type 'unsigned long'. Try hard to find a definition that can - dnl be used in a preprocessor #if, i.e. doesn't contain a cast. - AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1], - [#include -#include ], [size_t_bits_minus_1=]) - AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)], - [#include ], [fits_in_uint=]) - if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then - if test $fits_in_uint = 1; then - dnl Even though SIZE_MAX fits in an unsigned int, it must be of type - dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - extern size_t foo; - extern unsigned long foo; - ]], - [[]])], - [fits_in_uint=0]) - fi - dnl We cannot use 'expr' to simplify this expression, because 'expr' - dnl works only with 'long' integers in the host environment, while we - dnl might be cross-compiling from a 32-bit platform to a 64-bit platform. - if test $fits_in_uint = 1; then - gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" - else - gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" - fi - else - dnl Shouldn't happen, but who knows... - gl_cv_size_max='((size_t)~(size_t)0)' - fi - fi - ]) - if test "$gl_cv_size_max" != yes; then - AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max], - [Define as the maximum value of type 'size_t', if the system doesn't define it.]) - fi - dnl Don't redefine SIZE_MAX in config.h if config.h is re-included after - dnl . Remember that the #undef in AH_VERBATIM gets replaced with - dnl #define by AC_DEFINE_UNQUOTED. - AH_VERBATIM([SIZE_MAX], -[/* Define as the maximum value of type 'size_t', if the system doesn't define - it. */ -#ifndef SIZE_MAX -# undef SIZE_MAX -#endif]) -]) - -dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. -dnl Remove this when we can assume autoconf >= 2.61. -m4_ifdef([AC_COMPUTE_INT], [], [ - AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) -]) diff --git a/m4/sleep.m4 b/m4/sleep.m4 deleted file mode 100644 index a27baa6d5..000000000 --- a/m4/sleep.m4 +++ /dev/null @@ -1,62 +0,0 @@ -# sleep.m4 serial 7 -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_SLEEP], -[ - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - dnl We expect to see the declaration of sleep() in a header file. - dnl Older versions of mingw have a sleep() function that is an alias to - dnl _sleep() in MSVCRT. It has a different signature than POSIX sleep(): - dnl it takes the number of milliseconds as argument and returns void. - dnl mingw does not declare this function. - AC_CHECK_DECLS([sleep], , , [[#include ]]) - AC_CHECK_FUNCS_ONCE([sleep]) - if test $ac_cv_have_decl_sleep != yes; then - HAVE_SLEEP=0 - else - dnl Cygwin 1.5.x has a bug where sleep can't exceed 49.7 days. - AC_CACHE_CHECK([for working sleep], [gl_cv_func_sleep_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -static void -handle_alarm (int sig) -{ - if (sig != SIGALRM) - _exit (2); -} -]], [[ - /* Failure to compile this test due to missing alarm is okay, - since all such platforms (mingw) also lack sleep. */ - unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ - unsigned int remaining; - signal (SIGALRM, handle_alarm); - alarm (1); - remaining = sleep (pentecost); - if (remaining > pentecost) - return 3; - if (remaining <= pentecost - 10) - return 4; - return 0; - ]])], - [gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_sleep_works="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_sleep_works="guessing no" ;; - esac - ])]) - case "$gl_cv_func_sleep_works" in - *yes) ;; - *) - REPLACE_SLEEP=1 - ;; - esac - fi -]) diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4 deleted file mode 100644 index 633813434..000000000 --- a/m4/ssize_t.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# ssize_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. -dnl Test whether ssize_t is defined. - -AC_DEFUN([gt_TYPE_SSIZE_T], -[ - AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[int x = sizeof (ssize_t *) + sizeof (ssize_t); - return !x;]])], - [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) - if test $gt_cv_ssize_t = no; then - AC_DEFINE([ssize_t], [int], - [Define as a signed type of the same size as size_t.]) - fi -]) diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 deleted file mode 100644 index a866ff670..000000000 --- a/m4/stdalign.m4 +++ /dev/null @@ -1,52 +0,0 @@ -# Check for stdalign.h that conforms to C11. - -dnl Copyright 2011-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Prepare for substituting if it is not supported. - -AC_DEFUN([gl_STDALIGN_H], -[ - AC_CACHE_CHECK([for working stdalign.h], - [gl_cv_header_working_stdalign_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include - - /* Test that alignof yields a result consistent with offsetof. - This catches GCC bug 52023 - . */ - #ifdef __cplusplus - template struct alignof_helper { char a; t b; }; - # define ao(type) offsetof (alignof_helper, b) - #else - # define ao(type) offsetof (struct { char a; type b; }, b) - #endif - char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1]; - char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; - char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; - - /* Test _Alignas only on platforms where gnulib can help. */ - #if \ - (__GNUC__ || __IBMC__ || __IBMCPP__ \ - || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) - struct alignas_test { char c; char alignas (8) alignas_8; }; - char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 - ? 1 : -1]; - #endif - ]])], - [gl_cv_header_working_stdalign_h=yes], - [gl_cv_header_working_stdalign_h=no])]) - - if test $gl_cv_header_working_stdalign_h = yes; then - STDALIGN_H='' - else - STDALIGN_H='stdalign.h' - fi - - AC_SUBST([STDALIGN_H]) - AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) -]) diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 deleted file mode 100644 index 80d5559ab..000000000 --- a/m4/stdbool.m4 +++ /dev/null @@ -1,100 +0,0 @@ -# Check for stdbool.h that conforms to C99. - -dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -#serial 5 - -# Prepare for substituting if it is not supported. - -AC_DEFUN([AM_STDBOOL_H], -[ - AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) - - # Define two additional variables used in the Makefile substitution. - - if test "$ac_cv_header_stdbool_h" = yes; then - STDBOOL_H='' - else - STDBOOL_H='stdbool.h' - fi - AC_SUBST([STDBOOL_H]) - AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"]) - - if test "$ac_cv_type__Bool" = yes; then - HAVE__BOOL=1 - else - HAVE__BOOL=0 - fi - AC_SUBST([HAVE__BOOL]) -]) - -# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. -AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) - -# This version of the macro is needed in autoconf <= 2.68. - -AC_DEFUN([AC_CHECK_HEADER_STDBOOL], - [AC_CACHE_CHECK([for stdbool.h that conforms to C99], - [ac_cv_header_stdbool_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ - #include - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" - #endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - /* See body of main program for 'e'. */ - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - ]], - [[ - bool e = &s; - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - ]])], - [ac_cv_header_stdbool_h=yes], - [ac_cv_header_stdbool_h=no])]) - AC_CHECK_TYPES([_Bool]) -]) diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 deleted file mode 100644 index 5da8ab1ec..000000000 --- a/m4/stddef_h.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl A placeholder for POSIX 2008 , for platforms that have issues. -# stddef_h.m4 serial 4 -dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_STDDEF_H], -[ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) - STDDEF_H= - if test $gt_cv_c_wchar_t = no; then - HAVE_WCHAR_T=0 - STDDEF_H=stddef.h - fi - AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], - [gl_cv_decl_null_works], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include - int test[2 * (sizeof NULL == sizeof (void *)) -1]; -]])], - [gl_cv_decl_null_works=yes], - [gl_cv_decl_null_works=no])]) - if test $gl_cv_decl_null_works = no; then - REPLACE_NULL=1 - STDDEF_H=stddef.h - fi - AC_SUBST([STDDEF_H]) - AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) - if test -n "$STDDEF_H"; then - gl_NEXT_HEADERS([stddef.h]) - fi -]) - -AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -]) - -AC_DEFUN([gl_STDDEF_H_DEFAULTS], -[ - dnl Assume proper GNU behavior unless another module says otherwise. - REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) - HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) -]) diff --git a/m4/stdint.m4 b/m4/stdint.m4 deleted file mode 100644 index 27cdcdb9a..000000000 --- a/m4/stdint.m4 +++ /dev/null @@ -1,484 +0,0 @@ -# stdint.m4 serial 43 -dnl Copyright (C) 2001-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert and Bruno Haible. -dnl Test whether is supported or must be substituted. - -AC_DEFUN_ONCE([gl_STDINT_H], -[ - AC_PREREQ([2.59])dnl - - dnl Check for long long int and unsigned long long int. - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - if test $ac_cv_type_long_long_int = yes; then - HAVE_LONG_LONG_INT=1 - else - HAVE_LONG_LONG_INT=0 - fi - AC_SUBST([HAVE_LONG_LONG_INT]) - AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - if test $ac_cv_type_unsigned_long_long_int = yes; then - HAVE_UNSIGNED_LONG_LONG_INT=1 - else - HAVE_UNSIGNED_LONG_LONG_INT=0 - fi - AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT]) - - dnl Check for , in the same way as gl_WCHAR_H does. - AC_CHECK_HEADERS_ONCE([wchar.h]) - if test $ac_cv_header_wchar_h = yes; then - HAVE_WCHAR_H=1 - else - HAVE_WCHAR_H=0 - fi - AC_SUBST([HAVE_WCHAR_H]) - - dnl Check for . - dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. - if test $ac_cv_header_inttypes_h = yes; then - HAVE_INTTYPES_H=1 - else - HAVE_INTTYPES_H=0 - fi - AC_SUBST([HAVE_INTTYPES_H]) - - dnl Check for . - dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. - if test $ac_cv_header_sys_types_h = yes; then - HAVE_SYS_TYPES_H=1 - else - HAVE_SYS_TYPES_H=0 - fi - AC_SUBST([HAVE_SYS_TYPES_H]) - - gl_CHECK_NEXT_HEADERS([stdint.h]) - if test $ac_cv_header_stdint_h = yes; then - HAVE_STDINT_H=1 - else - HAVE_STDINT_H=0 - fi - AC_SUBST([HAVE_STDINT_H]) - - dnl Now see whether we need a substitute . - if test $ac_cv_header_stdint_h = yes; then - AC_CACHE_CHECK([whether stdint.h conforms to C99], - [gl_cv_header_working_stdint_h], - [gl_cv_header_working_stdint_h=no - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ -#include -/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ -#if !(defined WCHAR_MIN && defined WCHAR_MAX) -#error "WCHAR_MIN, WCHAR_MAX not defined in " -#endif -] -gl_STDINT_INCLUDES -[ -#ifdef INT8_MAX -int8_t a1 = INT8_MAX; -int8_t a1min = INT8_MIN; -#endif -#ifdef INT16_MAX -int16_t a2 = INT16_MAX; -int16_t a2min = INT16_MIN; -#endif -#ifdef INT32_MAX -int32_t a3 = INT32_MAX; -int32_t a3min = INT32_MIN; -#endif -#ifdef INT64_MAX -int64_t a4 = INT64_MAX; -int64_t a4min = INT64_MIN; -#endif -#ifdef UINT8_MAX -uint8_t b1 = UINT8_MAX; -#else -typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; -#endif -#ifdef UINT16_MAX -uint16_t b2 = UINT16_MAX; -#endif -#ifdef UINT32_MAX -uint32_t b3 = UINT32_MAX; -#endif -#ifdef UINT64_MAX -uint64_t b4 = UINT64_MAX; -#endif -int_least8_t c1 = INT8_C (0x7f); -int_least8_t c1max = INT_LEAST8_MAX; -int_least8_t c1min = INT_LEAST8_MIN; -int_least16_t c2 = INT16_C (0x7fff); -int_least16_t c2max = INT_LEAST16_MAX; -int_least16_t c2min = INT_LEAST16_MIN; -int_least32_t c3 = INT32_C (0x7fffffff); -int_least32_t c3max = INT_LEAST32_MAX; -int_least32_t c3min = INT_LEAST32_MIN; -int_least64_t c4 = INT64_C (0x7fffffffffffffff); -int_least64_t c4max = INT_LEAST64_MAX; -int_least64_t c4min = INT_LEAST64_MIN; -uint_least8_t d1 = UINT8_C (0xff); -uint_least8_t d1max = UINT_LEAST8_MAX; -uint_least16_t d2 = UINT16_C (0xffff); -uint_least16_t d2max = UINT_LEAST16_MAX; -uint_least32_t d3 = UINT32_C (0xffffffff); -uint_least32_t d3max = UINT_LEAST32_MAX; -uint_least64_t d4 = UINT64_C (0xffffffffffffffff); -uint_least64_t d4max = UINT_LEAST64_MAX; -int_fast8_t e1 = INT_FAST8_MAX; -int_fast8_t e1min = INT_FAST8_MIN; -int_fast16_t e2 = INT_FAST16_MAX; -int_fast16_t e2min = INT_FAST16_MIN; -int_fast32_t e3 = INT_FAST32_MAX; -int_fast32_t e3min = INT_FAST32_MIN; -int_fast64_t e4 = INT_FAST64_MAX; -int_fast64_t e4min = INT_FAST64_MIN; -uint_fast8_t f1 = UINT_FAST8_MAX; -uint_fast16_t f2 = UINT_FAST16_MAX; -uint_fast32_t f3 = UINT_FAST32_MAX; -uint_fast64_t f4 = UINT_FAST64_MAX; -#ifdef INTPTR_MAX -intptr_t g = INTPTR_MAX; -intptr_t gmin = INTPTR_MIN; -#endif -#ifdef UINTPTR_MAX -uintptr_t h = UINTPTR_MAX; -#endif -intmax_t i = INTMAX_MAX; -uintmax_t j = UINTMAX_MAX; - -#include /* for CHAR_BIT */ -#define TYPE_MINIMUM(t) \ - ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) -#define TYPE_MAXIMUM(t) \ - ((t) ((t) 0 < (t) -1 \ - ? (t) -1 \ - : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) -struct s { - int check_PTRDIFF: - PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) - && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) - ? 1 : -1; - /* Detect bug in FreeBSD 6.0 / ia64. */ - int check_SIG_ATOMIC: - SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) - && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) - ? 1 : -1; - int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; - int check_WCHAR: - WCHAR_MIN == TYPE_MINIMUM (wchar_t) - && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) - ? 1 : -1; - /* Detect bug in mingw. */ - int check_WINT: - WINT_MIN == TYPE_MINIMUM (wint_t) - && WINT_MAX == TYPE_MAXIMUM (wint_t) - ? 1 : -1; - - /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ - int check_UINT8_C: - (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; - int check_UINT16_C: - (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; - - /* Detect bugs in OpenBSD 3.9 stdint.h. */ -#ifdef UINT8_MAX - int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; -#endif -#ifdef UINT16_MAX - int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; -#endif -#ifdef UINT32_MAX - int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; -#endif -#ifdef UINT64_MAX - int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; -#endif - int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; - int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; - int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; - int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; - int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; - int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; - int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; - int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; - int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; - int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; - int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; -}; - ]])], - [dnl Determine whether the various *_MIN, *_MAX macros are usable - dnl in preprocessor expression. We could do it by compiling a test - dnl program for each of these macros. It is faster to run a program - dnl that inspects the macro expansion. - dnl This detects a bug on HP-UX 11.23/ia64. - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[ -#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ -#include -] -gl_STDINT_INCLUDES -[ -#include -#include -#define MVAL(macro) MVAL1(macro) -#define MVAL1(expression) #expression -static const char *macro_values[] = - { -#ifdef INT8_MAX - MVAL (INT8_MAX), -#endif -#ifdef INT16_MAX - MVAL (INT16_MAX), -#endif -#ifdef INT32_MAX - MVAL (INT32_MAX), -#endif -#ifdef INT64_MAX - MVAL (INT64_MAX), -#endif -#ifdef UINT8_MAX - MVAL (UINT8_MAX), -#endif -#ifdef UINT16_MAX - MVAL (UINT16_MAX), -#endif -#ifdef UINT32_MAX - MVAL (UINT32_MAX), -#endif -#ifdef UINT64_MAX - MVAL (UINT64_MAX), -#endif - NULL - }; -]], [[ - const char **mv; - for (mv = macro_values; *mv != NULL; mv++) - { - const char *value = *mv; - /* Test whether it looks like a cast expression. */ - if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 - || strncmp (value, "((unsigned short)"/*)*/, 17) == 0 - || strncmp (value, "((unsigned char)"/*)*/, 16) == 0 - || strncmp (value, "((int)"/*)*/, 6) == 0 - || strncmp (value, "((signed short)"/*)*/, 15) == 0 - || strncmp (value, "((signed char)"/*)*/, 14) == 0) - return mv - macro_values + 1; - } - return 0; -]])], - [gl_cv_header_working_stdint_h=yes], - [], - [dnl When cross-compiling, assume it works. - gl_cv_header_working_stdint_h=yes - ]) - ]) - ]) - fi - if test "$gl_cv_header_working_stdint_h" = yes; then - STDINT_H= - else - dnl Check for , and for - dnl (used in Linux libc4 >= 4.6.7 and libc5). - AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h]) - if test $ac_cv_header_sys_inttypes_h = yes; then - HAVE_SYS_INTTYPES_H=1 - else - HAVE_SYS_INTTYPES_H=0 - fi - AC_SUBST([HAVE_SYS_INTTYPES_H]) - if test $ac_cv_header_sys_bitypes_h = yes; then - HAVE_SYS_BITYPES_H=1 - else - HAVE_SYS_BITYPES_H=0 - fi - AC_SUBST([HAVE_SYS_BITYPES_H]) - - gl_STDINT_TYPE_PROPERTIES - STDINT_H=stdint.h - fi - AC_SUBST([STDINT_H]) - AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) -]) - -dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) -dnl Determine the size of each of the given types in bits. -AC_DEFUN([gl_STDINT_BITSIZEOF], -[ - dnl Use a shell loop, to avoid bloating configure, and - dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into - dnl config.h.in, - dnl - extra AC_SUBST calls, so that the right substitutions are made. - m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), - [Define to the number of bits in type ']gltype['.])]) - for gltype in $1 ; do - AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], - [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT], - [$2 -#include ], [result=unknown]) - eval gl_cv_bitsizeof_${gltype}=\$result - ]) - eval result=\$gl_cv_bitsizeof_${gltype} - if test $result = unknown; then - dnl Use a nonempty default, because some compilers, such as IRIX 5 cc, - dnl do a syntax check even on unused #if conditions and give an error - dnl on valid C code like this: - dnl #if 0 - dnl # if > 32 - dnl # endif - dnl #endif - result=0 - fi - GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` - AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) - eval BITSIZEOF_${GLTYPE}=\$result - done - m4_foreach_w([gltype], [$1], - [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) -]) - -dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) -dnl Determine the signedness of each of the given types. -dnl Define HAVE_SIGNED_TYPE if type is signed. -AC_DEFUN([gl_CHECK_TYPES_SIGNED], -[ - dnl Use a shell loop, to avoid bloating configure, and - dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into - dnl config.h.in, - dnl - extra AC_SUBST calls, so that the right substitutions are made. - m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), - [Define to 1 if ']gltype[' is a signed integer type.])]) - for gltype in $1 ; do - AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([$2[ - int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])], - result=yes, result=no) - eval gl_cv_type_${gltype}_signed=\$result - ]) - eval result=\$gl_cv_type_${gltype}_signed - GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` - if test "$result" = yes; then - AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1]) - eval HAVE_SIGNED_${GLTYPE}=1 - else - eval HAVE_SIGNED_${GLTYPE}=0 - fi - done - m4_foreach_w([gltype], [$1], - [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) -]) - -dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) -dnl Determine the suffix to use for integer constants of the given types. -dnl Define t_SUFFIX for each such type. -AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], -[ - dnl Use a shell loop, to avoid bloating configure, and - dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into - dnl config.h.in, - dnl - extra AC_SUBST calls, so that the right substitutions are made. - m4_foreach_w([gltype], [$1], - [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], - [Define to l, ll, u, ul, ull, etc., as suitable for - constants of type ']gltype['.])]) - for gltype in $1 ; do - AC_CACHE_CHECK([for $gltype integer literal suffix], - [gl_cv_type_${gltype}_suffix], - [eval gl_cv_type_${gltype}_suffix=no - eval result=\$gl_cv_type_${gltype}_signed - if test "$result" = yes; then - glsufu= - else - glsufu=u - fi - for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do - case $glsuf in - '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; - ui64)gltype1='unsigned __int64';; - esac - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([$2[ - extern $gltype foo; - extern $gltype1 foo;]])], - [eval gl_cv_type_${gltype}_suffix=\$glsuf]) - eval result=\$gl_cv_type_${gltype}_suffix - test "$result" != no && break - done]) - GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` - eval result=\$gl_cv_type_${gltype}_suffix - test "$result" = no && result= - eval ${GLTYPE}_SUFFIX=\$result - AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) - done - m4_foreach_w([gltype], [$1], - [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) -]) - -dnl gl_STDINT_INCLUDES -AC_DEFUN([gl_STDINT_INCLUDES], -[[ - /* BSD/OS 4.0.1 has a bug: , and must be - included before . */ - #include - #include - #if HAVE_WCHAR_H - # include - # include - # include - #endif -]]) - -dnl gl_STDINT_TYPE_PROPERTIES -dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t -dnl of interest to stdint.in.h. -AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], -[ - AC_REQUIRE([gl_MULTIARCH]) - if test $APPLE_UNIVERSAL_BUILD = 0; then - gl_STDINT_BITSIZEOF([ptrdiff_t size_t], - [gl_STDINT_INCLUDES]) - fi - gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t], - [gl_STDINT_INCLUDES]) - gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t], - [gl_STDINT_INCLUDES]) - gl_cv_type_ptrdiff_t_signed=yes - gl_cv_type_size_t_signed=no - if test $APPLE_UNIVERSAL_BUILD = 0; then - gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t], - [gl_STDINT_INCLUDES]) - fi - gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], - [gl_STDINT_INCLUDES]) - - dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99 - dnl requirement that wint_t is "unchanged by default argument promotions". - dnl In this case gnulib's and override wint_t. - dnl Set the variable BITSIZEOF_WINT_T accordingly. - if test $BITSIZEOF_WINT_T -lt 32; then - BITSIZEOF_WINT_T=32 - fi -]) - -dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. -dnl Remove this when we can assume autoconf >= 2.61. -m4_ifdef([AC_COMPUTE_INT], [], [ - AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) -]) - -# Hey Emacs! -# Local Variables: -# indent-tabs-mode: nil -# End: diff --git a/m4/stdint_h.m4 b/m4/stdint_h.m4 deleted file mode 100644 index 511ab4e9c..000000000 --- a/m4/stdint_h.m4 +++ /dev/null @@ -1,27 +0,0 @@ -# stdint_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -# Define HAVE_STDINT_H_WITH_UINTMAX if exists, -# doesn't clash with , and declares uintmax_t. - -AC_DEFUN([gl_AC_HEADER_STDINT_H], -[ - AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include ]], - [[uintmax_t i = (uintmax_t) -1; return !i;]])], - [gl_cv_header_stdint_h=yes], - [gl_cv_header_stdint_h=no])]) - if test $gl_cv_header_stdint_h = yes; then - AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], - [Define if exists, doesn't clash with , - and declares uintmax_t. ]) - fi -]) diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 deleted file mode 100644 index ebade067d..000000000 --- a/m4/stdio_h.m4 +++ /dev/null @@ -1,194 +0,0 @@ -# stdio_h.m4 serial 43 -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_STDIO_H], -[ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - gl_NEXT_HEADERS([stdio.h]) - - dnl No need to create extra modules for these functions. Everyone who uses - dnl likely needs them. - GNULIB_FSCANF=1 - gl_MODULE_INDICATOR([fscanf]) - GNULIB_SCANF=1 - gl_MODULE_INDICATOR([scanf]) - GNULIB_FGETC=1 - GNULIB_GETC=1 - GNULIB_GETCHAR=1 - GNULIB_FGETS=1 - GNULIB_FREAD=1 - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING - dnl or GNULIB_NONBLOCKING redundant. - m4_ifdef([gl_NONBLOCKING_IO], [ - gl_NONBLOCKING_IO - if test $gl_cv_have_nonblocking != yes; then - REPLACE_STDIO_READ_FUNCS=1 - AC_LIBOBJ([stdio-read]) - fi - ]) - - dnl No need to create extra modules for these functions. Everyone who uses - dnl likely needs them. - GNULIB_FPRINTF=1 - GNULIB_PRINTF=1 - GNULIB_VFPRINTF=1 - GNULIB_VPRINTF=1 - GNULIB_FPUTC=1 - GNULIB_PUTC=1 - GNULIB_PUTCHAR=1 - GNULIB_FPUTS=1 - GNULIB_PUTS=1 - GNULIB_FWRITE=1 - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or - dnl GNULIB_SIGPIPE redundant. - m4_ifdef([gl_SIGNAL_SIGPIPE], [ - gl_SIGNAL_SIGPIPE - if test $gl_cv_header_signal_h_SIGPIPE != yes; then - REPLACE_STDIO_WRITE_FUNCS=1 - AC_LIBOBJ([stdio-write]) - fi - ]) - dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" - dnl "expected source file, required through AC_LIBSOURCES, not found". It is - dnl also an optimization, to avoid performing a configure check whose result - dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING - dnl or GNULIB_NONBLOCKING redundant. - m4_ifdef([gl_NONBLOCKING_IO], [ - gl_NONBLOCKING_IO - if test $gl_cv_have_nonblocking != yes; then - REPLACE_STDIO_WRITE_FUNCS=1 - AC_LIBOBJ([stdio-write]) - fi - ]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use, and which is not - dnl guaranteed by both C89 and C11. - gl_WARN_ON_USE_PREPARE([[#include - ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen - renameat snprintf tmpfile vdprintf vsnprintf]) -]) - -AC_DEFUN([gl_STDIO_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_STDIO_H_DEFAULTS], -[ - GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF]) - GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) - GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN]) - GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) - GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC]) - GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS]) - GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) - GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF]) - GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) - GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) - GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) - GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS]) - GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD]) - GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) - GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF]) - GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) - GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) - GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) - GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) - GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE]) - GNULIB_GETC=0; AC_SUBST([GNULIB_GETC]) - GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR]) - GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) - GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) - GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF]) - GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX]) - GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE]) - GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR]) - GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN]) - GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF]) - GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX]) - GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC]) - GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR]) - GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS]) - GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE]) - GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME]) - GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT]) - GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF]) - GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) - GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) - GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING]) - GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) - GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) - GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) - GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF]) - GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF]) - GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) - GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) - GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) - GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF]) - GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX]) - GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) - GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) - HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) - HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) - HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) - HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) - HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) - HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) - HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) - HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) - HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) - HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) - HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE]) - HAVE_POPEN=1; AC_SUBST([HAVE_POPEN]) - HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT]) - HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) - HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF]) - REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF]) - REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE]) - REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) - REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) - REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) - REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) - REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) - REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) - REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK]) - REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO]) - REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL]) - REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) - REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM]) - REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE]) - REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF]) - REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR]) - REPLACE_POPEN=0; AC_SUBST([REPLACE_POPEN]) - REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF]) - REPLACE_REMOVE=0; AC_SUBST([REPLACE_REMOVE]) - REPLACE_RENAME=0; AC_SUBST([REPLACE_RENAME]) - REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT]) - REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) - REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) - REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS]) - REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS]) - REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE]) - REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) - REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF]) - REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF]) - REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF]) - REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF]) - REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF]) -]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 deleted file mode 100644 index 2027ab3c1..000000000 --- a/m4/stdlib_h.m4 +++ /dev/null @@ -1,117 +0,0 @@ -# stdlib_h.m4 serial 42 -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_STDLIB_H], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - gl_NEXT_HEADERS([stdlib.h]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use, and which is not - dnl guaranteed by C89. - gl_WARN_ON_USE_PREPARE([[#include -#if HAVE_SYS_LOADAVG_H -# include -#endif -#if HAVE_RANDOM_H -# include -#endif - ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt - initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps - posix_openpt ptsname ptsname_r random random_r realpath rpmatch - secure_getenv setenv setstate setstate_r srandom srandom_r - strtod strtoll strtoull unlockpt unsetenv]) -]) - -AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_STDLIB_H_DEFAULTS], -[ - GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) - GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) - GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) - GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) - GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG]) - GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT]) - GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT]) - GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX]) - GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC]) - GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP]) - GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP]) - GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) - GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) - GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) - GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT]) - GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) - GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R]) - GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) - GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM]) - GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) - GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX]) - GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH]) - GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH]) - GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV]) - GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV]) - GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) - GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) - GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) - GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX]) - GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) - GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) - GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) - HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) - HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) - HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) - HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) - HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) - HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) - HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) - HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) - HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) - HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) - HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) - HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) - HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) - HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) - HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) - HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) - HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) - HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) - HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) - HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) - HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) - HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) - HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) - HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) - HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) - HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) - HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) - HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) - REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) - REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) - REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) - REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) - REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) - REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) - REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) - REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) - REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) - REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) - REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) - REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) - REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) - REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) - REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) -]) diff --git a/m4/strcase.m4 b/m4/strcase.m4 deleted file mode 100644 index 22bf57c95..000000000 --- a/m4/strcase.m4 +++ /dev/null @@ -1,45 +0,0 @@ -# strcase.m4 serial 11 -dnl Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_STRCASE], -[ - gl_FUNC_STRCASECMP - gl_FUNC_STRNCASECMP -]) - -AC_DEFUN([gl_FUNC_STRCASECMP], -[ - AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) - AC_CHECK_FUNCS([strcasecmp]) - if test $ac_cv_func_strcasecmp = no; then - HAVE_STRCASECMP=0 - fi -]) - -AC_DEFUN([gl_FUNC_STRNCASECMP], -[ - AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) - AC_CHECK_FUNCS([strncasecmp]) - if test $ac_cv_func_strncasecmp = yes; then - HAVE_STRNCASECMP=1 - else - HAVE_STRNCASECMP=0 - fi - AC_CHECK_DECLS([strncasecmp]) - if test $ac_cv_have_decl_strncasecmp = no; then - HAVE_DECL_STRNCASECMP=0 - fi -]) - -# Prerequisites of lib/strcasecmp.c. -AC_DEFUN([gl_PREREQ_STRCASECMP], [ - : -]) - -# Prerequisites of lib/strncasecmp.c. -AC_DEFUN([gl_PREREQ_STRNCASECMP], [ - : -]) diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4 deleted file mode 100644 index b59eda9d7..000000000 --- a/m4/strchrnul.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# strchrnul.m4 serial 9 -dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_STRCHRNUL], -[ - dnl Persuade glibc to declare strchrnul(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_FUNCS([strchrnul]) - if test $ac_cv_func_strchrnul = no; then - HAVE_STRCHRNUL=0 - else - AC_CACHE_CHECK([whether strchrnul works], - [gl_cv_func_strchrnul_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include /* for strchrnul */ -]], [[const char *buf = "a"; - return strchrnul (buf, 'b') != buf + 1; - ]])], - [gl_cv_func_strchrnul_works=yes], - [gl_cv_func_strchrnul_works=no], - [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10 - AC_EGREP_CPP([Lucky user], - [ -#if defined __CYGWIN__ - #include - #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9) - Lucky user - #endif -#else - Lucky user -#endif - ], - [gl_cv_func_strchrnul_works="guessing yes"], - [gl_cv_func_strchrnul_works="guessing no"]) - ]) - ]) - case "$gl_cv_func_strchrnul_works" in - *yes) ;; - *) REPLACE_STRCHRNUL=1 ;; - esac - fi -]) - -# Prerequisites of lib/strchrnul.c. -AC_DEFUN([gl_PREREQ_STRCHRNUL], [:]) diff --git a/m4/strerror.m4 b/m4/strerror.m4 deleted file mode 100644 index 3989844b2..000000000 --- a/m4/strerror.m4 +++ /dev/null @@ -1,96 +0,0 @@ -# strerror.m4 serial 17 -dnl Copyright (C) 2002, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_STRERROR], -[ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_REQUIRE([gl_HEADER_ERRNO_H]) - AC_REQUIRE([gl_FUNC_STRERROR_0]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ - AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) - ]) - if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then - AC_CACHE_CHECK([for working strerror function], - [gl_cv_func_working_strerror], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - ]], - [[if (!*strerror (-2)) return 1;]])], - [gl_cv_func_working_strerror=yes], - [gl_cv_func_working_strerror=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_working_strerror="guessing no" ;; - esac - ]) - ]) - case "$gl_cv_func_working_strerror" in - *yes) ;; - *) - dnl The system's strerror() fails to return a string for out-of-range - dnl integers. Replace it. - REPLACE_STRERROR=1 - ;; - esac - m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ - dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's - dnl buffer, we must replace strerror. - case "$gl_cv_func_strerror_r_works" in - *no) REPLACE_STRERROR=1 ;; - esac - ]) - else - dnl The system's strerror() cannot know about the new errno values we add - dnl to , or any fix for strerror(0). Replace it. - REPLACE_STRERROR=1 - fi -]) - -dnl Detect if strerror(0) passes (that is, does not set errno, and does not -dnl return a string that matches strerror(-1)). -AC_DEFUN([gl_FUNC_STRERROR_0], -[ - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - REPLACE_STRERROR_0=0 - AC_CACHE_CHECK([whether strerror(0) succeeds], - [gl_cv_func_strerror_0_works], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include - ]], - [[int result = 0; - char *str; - errno = 0; - str = strerror (0); - if (!*str) result |= 1; - if (errno) result |= 2; - if (strstr (str, "nknown") || strstr (str, "ndefined")) - result |= 4; - return result;]])], - [gl_cv_func_strerror_0_works=yes], - [gl_cv_func_strerror_0_works=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_strerror_0_works="guessing no" ;; - esac - ]) - ]) - case "$gl_cv_func_strerror_0_works" in - *yes) ;; - *) - REPLACE_STRERROR_0=1 - AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0) - does not return a message implying success.]) - ;; - esac -]) diff --git a/m4/string_h.m4 b/m4/string_h.m4 deleted file mode 100644 index cc5fbbb32..000000000 --- a/m4/string_h.m4 +++ /dev/null @@ -1,120 +0,0 @@ -# Configure a GNU-like replacement for . - -# Copyright (C) 2007-2013 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 21 - -# Written by Paul Eggert. - -AC_DEFUN([gl_HEADER_STRING_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_HEADER_STRING_H_BODY]) -]) - -AC_DEFUN([gl_HEADER_STRING_H_BODY], -[ - AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - gl_NEXT_HEADERS([string.h]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use, and which is not - dnl guaranteed by C89. - gl_WARN_ON_USE_PREPARE([[#include - ]], - [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul - strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r - strerror_r strsignal strverscmp]) -]) - -AC_DEFUN([gl_STRING_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], -[ - GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL]) - GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL]) - GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) - GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) - GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) - GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) - GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) - GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) - GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) - GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) - GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) - GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) - GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) - GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) - GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) - GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) - GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) - GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) - GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) - GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) - GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) - GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) - GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) - GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) - GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) - GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) - GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) - GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) - GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) - GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) - GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) - GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) - GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) - GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) - GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) - GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) - GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) - HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) - HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) - HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) - HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) - HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) - HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) - HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) - HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) - HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) - HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) - HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) - HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) - HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) - HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) - HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) - HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) - HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) - HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) - HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) - HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) - REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) - REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) - REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) - REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) - REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) - REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) - REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) - REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) - REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) - REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) - REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) - REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) - REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) - REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) - UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) -]) diff --git a/m4/strings_h.m4 b/m4/strings_h.m4 deleted file mode 100644 index 76ef2424e..000000000 --- a/m4/strings_h.m4 +++ /dev/null @@ -1,52 +0,0 @@ -# Configure a replacement for . -# serial 6 - -# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_HEADER_STRINGS_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_HEADER_STRINGS_H_BODY]) -]) - -AC_DEFUN([gl_HEADER_STRINGS_H_BODY], -[ - AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) - - gl_CHECK_NEXT_HEADERS([strings.h]) - if test $ac_cv_header_strings_h = yes; then - HAVE_STRINGS_H=1 - else - HAVE_STRINGS_H=0 - fi - AC_SUBST([HAVE_STRINGS_H]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[ - /* Minix 3.1.8 has a bug: must be included before - . */ - #include - #include - ]], [ffs strcasecmp strncasecmp]) -]) - -AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -]) - -AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS], -[ - GNULIB_FFS=0; AC_SUBST([GNULIB_FFS]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_FFS=1; AC_SUBST([HAVE_FFS]) - HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) - HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) -]) diff --git a/m4/strndup.m4 b/m4/strndup.m4 deleted file mode 100644 index a1f82743f..000000000 --- a/m4/strndup.m4 +++ /dev/null @@ -1,55 +0,0 @@ -# strndup.m4 serial 21 -dnl Copyright (C) 2002-2003, 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_STRNDUP], -[ - dnl Persuade glibc to declare strndup(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_DECLS_ONCE([strndup]) - AC_CHECK_FUNCS_ONCE([strndup]) - if test $ac_cv_have_decl_strndup = no; then - HAVE_DECL_STRNDUP=0 - fi - - if test $ac_cv_func_strndup = yes; then - HAVE_STRNDUP=1 - # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. - AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works], - [AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[#include - #include ]], [[ -#if !HAVE_DECL_STRNDUP - extern - #ifdef __cplusplus - "C" - #endif - char *strndup (const char *, size_t); -#endif - char *s; - s = strndup ("some longer string", 15); - free (s); - s = strndup ("shorter string", 13); - return s[13] != '\0';]])], - [gl_cv_func_strndup_works=yes], - [gl_cv_func_strndup_works=no], - [ -changequote(,)dnl - case $host_os in - aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";; - *) gl_cv_func_strndup_works="guessing yes";; - esac -changequote([,])dnl - ])]) - case $gl_cv_func_strndup_works in - *no) REPLACE_STRNDUP=1 ;; - esac - else - HAVE_STRNDUP=0 - fi -]) diff --git a/m4/strnlen.m4 b/m4/strnlen.m4 deleted file mode 100644 index eae82b772..000000000 --- a/m4/strnlen.m4 +++ /dev/null @@ -1,30 +0,0 @@ -# strnlen.m4 serial 13 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_STRNLEN], -[ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - - dnl Persuade glibc to declare strnlen(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS_ONCE([strnlen]) - if test $ac_cv_have_decl_strnlen = no; then - HAVE_DECL_STRNLEN=0 - else - m4_pushdef([AC_LIBOBJ], [:]) - dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]). - AC_FUNC_STRNLEN - m4_popdef([AC_LIBOBJ]) - if test $ac_cv_func_strnlen_working = no; then - REPLACE_STRNLEN=1 - fi - fi -]) - -# Prerequisites of lib/strnlen.c. -AC_DEFUN([gl_PREREQ_STRNLEN], [:]) diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 deleted file mode 100644 index 94863776d..000000000 --- a/m4/sys_socket_h.m4 +++ /dev/null @@ -1,176 +0,0 @@ -# sys_socket_h.m4 serial 23 -dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Simon Josefsson. - -AC_DEFUN([gl_HEADER_SYS_SOCKET], -[ - AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) - - dnl On OSF/1, the functions recv(), send(), recvfrom(), sendto() have - dnl old-style declarations (with return type 'int' instead of 'ssize_t') - dnl unless _POSIX_PII_SOCKET is defined. - case "$host_os" in - osf*) - AC_DEFINE([_POSIX_PII_SOCKET], [1], - [Define to 1 in order to get the POSIX compatible declarations - of socket functions.]) - ;; - esac - - AC_CACHE_CHECK([whether is self-contained], - [gl_cv_header_sys_socket_h_selfcontained], - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])], - [gl_cv_header_sys_socket_h_selfcontained=yes], - [gl_cv_header_sys_socket_h_selfcontained=no]) - ]) - if test $gl_cv_header_sys_socket_h_selfcontained = yes; then - dnl If the shutdown function exists, should define - dnl SHUT_RD, SHUT_WR, SHUT_RDWR. - AC_CHECK_FUNCS([shutdown]) - if test $ac_cv_func_shutdown = yes; then - AC_CACHE_CHECK([whether defines the SHUT_* macros], - [gl_cv_header_sys_socket_h_shut], - [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };]])], - [gl_cv_header_sys_socket_h_shut=yes], - [gl_cv_header_sys_socket_h_shut=no]) - ]) - if test $gl_cv_header_sys_socket_h_shut = no; then - SYS_SOCKET_H='sys/socket.h' - fi - fi - fi - # We need to check for ws2tcpip.h now. - gl_PREREQ_SYS_H_SOCKET - AC_CHECK_TYPES([struct sockaddr_storage, sa_family_t],,,[ - /* sys/types.h is not needed according to POSIX, but the - sys/socket.h in i386-unknown-freebsd4.10 and - powerpc-apple-darwin5.5 required it. */ -#include -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_WS2TCPIP_H -#include -#endif -]) - if test $ac_cv_type_struct_sockaddr_storage = no; then - HAVE_STRUCT_SOCKADDR_STORAGE=0 - fi - if test $ac_cv_type_sa_family_t = no; then - HAVE_SA_FAMILY_T=0 - fi - if test $ac_cv_type_struct_sockaddr_storage != no; then - AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], - [], - [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0], - [#include - #ifdef HAVE_SYS_SOCKET_H - #include - #endif - #ifdef HAVE_WS2TCPIP_H - #include - #endif - ]) - fi - if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ - || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then - SYS_SOCKET_H='sys/socket.h' - fi - gl_PREREQ_SYS_H_WINSOCK2 - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[ -/* Some systems require prerequisite headers. */ -#include -#include - ]], [socket connect accept bind getpeername getsockname getsockopt - listen recv send recvfrom sendto setsockopt shutdown accept4]) -]) - -AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], -[ - dnl Check prerequisites of the replacement. - AC_REQUIRE([gl_CHECK_SOCKET_HEADERS]) - gl_CHECK_NEXT_HEADERS([sys/socket.h]) - if test $ac_cv_header_sys_socket_h = yes; then - HAVE_SYS_SOCKET_H=1 - HAVE_WS2TCPIP_H=0 - else - HAVE_SYS_SOCKET_H=0 - if test $ac_cv_header_ws2tcpip_h = yes; then - HAVE_WS2TCPIP_H=1 - else - HAVE_WS2TCPIP_H=0 - fi - fi - AC_SUBST([HAVE_SYS_SOCKET_H]) - AC_SUBST([HAVE_WS2TCPIP_H]) -]) - -# Common prerequisites of the replacement and of the -# replacement. -# Sets and substitutes HAVE_WINSOCK2_H. -AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2], -[ - m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])]) - m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])]) - AC_CHECK_HEADERS_ONCE([sys/socket.h]) - if test $ac_cv_header_sys_socket_h != yes; then - dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make - dnl the check for those headers unconditional; yet cygwin reports - dnl that the headers are present but cannot be compiled (since on - dnl cygwin, all socket information should come from sys/socket.h). - AC_CHECK_HEADERS([winsock2.h]) - fi - if test "$ac_cv_header_winsock2_h" = yes; then - HAVE_WINSOCK2_H=1 - UNISTD_H_HAVE_WINSOCK2_H=1 - SYS_IOCTL_H_HAVE_WINSOCK2_H=1 - else - HAVE_WINSOCK2_H=0 - fi - AC_SUBST([HAVE_WINSOCK2_H]) -]) - -AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], -[ - GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET]) - GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT]) - GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT]) - GNULIB_BIND=0; AC_SUBST([GNULIB_BIND]) - GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME]) - GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME]) - GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT]) - GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN]) - GNULIB_RECV=0; AC_SUBST([GNULIB_RECV]) - GNULIB_SEND=0; AC_SUBST([GNULIB_SEND]) - GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM]) - GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO]) - GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT]) - GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) - GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4]) - HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) - HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; - AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) - HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T]) - HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4]) -]) diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 deleted file mode 100644 index d15c1b370..000000000 --- a/m4/sys_types_h.m4 +++ /dev/null @@ -1,24 +0,0 @@ -# sys_types_h.m4 serial 5 -dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN_ONCE([gl_SYS_TYPES_H], -[ - AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) - gl_NEXT_HEADERS([sys/types.h]) - - dnl Ensure the type pid_t gets defined. - AC_REQUIRE([AC_TYPE_PID_T]) - - dnl Ensure the type mode_t gets defined. - AC_REQUIRE([AC_TYPE_MODE_T]) - - dnl Whether to override the 'off_t' type. - AC_REQUIRE([gl_TYPE_OFF_T]) -]) - -AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], -[ -]) diff --git a/m4/sysexits.m4 b/m4/sysexits.m4 deleted file mode 100644 index bd8abaa0d..000000000 --- a/m4/sysexits.m4 +++ /dev/null @@ -1,44 +0,0 @@ -# sysexits.m4 serial 6 -dnl Copyright (C) 2003, 2005, 2007, 2009-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_SYSEXITS], -[ - AC_CHECK_HEADERS_ONCE([sysexits.h]) - if test $ac_cv_header_sysexits_h = yes; then - HAVE_SYSEXITS_H=1 - gl_CHECK_NEXT_HEADERS([sysexits.h]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[switch (0) - { - case EX_OK: - case EX_USAGE: - case EX_DATAERR: - case EX_NOINPUT: - case EX_NOUSER: - case EX_NOHOST: - case EX_UNAVAILABLE: - case EX_SOFTWARE: - case EX_OSERR: - case EX_OSFILE: - case EX_CANTCREAT: - case EX_IOERR: - case EX_TEMPFAIL: - case EX_PROTOCOL: - case EX_NOPERM: - case EX_CONFIG: - break; - } - ]])], - [SYSEXITS_H=], - [SYSEXITS_H=sysexits.h]) - else - HAVE_SYSEXITS_H=0 - SYSEXITS_H=sysexits.h - fi - AC_SUBST([HAVE_SYSEXITS_H]) - AC_SUBST([SYSEXITS_H]) - AM_CONDITIONAL([GL_GENERATE_SYSEXITS_H], [test -n "$SYSEXITS_H"]) -]) diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 deleted file mode 100644 index 26bdeb58a..000000000 --- a/m4/threadlib.m4 +++ /dev/null @@ -1,371 +0,0 @@ -# threadlib.m4 serial 10 (gettext-0.18.2) -dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl gl_THREADLIB -dnl ------------ -dnl Tests for a multithreading library to be used. -dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO -dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the -dnl default is 'no', otherwise it is system dependent. In both cases, the user -dnl can change the choice through the options --enable-threads=choice or -dnl --disable-threads. -dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, -dnl USE_PTH_THREADS, USE_WINDOWS_THREADS -dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use -dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with -dnl libtool). -dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for -dnl programs that really need multithread functionality. The difference -dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak -dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". -dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for -dnl multithread-safe programs. - -AC_DEFUN([gl_THREADLIB_EARLY], -[ - AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) -]) - -dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. - -AC_DEFUN([gl_THREADLIB_EARLY_BODY], -[ - dnl Ordering constraints: This macro modifies CPPFLAGS in a way that - dnl influences the result of the autoconf tests that test for *_unlocked - dnl declarations, on AIX 5 at least. Therefore it must come early. - AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl - AC_BEFORE([$0], [gl_ARGP])dnl - - AC_REQUIRE([AC_CANONICAL_HOST]) - dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. - dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes - dnl AC_GNU_SOURCE. - m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], - [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], - [AC_REQUIRE([AC_GNU_SOURCE])]) - dnl Check for multithreading. - m4_ifdef([gl_THREADLIB_DEFAULT_NO], - [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], - [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) - AC_ARG_ENABLE([threads], -AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ -AC_HELP_STRING([--disable-threads], [build without multithread safety])]), - [gl_use_threads=$enableval], - [if test -n "$gl_use_threads_default"; then - gl_use_threads="$gl_use_threads_default" - else -changequote(,)dnl - case "$host_os" in - dnl Disable multithreading by default on OSF/1, because it interferes - dnl with fork()/exec(): When msgexec is linked with -lpthread, its - dnl child process gets an endless segmentation fault inside execvp(). - dnl Disable multithreading by default on Cygwin 1.5.x, because it has - dnl bugs that lead to endless loops or crashes. See - dnl . - osf*) gl_use_threads=no ;; - cygwin*) - case `uname -r` in - 1.[0-5].*) gl_use_threads=no ;; - *) gl_use_threads=yes ;; - esac - ;; - *) gl_use_threads=yes ;; - esac -changequote([,])dnl - fi - ]) - if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - # For using : - case "$host_os" in - osf*) - # On OSF/1, the compiler needs the flag -D_REENTRANT so that it - # groks . cc also understands the flag -pthread, but - # we don't use it because 1. gcc-2.95 doesn't understand -pthread, - # 2. putting a flag into CPPFLAGS that has an effect on the linker - # causes the AC_LINK_IFELSE test below to succeed unexpectedly, - # leading to wrong values of LIBTHREAD and LTLIBTHREAD. - CPPFLAGS="$CPPFLAGS -D_REENTRANT" - ;; - esac - # Some systems optimize for single-threaded programs by default, and - # need special flags to disable these optimizations. For example, the - # definition of 'errno' in . - case "$host_os" in - aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; - solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; - esac - fi -]) - -dnl The guts of gl_THREADLIB. Needs to be expanded only once. - -AC_DEFUN([gl_THREADLIB_BODY], -[ - AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) - gl_threads_api=none - LIBTHREAD= - LTLIBTHREAD= - LIBMULTITHREAD= - LTLIBMULTITHREAD= - if test "$gl_use_threads" != no; then - dnl Check whether the compiler and linker support weak declarations. - AC_CACHE_CHECK([whether imported symbols can be declared weak], - [gl_cv_have_weak], - [gl_cv_have_weak=no - dnl First, test whether the compiler accepts it syntactically. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[extern void xyzzy (); -#pragma weak xyzzy]], - [[xyzzy();]])], - [gl_cv_have_weak=maybe]) - if test $gl_cv_have_weak = maybe; then - dnl Second, test whether it actually works. On Cygwin 1.7.2, with - dnl gcc 4.3, symbols declared weak always evaluate to the address 0. - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#pragma weak fputs -int main () -{ - return (fputs == NULL); -}]])], - [gl_cv_have_weak=yes], - [gl_cv_have_weak=no], - [dnl When cross-compiling, assume that only ELF platforms support - dnl weak symbols. - AC_EGREP_CPP([Extensible Linking Format], - [#ifdef __ELF__ - Extensible Linking Format - #endif - ], - [gl_cv_have_weak="guessing yes"], - [gl_cv_have_weak="guessing no"]) - ]) - fi - ]) - if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that - # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. - AC_CHECK_HEADER([pthread.h], - [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) - if test "$gl_have_pthread_h" = yes; then - # Other possible tests: - # -lpthreads (FSU threads, PCthreads) - # -lgthreads - gl_have_pthread= - # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist - # in libc. IRIX 6.5 has the first one in both libc and libpthread, but - # the second one only in libpthread, and lock.c needs it. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[pthread_mutex_lock((pthread_mutex_t*)0); - pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], - [gl_have_pthread=yes]) - # Test for libpthread by looking for pthread_kill. (Not pthread_self, - # since it is defined as a macro on OSF/1.) - if test -n "$gl_have_pthread"; then - # The program links fine without libpthread. But it may actually - # need to link with libpthread in order to create multiple threads. - AC_CHECK_LIB([pthread], [pthread_kill], - [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread - # On Solaris and HP-UX, most pthread functions exist also in libc. - # Therefore pthread_in_use() needs to actually try to create a - # thread: pthread_create from libc will fail, whereas - # pthread_create will actually create a thread. - case "$host_os" in - solaris* | hpux*) - AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], - [Define if the pthread_in_use() detection is hard.]) - esac - ]) - else - # Some library is needed. Try libpthread and libc_r. - AC_CHECK_LIB([pthread], [pthread_kill], - [gl_have_pthread=yes - LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread - LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) - if test -z "$gl_have_pthread"; then - # For FreeBSD 4. - AC_CHECK_LIB([c_r], [pthread_kill], - [gl_have_pthread=yes - LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r - LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) - fi - fi - if test -n "$gl_have_pthread"; then - gl_threads_api=posix - AC_DEFINE([USE_POSIX_THREADS], [1], - [Define if the POSIX multithreading library can be used.]) - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then - AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], - [Define if references to the POSIX multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - fi - fi - fi - if test -z "$gl_have_pthread"; then - if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then - gl_have_solaristhread= - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lthread" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[thr_self();]])], - [gl_have_solaristhread=yes]) - LIBS="$gl_save_LIBS" - if test -n "$gl_have_solaristhread"; then - gl_threads_api=solaris - LIBTHREAD=-lthread - LTLIBTHREAD=-lthread - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - AC_DEFINE([USE_SOLARIS_THREADS], [1], - [Define if the old Solaris multithreading library can be used.]) - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then - AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], - [Define if references to the old Solaris multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - fi - fi - if test "$gl_use_threads" = pth; then - gl_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_LINKFLAGS([pth]) - gl_have_pth= - gl_save_LIBS="$LIBS" - LIBS="$LIBS $LIBPTH" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[#include ]], [[pth_self();]])], - [gl_have_pth=yes]) - LIBS="$gl_save_LIBS" - if test -n "$gl_have_pth"; then - gl_threads_api=pth - LIBTHREAD="$LIBPTH" - LTLIBTHREAD="$LTLIBPTH" - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - AC_DEFINE([USE_PTH_THREADS], [1], - [Define if the GNU Pth multithreading library can be used.]) - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then - AC_DEFINE([USE_PTH_THREADS_WEAK], [1], - [Define if references to the GNU Pth multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - else - CPPFLAGS="$gl_save_CPPFLAGS" - fi - fi - if test -z "$gl_have_pthread"; then - case "$gl_use_threads" in - yes | windows | win32) # The 'win32' is for backward compatibility. - if { case "$host_os" in - mingw*) true;; - *) false;; - esac - }; then - gl_threads_api=windows - AC_DEFINE([USE_WINDOWS_THREADS], [1], - [Define if the native Windows multithreading API can be used.]) - fi - ;; - esac - fi - fi - AC_MSG_CHECKING([for multithread API to use]) - AC_MSG_RESULT([$gl_threads_api]) - AC_SUBST([LIBTHREAD]) - AC_SUBST([LTLIBTHREAD]) - AC_SUBST([LIBMULTITHREAD]) - AC_SUBST([LTLIBMULTITHREAD]) -]) - -AC_DEFUN([gl_THREADLIB], -[ - AC_REQUIRE([gl_THREADLIB_EARLY]) - AC_REQUIRE([gl_THREADLIB_BODY]) -]) - - -dnl gl_DISABLE_THREADS -dnl ------------------ -dnl Sets the gl_THREADLIB default so that threads are not used by default. -dnl The user can still override it at installation time, by using the -dnl configure option '--enable-threads'. - -AC_DEFUN([gl_DISABLE_THREADS], [ - m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) -]) - - -dnl Survey of platforms: -dnl -dnl Platform Available Compiler Supports test-lock -dnl flavours option weak result -dnl --------------- --------- --------- -------- --------- -dnl Linux 2.4/glibc posix -lpthread Y OK -dnl -dnl GNU Hurd/glibc posix -dnl -dnl FreeBSD 5.3 posix -lc_r Y -dnl posix -lkse ? Y -dnl posix -lpthread ? Y -dnl posix -lthr Y -dnl -dnl FreeBSD 5.2 posix -lc_r Y -dnl posix -lkse Y -dnl posix -lthr Y -dnl -dnl FreeBSD 4.0,4.10 posix -lc_r Y OK -dnl -dnl NetBSD 1.6 -- -dnl -dnl OpenBSD 3.4 posix -lpthread Y OK -dnl -dnl Mac OS X 10.[123] posix -lpthread Y OK -dnl -dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK -dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK -dnl -dnl HP-UX 11 posix -lpthread N (cc) OK -dnl Y (gcc) -dnl -dnl IRIX 6.5 posix -lpthread Y 0.5 -dnl -dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK -dnl -dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK -dnl -lpthread (gcc) Y -dnl -dnl Cygwin posix -lpthread Y OK -dnl -dnl Any of the above pth -lpth 0.0 -dnl -dnl Mingw windows N OK -dnl -dnl BeOS 5 -- -dnl -dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is -dnl turned off: -dnl OK if all three tests terminate OK, -dnl 0.5 if the first test terminates OK but the second one loops endlessly, -dnl 0.0 if the first test already loops endlessly. diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4 deleted file mode 100644 index c6ff80067..000000000 --- a/m4/uintmax_t.m4 +++ /dev/null @@ -1,30 +0,0 @@ -# uintmax_t.m4 serial 12 -dnl Copyright (C) 1997-2004, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -AC_PREREQ([2.13]) - -# Define uintmax_t to 'unsigned long' or 'unsigned long long' -# if it is not already defined in or . - -AC_DEFUN([gl_AC_TYPE_UINTMAX_T], -[ - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then - AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - test $ac_cv_type_unsigned_long_long_int = yes \ - && ac_type='unsigned long long' \ - || ac_type='unsigned long' - AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], - [Define to unsigned long or unsigned long long - if and don't define.]) - else - AC_DEFINE([HAVE_UINTMAX_T], [1], - [Define if you have the 'uintmax_t' type in or .]) - fi -]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 deleted file mode 100644 index 32dcfa582..000000000 --- a/m4/unistd_h.m4 +++ /dev/null @@ -1,186 +0,0 @@ -# unistd_h.m4 serial 66 -dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Simon Josefsson, Bruno Haible. - -AC_DEFUN([gl_UNISTD_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - - gl_CHECK_NEXT_HEADERS([unistd.h]) - if test $ac_cv_header_unistd_h = yes; then - HAVE_UNISTD_H=1 - else - HAVE_UNISTD_H=0 - fi - AC_SUBST([HAVE_UNISTD_H]) - - dnl Ensure the type pid_t gets defined. - AC_REQUIRE([AC_TYPE_PID_T]) - - dnl Determine WINDOWS_64_BIT_OFF_T. - AC_REQUIRE([gl_TYPE_OFF_T]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[ -#if HAVE_UNISTD_H -# include -#endif -/* Some systems declare various items in the wrong headers. */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -# include -# include -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -# include -# endif -#endif - ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat - fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups - gethostname getlogin getlogin_r getpagesize - getusershell setusershell endusershell - group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite - readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r - unlink unlinkat usleep]) -]) - -AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_UNISTD_H_DEFAULTS], -[ - GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR]) - GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) - GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE]) - GNULIB_DUP=0; AC_SUBST([GNULIB_DUP]) - GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) - GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3]) - GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON]) - GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS]) - GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT]) - GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) - GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT]) - GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC]) - GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC]) - GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) - GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) - GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME]) - GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) - GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS]) - GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) - GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) - GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) - GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) - GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) - GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER]) - GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY]) - GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) - GNULIB_LINK=0; AC_SUBST([GNULIB_LINK]) - GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT]) - GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) - GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE]) - GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) - GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) - GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) - GNULIB_READ=0; AC_SUBST([GNULIB_READ]) - GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) - GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) - GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) - GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME]) - GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) - GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) - GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) - GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) - GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING]) - GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) - GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK]) - GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT]) - GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP]) - GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) - HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) - HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) - HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) - HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) - HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) - HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) - HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) - HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) - HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) - HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) - HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) - HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) - HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) - HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) - HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) - HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) - HAVE_LINK=1; AC_SUBST([HAVE_LINK]) - HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) - HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) - HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) - HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) - HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) - HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) - HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) - HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) - HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) - HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) - HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) - HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) - HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) - HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) - HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) - HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) - HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) - HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) - HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) - HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) - HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) - HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) - HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) - HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) - REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) - REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) - REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) - REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) - REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) - REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) - REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) - REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) - REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) - REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) - REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) - REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) - REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) - REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) - REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) - REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) - REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) - REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) - REPLACE_READ=0; AC_SUBST([REPLACE_READ]) - REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) - REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) - REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) - REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) - REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) - REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) - REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) - REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) - REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) - UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) - UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; - AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) -]) diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4 deleted file mode 100644 index d730e435a..000000000 --- a/m4/vasnprintf.m4 +++ /dev/null @@ -1,291 +0,0 @@ -# vasnprintf.m4 serial 36 -dnl Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_VASNPRINTF], -[ - AC_CHECK_FUNCS_ONCE([vasnprintf]) - if test $ac_cv_func_vasnprintf = no; then - gl_REPLACE_VASNPRINTF - fi -]) - -AC_DEFUN([gl_REPLACE_VASNPRINTF], -[ - AC_CHECK_FUNCS_ONCE([vasnprintf]) - AC_LIBOBJ([vasnprintf]) - AC_LIBOBJ([printf-args]) - AC_LIBOBJ([printf-parse]) - AC_LIBOBJ([asnprintf]) - if test $ac_cv_func_vasnprintf = yes; then - AC_DEFINE([REPLACE_VASNPRINTF], [1], - [Define if vasnprintf exists but is overridden by gnulib.]) - fi - gl_PREREQ_PRINTF_ARGS - gl_PREREQ_PRINTF_PARSE - gl_PREREQ_VASNPRINTF - gl_PREREQ_ASNPRINTF -]) - -# Prerequisites of lib/printf-args.h, lib/printf-args.c. -AC_DEFUN([gl_PREREQ_PRINTF_ARGS], -[ - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) - AC_REQUIRE([gt_TYPE_WINT_T]) -]) - -# Prerequisites of lib/printf-parse.h, lib/printf-parse.c. -AC_DEFUN([gl_PREREQ_PRINTF_PARSE], -[ - AC_REQUIRE([gl_FEATURES_H]) - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) - AC_REQUIRE([gt_TYPE_WINT_T]) - AC_REQUIRE([AC_TYPE_SIZE_T]) - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], - [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) - ]) - AC_REQUIRE([gt_AC_TYPE_INTMAX_T]) -]) - -# Prerequisites of lib/vasnprintf.c. -AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], -[ - AC_REQUIRE([AC_FUNC_ALLOCA]) - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) - AC_REQUIRE([gt_TYPE_WINT_T]) - AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) - dnl Use the _snprintf function only if it is declared (because on NetBSD it - dnl is defined as a weak alias of snprintf; we prefer to use the latter). - AC_CHECK_DECLS([_snprintf], , , [[#include ]]) - dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization - dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE. - AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) - dnl We can avoid a lot of code by assuming that snprintf's return value - dnl conforms to ISO C99. So check that. - AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) - case "$gl_cv_func_snprintf_retval_c99" in - *yes) - AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1], - [Define if the return value of the snprintf function is the number of - of bytes (excluding the terminating NUL) that would have been produced - if the buffer had been large enough.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' -# arguments. -AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], -[ - AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) - case "$gl_cv_func_printf_long_double" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - 'long double' arguments.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double' -# arguments. -AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE], -[ - AC_REQUIRE([gl_PRINTF_INFINITE]) - case "$gl_cv_func_printf_infinite" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - infinite 'double' arguments.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double' -# arguments. -AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE], -[ - AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) - dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if - dnl NEED_PRINTF_LONG_DOUBLE is already set. - AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE]) - case "$gl_cv_func_printf_long_double" in - *yes) - case "$gl_cv_func_printf_infinite_long_double" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - infinite 'long double' arguments.]) - ;; - esac - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive. -AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A], -[ - AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) - case "$gl_cv_func_printf_directive_a" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1], - [Define if the vasnprintf implementation needs special code for - the 'a' and 'A' directives.]) - AC_CHECK_FUNCS([nl_langinfo]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive. -AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F], -[ - AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) - case "$gl_cv_func_printf_directive_f" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1], - [Define if the vasnprintf implementation needs special code for - the 'F' directive.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive. -AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS], -[ - AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS]) - case "$gl_cv_func_printf_directive_ls" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1], - [Define if the vasnprintf implementation needs special code for - the 'ls' directive.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. -AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], -[ - AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) - case "$gl_cv_func_printf_flag_grouping" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1], - [Define if the vasnprintf implementation needs special code for the - ' flag.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag. -AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST], -[ - AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST]) - case "$gl_cv_func_printf_flag_leftadjust" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1], - [Define if the vasnprintf implementation needs special code for the - '-' flag.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag. -AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO], -[ - AC_REQUIRE([gl_PRINTF_FLAG_ZERO]) - case "$gl_cv_func_printf_flag_zero" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1], - [Define if the vasnprintf implementation needs special code for the - 0 flag.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for supporting large precisions. -AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], -[ - AC_REQUIRE([gl_PRINTF_PRECISION]) - case "$gl_cv_func_printf_precision" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1], - [Define if the vasnprintf implementation needs special code for - supporting large precisions without arbitrary bounds.]) - AC_DEFINE([NEED_PRINTF_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - 'double' arguments.]) - AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - 'long double' arguments.]) - ;; - esac -]) - -# Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory -# conditions. -AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM], -[ - AC_REQUIRE([gl_PRINTF_ENOMEM]) - case "$gl_cv_func_printf_enomem" in - *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_ENOMEM], [1], - [Define if the vasnprintf implementation needs special code for - surviving out-of-memory conditions.]) - AC_DEFINE([NEED_PRINTF_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - 'double' arguments.]) - AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], - [Define if the vasnprintf implementation needs special code for - 'long double' arguments.]) - ;; - esac -]) - -# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. -AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS], -[ - AC_REQUIRE([gl_PREREQ_VASNPRINTF]) - gl_PREREQ_VASNPRINTF_LONG_DOUBLE - gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE - gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE - gl_PREREQ_VASNPRINTF_DIRECTIVE_A - gl_PREREQ_VASNPRINTF_DIRECTIVE_F - gl_PREREQ_VASNPRINTF_DIRECTIVE_LS - gl_PREREQ_VASNPRINTF_FLAG_GROUPING - gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST - gl_PREREQ_VASNPRINTF_FLAG_ZERO - gl_PREREQ_VASNPRINTF_PRECISION - gl_PREREQ_VASNPRINTF_ENOMEM -]) - -# Prerequisites of lib/asnprintf.c. -AC_DEFUN([gl_PREREQ_ASNPRINTF], -[ -]) diff --git a/m4/visibility.m4 b/m4/visibility.m4 deleted file mode 100644 index 6cbd7e5f2..000000000 --- a/m4/visibility.m4 +++ /dev/null @@ -1,77 +0,0 @@ -# visibility.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl Tests whether the compiler supports the command-line option -dnl -fvisibility=hidden and the function and variable attributes -dnl __attribute__((__visibility__("hidden"))) and -dnl __attribute__((__visibility__("default"))). -dnl Does *not* test for __visibility__("protected") - which has tricky -dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on -dnl Mac OS X. -dnl Does *not* test for __visibility__("internal") - which has processor -dnl dependent semantics. -dnl Does *not* test for #pragma GCC visibility push(hidden) - which is -dnl "really only recommended for legacy code". -dnl Set the variable CFLAG_VISIBILITY. -dnl Defines and sets the variable HAVE_VISIBILITY. - -AC_DEFUN([gl_VISIBILITY], -[ - AC_REQUIRE([AC_PROG_CC]) - CFLAG_VISIBILITY= - HAVE_VISIBILITY=0 - if test -n "$GCC"; then - dnl First, check whether -Werror can be added to the command line, or - dnl whether it leads to an error because of some other option that the - dnl user has put into $CC $CFLAGS $CPPFLAGS. - AC_MSG_CHECKING([whether the -Werror option is usable]) - AC_CACHE_VAL([gl_cv_cc_vis_werror], [ - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [gl_cv_cc_vis_werror=yes], - [gl_cv_cc_vis_werror=no]) - CFLAGS="$gl_save_CFLAGS"]) - AC_MSG_RESULT([$gl_cv_cc_vis_werror]) - dnl Now check whether visibility declarations are supported. - AC_MSG_CHECKING([for simple visibility declarations]) - AC_CACHE_VAL([gl_cv_cc_visibility], [ - gl_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fvisibility=hidden" - dnl We use the option -Werror and a function dummyfunc, because on some - dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning - dnl "visibility attribute not supported in this configuration; ignored" - dnl at the first function definition in every compilation unit, and we - dnl don't want to use the option in this case. - if test $gl_cv_cc_vis_werror = yes; then - CFLAGS="$CFLAGS -Werror" - fi - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; - extern __attribute__((__visibility__("default"))) int exportedvar; - extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void); - void dummyfunc (void) {} - ]], - [[]])], - [gl_cv_cc_visibility=yes], - [gl_cv_cc_visibility=no]) - CFLAGS="$gl_save_CFLAGS"]) - AC_MSG_RESULT([$gl_cv_cc_visibility]) - if test $gl_cv_cc_visibility = yes; then - CFLAG_VISIBILITY="-fvisibility=hidden" - HAVE_VISIBILITY=1 - fi - fi - AC_SUBST([CFLAG_VISIBILITY]) - AC_SUBST([HAVE_VISIBILITY]) - AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], - [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) -]) diff --git a/m4/vsnprintf.m4 b/m4/vsnprintf.m4 deleted file mode 100644 index 4900764ee..000000000 --- a/m4/vsnprintf.m4 +++ /dev/null @@ -1,54 +0,0 @@ -# vsnprintf.m4 serial 6 -dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Libintl 0.17 will replace vsnprintf only if it does not support %1$s, -dnl but defers to any gnulib vsnprintf replacements. Therefore, gnulib -dnl must guarantee that the decision for replacing vsnprintf is a superset -dnl of the reasons checked by libintl. -AC_DEFUN([gl_FUNC_VSNPRINTF], -[ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - gl_cv_func_vsnprintf_usable=no - AC_CHECK_FUNCS([vsnprintf]) - if test $ac_cv_func_vsnprintf = yes; then - gl_SNPRINTF_SIZE1 - case "$gl_cv_func_snprintf_size1" in - *yes) - gl_SNPRINTF_RETVAL_C99 - case "$gl_cv_func_snprintf_retval_c99" in - *yes) - gl_PRINTF_POSITIONS - case "$gl_cv_func_printf_positions" in - *yes) - gl_cv_func_vsnprintf_usable=yes - ;; - esac - ;; - esac - ;; - esac - fi - if test $gl_cv_func_vsnprintf_usable = no; then - gl_REPLACE_VSNPRINTF - fi - AC_CHECK_DECLS_ONCE([vsnprintf]) - if test $ac_cv_have_decl_vsnprintf = no; then - HAVE_DECL_VSNPRINTF=0 - fi -]) - -AC_DEFUN([gl_REPLACE_VSNPRINTF], -[ - AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - AC_LIBOBJ([vsnprintf]) - if test $ac_cv_func_vsnprintf = yes; then - REPLACE_VSNPRINTF=1 - fi - gl_PREREQ_VSNPRINTF -]) - -# Prerequisites of lib/vsnprintf.c. -AC_DEFUN([gl_PREREQ_VSNPRINTF], [:]) diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4 deleted file mode 100644 index e43beebd9..000000000 --- a/m4/warn-on-use.m4 +++ /dev/null @@ -1,47 +0,0 @@ -# warn-on-use.m4 serial 5 -dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) -# --------------------------------------- -# For each whitespace-separated element in the list of NAMES, define -# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES -# even after being undefined as a macro. -# -# See warn-on-use.h for some hints on how to poison function names, as -# well as ideas on poisoning global variables and macros. NAMES may -# include global variables, but remember that only functions work with -# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single -# header, but if the replacement header pulls in other headers because -# some systems declare functions in the wrong header, then INCLUDES -# should do likewise. -# -# It is generally safe to assume declarations for functions declared -# in the intersection of C89 and C11 (such as printf) without -# needing gl_WARN_ON_USE_PREPARE. -AC_DEFUN([gl_WARN_ON_USE_PREPARE], -[ - m4_foreach_w([gl_decl], [$2], - [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), - [Define to 1 if ]m4_defn([gl_decl])[ is declared even after - undefining macros.])])dnl -dnl FIXME: gl_Symbol must be used unquoted until we can assume -dnl autoconf 2.64 or newer. - for gl_func in m4_flatten([$2]); do - AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl - AC_CACHE_CHECK([whether $gl_func is declared without a macro], - gl_Symbol, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], -[@%:@undef $gl_func - (void) $gl_func;])], - [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) - AS_VAR_IF(gl_Symbol, [yes], - [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) - dnl shortcut - if the raw declaration exists, then set a cache - dnl variable to allow skipping any later AC_CHECK_DECL efforts - eval ac_cv_have_decl_$gl_func=yes]) - AS_VAR_POPDEF([gl_Symbol])dnl - done -]) diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4 deleted file mode 100644 index bedb15a44..000000000 --- a/m4/wchar_h.m4 +++ /dev/null @@ -1,225 +0,0 @@ -dnl A placeholder for ISO C99 , for platforms that have issues. - -dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Eric Blake. - -# wchar_h.m4 serial 39 - -AC_DEFUN([gl_WCHAR_H], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) - dnl Prepare for creating substitute . - dnl Check for (missing in Linux uClibc when built without wide - dnl character support). - dnl is always overridden, because of GNULIB_POSIXCHECK. - gl_CHECK_NEXT_HEADERS([wchar.h]) - if test $ac_cv_header_wchar_h = yes; then - HAVE_WCHAR_H=1 - else - HAVE_WCHAR_H=0 - fi - AC_SUBST([HAVE_WCHAR_H]) - - AC_REQUIRE([gl_FEATURES_H]) - - AC_REQUIRE([gt_TYPE_WINT_T]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else - HAVE_WINT_T=0 - fi - AC_SUBST([HAVE_WINT_T]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -# include -# include -#endif -#include - ]], - [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb - wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset - wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp - wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr - wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth - ]) -]) - -dnl Check whether is usable at all. -AC_DEFUN([gl_WCHAR_H_INLINE_OK], -[ - dnl Test whether suffers due to the transition from '__inline' to - dnl 'gnu_inline'. See - dnl and . In summary, - dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and - dnl the option -std=c99 or -std=gnu99, leads to a broken . - AC_CACHE_CHECK([whether uses 'inline' correctly], - [gl_cv_header_wchar_h_correct_inline], - [gl_cv_header_wchar_h_correct_inline=yes - AC_LANG_CONFTEST([ - AC_LANG_SOURCE([[#define wcstod renamed_wcstod -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -extern int zero (void); -int main () { return zero(); } -]])]) - if AC_TRY_EVAL([ac_compile]); then - mv conftest.$ac_objext conftest1.$ac_objext - AC_LANG_CONFTEST([ - AC_LANG_SOURCE([[#define wcstod renamed_wcstod -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int zero (void) { return 0; } -]])]) - if AC_TRY_EVAL([ac_compile]); then - mv conftest.$ac_objext conftest2.$ac_objext - if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then - : - else - gl_cv_header_wchar_h_correct_inline=no - fi - fi - fi - rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext - ]) - if test $gl_cv_header_wchar_h_correct_inline = no; then - AC_MSG_ERROR([ cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). -This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in -C99 mode. You have four options: - - Add the flag -fgnu89-inline to CC and reconfigure, or - - Fix your include files, using parts of - , or - - Use a gcc version older than 4.3, or - - Don't use the flags -std=c99 or -std=gnu99. -Configuration aborted.]) - fi -]) - -AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_WCHAR_H_DEFAULTS], -[ - GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC]) - GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB]) - GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT]) - GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC]) - GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN]) - GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS]) - GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS]) - GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB]) - GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS]) - GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS]) - GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) - GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR]) - GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP]) - GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY]) - GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE]) - GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET]) - GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN]) - GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN]) - GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY]) - GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY]) - GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY]) - GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY]) - GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT]) - GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT]) - GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP]) - GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP]) - GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP]) - GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP]) - GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL]) - GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM]) - GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP]) - GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR]) - GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR]) - GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN]) - GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN]) - GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK]) - GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR]) - GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK]) - GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) - HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) - HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC]) - HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN]) - HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS]) - HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS]) - HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB]) - HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS]) - HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS]) - HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR]) - HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) - HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) - HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) - HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) - HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) - HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) - HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY]) - HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY]) - HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY]) - HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY]) - HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT]) - HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT]) - HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP]) - HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP]) - HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP]) - HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP]) - HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL]) - HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM]) - HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP]) - HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR]) - HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR]) - HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN]) - HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN]) - HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK]) - HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) - HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) - HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) - HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) - HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) - REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) - REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) - REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB]) - REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT]) - REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC]) - REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN]) - REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS]) - REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS]) - REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB]) - REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS]) - REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) - REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) - REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) -]) diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 deleted file mode 100644 index e1e1e699d..000000000 --- a/m4/wchar_t.m4 +++ /dev/null @@ -1,24 +0,0 @@ -# wchar_t.m4 serial 4 (gettext-0.18.2) -dnl Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. -dnl Test whether has the 'wchar_t' type. -dnl Prerequisite: AC_PROG_CC - -AC_DEFUN([gt_TYPE_WCHAR_T], -[ - AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include - wchar_t foo = (wchar_t)'\0';]], - [[]])], - [gt_cv_c_wchar_t=yes], - [gt_cv_c_wchar_t=no])]) - if test $gt_cv_c_wchar_t = yes; then - AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) - fi -]) diff --git a/m4/wcrtomb.m4 b/m4/wcrtomb.m4 deleted file mode 100644 index f56b5bae9..000000000 --- a/m4/wcrtomb.m4 +++ /dev/null @@ -1,112 +0,0 @@ -# wcrtomb.m4 serial 11 -dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_WCRTOMB], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - - AC_REQUIRE([AC_TYPE_MBSTATE_T]) - gl_MBSTATE_T_BROKEN - - AC_CHECK_FUNCS_ONCE([wcrtomb]) - if test $ac_cv_func_wcrtomb = no; then - HAVE_WCRTOMB=0 - AC_CHECK_DECLS([wcrtomb],,, [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -]]) - if test $ac_cv_have_decl_wcrtomb = yes; then - dnl On Minix 3.1.8, the system's declares wcrtomb() although - dnl it does not have the function. Avoid a collision with gnulib's - dnl replacement. - REPLACE_WCRTOMB=1 - fi - else - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_WCRTOMB=1 - else - dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes - dnl returns 0 instead of 1. - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gt_LOCALE_FR]) - AC_REQUIRE([gt_LOCALE_FR_UTF8]) - AC_REQUIRE([gt_LOCALE_JA]) - AC_REQUIRE([gt_LOCALE_ZH_CN]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether wcrtomb return value is correct], - [gl_cv_func_wcrtomb_retval], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. -changequote(,)dnl - case "$host_os" in - # Guess no on AIX 4, OSF/1 and Solaris. - aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_wcrtomb_retval="guessing yes" ;; - esac -changequote([,])dnl - if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#include -int main () -{ - int result = 0; - if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) - { - if (wcrtomb (NULL, 0, NULL) != 1) - result |= 1; - } - if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) - { - if (wcrtomb (NULL, 0, NULL) != 1) - result |= 2; - } - if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) - { - if (wcrtomb (NULL, 0, NULL) != 1) - result |= 4; - } - if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) - { - if (wcrtomb (NULL, 0, NULL) != 1) - result |= 8; - } - return result; -}]])], - [gl_cv_func_wcrtomb_retval=yes], - [gl_cv_func_wcrtomb_retval=no], - [:]) - fi - ]) - case "$gl_cv_func_wcrtomb_retval" in - *yes) ;; - *) REPLACE_WCRTOMB=1 ;; - esac - fi - fi -]) - -# Prerequisites of lib/wcrtomb.c. -AC_DEFUN([gl_PREREQ_WCRTOMB], [ - : -]) diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 deleted file mode 100644 index 82ada0eee..000000000 --- a/m4/wctype_h.m4 +++ /dev/null @@ -1,209 +0,0 @@ -# wctype_h.m4 serial 18 - -dnl A placeholder for ISO C99 , for platforms that lack it. - -dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Paul Eggert. - -AC_DEFUN([gl_WCTYPE_H], -[ - AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS_ONCE([iswcntrl]) - if test $ac_cv_func_iswcntrl = yes; then - HAVE_ISWCNTRL=1 - else - HAVE_ISWCNTRL=0 - fi - AC_SUBST([HAVE_ISWCNTRL]) - - AC_REQUIRE([gt_TYPE_WINT_T]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else - HAVE_WINT_T=0 - fi - AC_SUBST([HAVE_WINT_T]) - - gl_CHECK_NEXT_HEADERS([wctype.h]) - if test $ac_cv_header_wctype_h = yes; then - if test $ac_cv_func_iswcntrl = yes; then - dnl Linux libc5 has an iswprint function that returns 0 for all arguments. - dnl The other functions are likely broken in the same way. - AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ - /* Tru64 with Desktop Toolkit C has a bug: must be - included before . - BSD/OS 4.0.1 has a bug: , and - must be included before . */ - #include - #include - #include - #include - #include - int main () { return iswprint ('x') == 0; } - ]])], - [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include - #if __GNU_LIBRARY__ == 1 - Linux libc5 i18n is broken. - #endif]], [])], - [gl_cv_func_iswcntrl_works="guessing yes"], - [gl_cv_func_iswcntrl_works="guessing no"]) - ]) - ]) - fi - HAVE_WCTYPE_H=1 - else - HAVE_WCTYPE_H=0 - fi - AC_SUBST([HAVE_WCTYPE_H]) - - case "$gl_cv_func_iswcntrl_works" in - *yes) REPLACE_ISWCNTRL=0 ;; - *) REPLACE_ISWCNTRL=1 ;; - esac - AC_SUBST([REPLACE_ISWCNTRL]) - - if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then - dnl Redefine all of iswcntrl, ..., iswxdigit in . - : - fi - - if test $REPLACE_ISWCNTRL = 1; then - REPLACE_TOWLOWER=1 - else - AC_CHECK_FUNCS([towlower]) - if test $ac_cv_func_towlower = yes; then - REPLACE_TOWLOWER=0 - else - AC_CHECK_DECLS([towlower],,, - [[/* Tru64 with Desktop Toolkit C has a bug: must be - included before . - BSD/OS 4.0.1 has a bug: , and - must be included before . */ - #include - #include - #include - #include - #if HAVE_WCTYPE_H - # include - #endif - ]]) - if test $ac_cv_have_decl_towlower = yes; then - dnl On Minix 3.1.8, the system's declares towlower() and - dnl towupper() although it does not have the functions. Avoid a - dnl collision with gnulib's replacement. - REPLACE_TOWLOWER=1 - else - REPLACE_TOWLOWER=0 - fi - fi - fi - AC_SUBST([REPLACE_TOWLOWER]) - - if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then - dnl Redefine towlower, towupper in . - : - fi - - dnl We assume that the wctype() and iswctype() functions exist if and only - dnl if the type wctype_t is defined in or in if that - dnl exists. - dnl HP-UX 11.00 declares all these in and lacks . - AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[/* Tru64 with Desktop Toolkit C has a bug: must be - included before . - BSD/OS 4.0.1 has a bug: , and - must be included before . */ - #include - #include - #include - #include - #if HAVE_WCTYPE_H - # include - #endif - wctype_t a; - ]], - [[]])], - [gl_cv_type_wctype_t=yes], - [gl_cv_type_wctype_t=no]) - ]) - if test $gl_cv_type_wctype_t = no; then - HAVE_WCTYPE_T=0 - fi - - dnl We assume that the wctrans() and towctrans() functions exist if and only - dnl if the type wctrans_t is defined in . - AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[/* Tru64 with Desktop Toolkit C has a bug: must be - included before . - BSD/OS 4.0.1 has a bug: , and - must be included before . */ - #include - #include - #include - #include - #include - wctrans_t a; - ]], - [[]])], - [gl_cv_type_wctrans_t=yes], - [gl_cv_type_wctrans_t=no]) - ]) - if test $gl_cv_type_wctrans_t = no; then - HAVE_WCTRANS_T=0 - fi - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -# include -# include -# include -#endif -#include - ]], - [wctype iswctype wctrans towctrans - ]) -]) - -AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_WCTYPE_H_DEFAULTS], -[ - GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK]) - GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE]) - GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE]) - GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS]) - GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) - HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) - HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) - REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) -]) diff --git a/m4/wcwidth.m4 b/m4/wcwidth.m4 deleted file mode 100644 index 740f81ee1..000000000 --- a/m4/wcwidth.m4 +++ /dev/null @@ -1,101 +0,0 @@ -# wcwidth.m4 serial 23 -dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_WCWIDTH], -[ - AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Persuade glibc to declare wcwidth(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([gt_TYPE_WCHAR_T]) - AC_REQUIRE([gt_TYPE_WINT_T]) - - AC_CHECK_HEADERS_ONCE([wchar.h]) - AC_CHECK_FUNCS_ONCE([wcwidth]) - - AC_CHECK_DECLS([wcwidth], [], [], [[ -/* AIX 3.2.5 declares wcwidth in . */ -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include -#include -]]) - if test $ac_cv_have_decl_wcwidth != yes; then - HAVE_DECL_WCWIDTH=0 - fi - - if test $ac_cv_func_wcwidth = yes; then - HAVE_WCWIDTH=1 - dnl On Mac OS X 10.3, wcwidth(0x0301) (COMBINING ACUTE ACCENT) returns 1. - dnl On OpenBSD 5.0, wcwidth(0x05B0) (HEBREW POINT SHEVA) returns 1. - dnl On OSF/1 5.1, wcwidth(0x200B) (ZERO WIDTH SPACE) returns 1. - dnl This leads to bugs in 'ls' (coreutils). - AC_CACHE_CHECK([whether wcwidth works reasonably in UTF-8 locales], - [gl_cv_func_wcwidth_works], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -/* AIX 3.2.5 declares wcwidth in . */ -#include -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include -#include -#if !HAVE_DECL_WCWIDTH -extern -# ifdef __cplusplus -"C" -# endif -int wcwidth (int); -#endif -int main () -{ - int result = 0; - if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL) - { - if (wcwidth (0x0301) > 0) - result |= 1; - if (wcwidth (0x05B0) > 0) - result |= 2; - if (wcwidth (0x200B) > 0) - result |= 4; - } - return result; -}]])], - [gl_cv_func_wcwidth_works=yes], - [gl_cv_func_wcwidth_works=no], - [ -changequote(,)dnl - case "$host_os" in - # Guess yes on glibc and AIX 7 systems. - *-gnu* | aix[7-9]*) gl_cv_func_wcwidth_works="guessing yes";; - *) gl_cv_func_wcwidth_works="guessing no";; - esac -changequote([,])dnl - ]) - ]) - case "$gl_cv_func_wcwidth_works" in - *yes) ;; - *no) REPLACE_WCWIDTH=1 ;; - esac - else - HAVE_WCWIDTH=0 - fi - dnl We don't substitute HAVE_WCWIDTH. We assume that if the system does not - dnl have the wcwidth function, then it does not declare it. -]) diff --git a/m4/wint_t.m4 b/m4/wint_t.m4 deleted file mode 100644 index d7cd3db93..000000000 --- a/m4/wint_t.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# wint_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. -dnl Test whether has the 'wint_t' type. -dnl Prerequisite: AC_PROG_CC - -AC_DEFUN([gt_TYPE_WINT_T], -[ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include -#include - wint_t foo = (wchar_t)'\0';]], - [[]])], - [gt_cv_c_wint_t=yes], - [gt_cv_c_wint_t=no])]) - if test $gt_cv_c_wint_t = yes; then - AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) - fi -]) diff --git a/m4/xsize.m4 b/m4/xsize.m4 deleted file mode 100644 index 8ea9f2cd3..000000000 --- a/m4/xsize.m4 +++ /dev/null @@ -1,12 +0,0 @@ -# xsize.m4 serial 5 -dnl Copyright (C) 2003-2004, 2008-2013 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_XSIZE], -[ - dnl Prerequisites of lib/xsize.h. - AC_REQUIRE([gl_SIZE_MAX]) - AC_CHECK_HEADERS([stdint.h]) -]) diff --git a/po/Makefile.in.in b/po/Makefile.in.in deleted file mode 100644 index e68e9da84..000000000 --- a/po/Makefile.in.in +++ /dev/null @@ -1,469 +0,0 @@ -# Makefile for PO directory in any package using GNU gettext. -# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper -# -# This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU General Public -# License but which still want to provide support for the GNU gettext -# functionality. -# Please note that the actual code of GNU gettext is covered by the GNU -# General Public License and is *not* in the public domain. -# -# Origin: gettext-0.18 -GETTEXT_MACRO_VERSION = 0.18 - -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ - -SHELL = @SHELL@ -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -datarootdir = @datarootdir@ -datadir = @datadir@ -localedir = @localedir@ -gettextsrcdir = $(datadir)/gettext/po - -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -# We use $(mkdir_p). -# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as -# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, -# @install_sh@ does not start with $(SHELL), so we add it. -# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined -# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake -# versions, $(mkinstalldirs) and $(install_sh) are unused. -mkinstalldirs = $(SHELL) @install_sh@ -d -install_sh = $(SHELL) @install_sh@ -MKDIR_P = @MKDIR_P@ -mkdir_p = @mkdir_p@ - -GMSGFMT_ = @GMSGFMT@ -GMSGFMT_no = @GMSGFMT@ -GMSGFMT_yes = @GMSGFMT_015@ -GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) -MSGFMT_ = @MSGFMT@ -MSGFMT_no = @MSGFMT@ -MSGFMT_yes = @MSGFMT_015@ -MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) -XGETTEXT_ = @XGETTEXT@ -XGETTEXT_no = @XGETTEXT@ -XGETTEXT_yes = @XGETTEXT_015@ -XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) -MSGMERGE = msgmerge -MSGMERGE_UPDATE = @MSGMERGE@ --update -MSGINIT = msginit -MSGCONV = msgconv -MSGFILTER = msgfilter - -POFILES = @POFILES@ -GMOFILES = @GMOFILES@ -UPDATEPOFILES = @UPDATEPOFILES@ -DUMMYPOFILES = @DUMMYPOFILES@ -DISTFILES.common = Makefile.in.in remove-potcdate.sin \ -$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) \ -$(DISTFILES.common.extra3) $(DISTFILES.common.extra4) $(DISTFILES.common.extra5) -DISTFILES = $(DISTFILES.common) Makevars POTFILES.in POTFILES-shell.in \ -$(POFILES) $(GMOFILES) \ -$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) $(DISTFILES.extra4) $(DISTFILES.extra5) grub.d.sed README - -POTFILES = \ - -CATALOGS = @CATALOGS@ - -# Makevars gets inserted here. (Don't remove this line!) - -.SUFFIXES: -.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update - -.po.mo: - @echo "$(MSGFMT) -c -o $@ $<"; \ - $(MSGFMT) --endianness=little -c -o t-$@ $< && mv t-$@ $@ - -.po.gmo: - @lang=`echo $* | sed -e 's,.*/,,'`; \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) --endianness=little -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ - cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) --endianness=little -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo - -.sin.sed: - sed -e '/^#/d' $< > t-$@ - mv t-$@ $@ - - -all: check-macro-version all-@USE_NLS@ - -all-yes: stamp-po -all-no: - -# Ensure that the gettext macros and this Makefile.in.in are in sync. -check-macro-version: - @test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ - || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ - exit 1; \ - } - -# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no -# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because -# we don't want to bother translators with empty POT files). We assume that -# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. -# In this case, stamp-po is a nop (i.e. a phony target). - -# stamp-po is a timestamp denoting the last time at which the CATALOGS have -# been loosely updated. Its purpose is that when a developer or translator -# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, -# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent -# invocations of "make" will do nothing. This timestamp would not be necessary -# if updating the $(CATALOGS) would always touch them; however, the rule for -# $(POFILES) has been designed to not touch files that don't need to be -# changed. -stamp-po: $(srcdir)/$(DOMAIN).pot - test ! -f $(srcdir)/$(DOMAIN).pot || \ - test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) - @test ! -f $(srcdir)/$(DOMAIN).pot || { \ - echo "touch stamp-po" && \ - echo timestamp > stamp-poT && \ - mv stamp-poT stamp-po; \ - } - -# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', -# otherwise packages like GCC can not be built if only parts of the source -# have been downloaded. - -# This target rebuilds $(DOMAIN).pot; it is an expensive operation. -# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. -$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell.in remove-potcdate.sed - if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \ - package_gnu='GNU '; \ - else \ - package_gnu=''; \ - fi; \ - if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ - msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ - else \ - msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ - fi; \ - case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - *) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --package-name="$${package_gnu}@PACKAGE@" \ - --package-version='@VERSION@' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - esac; \ - case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES-shell.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - --join-existing --language=Shell \ - --keyword=gettext_quoted --keyword=gettext_printf \ - ;; \ - *) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES-shell.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --package-name="$${package_gnu}@PACKAGE@" \ - --package-version='@VERSION@' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - --join-existing --language=Shell \ - --keyword=gettext_quoted --keyword=gettext_printf \ - ;; \ - esac ; \ - test ! -f $(DOMAIN).po || { \ - sed -f grub.d.sed < $(DOMAIN).po > $(DOMAIN).1po && \ - mv $(DOMAIN).1po $(DOMAIN).po; \ - if test -f $(srcdir)/$(DOMAIN).pot; then \ - sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ - sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ - if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ - rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ - else \ - rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ - mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ - fi; \ - else \ - mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ - fi; \ - } - -# This rule has no dependencies: we don't need to update $(DOMAIN).pot at -# every "make" invocation, only create it when it is missing. -# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. -$(srcdir)/$(DOMAIN).pot: - $(MAKE) $(DOMAIN).pot-update - -# This target rebuilds a PO file if $(DOMAIN).pot has changed. -# Note that a PO file is not touched if it doesn't need to be changed. -$(POFILES): $(srcdir)/$(DOMAIN).pot - @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ - if test -f "$(srcdir)/$${lang}.po"; then \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ - cd $(srcdir) \ - && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \ - esac; \ - }; \ - else \ - $(MAKE) $${lang}.po-create; \ - fi - - -install: install-exec install-data -install-exec: -install-data: install-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ - for file in $(DISTFILES.common) Makevars.template; do \ - $(INSTALL_DATA) $(srcdir)/$$file \ - $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - for file in Makevars; do \ - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - else \ - : ; \ - fi -install-data-no: all -install-data-yes: all - @catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - dir=$(localedir)/$$lang/LC_MESSAGES; \ - $(mkdir_p) $(DESTDIR)$$dir; \ - if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ - $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ - echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ - for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ - if test -n "$$lc"; then \ - if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ - fi; \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ - ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ - cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ - fi; \ - done; \ - done - -install-strip: install - -installdirs: installdirs-exec installdirs-data -installdirs-exec: -installdirs-data: installdirs-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ - else \ - : ; \ - fi -installdirs-data-no: -installdirs-data-yes: - @catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - dir=$(localedir)/$$lang/LC_MESSAGES; \ - $(mkdir_p) $(DESTDIR)$$dir; \ - for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ - if test -n "$$lc"; then \ - if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ - fi; \ - fi; \ - done; \ - done - -# Define this as empty until I found a useful application. -installcheck: - -uninstall: uninstall-exec uninstall-data -uninstall-exec: -uninstall-data: uninstall-data-@USE_NLS@ - if test "$(PACKAGE)" = "gettext-tools"; then \ - for file in $(DISTFILES.common) Makevars.template; do \ - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ - done; \ - else \ - : ; \ - fi -uninstall-data-no: -uninstall-data-yes: - catalogs='$(CATALOGS)'; \ - for cat in $$catalogs; do \ - cat=`basename $$cat`; \ - lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ - for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ - done; \ - done - -check: all - -info dvi ps pdf html tags TAGS ctags CTAGS ID: - -mostlyclean: - rm -f remove-potcdate.sed - rm -f stamp-poT - rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po - rm -fr *.o - -clean: mostlyclean - -distclean: clean - rm -f Makefile Makefile.in POTFILES *.mo - -maintainer-clean: distclean - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - rm -f stamp-po $(GMOFILES) - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -dist distdir: - $(MAKE) update-po - @$(MAKE) dist2 -# This is a separate target because 'update-po' must be executed before. -dist2: stamp-po $(DISTFILES) - dists="$(DISTFILES)"; \ - if test "$(PACKAGE)" = "gettext-tools"; then \ - dists="$$dists Makevars.template"; \ - fi; \ - if test -f $(srcdir)/$(DOMAIN).pot; then \ - dists="$$dists $(DOMAIN).pot stamp-po"; \ - fi; \ - if test -f $(srcdir)/ChangeLog; then \ - dists="$$dists ChangeLog"; \ - fi; \ - for i in 0 1 2 3 4 5 6 7 8 9; do \ - if test -f $(srcdir)/ChangeLog.$$i; then \ - dists="$$dists ChangeLog.$$i"; \ - fi; \ - done; \ - if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ - for file in $$dists; do \ - if test -f $$file; then \ - cp -p $$file $(distdir) || exit 1; \ - else \ - cp -p $(srcdir)/$$file $(distdir) || exit 1; \ - fi; \ - done - -update-po: Makefile - $(MAKE) $(DOMAIN).pot-update - test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) - $(MAKE) update-gmo - -# General rule for creating PO files. - -.nop.po-create: - @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ - echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ - exit 1 - -# General rule for updating PO files. - -.nop.po-update: - @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ - if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ - tmpdir=`pwd`; \ - echo "$$lang:"; \ - test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ - cd $(srcdir); \ - if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - esac; \ - }; then \ - if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ - rm -f $$tmpdir/$$lang.new.po; \ - else \ - if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ - :; \ - else \ - echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ - exit 1; \ - fi; \ - fi; \ - else \ - echo "msgmerge for $$lang.po failed!" 1>&2; \ - rm -f $$tmpdir/$$lang.new.po; \ - fi - -$(DUMMYPOFILES): - -update-gmo: Makefile $(GMOFILES) - @: - -# Recreate Makefile by invoking config.status. Explicitly invoke the shell, -# because execution permission bits may not work on the current file system. -# Use @SHELL@, which is the shell determined by autoconf for the use by its -# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient. -Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ - cd $(top_builddir) \ - && @SHELL@ ./config.status $(subdir)/$@.in po-directories - -force: - -# Tell versions [3.59,3.63) of GNU make not to export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/po/Makevars b/po/Makevars deleted file mode 100644 index 44857b1b8..000000000 --- a/po/Makevars +++ /dev/null @@ -1,41 +0,0 @@ -# Makefile variables for PO directory in any package using GNU gettext. - -# Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) - -# These two variables depend on the location of this directory. -subdir = po -top_builddir = .. - -# These options get passed to xgettext. -XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ - -# This is the copyright holder that gets inserted into the header of the -# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding -# package. (Note that the msgstr strings, extracted from the package's -# sources, belong to the copyright holder of the package.) Translators are -# expected to transfer the copyright for their translations to this person -# or entity, or to disclaim their copyright. The empty string stands for -# the public domain; in this case the translators are expected to disclaim -# their copyright. -COPYRIGHT_HOLDER = Free Software Foundation, Inc. - -# This is the email address or URL to which the translators shall report -# bugs in the untranslated strings: -# - Strings which are not entire sentences, see the maintainer guidelines -# in the GNU gettext documentation, section 'Preparing Strings'. -# - Strings which use unclear terms or require additional context to be -# understood. -# - Strings which make invalid assumptions about notation of date, time or -# money. -# - Pluralisation problems. -# - Incorrect English spelling. -# - Incorrect formatting. -# It can be your email address, or a mailing list address where translators -# can write to without being subscribed, or the URL of a web page through -# which the translators can contact you. -MSGID_BUGS_ADDRESS = bug-grub@gnu.org - -# This is the list of locale categories, beyond LC_MESSAGES, for which the -# message catalogs shall be used. It is usually empty. -EXTRA_LOCALE_CATEGORIES = diff --git a/po/Rules-quot b/po/Rules-quot deleted file mode 100644 index af5248792..000000000 --- a/po/Rules-quot +++ /dev/null @@ -1,47 +0,0 @@ -# Special Makefile rules for English message catalogs with quotation marks. - -DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot - -.SUFFIXES: .insert-header .po-update-en - -en@quot.po-create: - $(MAKE) en@quot.po-update -en@boldquot.po-create: - $(MAKE) en@boldquot.po-update - -en@quot.po-update: en@quot.po-update-en -en@boldquot.po-update: en@boldquot.po-update-en - -.insert-header.po-update-en: - @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ - if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ - tmpdir=`pwd`; \ - echo "$$lang:"; \ - ll=`echo $$lang | sed -e 's/@.*//'`; \ - LC_ALL=C; export LC_ALL; \ - cd $(srcdir); \ - if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ - if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ - rm -f $$tmpdir/$$lang.new.po; \ - else \ - if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ - :; \ - else \ - echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ - exit 1; \ - fi; \ - fi; \ - else \ - echo "creation of $$lang.po failed!" 1>&2; \ - rm -f $$tmpdir/$$lang.new.po; \ - fi - -en@quot.insert-header: insert-header.sin - sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header - -en@boldquot.insert-header: insert-header.sin - sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header - -mostlyclean: mostlyclean-quot -mostlyclean-quot: - rm -f *.insert-header diff --git a/util/grub-setup.c b/util/grub-setup.c index 993b02068..42b98ad3c 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -69,7 +69,7 @@ #define DEFAULT_CORE_FILE "core.img" /* Non-printable "keys" for arguments with no short form. - * See grub-core/gnulib/argp.h for details. */ + * See grub-core/lib/gnulib/argp.h for details. */ enum { NO_RS_CODES_KEY = 0x100, }; From 41121742df1af73699965a2aab5fb1f5e6555ad5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Mar 2019 14:19:27 +0100 Subject: [PATCH 0936/1167] windows/platform.c: Fix compilation errors --- grub-core/osdep/windows/platform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index 912269191..7eb53fe01 100644 --- a/grub-core/osdep/windows/platform.c +++ b/grub-core/osdep/windows/platform.c @@ -201,7 +201,7 @@ set_efi_variable_bootn (grub_uint16_t n, void *in, grub_size_t len) set_efi_variable (varname, in, len); } -void +int grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor) @@ -363,7 +363,7 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, grub_util_error ("%s", grub_errmsg); efidir_grub_dev->disk->partition = p; grub_memcpy (hddp->partition_signature, - gptdata.guid, 16); + &gptdata.guid, 16); hddp->partmap_type = 2; hddp->signature_type = 2; @@ -407,6 +407,8 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, set_efi_variable_bootn (order_num, entry, (grub_uint8_t *) pathptr - entry); set_efi_variable (L"BootOrder", new_boot_order, new_boot_order_len * sizeof (grub_uint16_t)); + + return 0; } void From 6c5ee45548fcb65d7921c9fca5867b256f9a48ad Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Thu, 7 Mar 2019 12:16:06 +0100 Subject: [PATCH 0937/1167] Makefile: Allow to set file systems modules for default_payload.elf By default all file system modules are added to the GRUB coreboot payload `default_payload.elf`. This makes the image quite big, especially as often not all modules are needed. Introduce the variable `FS_PAYLOAD_MODULES`, which can be used to explicitly set file systems modules to be added. $ make default_payload.elf test -f default_payload.elf && rm default_payload.elf || true pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu affs afs bfs btrfs cbfs cpio cpio_be exfat ext2 f2fs fat hfs hfsplus iso9660 jfs minix minix2 minix2_be minix3 minix3_be minix_be newc nilfs2 ntfs odc procfs reiserfs romfs sfs squash4 tar udf ufs1 ufs1_be ufs2 xfs zfs password_pbkdf2 ' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg $ ls -l default_payload.elf -rw-rw---- 1 joey joey 1199568 Mar 6 13:58 default_payload.elf $ make default_payload.elf FS_PAYLOAD_MODULES="" # ext2 already in `--modules` test -f default_payload.elf && rm default_payload.elf || true pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu password_pbkdf2 ' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg $ ls -l default_payload.elf -rw-rw---- 1 joey joey 832976 Mar 7 12:13 default_payload.elf So, the resulting payload size is around 370 kB smaller. (Adding it to the CBFS, it will be compressed, so the effective size difference will be smaller.) Signed-off-by: Paul Menzel Reviewed-by: Daniel Kiper --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 94296a37e..1f4bb9b8c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -422,9 +422,10 @@ BOOTCHECK_TIMEOUT=180 bootcheck: $(BOOTCHECKS) if COND_i386_coreboot +FS_PAYLOAD_MODULES ?= $(shell cat grub-core/fs.lst) default_payload.elf: grub-mkstandalone grub-mkimage FORCE test -f $@ && rm $@ || true - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(FS_PAYLOAD_MODULES) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From 3434ddec0e295011d3adb890ade0da79579dfc14 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 4 Mar 2019 17:27:39 -0800 Subject: [PATCH 0938/1167] ieee1275: obdisk driver Add a new disk driver called obdisk for IEEE1275 platforms. Currently the only platform using this disk driver is SPARC, however other IEEE1275 platforms could start using it if they so choose. While the functionality within the current IEEE1275 ofdisk driver may be suitable for PPC and x86, it presented too many problems on SPARC hardware. Within the old ofdisk, there is not a way to determine the true canonical name for the disk. Within Open Boot, the same disk can have multiple names but all reference the same disk. For example the same disk can be referenced by its SAS WWN, using this form: /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@w5000cca02f037d6d,0 It can also be referenced by its PHY identifier using this form: /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@p0 It can also be referenced by its Target identifier using this form: /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@0 Also, when the LUN=0, it is legal to omit the ,0 from the device name. So with the disk above, before taking into account the device aliases, there are 6 ways to reference the same disk. Then it is possible to have 0 .. n device aliases all representing the same disk. Within this new driver the true canonical name is determined using the the IEEE1275 encode-unit and decode-unit commands when address_cells == 4. This will determine the true single canonical name for the device so multiple ihandles are not opened for the same device. This is what frequently happens with the old ofdisk driver. With some devices when they are opened multiple times it causes the entire system to hang. Another problem solved with this driver is devices that do not have a device alias can be booted and used within GRUB. Within the old ofdisk, this was not possible, unless it was the original boot device. All devices behind a SAS or SCSI parent can be found. Within the old ofdisk, finding these disks relied on there being an alias defined. The alias requirement is not necessary with this new driver. It can also find devices behind a parent after they have been hot-plugged. This is something that is not possible with the old ofdisk driver. The old ofdisk driver also incorrectly assumes that the device pointing to by a device alias is in its true canonical form. This assumption is never made with this new driver. Another issue solved with this driver is that it properly caches the ihandle for all open devices. The old ofdisk tries to do this by caching the last opened ihandle. However this does not work properly because the layer above does not use a consistent device name for the same disk when calling into the driver. This is because the upper layer uses the bootpath value returned within /chosen, other times it uses the device alias, and other times it uses the value within grub.cfg. It does not have a way to figure out that these devices are the same disk. This is not a problem with this new driver. Due to the way GRUB repeatedly opens and closes the same disk. Caching the ihandle is important on SPARC. Without caching, some SAS devices can take 15 - 20 minutes to get to the GRUB menu. This ihandle caching is not possible without correctly having the canonical disk name. When available, this driver also tries to use the deblocker #blocks and a way of determining the disk size. Finally and probably most importantly, this new driver is also capable of seeing all partitions on a GPT disk. With the old driver, the GPT partition table can not be read and only the first partition on the disk can be seen. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 1 + grub-core/commands/nativedisk.c | 1 + grub-core/disk/ieee1275/obdisk.c | 1076 ++++++++++++++++++++++++++++++ grub-core/kern/ieee1275/cmain.c | 3 + grub-core/kern/ieee1275/init.c | 12 +- include/grub/disk.h | 1 + include/grub/ieee1275/ieee1275.h | 2 + include/grub/ieee1275/obdisk.h | 25 + 8 files changed, 1120 insertions(+), 1 deletion(-) create mode 100644 grub-core/disk/ieee1275/obdisk.c create mode 100644 include/grub/ieee1275/obdisk.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 58df4ab07..ea8b99823 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -317,6 +317,7 @@ kernel = { sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c; sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c; + sparc64_ieee1275 = disk/ieee1275/obdisk.c; arm = kern/arm/dl.c; arm = kern/arm/dl_helper.c; diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index c278f377b..87a9845fe 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -66,6 +66,7 @@ get_uuid (const char *name, char **uuid, int getnative) /* Firmware disks. */ case GRUB_DISK_DEVICE_BIOSDISK_ID: case GRUB_DISK_DEVICE_OFDISK_ID: + case GRUB_DISK_DEVICE_OBDISK_ID: case GRUB_DISK_DEVICE_EFIDISK_ID: case GRUB_DISK_DEVICE_NAND_ID: case GRUB_DISK_DEVICE_ARCDISK_ID: diff --git a/grub-core/disk/ieee1275/obdisk.c b/grub-core/disk/ieee1275/obdisk.c new file mode 100644 index 000000000..877f65c9e --- /dev/null +++ b/grub-core/disk/ieee1275/obdisk.c @@ -0,0 +1,1076 @@ +/* obdisk.c - Open Boot disk access. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IEEE1275_DEV "ieee1275/" +#define IEEE1275_DISK_ALIAS "/disk@" + +struct disk_dev +{ + struct disk_dev *next; + struct disk_dev **prev; + char *name; + char *raw_name; + char *grub_devpath; + char *grub_alias_devpath; + grub_ieee1275_ihandle_t ihandle; + grub_uint32_t block_size; + grub_uint64_t num_blocks; + unsigned int log_sector_size; + grub_uint32_t opened; + grub_uint32_t valid; + grub_uint32_t boot_dev; +}; + +struct parent_dev +{ + struct parent_dev *next; + struct parent_dev **prev; + char *name; + char *type; + grub_ieee1275_ihandle_t ihandle; + grub_uint32_t address_cells; +}; + +static struct grub_scsi_test_unit_ready tur = +{ + .opcode = grub_scsi_cmd_test_unit_ready, + .lun = 0, + .reserved1 = 0, + .reserved2 = 0, + .reserved3 = 0, + .control = 0, +}; + +static int disks_enumerated; +static struct disk_dev *disk_devs; +static struct parent_dev *parent_devs; + +static const char *block_blacklist[] = { + /* Requires additional work in grub before being able to be used. */ + "/iscsi-hba", + /* This block device should never be used by grub. */ + "/reboot-memory@0", + 0 +}; + +#define STRCMP(a, b) ((a) && (b) && (grub_strcmp (a, b) == 0)) + +static char * +strip_ob_partition (char *path) +{ + char *sptr; + + sptr = grub_strstr (path, ":"); + + if (sptr != NULL) + *sptr = '\0'; + + return path; +} + +static void +escape_commas (const char *src, char *dest) +{ + const char *iptr; + + for (iptr = src; *iptr; ) + { + if (*iptr == ',') + *dest++ ='\\'; + + *dest++ = *iptr++; + } + + *dest = '\0'; +} + +static int +count_commas (const char *src) +{ + int count = 0; + + for ( ; *src; src++) + if (*src == ',') + count++; + + return count; +} + + +static char * +decode_grub_devname (const char *name) +{ + char *devpath = grub_malloc (grub_strlen (name) + 1); + char *p, c; + + if (devpath == NULL) + return NULL; + + /* Un-escape commas. */ + p = devpath; + while ((c = *name++) != '\0') + { + if (c == '\\' && *name == ',') + { + *p++ = ','; + name++; + } + else + *p++ = c; + } + + *p++ = '\0'; + + return devpath; +} + +static char * +encode_grub_devname (const char *path) +{ + char *encoding, *optr; + + if (path == NULL) + return NULL; + + encoding = grub_malloc (sizeof (IEEE1275_DEV) + count_commas (path) + + grub_strlen (path) + 1); + + if (encoding == NULL) + { + grub_print_error (); + return NULL; + } + + optr = grub_stpcpy (encoding, IEEE1275_DEV); + escape_commas (path, optr); + return encoding; +} + +static char * +get_parent_devname (const char *devname) +{ + char *parent, *pptr; + + parent = grub_strdup (devname); + + if (parent == NULL) + { + grub_print_error (); + return NULL; + } + + pptr = grub_strstr (parent, IEEE1275_DISK_ALIAS); + + if (pptr != NULL) + *pptr = '\0'; + + return parent; +} + +static void +free_parent_dev (struct parent_dev *parent) +{ + if (parent != NULL) + { + grub_free (parent->name); + grub_free (parent->type); + grub_free (parent); + } +} + +static struct parent_dev * +init_parent (const char *parent) +{ + struct parent_dev *op; + + op = grub_zalloc (sizeof (struct parent_dev)); + + if (op == NULL) + { + grub_print_error (); + return NULL; + } + + op->name = grub_strdup (parent); + op->type = grub_malloc (IEEE1275_MAX_PROP_LEN); + + if ((op->name == NULL) || (op->type == NULL)) + { + grub_print_error (); + free_parent_dev (op); + return NULL; + } + + return op; +} + +static struct parent_dev * +open_new_parent (const char *parent) +{ + struct parent_dev *op = init_parent(parent); + grub_ieee1275_ihandle_t ihandle; + grub_ieee1275_phandle_t phandle; + grub_uint32_t address_cells = 2; + + if (op == NULL) + return NULL; + + grub_ieee1275_open (parent, &ihandle); + + if (ihandle == 0) + { + grub_error (GRUB_ERR_BAD_DEVICE, "unable to open %s", parent); + grub_print_error (); + free_parent_dev (op); + return NULL; + } + + if (grub_ieee1275_instance_to_package (ihandle, &phandle)) + { + grub_error (GRUB_ERR_BAD_DEVICE, "unable to get parent %s", parent); + grub_print_error (); + free_parent_dev (op); + return NULL; + } + + /* + * IEEE Std 1275-1994 page 110: A missing "address-cells" property + * signifies that the number of address cells is two. So ignore on error. + */ + if (grub_ieee1275_get_integer_property (phandle, "#address-cells", + &address_cells, + sizeof (address_cells), 0) != 0) + address_cells = 2; + + grub_ieee1275_get_property (phandle, "device_type", op->type, + IEEE1275_MAX_PROP_LEN, NULL); + + op->ihandle = ihandle; + op->address_cells = address_cells; + return op; +} + +static struct parent_dev * +open_parent (const char *parent) +{ + struct parent_dev *op; + + op = grub_named_list_find (GRUB_AS_NAMED_LIST (parent_devs), parent); + + if (op == NULL) + { + op = open_new_parent (parent); + + if (op != NULL) + grub_list_push (GRUB_AS_LIST_P (&parent_devs), GRUB_AS_LIST (op)); + } + + return op; +} + +static void +display_parents (void) +{ + struct parent_dev *parent; + + grub_printf ("-------------------- PARENTS --------------------\n"); + + FOR_LIST_ELEMENTS (parent, parent_devs) + { + grub_printf ("name: %s\n", parent->name); + grub_printf ("type: %s\n", parent->type); + grub_printf ("address_cells %x\n", parent->address_cells); + } + + grub_printf ("-------------------------------------------------\n"); +} + +static char * +canonicalise_4cell_ua (grub_ieee1275_ihandle_t ihandle, char *unit_address) +{ + grub_uint32_t phy_lo, phy_hi, lun_lo, lun_hi; + int valid_phy = 0; + grub_size_t size; + char *canon = NULL; + + valid_phy = grub_ieee1275_decode_unit4 (ihandle, unit_address, + grub_strlen (unit_address), &phy_lo, + &phy_hi, &lun_lo, &lun_hi); + + if ((valid_phy == 0) && (phy_hi != 0xffffffff)) + canon = grub_ieee1275_encode_uint4 (ihandle, phy_lo, phy_hi, + lun_lo, lun_hi, &size); + + return canon; +} + +static char * +canonicalise_disk (const char *devname) +{ + char *canon, *parent; + struct parent_dev *op; + + canon = grub_ieee1275_canonicalise_devname (devname); + + if (canon == NULL) + { + /* This should not happen. */ + grub_error (GRUB_ERR_BAD_DEVICE, "canonicalise devname failed"); + grub_print_error (); + return NULL; + } + + /* Don't try to open the parent of a virtual device. */ + if (grub_strstr (canon, "virtual-devices")) + return canon; + + parent = get_parent_devname (canon); + + if (parent == NULL) + return NULL; + + op = open_parent (parent); + + /* + * Devices with 4 address cells can have many different types of addressing + * (phy, wwn, and target lun). Use the parents encode-unit / decode-unit + * to find the true canonical name. + */ + if ((op) && (op->address_cells == 4)) + { + char *unit_address, *real_unit_address, *real_canon; + grub_size_t real_unit_str_len; + + unit_address = grub_strstr (canon, IEEE1275_DISK_ALIAS); + unit_address += grub_strlen (IEEE1275_DISK_ALIAS); + + if (unit_address == NULL) + { + /* + * This should not be possible, but return the canonical name for + * the non-disk block device. + */ + grub_free (parent); + return (canon); + } + + real_unit_address = canonicalise_4cell_ua (op->ihandle, unit_address); + + if (real_unit_address == NULL) + { + /* + * This is not an error, since this function could be called with a devalias + * containing a drive that isn't installed in the system. + */ + grub_free (parent); + return NULL; + } + + real_unit_str_len = grub_strlen (op->name) + sizeof (IEEE1275_DISK_ALIAS) + + grub_strlen (real_unit_address); + + real_canon = grub_malloc (real_unit_str_len); + + grub_snprintf (real_canon, real_unit_str_len, "%s/disk@%s", + op->name, real_unit_address); + + grub_free (canon); + canon = real_canon; + } + + grub_free (parent); + return (canon); +} + +static struct disk_dev * +add_canon_disk (const char *cname) +{ + struct disk_dev *dev; + + dev = grub_zalloc (sizeof (struct disk_dev)); + + if (dev == NULL) + goto failed; + + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_RAW_DEVNAMES)) + { + /* + * Append :nolabel to the end of all SPARC disks. + * nolabel is mutually exclusive with all other + * arguments and allows a client program to open + * the entire (raw) disk. Any disk label is ignored. + */ + dev->raw_name = grub_malloc (grub_strlen (cname) + sizeof (":nolabel")); + + if (dev->raw_name == NULL) + goto failed; + + grub_snprintf (dev->raw_name, grub_strlen (cname) + sizeof (":nolabel"), + "%s:nolabel", cname); + } + + /* + * Don't use grub_ieee1275_encode_devname here, the devpath in grub.cfg doesn't + * understand device aliases, which the layer above sometimes sends us. + */ + dev->grub_devpath = encode_grub_devname(cname); + + if (dev->grub_devpath == NULL) + goto failed; + + dev->name = grub_strdup (cname); + + if (dev->name == NULL) + goto failed; + + dev->valid = 1; + grub_list_push (GRUB_AS_LIST_P (&disk_devs), GRUB_AS_LIST (dev)); + return dev; + + failed: + grub_print_error (); + + if (dev != NULL) + { + grub_free (dev->name); + grub_free (dev->grub_devpath); + grub_free (dev->raw_name); + } + + grub_free (dev); + return NULL; +} + +static grub_err_t +add_disk (const char *path) +{ + grub_err_t ret = GRUB_ERR_NONE; + struct disk_dev *dev; + char *canon; + + canon = canonicalise_disk (path); + dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon); + + if ((canon != NULL) && (dev == NULL)) + { + struct disk_dev *ob_device; + + ob_device = add_canon_disk (canon); + + if (ob_device == NULL) + ret = grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure to add disk"); + } + else if (dev != NULL) + dev->valid = 1; + + grub_free (canon); + return (ret); +} + +static grub_err_t +grub_obdisk_read (grub_disk_t disk, grub_disk_addr_t sector, + grub_size_t size, char *dest) +{ + grub_err_t ret = GRUB_ERR_NONE; + struct disk_dev *dev; + unsigned long long pos; + grub_ssize_t result = 0; + + if (disk->data == NULL) + return grub_error (GRUB_ERR_BAD_DEVICE, "invalid disk data"); + + dev = (struct disk_dev *)disk->data; + pos = sector << disk->log_sector_size; + grub_ieee1275_seek (dev->ihandle, pos, &result); + + if (result < 0) + { + dev->opened = 0; + return grub_error (GRUB_ERR_READ_ERROR, "seek error, can't seek block %llu", + (long long) sector); + } + + grub_ieee1275_read (dev->ihandle, dest, size << disk->log_sector_size, + &result); + + if (result != (grub_ssize_t) (size << disk->log_sector_size)) + { + dev->opened = 0; + return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx " + "from `%s'"), + (unsigned long long) sector, + disk->name); + } + return ret; +} + +static void +grub_obdisk_close (grub_disk_t disk) +{ + grub_memset (disk, 0, sizeof (*disk)); +} + +static void +scan_usb_disk (const char *parent) +{ + struct parent_dev *op; + grub_ssize_t result; + + op = open_parent (parent); + + if (op == NULL) + { + grub_error (GRUB_ERR_BAD_DEVICE, "unable to open %s", parent); + grub_print_error (); + return; + } + + if ((grub_ieee1275_set_address (op->ihandle, 0, 0) == 0) && + (grub_ieee1275_no_data_command (op->ihandle, &tur, &result) == 0) && + (result == 0)) + { + char *buf; + + buf = grub_malloc (IEEE1275_MAX_PATH_LEN); + + if (buf == NULL) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure"); + grub_print_error (); + return; + } + + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@0", parent); + add_disk (buf); + grub_free (buf); + } +} + +static void +scan_nvme_disk (const char *path) +{ + char *buf; + + buf = grub_malloc (IEEE1275_MAX_PATH_LEN); + + if (buf == NULL) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure"); + grub_print_error (); + return; + } + + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@1", path); + add_disk (buf); + grub_free (buf); +} + +static void +scan_sparc_sas_2cell (struct parent_dev *op) +{ + grub_ssize_t result; + grub_uint8_t tgt; + char *buf; + + buf = grub_malloc (IEEE1275_MAX_PATH_LEN); + + if (buf == NULL) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure"); + grub_print_error (); + return; + } + + for (tgt = 0; tgt < 0xf; tgt++) + { + + if ((grub_ieee1275_set_address(op->ihandle, tgt, 0) == 0) && + (grub_ieee1275_no_data_command (op->ihandle, &tur, &result) == 0) && + (result == 0)) + { + + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@%" + PRIxGRUB_UINT32_T, op->name, tgt); + + add_disk (buf); + } + } +} + +static void +scan_sparc_sas_4cell (struct parent_dev *op) +{ + grub_uint16_t exp; + grub_uint8_t phy; + char *buf; + + buf = grub_malloc (IEEE1275_MAX_PATH_LEN); + + if (buf == NULL) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure"); + grub_print_error (); + return; + } + + /* + * Cycle thru the potential for dual ported SAS disks + * behind a SAS expander. + */ + for (exp = 0; exp <= 0x100; exp+=0x100) + + /* The current limit is 32 disks on a phy. */ + for (phy = 0; phy < 0x20; phy++) + { + char *canon = NULL; + + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "p%" PRIxGRUB_UINT32_T ",0", + exp | phy); + + canon = canonicalise_4cell_ua (op->ihandle, buf); + + if (canon != NULL) + { + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@%s", + op->name, canon); + + add_disk (buf); + grub_free (canon); + } + } + + grub_free (buf); +} + +static void +scan_sparc_sas_disk (const char *parent) +{ + struct parent_dev *op; + + op = open_parent (parent); + + if ((op != NULL) && (op->address_cells == 4)) + scan_sparc_sas_4cell (op); + else if ((op != NULL) && (op->address_cells == 2)) + scan_sparc_sas_2cell (op); +} + +static void +iterate_devtree (const struct grub_ieee1275_devalias *alias) +{ + struct grub_ieee1275_devalias child; + + if ((grub_strcmp (alias->type, "scsi-2") == 0) || + (grub_strcmp (alias->type, "scsi-sas") == 0)) + return scan_sparc_sas_disk (alias->path); + + else if (grub_strcmp (alias->type, "nvme") == 0) + return scan_nvme_disk (alias->path); + + else if (grub_strcmp (alias->type, "scsi-usb") == 0) + return scan_usb_disk (alias->path); + + else if (grub_strcmp (alias->type, "block") == 0) + { + const char **bl = block_blacklist; + + while (*bl != NULL) + { + if (grub_strstr (alias->path, *bl)) + return; + bl++; + } + + add_disk (alias->path); + return; + } + + FOR_IEEE1275_DEVCHILDREN (alias->path, child) + iterate_devtree (&child); +} + +static void +enumerate_disks (void) +{ + struct grub_ieee1275_devalias alias; + + FOR_IEEE1275_DEVCHILDREN("/", alias) + iterate_devtree (&alias); +} + +static grub_err_t +add_bootpath (void) +{ + struct disk_dev *ob_device; + grub_err_t ret = GRUB_ERR_NONE; + char *dev, *alias; + char *type; + + dev = grub_ieee1275_get_boot_dev (); + + if (dev == NULL) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device"); + + type = grub_ieee1275_get_device_type (dev); + + if (type == NULL) + { + grub_free (dev); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device"); + } + + alias = NULL; + + if (grub_strcmp (type, "network") != 0) + { + dev = strip_ob_partition (dev); + ob_device = add_canon_disk (dev); + + if (ob_device == NULL) + ret = grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device"); + + ob_device->valid = 1; + + alias = grub_ieee1275_get_devname (dev); + + if (alias && grub_strcmp (alias, dev) != 0) + ob_device->grub_alias_devpath = grub_ieee1275_encode_devname (dev); + + ob_device->boot_dev = 1; + } + + grub_free (type); + grub_free (dev); + grub_free (alias); + return ret; +} + +static void +enumerate_aliases (void) +{ + struct grub_ieee1275_devalias alias; + + /* + * Some block device aliases are not in canonical form + * + * For example: + * + * disk3 /pci@301/pci@1/scsi@0/disk@p3 + * disk2 /pci@301/pci@1/scsi@0/disk@p2 + * disk1 /pci@301/pci@1/scsi@0/disk@p1 + * disk /pci@301/pci@1/scsi@0/disk@p0 + * disk0 /pci@301/pci@1/scsi@0/disk@p0 + * + * None of these devices are in canonical form. + * + * Also, just because there is a devalias, doesn't mean there is a disk + * at that location. And a valid boot block device doesn't have to have + * a devalias at all. + * + * At this point, all valid disks have been found in the system + * and devaliases that point to canonical names are stored in the + * disk_devs list already. + */ + FOR_IEEE1275_DEVALIASES (alias) + { + struct disk_dev *dev; + char *canon; + + if (grub_strcmp (alias.type, "block") != 0) + continue; + + canon = canonicalise_disk (alias.name); + + if (canon == NULL) + /* This is not an error, a devalias could point to a nonexistent disk. */ + continue; + + dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon); + + if (dev != NULL) + { + /* + * If more than one alias points to the same device, + * remove the previous one unless it is the boot dev, + * since the upper level will use the first one. The reason + * all the others are redone is in the case of hot-plugging + * a disk. If the boot disk gets hot-plugged, it will come + * thru here with a different name without the boot_dev flag + * set. + */ + if ((dev->boot_dev) && (dev->grub_alias_devpath)) + continue; + + grub_free (dev->grub_alias_devpath); + dev->grub_alias_devpath = grub_ieee1275_encode_devname (alias.path); + } + grub_free (canon); + } +} + +static void +display_disks (void) +{ + struct disk_dev *dev; + + grub_printf ("--------------------- DISKS ---------------------\n"); + + FOR_LIST_ELEMENTS (dev, disk_devs) + { + grub_printf ("name: %s\n", dev->name); + grub_printf ("grub_devpath: %s\n", dev->grub_devpath); + grub_printf ("grub_alias_devpath: %s\n", dev->grub_alias_devpath); + grub_printf ("valid: %s\n", (dev->valid) ? "yes" : "no"); + grub_printf ("boot_dev: %s\n", (dev->boot_dev) ? "yes" : "no"); + grub_printf ("opened: %s\n", (dev->ihandle) ? "yes" : "no"); + grub_printf ("block size: %" PRIuGRUB_UINT32_T "\n", + dev->block_size); + grub_printf ("num blocks: %" PRIuGRUB_UINT64_T "\n", + dev->num_blocks); + grub_printf ("log sector size: %" PRIuGRUB_UINT32_T "\n", + dev->log_sector_size); + grub_printf ("\n"); + } + + grub_printf ("-------------------------------------------------\n"); +} + +static void +display_stats (void) +{ + const char *debug = grub_env_get ("debug"); + + if (debug == NULL) + return; + + if (grub_strword (debug, "all") || grub_strword (debug, "obdisk")) + { + display_parents (); + display_disks (); + } +} + +static void +invalidate_all_disks (void) +{ + struct disk_dev *dev = NULL; + + if (disks_enumerated != 0) + FOR_LIST_ELEMENTS (dev, disk_devs) + dev->valid = 0; +} + +static struct disk_dev * +find_legacy_grub_devpath (const char *name) +{ + struct disk_dev *dev = NULL; + char *canon, *devpath = NULL; + + devpath = decode_grub_devname (name + sizeof ("ieee1275")); + canon = canonicalise_disk (devpath); + + if (canon != NULL) + dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon); + + grub_free (devpath); + grub_free (canon); + return dev; +} + +static void +enumerate_devices (void) +{ + invalidate_all_disks (); + enumerate_disks (); + enumerate_aliases (); + disks_enumerated = 1; + display_stats (); +} + +static struct disk_dev * +find_grub_devpath_real (const char *name) +{ + struct disk_dev *dev = NULL; + + FOR_LIST_ELEMENTS (dev, disk_devs) + { + if ((STRCMP (dev->grub_devpath, name)) + || (STRCMP (dev->grub_alias_devpath, name))) + break; + } + + return dev; +} + +static struct disk_dev * +find_grub_devpath (const char *name) +{ + struct disk_dev *dev = NULL; + int enumerated; + + do { + enumerated = disks_enumerated; + dev = find_grub_devpath_real (name); + + if (dev != NULL) + break; + + dev = find_legacy_grub_devpath (name); + + if (dev != NULL) + break; + + enumerate_devices (); + } while (enumerated == 0); + + return dev; +} + +static int +grub_obdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, + grub_disk_pull_t pull) +{ + struct disk_dev *dev; + const char *name; + + if (pull != GRUB_DISK_PULL_NONE) + return 0; + + enumerate_devices (); + + FOR_LIST_ELEMENTS (dev, disk_devs) + { + if (dev->valid == 1) + { + if (dev->grub_alias_devpath) + name = dev->grub_alias_devpath; + else + name = dev->grub_devpath; + + if (hook (name, hook_data)) + return 1; + } + } + + return 0; +} + +static grub_err_t +grub_obdisk_open (const char *name, grub_disk_t disk) +{ + grub_ieee1275_ihandle_t ihandle = 0; + struct disk_dev *dev = NULL; + + if (grub_strncmp (name, IEEE1275_DEV, sizeof (IEEE1275_DEV) - 1) != 0) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not IEEE1275 device"); + + dev = find_grub_devpath (name); + + if (dev == NULL) + { + grub_printf ("UNKNOWN DEVICE: %s\n", name); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "%s", name); + } + + if (dev->opened == 0) + { + if (dev->raw_name != NULL) + grub_ieee1275_open (dev->raw_name, &ihandle); + else + grub_ieee1275_open (dev->name, &ihandle); + + if (ihandle == 0) + { + grub_printf ("Can't open device %s\n", name); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device %s", name); + } + + dev->block_size = grub_ieee1275_get_block_size (ihandle); + dev->num_blocks = grub_ieee1275_num_blocks (ihandle); + + if (dev->num_blocks == 0) + dev->num_blocks = grub_ieee1275_num_blocks64 (ihandle); + + if (dev->num_blocks == 0) + dev->num_blocks = GRUB_DISK_SIZE_UNKNOWN; + + if (dev->block_size != 0) + { + for (dev->log_sector_size = 0; + (1U << dev->log_sector_size) < dev->block_size; + dev->log_sector_size++); + } + else + dev->log_sector_size = 9; + + dev->ihandle = ihandle; + dev->opened = 1; + } + + disk->total_sectors = dev->num_blocks; + disk->id = dev->ihandle; + disk->data = dev; + disk->log_sector_size = dev->log_sector_size; + return GRUB_ERR_NONE; +} + + +static struct grub_disk_dev grub_obdisk_dev = + { + .name = "obdisk", + .id = GRUB_DISK_DEVICE_OBDISK_ID, + .iterate = grub_obdisk_iterate, + .open = grub_obdisk_open, + .close = grub_obdisk_close, + .read = grub_obdisk_read, + }; + +void +grub_obdisk_init (void) +{ + grub_disk_firmware_fini = grub_obdisk_fini; + add_bootpath (); + grub_disk_dev_register (&grub_obdisk_dev); +} + +void +grub_obdisk_fini (void) +{ + struct disk_dev *dev; + + FOR_LIST_ELEMENTS (dev, disk_devs) + { + if (dev->opened != 0) + grub_ieee1275_close (dev->ihandle); + } + + grub_disk_dev_unregister (&grub_obdisk_dev); +} diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index 3e12e6b24..20cbbd761 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -108,6 +108,9 @@ grub_ieee1275_find_options (void) if (rc >= 0) { char *ptr; + + if (grub_strncmp (tmp, "sun4v", 5) == 0) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_RAW_DEVNAMES); for (ptr = tmp; ptr - tmp < actual; ptr += grub_strlen (ptr) + 1) { if (grub_memcmp (ptr, "MacRISC", sizeof ("MacRISC") - 1) == 0 diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 0d8ebf58b..d483e35ee 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -30,6 +30,9 @@ #include #include #include +#ifdef __sparc__ +#include +#endif #include #include #include @@ -280,8 +283,11 @@ grub_machine_init (void) grub_console_init_early (); grub_claim_heap (); grub_console_init_lately (); +#ifdef __sparc__ + grub_obdisk_init (); +#else grub_ofdisk_init (); - +#endif grub_parse_cmdline (); #ifdef __i386__ @@ -296,7 +302,11 @@ grub_machine_fini (int flags) { if (flags & GRUB_LOADER_FLAG_NORETURN) { +#ifdef __sparc__ + grub_obdisk_fini (); +#else grub_ofdisk_fini (); +#endif grub_console_fini (); } } diff --git a/include/grub/disk.h b/include/grub/disk.h index b385af826..bd58b11d5 100644 --- a/include/grub/disk.h +++ b/include/grub/disk.h @@ -49,6 +49,7 @@ enum grub_disk_dev_id GRUB_DISK_DEVICE_CBFSDISK_ID, GRUB_DISK_DEVICE_UBOOTDISK_ID, GRUB_DISK_DEVICE_XEN, + GRUB_DISK_DEVICE_OBDISK_ID, }; struct grub_disk; diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 8868f3a75..73e2f4644 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -146,6 +146,8 @@ enum grub_ieee1275_flag GRUB_IEEE1275_FLAG_BROKEN_REPEAT, GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, + + GRUB_IEEE1275_FLAG_RAW_DEVNAMES, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff --git a/include/grub/ieee1275/obdisk.h b/include/grub/ieee1275/obdisk.h new file mode 100644 index 000000000..5da51f812 --- /dev/null +++ b/include/grub/ieee1275/obdisk.h @@ -0,0 +1,25 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#ifndef GRUB_OBDISK_HEADER +#define GRUB_OBDISK_HEADER 1 + +extern void grub_obdisk_init (void); +extern void grub_obdisk_fini (void); + +#endif From 9a0703b55948144f58b686a7e313cbdb4203a444 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 4 Mar 2019 17:34:01 -0800 Subject: [PATCH 0939/1167] sparc64: Add bios boot partition support Add BIOS Boot Partition support for sparc64 platforms. This will work a little different than x86. With GPT, both the OBP "load" and "boot" commands are partition aware and neither command can see the partition table. Therefore the entire boot-loader is stored within the BIOS Boot Partition and nothing is stored within the bootstrap code area of MBR. To use it, the end user will issue the boot command with the path pointing to the BIOS Boot Partition. For example with the disk below: Model: Unknown (unknown) Disk /dev/nvme1n1: 1600GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 1075MB 1074MB ext3 2 1075MB 1076MB 1049kB bios_grub 3 1076MB 1600GB 1599GB lvm To boot grub2 from OBP, you would use: boot /pci@302/pci@1/pci@0/pci@13/nvme@0/disk@1:b Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- util/setup.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/util/setup.c b/util/setup.c index 8954dd479..92a5af9ba 100644 --- a/util/setup.c +++ b/util/setup.c @@ -205,7 +205,6 @@ save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length, #endif } -#ifdef GRUB_SETUP_BIOS /* Context for setup/identify_partmap. */ struct identify_partmap_ctx { @@ -241,7 +240,6 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)), ctx->multiple_partmaps = 1; return 1; } -#endif #ifdef GRUB_SETUP_BIOS #define SETUP grub_util_bios_setup @@ -262,9 +260,7 @@ SETUP (const char *dir, char *boot_img, *core_img, *boot_path; char *root = 0; size_t boot_size, core_size; -#ifdef GRUB_SETUP_BIOS grub_uint16_t core_sectors; -#endif grub_device_t root_dev = 0, dest_dev, core_dev; grub_util_fd_t fp; struct blocklists bl; @@ -288,10 +284,8 @@ SETUP (const char *dir, core_path = grub_util_get_path (dir, core_file); core_size = grub_util_get_image_size (core_path); -#ifdef GRUB_SETUP_BIOS core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); -#endif if (core_size < GRUB_DISK_SECTOR_SIZE) grub_util_error (_("the size of `%s' is too small"), core_path); #ifdef GRUB_SETUP_BIOS @@ -372,8 +366,8 @@ SETUP (const char *dir, if (grub_env_set ("root", root) != GRUB_ERR_NONE) grub_util_error ("%s", grub_errmsg); -#ifdef GRUB_SETUP_BIOS { +#ifdef GRUB_SETUP_BIOS char *tmp_img; grub_uint8_t *boot_drive_check; @@ -398,6 +392,7 @@ SETUP (const char *dir, boot_drive_check[0] = 0x90; boot_drive_check[1] = 0x90; } +#endif struct identify_partmap_ctx ctx = { .dest_partmap = NULL, @@ -413,6 +408,7 @@ SETUP (const char *dir, grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx); +#ifdef GRUB_SETUP_BIOS /* Copy the partition table. */ if (ctx.dest_partmap || (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))) @@ -421,6 +417,7 @@ SETUP (const char *dir, GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC); free (tmp_img); +#endif if (ctx.container && grub_strcmp (ctx.container->partmap->name, "msdos") == 0 @@ -508,10 +505,22 @@ SETUP (const char *dir, else maxsec = core_sectors; +#ifdef GRUB_SETUP_BIOS if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR) >> GRUB_DISK_SECTOR_BITS)) maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR) >> GRUB_DISK_SECTOR_BITS); +#endif + +#ifdef GRUB_SETUP_SPARC64 + /* + * On SPARC we need two extra. One is because we are combining the + * core.img with the boot.img. The other is because the boot sector + * starts at 1. + */ + nsec += 2; + maxsec += 2; +#endif if (is_ldm) err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec, @@ -560,9 +569,39 @@ SETUP (const char *dir, bl.block--; bl.block->start = 0; bl.block->len = 0; +#ifdef GRUB_SETUP_BIOS bl.block->segment = 0; +#endif +#ifdef GRUB_SETUP_SPARC64 + { + /* + * On SPARC, the block-list entries need to be based off the beginning + * of the parition, not the beginning of the disk. + */ + struct grub_boot_blocklist *block; + block = bl.first_block; + + while (block->len) + { + block->start -= bl.first_sector; + block--; + } + } + + /* + * Reserve space for the boot block since it can not be in the + * Parition table on SPARC. + */ + assert (bl.first_block->len > 2); + bl.first_block->start += 2; + bl.first_block->len -= 2; + write_rootdev (root_dev, boot_img, sectors[BOOT_SECTOR + 1] - bl.first_sector); +#endif + +#ifdef GRUB_SETUP_BIOS write_rootdev (root_dev, boot_img, bl.first_sector); +#endif /* Round up to the nearest sector boundary, and zero the extra memory */ core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE); @@ -572,7 +611,7 @@ SETUP (const char *dir, bl.first_block = (struct grub_boot_blocklist *) (core_img + GRUB_DISK_SECTOR_SIZE - sizeof (*bl.block)); - +#if GRUB_SETUP_BIOS grub_size_t no_rs_length; no_rs_length = grub_target_to_host16 (grub_get_unaligned16 (core_img @@ -603,14 +642,34 @@ SETUP (const char *dir, grub_disk_write (dest_dev->disk, sectors[i], 0, GRUB_DISK_SECTOR_SIZE, core_img + i * GRUB_DISK_SECTOR_SIZE); +#endif +#ifdef GRUB_SETUP_SPARC64 + { + int isec = BOOT_SECTOR; + + /* Write the boot image onto the disk. */ + if (grub_disk_write (dest_dev->disk, sectors[isec++], 0, + GRUB_DISK_SECTOR_SIZE, boot_img)) + grub_util_error ("%s", grub_errmsg); + + /* Write the core image onto the disk. */ + for (i = 0 ; isec < nsec; i++, isec++) + { + if (grub_disk_write (dest_dev->disk, sectors[isec], 0, + GRUB_DISK_SECTOR_SIZE, + core_img + i * GRUB_DISK_SECTOR_SIZE)) + grub_util_error ("%s", grub_errmsg); + } + } + +#endif grub_free (sectors); goto finish; } unable_to_embed: -#endif if (dest_dev->disk->dev->id != root_dev->disk->dev->id) grub_util_error ("%s", _("embedding is not possible, but this is required for " @@ -799,6 +858,10 @@ unable_to_embed: 0, GRUB_DISK_SECTOR_SIZE, boot_img)) grub_util_error ("%s", grub_errmsg); +#ifdef GRUB_SETUP_SPARC64 + finish: +#endif + grub_util_biosdisk_flush (root_dev->disk); grub_util_biosdisk_flush (dest_dev->disk); From 3611c4f42ee90d2b31082a1ee3d82ebc863585d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Di=C3=A9guez=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 01:26:36 +0100 Subject: [PATCH 0940/1167] asm: Replace "__asm__ __volatile__" with "asm volatile" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to maintain the coding style consistency, it was requested to replace the methods that use "__asm__ __volatile__" with "asm volatile". Signed-off-by: Jesús Diéguez Fernández Reviewed-by: Daniel Kiper --- grub-core/efiemu/runtime/efiemu.c | 10 +++++----- grub-core/lib/i386/halt.c | 2 +- include/grub/arm/time.h | 2 +- include/grub/arm64/time.h | 2 +- include/grub/i386/io.h | 12 ++++++------ include/grub/i386/time.h | 2 +- include/grub/i386/tsc.h | 2 +- include/grub/x86_64/time.h | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c index d923e409f..5db1f347b 100644 --- a/grub-core/efiemu/runtime/efiemu.c +++ b/grub-core/efiemu/runtime/efiemu.c @@ -174,17 +174,17 @@ efiemu_memset (grub_uint8_t *a, grub_uint8_t b, grub_size_t n) static inline void write_cmos (grub_uint8_t addr, grub_uint8_t val) { - __asm__ __volatile__ ("outb %%al,$0x70\n" - "mov %%cl, %%al\n" - "outb %%al,$0x71": :"a" (addr), "c" (val)); + asm volatile ("outb %%al,$0x70\n" + "mov %%cl, %%al\n" + "outb %%al,$0x71": :"a" (addr), "c" (val)); } static inline grub_uint8_t read_cmos (grub_uint8_t addr) { grub_uint8_t ret; - __asm__ __volatile__ ("outb %%al, $0x70\n" - "inb $0x71, %%al": "=a"(ret) :"a" (addr)); + asm volatile ("outb %%al, $0x70\n" + "inb $0x71, %%al": "=a"(ret) :"a" (addr)); return ret; } diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c index 9f8405494..2364fe4d7 100644 --- a/grub-core/lib/i386/halt.c +++ b/grub-core/lib/i386/halt.c @@ -66,7 +66,7 @@ grub_halt (void) #endif /* Disable interrupts. */ - __asm__ __volatile__ ("cli"); + asm volatile ("cli"); /* Bochs, QEMU, etc. Removed in newer QEMU releases. */ for (i = 0; i < sizeof (bochs_shutdown) - 1; i++) diff --git a/include/grub/arm/time.h b/include/grub/arm/time.h index 4128506cb..c5a685225 100644 --- a/include/grub/arm/time.h +++ b/include/grub/arm/time.h @@ -23,7 +23,7 @@ static __inline void grub_cpu_idle (void) { /* FIXME: this can't work until we handle interrupts. */ -/* __asm__ __volatile__ ("wfi"); */ +/* asm volatile ("wfi"); */ } #endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/include/grub/arm64/time.h b/include/grub/arm64/time.h index 4128506cb..c5a685225 100644 --- a/include/grub/arm64/time.h +++ b/include/grub/arm64/time.h @@ -23,7 +23,7 @@ static __inline void grub_cpu_idle (void) { /* FIXME: this can't work until we handle interrupts. */ -/* __asm__ __volatile__ ("wfi"); */ +/* asm volatile ("wfi"); */ } #endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/include/grub/i386/io.h b/include/grub/i386/io.h index ae12a3e3d..e9cd80957 100644 --- a/include/grub/i386/io.h +++ b/include/grub/i386/io.h @@ -28,7 +28,7 @@ grub_inb (unsigned short int port) { unsigned char _v; - __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); + asm volatile ("inb %w1,%0":"=a" (_v):"Nd" (port)); return _v; } @@ -37,7 +37,7 @@ grub_inw (unsigned short int port) { unsigned short _v; - __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); + asm volatile ("inw %w1,%0":"=a" (_v):"Nd" (port)); return _v; } @@ -46,27 +46,27 @@ grub_inl (unsigned short int port) { unsigned int _v; - __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); + asm volatile ("inl %w1,%0":"=a" (_v):"Nd" (port)); return _v; } static __inline void grub_outb (unsigned char value, unsigned short int port) { - __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); + asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (port)); } static __inline void grub_outw (unsigned short int value, unsigned short int port) { - __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); + asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (port)); } static __inline void grub_outl (unsigned int value, unsigned short int port) { - __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); + asm volatile ("outl %0,%w1": :"a" (value), "Nd" (port)); } #endif /* _SYS_IO_H */ diff --git a/include/grub/i386/time.h b/include/grub/i386/time.h index 842882cf2..4da5ae93c 100644 --- a/include/grub/i386/time.h +++ b/include/grub/i386/time.h @@ -23,7 +23,7 @@ static __inline void grub_cpu_idle (void) { /* FIXME: this can't work until we handle interrupts. */ -/* __asm__ __volatile__ ("hlt"); */ +/* asm volatile ("hlt"); */ } #endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 324174ded..947e62fa1 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -46,7 +46,7 @@ grub_get_tsc (void) grub_cpuid (0,a,b,c,d); /* Read TSC value. We cannot use "=A", since this would use %rax on x86_64. */ - __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); + asm volatile ("rdtsc":"=a" (lo), "=d" (hi)); return (((grub_uint64_t) hi) << 32) | lo; } diff --git a/include/grub/x86_64/time.h b/include/grub/x86_64/time.h index 842882cf2..4da5ae93c 100644 --- a/include/grub/x86_64/time.h +++ b/include/grub/x86_64/time.h @@ -23,7 +23,7 @@ static __inline void grub_cpu_idle (void) { /* FIXME: this can't work until we handle interrupts. */ -/* __asm__ __volatile__ ("hlt"); */ +/* asm volatile ("hlt"); */ } #endif /* ! KERNEL_CPU_TIME_HEADER */ From 46f5d5134392384c45710554bfe717ffa9c6dd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Di=C3=A9guez=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 01:26:37 +0100 Subject: [PATCH 0941/1167] msr: Add new MSR modules (rdmsr/wrmsr) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to be able to read from and write to model-specific registers, two new modules are added. They are i386 specific, as the cpuid module. rdmsr module registers the command rdmsr that allows reading from a MSR. wrmsr module registers the command wrmsr that allows writing to a MSR. wrmsr module is disabled if UEFI secure boot is enabled. Please note that on SMP systems, interacting with a MSR that has a scope per hardware thread, implies that the value only applies to the particular cpu/core/thread that ran the command. Also, if you specify a reserved or unimplemented MSR address, it will cause a general protection exception (which is not currently being handled) and the system will reboot. Signed-off-by: Jesús Diéguez Fernández Reviewed-by: Daniel Kiper --- docs/grub.texi | 53 +++++++++++++-- grub-core/Makefile.core.def | 10 +++ grub-core/commands/efi/shim_lock.c | 2 +- grub-core/commands/i386/rdmsr.c | 102 +++++++++++++++++++++++++++++ grub-core/commands/i386/wrmsr.c | 93 ++++++++++++++++++++++++++ include/grub/i386/rdmsr.h | 36 ++++++++++ include/grub/i386/wrmsr.h | 34 ++++++++++ 7 files changed, 324 insertions(+), 6 deletions(-) create mode 100644 grub-core/commands/i386/rdmsr.c create mode 100644 grub-core/commands/i386/wrmsr.c create mode 100644 include/grub/i386/rdmsr.h create mode 100644 include/grub/i386/wrmsr.h diff --git a/docs/grub.texi b/docs/grub.texi index ecaba9d5c..308b25074 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3931,6 +3931,7 @@ you forget a command, you can run the command @command{help} * play:: Play a tune * probe:: Retrieve device info * pxe_unload:: Unload the PXE environment +* rdmsr:: Read values from model-specific registers * read:: Read user input * reboot:: Reboot your computer * regexp:: Test if regular expression matches string @@ -3953,6 +3954,7 @@ you forget a command, you can run the command @command{help} * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes @comment * xen_*:: Xen boot commands for AArch64 +* wrmsr:: Write values to model-specific registers * xen_hypervisor:: Load xen hypervisor binary (only on AArch64) * xen_module:: Load xen modules for xen hypervisor (only on AArch64) @end menu @@ -4785,6 +4787,24 @@ This command is only available on PC BIOS systems. @end deffn +@node rdmsr +@subsection rdmsr + +@deffn Command: rdmsr 0xADDR [-v VARNAME] +Read a model-specific register at address 0xADDR. If the parameter +@option{-v} is used and an environment variable @var{VARNAME} is +given, set that environment variable to the value that was read. + +Please note that on SMP systems, reading from a MSR that has a +scope per hardware thread, implies that the value that is returned +only applies to the particular cpu/core/thread that runs the command. + +Also, if you specify a reserved or unimplemented MSR address, it will +cause a general protection exception (which is not currently being handled) +and the system will reboot. +@end deffn + + @node read @subsection read @@ -5223,6 +5243,21 @@ successfully. If validation fails, it is set to a non-zero value. List available video modes. If resolution is given, show only matching modes. @end deffn +@node wrmsr +@subsection wrmsr + +@deffn Command: wrmsr 0xADDR 0xVALUE +Write a 0xVALUE to a model-specific register at address 0xADDR. + +Please note that on SMP systems, writing to a MSR that has a scope +per hardware thread, implies that the value that is written +only applies to the particular cpu/core/thread that runs the command. + +Also, if you specify a reserved or unimplemented MSR address, it will +cause a general protection exception (which is not currently being handled) +and the system will reboot. +@end deffn + @node xen_hypervisor @subsection xen_hypervisor @@ -5716,11 +5751,11 @@ boot and the shim. This functionality is provided by the shim_lock module. It is recommend to build in this and other required modules into the @file{core.img}. All modules not stored in the @file{core.img} and the ACPI tables for the @command{acpi} command have to be signed, e.g. using PGP. Additionally, the -@command{iorw} and the @command{memrw} commands are prohibited if the UEFI -secure boot is enabled. This is done due to security reasons. All above -mentioned requirements are enforced by the shim_lock module. And itself it -is a persistent module which means that it cannot be unloaded if it was -loaded into the memory. +@command{iorw}, the @command{memrw} and the @command{wrmsr} commands are +prohibited if the UEFI secure boot is enabled. This is done due to +security reasons. All above mentioned requirements are enforced by the +shim_lock module. And itself it is a persistent module which means that +it cannot be unloaded if it was loaded into the memory. @node Measured Boot @section Measuring boot components @@ -5831,6 +5866,8 @@ to install to is specified, UUID is used instead as well. @item USB @tab yes @tab yes @tab yes @tab yes @item chainloader @tab local @tab yes @tab yes @tab no @item cpuid @tab partial @tab partial @tab partial @tab partial +@item rdmsr @tab partial @tab partial @tab partial @tab partial +@item wrmsr @tab partial @tab partial @tab partial @tab partial @item hints @tab guess @tab guess @tab guess @tab guess @item PCI @tab yes @tab yes @tab yes @tab yes @item badram @tab yes @tab yes @tab yes @tab yes @@ -5850,6 +5887,8 @@ to install to is specified, UUID is used instead as well. @item USB @tab yes @tab yes @tab yes @tab no @item chainloader @tab local @tab local @tab no @tab local @item cpuid @tab partial @tab partial @tab partial @tab no +@item rdmsr @tab partial @tab partial @tab partial @tab no +@item wrmsr @tab partial @tab partial @tab partial @tab no @item hints @tab guess @tab guess @tab good @tab guess @item PCI @tab yes @tab yes @tab yes @tab no @item badram @tab yes @tab yes @tab no @tab yes @@ -5869,6 +5908,8 @@ to install to is specified, UUID is used instead as well. @item USB @tab yes @tab no @tab no @tab no @item chainloader @tab yes @tab no @tab no @tab no @item cpuid @tab no @tab no @tab no @tab no +@item rdmsr @tab no @tab no @tab no @tab no +@item wrmsr @tab no @tab no @tab no @tab no @item hints @tab good @tab good @tab good @tab no @item PCI @tab yes @tab no @tab no @tab no @item badram @tab yes (*) @tab no @tab no @tab no @@ -5888,6 +5929,8 @@ to install to is specified, UUID is used instead as well. @item USB @tab N/A @tab yes @tab no @item chainloader @tab yes @tab no @tab yes @item cpuid @tab no @tab no @tab yes +@item rdmsr @tab no @tab no @tab yes +@item wrmsr @tab no @tab no @tab yes @item hints @tab guess @tab no @tab no @item PCI @tab no @tab no @tab no @item badram @tab yes (*) @tab no @tab no diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index ea8b99823..43ed42191 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -2485,3 +2485,13 @@ module = { common = loader/i386/xen_file64.c; extra_dist = loader/i386/xen_fileXX.c; }; +module = { + name = rdmsr; + common = commands/i386/rdmsr.c; + enable = x86; +}; +module = { + name = wrmsr; + common = commands/i386/wrmsr.c; + enable = x86; +}; diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c index 83568cb2b..764098cfc 100644 --- a/grub-core/commands/efi/shim_lock.c +++ b/grub-core/commands/efi/shim_lock.c @@ -43,7 +43,7 @@ static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID; static grub_efi_shim_lock_protocol_t *sl; /* List of modules which cannot be loaded if UEFI secure boot mode is enabled. */ -static const char * const disabled_mods[] = {"iorw", "memrw", NULL}; +static const char * const disabled_mods[] = {"iorw", "memrw", "wrmsr", NULL}; static grub_err_t shim_lock_init (grub_file_t io, enum grub_file_type type, diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c new file mode 100644 index 000000000..15b9adfca --- /dev/null +++ b/grub-core/commands/i386/rdmsr.c @@ -0,0 +1,102 @@ +/* rdmsr.c - Read CPU model-specific registers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 Free Software Foundation, Inc. + * Based on gcc/gcc/config/i386/driver-i386.c + * + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE("GPLv3+"); + +static grub_extcmd_t cmd_read; + +static const struct grub_arg_option options[] = +{ + {0, 'v', 0, N_("Save read value into variable VARNAME."), + N_("VARNAME"), ARG_TYPE_STRING}, + {0, 0, 0, 0, 0, 0} +}; + +static grub_err_t +grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv) +{ + grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; + grub_uint64_t value; + char *ptr; + char buf[sizeof("1122334455667788")]; + + /* + * The CPUID instruction should be used to determine whether MSRs + * are supported. (CPUID.01H:EDX[5] = 1) + */ + if (! grub_cpu_is_cpuid_supported ()) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]); + + if (max_cpuid < 1) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + grub_cpuid (1, a, b, c, features); + + if (!(features & (1 << 5))) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + if (argc != 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); + + grub_errno = GRUB_ERR_NONE; + ptr = argv[0]; + addr = grub_strtoul (ptr, &ptr, 0); + + if (grub_errno != GRUB_ERR_NONE) + return grub_errno; + if (*ptr != '\0') + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + + value = grub_msr_read (addr); + + if (ctxt->state[0].set) + { + grub_snprintf (buf, sizeof(buf), "%llx", (unsigned long long) value); + grub_env_set (ctxt->state[0].arg, buf); + } + else + grub_printf ("0x%llx\n", (unsigned long long) value); + + return GRUB_ERR_NONE; +} + +GRUB_MOD_INIT(rdmsr) +{ + cmd_read = grub_register_extcmd ("rdmsr", grub_cmd_msr_read, 0, N_("ADDR"), + N_("Read a CPU model specific register."), + options); +} + +GRUB_MOD_FINI(rdmsr) +{ + grub_unregister_extcmd (cmd_read); +} diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c new file mode 100644 index 000000000..9c5e510eb --- /dev/null +++ b/grub-core/commands/i386/wrmsr.c @@ -0,0 +1,93 @@ +/* wrmsr.c - Write CPU model-specific registers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 Free Software Foundation, Inc. + * Based on gcc/gcc/config/i386/driver-i386.c + * + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE("GPLv3+"); + +static grub_command_t cmd_write; + +static grub_err_t +grub_cmd_msr_write (grub_command_t cmd __attribute__ ((unused)), int argc, char **argv) +{ + grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; + grub_uint64_t value; + char *ptr; + + /* + * The CPUID instruction should be used to determine whether MSRs + * are supported. (CPUID.01H:EDX[5] = 1) + */ + if (!grub_cpu_is_cpuid_supported ()) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]); + + if (max_cpuid < 1) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + grub_cpuid (1, a, b, c, features); + + if (!(features & (1 << 5))) + return grub_error (GRUB_ERR_BUG, N_("unsupported instruction")); + + if (argc != 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected")); + + grub_errno = GRUB_ERR_NONE; + ptr = argv[0]; + addr = grub_strtoul (ptr, &ptr, 0); + + if (grub_errno != GRUB_ERR_NONE) + return grub_errno; + if (*ptr != '\0') + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + + ptr = argv[1]; + value = grub_strtoull (ptr, &ptr, 0); + + if (grub_errno != GRUB_ERR_NONE) + return grub_errno; + if (*ptr != '\0') + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + + grub_msr_write (addr, value); + + return GRUB_ERR_NONE; +} + +GRUB_MOD_INIT(wrmsr) +{ + cmd_write = grub_register_command ("wrmsr", grub_cmd_msr_write, N_("ADDR VALUE"), + N_("Write a value to a CPU model specific register.")); +} + +GRUB_MOD_FINI(wrmsr) +{ + grub_unregister_command (cmd_write); +} diff --git a/include/grub/i386/rdmsr.h b/include/grub/i386/rdmsr.h new file mode 100644 index 000000000..bddb7bbbb --- /dev/null +++ b/include/grub/i386/rdmsr.h @@ -0,0 +1,36 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#ifndef GRUB_RDMSR_H +#define GRUB_RDMSR_H 1 + +/* + * TODO: Add a general protection exception handler. + * Accessing a reserved or unimplemented MSR address results in a GP#. + */ + +extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id) +{ + grub_uint32_t low, high; + + asm volatile ("rdmsr" : "=a" (low), "=d" (high) : "c" (msr_id)); + + return ((grub_uint64_t)high << 32) | low; +} + +#endif /* GRUB_RDMSR_H */ diff --git a/include/grub/i386/wrmsr.h b/include/grub/i386/wrmsr.h new file mode 100644 index 000000000..e14d7807f --- /dev/null +++ b/include/grub/i386/wrmsr.h @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#ifndef GRUB_WRMSR_H +#define GRUB_WRMSR_H 1 + +/* + * TODO: Add a general protection exception handler. + * Accessing a reserved or unimplemented MSR address results in a GP#. + */ + +extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value) +{ + grub_uint32_t low = msr_value, high = msr_value >> 32; + + asm volatile ("wrmsr" : : "c" (msr_id), "a" (low), "d" (high)); +} + +#endif /* GRUB_WRMSR_H */ From 0b5c14c7f6fd7438d9caf1f1aaa459d328a9e3ce Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:07 +0000 Subject: [PATCH 0942/1167] net/dhcp: Remove dead code The comment is right, the "giaddr" fields holds the IP address of the BOOTP relay, not a general purpose router address. Just remove the commented code, archeologists can find it in the git history. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 9e2fdb795..c92dfbd3a 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -161,35 +161,6 @@ grub_net_configure_by_dhcp_ack (const char *name, if (!inter) return 0; -#if 0 - /* This is likely based on misunderstanding. gateway_ip refers to - address of BOOTP relay and should not be used after BOOTP transaction - is complete. - See RFC1542, 3.4 Interpretation of the 'giaddr' field - */ - if (bp->gateway_ip) - { - grub_net_network_level_netaddress_t target; - grub_net_network_level_address_t gw; - char *rname; - - target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target.ipv4.base = bp->server_ip; - target.ipv4.masksize = 32; - gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - gw.ipv4 = bp->gateway_ip; - rname = grub_xasprintf ("%s:gw", name); - if (rname) - grub_net_add_route_gw (rname, target, gw); - grub_free (rname); - - target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target.ipv4.base = bp->gateway_ip; - target.ipv4.masksize = 32; - grub_net_add_route (name, target, inter); - } -#endif - if (size > OFFSET_OF (boot_file, bp)) grub_env_set_net_property (name, "boot_file", bp->boot_file, sizeof (bp->boot_file)); From 4c44bbd83571fbda440f9aabc9917375d56889ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:08 +0000 Subject: [PATCH 0943/1167] net/dhcp: Replace parse_dhcp_vendor() with find_dhcp_option() For proper DHCP support we will need to parse DHCP options from a packet more often and at various places. Refactor the option parsing into a new function, which will scan a packet to find *a particular* option field. Use that new function in places where we were dealing with DHCP options before. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 231 ++++++++++++++++++++++-------------------- 1 file changed, 119 insertions(+), 112 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index c92dfbd3a..8d6763689 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,25 +25,41 @@ #include #include -static void -parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) +static const void * +find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, + grub_uint8_t opt_code, grub_uint8_t *opt_len) { - const grub_uint8_t *ptr, *ptr0; + const grub_uint8_t *ptr; + grub_size_t i; - ptr = ptr0 = vend; + if (opt_len) + *opt_len = 0; + + /* Is the packet big enough to hold at least the magic cookie? */ + if (size < sizeof (*bp) + sizeof (grub_uint32_t)) + return NULL; + + /* + * Pointer arithmetic to point behind the common stub packet, where + * the options start. + */ + ptr = (grub_uint8_t *) (bp + 1); if (ptr[0] != GRUB_NET_BOOTP_RFC1048_MAGIC_0 || ptr[1] != GRUB_NET_BOOTP_RFC1048_MAGIC_1 || ptr[2] != GRUB_NET_BOOTP_RFC1048_MAGIC_2 || ptr[3] != GRUB_NET_BOOTP_RFC1048_MAGIC_3) - return; - ptr = ptr + sizeof (grub_uint32_t); - while (ptr - ptr0 < limit) + return NULL; + + size -= sizeof (*bp); + i = sizeof (grub_uint32_t); + + while (i < size) { grub_uint8_t tagtype; grub_uint8_t taglength; - tagtype = *ptr++; + tagtype = ptr[i++]; /* Pad tag. */ if (tagtype == GRUB_NET_BOOTP_PAD) @@ -51,81 +67,27 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) /* End tag. */ if (tagtype == GRUB_NET_BOOTP_END) - return; + break; - taglength = *ptr++; + if (i >= size) + return NULL; - switch (tagtype) + taglength = ptr[i++]; + if (i + taglength >= size) + return NULL; + + /* FIXME RFC 3396 options concatentation */ + if (tagtype == opt_code) { - case GRUB_NET_BOOTP_NETMASK: - if (taglength == 4) - { - int i; - for (i = 0; i < 32; i++) - if (!(ptr[i / 8] & (1 << (7 - (i % 8))))) - break; - *mask = i; - } - break; - - case GRUB_NET_BOOTP_ROUTER: - if (taglength == 4) - { - grub_net_network_level_netaddress_t target; - grub_net_network_level_address_t gw; - char *rname; - - target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target.ipv4.base = 0; - target.ipv4.masksize = 0; - gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - grub_memcpy (&gw.ipv4, ptr, sizeof (gw.ipv4)); - rname = grub_xasprintf ("%s:default", name); - if (rname) - grub_net_add_route_gw (rname, target, gw, NULL); - grub_free (rname); - } - break; - case GRUB_NET_BOOTP_DNS: - { - int i; - for (i = 0; i < taglength / 4; i++) - { - struct grub_net_network_level_address s; - s.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - s.ipv4 = grub_get_unaligned32 (ptr); - s.option = DNS_OPTION_PREFER_IPV4; - grub_net_add_dns_server (&s); - ptr += 4; - } - } - continue; - case GRUB_NET_BOOTP_HOSTNAME: - grub_env_set_net_property (name, "hostname", (const char *) ptr, - taglength); - break; - - case GRUB_NET_BOOTP_DOMAIN: - grub_env_set_net_property (name, "domain", (const char *) ptr, - taglength); - break; - - case GRUB_NET_BOOTP_ROOT_PATH: - grub_env_set_net_property (name, "rootpath", (const char *) ptr, - taglength); - break; - - case GRUB_NET_BOOTP_EXTENSIONS_PATH: - grub_env_set_net_property (name, "extensionspath", (const char *) ptr, - taglength); - break; - - /* If you need any other options please contact GRUB - development team. */ + if (opt_len) + *opt_len = taglength; + return &ptr[i]; } - ptr += taglength; + i += taglength; } + + return NULL; } #define OFFSET_OF(x, y) ((grub_size_t)((grub_uint8_t *)((y)->x) - (grub_uint8_t *)(y))) @@ -143,6 +105,8 @@ grub_net_configure_by_dhcp_ack (const char *name, struct grub_net_network_level_interface *inter; int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; + const grub_uint8_t *opt; + grub_uint8_t opt_len; addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; addr.ipv4 = bp->your_ip; @@ -225,9 +189,69 @@ grub_net_configure_by_dhcp_ack (const char *name, **path = 0; } } - if (size > OFFSET_OF (vendor, bp)) - parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask); + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_NETMASK, &opt_len); + if (opt && opt_len == 4) + { + int i; + for (i = 0; i < 32; i++) + if (!(opt[i / 8] & (1 << (7 - (i % 8))))) + break; + mask = i; + } grub_net_add_ipv4_local (inter, mask); + + /* We do not implement dead gateway detection and the first entry SHOULD + be preferred one */ + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROUTER, &opt_len); + if (opt && opt_len && !(opt_len & 3)) + { + grub_net_network_level_netaddress_t target; + grub_net_network_level_address_t gw; + char *rname; + + target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + target.ipv4.base = 0; + target.ipv4.masksize = 0; + gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + gw.ipv4 = grub_get_unaligned32 (opt); + rname = grub_xasprintf ("%s:default", name); + if (rname) + grub_net_add_route_gw (rname, target, gw, 0); + grub_free (rname); + } + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_DNS, &opt_len); + if (opt && opt_len && !(opt_len & 3)) + { + int i; + for (i = 0; i < opt_len / 4; i++) + { + struct grub_net_network_level_address s; + + s.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + s.ipv4 = grub_get_unaligned32 (opt); + s.option = DNS_OPTION_PREFER_IPV4; + grub_net_add_dns_server (&s); + opt += 4; + } + } + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_HOSTNAME, &opt_len); + if (opt && opt_len) + grub_env_set_net_property (name, "hostname", (const char *) opt, opt_len); + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_DOMAIN, &opt_len); + if (opt && opt_len) + grub_env_set_net_property (name, "domain", (const char *) opt, opt_len); + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROOT_PATH, &opt_len); + if (opt && opt_len) + grub_env_set_net_property (name, "rootpath", (const char *) opt, opt_len); + + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_EXTENSIONS_PATH, &opt_len); + if (opt && opt_len) + grub_env_set_net_property (name, "extensionspath", (const char *) opt, opt_len); inter->dhcp_ack = grub_malloc (size); if (inter->dhcp_ack) @@ -286,8 +310,8 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) { struct grub_net_network_level_interface *inter; - int num; - grub_uint8_t *ptr; + unsigned num; + const grub_uint8_t *ptr; grub_uint8_t taglength; if (argc < 4) @@ -305,44 +329,27 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), if (!inter->dhcp_ack) return grub_error (GRUB_ERR_IO, N_("no DHCP info found")); - if (inter->dhcp_acklen <= OFFSET_OF (vendor, inter->dhcp_ack)) + ptr = inter->dhcp_ack->vendor; + + /* This duplicates check in find_dhcp_option to preserve previous error return */ + if (inter->dhcp_acklen < OFFSET_OF (vendor, inter->dhcp_ack) + sizeof (grub_uint32_t) + || ptr[0] != GRUB_NET_BOOTP_RFC1048_MAGIC_0 + || ptr[1] != GRUB_NET_BOOTP_RFC1048_MAGIC_1 + || ptr[2] != GRUB_NET_BOOTP_RFC1048_MAGIC_2 + || ptr[3] != GRUB_NET_BOOTP_RFC1048_MAGIC_3) return grub_error (GRUB_ERR_IO, N_("no DHCP options found")); num = grub_strtoul (args[2], 0, 0); if (grub_errno) return grub_errno; - ptr = inter->dhcp_ack->vendor; + /* Exclude PAD (0) and END (255) option codes */ + if (num == 0 || num > 254) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid DHCP option code")); - if (ptr[0] != GRUB_NET_BOOTP_RFC1048_MAGIC_0 - || ptr[1] != GRUB_NET_BOOTP_RFC1048_MAGIC_1 - || ptr[2] != GRUB_NET_BOOTP_RFC1048_MAGIC_2 - || ptr[3] != GRUB_NET_BOOTP_RFC1048_MAGIC_3) - return grub_error (GRUB_ERR_IO, N_("no DHCP options found")); - ptr = ptr + sizeof (grub_uint32_t); - while (1) - { - grub_uint8_t tagtype; - - if (ptr >= ((grub_uint8_t *) inter->dhcp_ack) + inter->dhcp_acklen) - return grub_error (GRUB_ERR_IO, N_("no DHCP option %d found"), num); - - tagtype = *ptr++; - - /* Pad tag. */ - if (tagtype == 0) - continue; - - /* End tag. */ - if (tagtype == 0xff) - return grub_error (GRUB_ERR_IO, N_("no DHCP option %d found"), num); - - taglength = *ptr++; - - if (tagtype == num) - break; - ptr += taglength; - } + ptr = find_dhcp_option (inter->dhcp_ack, inter->dhcp_acklen, num, &taglength); + if (!ptr) + return grub_error (GRUB_ERR_IO, N_("no DHCP option %u found"), num); if (grub_strcmp (args[3], "string") == 0) { From bd21d6465e4d243a442ebcde9fac2ceca13524c2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:09 +0000 Subject: [PATCH 0944/1167] net/dhcp: Allow overloading legacy bootfile and name field DHCP specifies a special dummy option OVERLOAD, to allow DHCP options to spill over into the (legacy) BOOTFILE and SNAME fields. Parse and handle this option properly. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 59 ++++++++++++++++++++++++++++++++++++++++++- include/grub/net.h | 1 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 8d6763689..860d9c80d 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,11 +25,19 @@ #include #include +enum +{ + GRUB_DHCP_OPT_OVERLOAD_FILE = 1, + GRUB_DHCP_OPT_OVERLOAD_SNAME = 2, +}; + static const void * find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, grub_uint8_t opt_code, grub_uint8_t *opt_len) { const grub_uint8_t *ptr; + grub_uint8_t overload = 0; + int end = 0; grub_size_t i; if (opt_len) @@ -54,6 +62,7 @@ find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, size -= sizeof (*bp); i = sizeof (grub_uint32_t); +again: while (i < size) { grub_uint8_t tagtype; @@ -67,7 +76,10 @@ find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, /* End tag. */ if (tagtype == GRUB_NET_BOOTP_END) - break; + { + end = 1; + break; + } if (i >= size) return NULL; @@ -84,9 +96,54 @@ find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, return &ptr[i]; } + if (tagtype == GRUB_NET_DHCP_OVERLOAD && taglength == 1) + overload = ptr[i]; + i += taglength; } + if (!end) + return NULL; + + /* RFC2131, 4.1, 23ff: + * If the options in a DHCP message extend into the 'sname' and 'file' + * fields, the 'option overload' option MUST appear in the 'options' + * field, with value 1, 2 or 3, as specified in RFC 1533. If the + * 'option overload' option is present in the 'options' field, the + * options in the 'options' field MUST be terminated by an 'end' option, + * and MAY contain one or more 'pad' options to fill the options field. + * The options in the 'sname' and 'file' fields (if in use as indicated + * by the 'options overload' option) MUST begin with the first octet of + * the field, MUST be terminated by an 'end' option, and MUST be + * followed by 'pad' options to fill the remainder of the field. Any + * individual option in the 'options', 'sname' and 'file' fields MUST be + * entirely contained in that field. The options in the 'options' field + * MUST be interpreted first, so that any 'option overload' options may + * be interpreted. The 'file' field MUST be interpreted next (if the + * 'option overload' option indicates that the 'file' field contains + * DHCP options), followed by the 'sname' field. + * + * FIXME: We do not explicitly check for trailing 'pad' options here. + */ + end = 0; + if (overload & GRUB_DHCP_OPT_OVERLOAD_FILE) + { + overload &= ~GRUB_DHCP_OPT_OVERLOAD_FILE; + ptr = (grub_uint8_t *) &bp->boot_file[0]; + size = sizeof (bp->boot_file); + i = 0; + goto again; + } + + if (overload & GRUB_DHCP_OPT_OVERLOAD_SNAME) + { + overload &= ~GRUB_DHCP_OPT_OVERLOAD_SNAME; + ptr = (grub_uint8_t *) &bp->server_name[0]; + size = sizeof (bp->server_name); + i = 0; + goto again; + } + return NULL; } diff --git a/include/grub/net.h b/include/grub/net.h index 1096b2432..0c7286bd2 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -457,6 +457,7 @@ enum GRUB_NET_BOOTP_DOMAIN = 0x0f, GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, + GRUB_NET_DHCP_OVERLOAD = 52, GRUB_NET_BOOTP_END = 0xff }; From 7ace83295acfeaf57d3b6e8ad2989b4e8304cf9f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:10 +0000 Subject: [PATCH 0945/1167] net/dhcp: Refactor DHCP packet transmission into separate function In contrast to BOOTP, DHCP uses a 4-way handshake, so requires to send packets more often. Refactor the generation and sending of the BOOTREQUEST packet into a separate function, so that future code can more easily reuse this. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 146 +++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 65 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 860d9c80d..1a7cd672b 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -31,6 +31,8 @@ enum GRUB_DHCP_OPT_OVERLOAD_SNAME = 2, }; +#define GRUB_BOOTP_MAX_OPTIONS_SIZE 64 + static const void * find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, grub_uint8_t opt_code, grub_uint8_t *opt_len) @@ -322,6 +324,77 @@ grub_net_configure_by_dhcp_ack (const char *name, return inter; } +static grub_err_t +send_dhcp_packet (struct grub_net_network_level_interface *iface) +{ + grub_err_t err; + struct grub_net_bootp_packet *pack; + struct grub_datetime date; + grub_int32_t t = 0; + struct grub_net_buff *nb; + struct udphdr *udph; + grub_net_network_level_address_t target; + grub_net_link_level_address_t ll_target; + + nb = grub_netbuff_alloc (sizeof (*pack) + GRUB_BOOTP_MAX_OPTIONS_SIZE + 128); + if (!nb) + return grub_errno; + + err = grub_netbuff_reserve (nb, sizeof (*pack) + GRUB_BOOTP_MAX_OPTIONS_SIZE + 128); + if (err) + goto out; + + err = grub_netbuff_push (nb, GRUB_BOOTP_MAX_OPTIONS_SIZE); + if (err) + goto out; + + grub_memset (nb->data, 0, GRUB_BOOTP_MAX_OPTIONS_SIZE); + + err = grub_netbuff_push (nb, sizeof (*pack)); + if (err) + goto out; + + pack = (void *) nb->data; + grub_memset (pack, 0, sizeof (*pack)); + pack->opcode = 1; + pack->hw_type = 1; + pack->hw_len = 6; + err = grub_get_datetime (&date); + if (err || !grub_datetime2unixtime (&date, &t)) + { + grub_errno = GRUB_ERR_NONE; + t = 0; + } + pack->seconds = grub_cpu_to_be16 (t); + pack->ident = grub_cpu_to_be32 (t); + + grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, 6); + + grub_netbuff_push (nb, sizeof (*udph)); + + udph = (struct udphdr *) nb->data; + udph->src = grub_cpu_to_be16_compile_time (68); + udph->dst = grub_cpu_to_be16_compile_time (67); + udph->chksum = 0; + udph->len = grub_cpu_to_be16 (nb->tail - nb->data); + target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + target.ipv4 = 0xffffffff; + err = grub_net_link_layer_resolve (iface, &target, &ll_target); + if (err) + goto out; + + udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP, + &iface->address, + &target); + + err = grub_net_send_ip_packet (iface, &target, &ll_target, nb, + GRUB_NET_IP_UDP); + +out: + grub_netbuff_free (nb); + return err; +} + void grub_net_process_dhcp (struct grub_net_buff *nb, struct grub_net_card *card) @@ -478,6 +551,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), unsigned j = 0; int interval; grub_err_t err; + unsigned i; FOR_NET_CARDS (card) { @@ -506,7 +580,6 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), card->num_ifaces++; if (!ifaces[j].name) { - unsigned i; for (i = 0; i < j; i++) grub_free (ifaces[i].name); grub_free (ifaces); @@ -524,78 +597,21 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), ifaces[0].prev = &grub_net_network_level_interfaces; for (interval = 200; interval < 10000; interval *= 2) { - int done = 0; + int need_poll = 0; for (j = 0; j < ncards; j++) { - struct grub_net_bootp_packet *pack; - struct grub_datetime date; - grub_int32_t t = 0; - struct grub_net_buff *nb; - struct udphdr *udph; - grub_net_network_level_address_t target; - grub_net_link_level_address_t ll_target; - if (!ifaces[j].prev) continue; - nb = grub_netbuff_alloc (sizeof (*pack) + 64 + 128); - if (!nb) - { - grub_netbuff_free (nb); - return grub_errno; - } - err = grub_netbuff_reserve (nb, sizeof (*pack) + 64 + 128); + + err = send_dhcp_packet (&ifaces[j]); if (err) { - grub_netbuff_free (nb); - return err; + grub_print_error (); + continue; } - err = grub_netbuff_push (nb, sizeof (*pack) + 64); - if (err) - { - grub_netbuff_free (nb); - return err; - } - pack = (void *) nb->data; - done = 1; - grub_memset (pack, 0, sizeof (*pack) + 64); - pack->opcode = 1; - pack->hw_type = 1; - pack->hw_len = 6; - err = grub_get_datetime (&date); - if (err || !grub_datetime2unixtime (&date, &t)) - { - grub_errno = GRUB_ERR_NONE; - t = 0; - } - pack->ident = grub_cpu_to_be32 (t); - pack->seconds = grub_cpu_to_be16 (t); - - grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); - - grub_netbuff_push (nb, sizeof (*udph)); - - udph = (struct udphdr *) nb->data; - udph->src = grub_cpu_to_be16_compile_time (68); - udph->dst = grub_cpu_to_be16_compile_time (67); - udph->chksum = 0; - udph->len = grub_cpu_to_be16 (nb->tail - nb->data); - target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target.ipv4 = 0xffffffff; - err = grub_net_link_layer_resolve (&ifaces[j], &target, &ll_target); - if (err) - return err; - - udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP, - &ifaces[j].address, - &target); - - err = grub_net_send_ip_packet (&ifaces[j], &target, &ll_target, nb, - GRUB_NET_IP_UDP); - grub_netbuff_free (nb); - if (err) - return err; + need_poll = 1; } - if (!done) + if (!need_poll) break; grub_net_poll_cards (interval, 0); } From 5459243465e148d91a5c26c07520e699ed115446 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:11 +0000 Subject: [PATCH 0946/1167] net/dhcp: Make grub_net_process_dhcp() take an interface Change the interface of the function dealing with incoming BOOTP packets to take an interface instead of a card, to allow more fine per-interface state (timeout, handshake state) later on. Use the opportunity to clean up the code a bit. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 29 ++++++++++++++--------------- grub-core/net/ip.c | 2 +- include/grub/net.h | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 1a7cd672b..5bb5b3d27 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -395,12 +395,19 @@ out: return err; } +/* + * This is called directly from net/ip.c:handle_dgram(), because those + * BOOTP/DHCP packets are a bit special due to their improper + * sender/receiver IP fields. + */ void grub_net_process_dhcp (struct grub_net_buff *nb, - struct grub_net_card *card) + struct grub_net_network_level_interface *iface) { char *name; - struct grub_net_network_level_interface *inf; + struct grub_net_card *card = iface->card; + const struct grub_net_bootp_packet *bp = (const struct grub_net_bootp_packet *) nb->data; + grub_size_t size = nb->tail - nb->data; name = grub_xasprintf ("%s:dhcp", card->name); if (!name) @@ -408,23 +415,15 @@ grub_net_process_dhcp (struct grub_net_buff *nb, grub_print_error (); return; } - grub_net_configure_by_dhcp_ack (name, card, - 0, (const struct grub_net_bootp_packet *) nb->data, - (nb->tail - nb->data), 0, 0, 0); + grub_net_configure_by_dhcp_ack (name, card, 0, bp, size, 0, 0, 0); grub_free (name); if (grub_errno) grub_print_error (); else - { - FOR_NET_NETWORK_LEVEL_INTERFACES(inf) - if (grub_memcmp (inf->name, card->name, grub_strlen (card->name)) == 0 - && grub_memcmp (inf->name + grub_strlen (card->name), - ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0) - { - grub_net_network_level_interface_unregister (inf); - break; - } - } + if (grub_memcmp (iface->name, card->name, grub_strlen (card->name)) == 0 && + grub_memcmp (iface->name + grub_strlen (card->name), + ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0) + grub_net_network_level_interface_unregister (iface); } static char diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index 7c95cc746..ea5edf8f1 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -279,7 +279,7 @@ handle_dgram (struct grub_net_buff *nb, && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr, sizeof (inf->hwaddress.mac)) == 0) { - grub_net_process_dhcp (nb, inf->card); + grub_net_process_dhcp (nb, inf); grub_netbuff_free (nb); return GRUB_ERR_NONE; } diff --git a/include/grub/net.h b/include/grub/net.h index 0c7286bd2..3f649d753 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -475,7 +475,7 @@ grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf, void grub_net_process_dhcp (struct grub_net_buff *nb, - struct grub_net_card *card); + struct grub_net_network_level_interface *iface); int grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, From 12e1b6e604968feebf3dd7040ea905dc1ab41911 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:12 +0000 Subject: [PATCH 0947/1167] net/dhcp: Introduce per-interface timeout Currently we have a global timeout for all network cards in the BOOTP/DHCP discovery process. Make this timeout a per-interface one, so better accommodate the upcoming 4-way DHCP handshake and to also cover the lease time limit a DHCP offer will come with. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 38 ++++++++++++++++++++++++++++++++++---- include/grub/net.h | 2 ++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 5bb5b3d27..2fb79d162 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -33,6 +33,9 @@ enum #define GRUB_BOOTP_MAX_OPTIONS_SIZE 64 +/* Max timeout when waiting for BOOTP/DHCP reply */ +#define GRUB_DHCP_MAX_PACKET_TIMEOUT 32 + static const void * find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, grub_uint8_t opt_code, grub_uint8_t *opt_len) @@ -548,7 +551,6 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), struct grub_net_network_level_interface *ifaces; grub_size_t ncards = 0; unsigned j = 0; - int interval; grub_err_t err; unsigned i; @@ -587,6 +589,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), ifaces[j].address.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV; grub_memcpy (&ifaces[j].hwaddress, &card->default_address, sizeof (ifaces[j].hwaddress)); + ifaces[j].dhcp_tmo = ifaces[j].dhcp_tmo_left = 1; j++; } ifaces[ncards - 1].next = grub_net_network_level_interfaces; @@ -594,25 +597,52 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), grub_net_network_level_interfaces->prev = & ifaces[ncards - 1].next; grub_net_network_level_interfaces = &ifaces[0]; ifaces[0].prev = &grub_net_network_level_interfaces; - for (interval = 200; interval < 10000; interval *= 2) + + /* + * Running DHCP restransmission timer is kept per interface in dhcp_tmo_left. + * When it runs off, dhcp_tmo is increased exponentionally and dhcp_tmo_left + * initialized to it. Max value is 32 which gives approximately 12s total per + * packet timeout assuming 200ms poll tick. Timeout is reset when DHCP OFFER + * is received, so total timeout is 25s in the worst case. + * + * DHCP NAK also resets timer and transaction starts again. + * + * Total wait time is limited to ~25s to prevent endless loop in case of + * permanent NAK + */ + for (i = 0; i < GRUB_DHCP_MAX_PACKET_TIMEOUT * 4; i++) { int need_poll = 0; for (j = 0; j < ncards; j++) { - if (!ifaces[j].prev) + if (!ifaces[j].prev || + ifaces[j].dhcp_tmo > GRUB_DHCP_MAX_PACKET_TIMEOUT) + continue; + + if (--ifaces[j].dhcp_tmo_left) + { + need_poll = 1; + continue; + } + + ifaces[j].dhcp_tmo *= 2; + if (ifaces[j].dhcp_tmo > GRUB_DHCP_MAX_PACKET_TIMEOUT) continue; err = send_dhcp_packet (&ifaces[j]); if (err) { grub_print_error (); + /* To ignore it during next poll */ + ifaces[j].dhcp_tmo = GRUB_DHCP_MAX_PACKET_TIMEOUT + 1; continue; } + ifaces[j].dhcp_tmo_left = ifaces[j].dhcp_tmo; need_poll = 1; } if (!need_poll) break; - grub_net_poll_cards (interval, 0); + grub_net_poll_cards (200, 0); } err = GRUB_ERR_NONE; diff --git a/include/grub/net.h b/include/grub/net.h index 3f649d753..a1138f5d4 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -292,6 +292,8 @@ struct grub_net_network_level_interface struct grub_net_bootp_packet *dhcp_ack; grub_size_t dhcp_acklen; grub_uint16_t vlantag; + unsigned dhcp_tmo_left; /* DHCPv4 running retransmission timeout */ + unsigned dhcp_tmo; /* DHCPv4 current retransmission timeout */ void *data; }; From 93289dc67c7e213b21df0eb09afea5e3b00ad7df Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:13 +0000 Subject: [PATCH 0948/1167] net/dhcp: Use DHCP options for name and bootfile The BOOTP RFC describes the boot file name and the server name as being part of the integral BOOTP data structure, with some limits on the size of them. DHCP extends this by allowing them to be separate DHCP options, which is more flexible. Teach the code dealing with those fields to check for those DHCP options first and use this information, if provided. We fall back to using the BOOTP information if those options are not used. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 72 +++++++++++++++++++++++++++++++------------ include/grub/net.h | 2 ++ 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 2fb79d162..bfde6ef10 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -168,7 +168,9 @@ grub_net_configure_by_dhcp_ack (const char *name, int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; const grub_uint8_t *opt; - grub_uint8_t opt_len; + grub_uint8_t opt_len, overload = 0; + const char *boot_file = 0, *server_name = 0; + grub_size_t boot_file_len, server_name_len; addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; addr.ipv4 = bp->your_ip; @@ -187,9 +189,36 @@ grub_net_configure_by_dhcp_ack (const char *name, if (!inter) return 0; - if (size > OFFSET_OF (boot_file, bp)) - grub_env_set_net_property (name, "boot_file", bp->boot_file, - sizeof (bp->boot_file)); + opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_OVERLOAD, &opt_len); + if (opt && opt_len == 1) + overload = *opt; + + opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_TFTP_SERVER_NAME, &opt_len); + if (opt && opt_len) + { + server_name = (const char *) opt; + server_name_len = opt_len; + } + else if (size > OFFSET_OF (server_name, bp) && !(overload & GRUB_DHCP_OPT_OVERLOAD_SNAME) && + bp->server_name[0]) + { + server_name = bp->server_name; + server_name_len = sizeof (bp->server_name); + } + + opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_BOOTFILE_NAME, &opt_len); + if (opt && opt_len) + { + boot_file = (const char *) opt; + boot_file_len = opt_len; + } + else if (size > OFFSET_OF (boot_file, bp) && !(overload && GRUB_DHCP_OPT_OVERLOAD_FILE) && + bp->boot_file[0]) + { + boot_file = bp->boot_file; + boot_file_len = sizeof (bp->boot_file); + } + if (bp->server_ip) { grub_snprintf (server_ip, sizeof (server_ip), "%d.%d.%d.%d", @@ -220,35 +249,38 @@ grub_net_configure_by_dhcp_ack (const char *name, *device = grub_xasprintf ("tftp,%s", server_ip); grub_print_error (); } - if (size > OFFSET_OF (server_name, bp) - && bp->server_name[0]) + + if (server_name) { - grub_env_set_net_property (name, "dhcp_server_name", bp->server_name, - sizeof (bp->server_name)); + grub_env_set_net_property (name, "dhcp_server_name", server_name, server_name_len); if (is_def && !grub_net_default_server) { - grub_net_default_server = grub_strdup (bp->server_name); + grub_net_default_server = grub_strdup (server_name); grub_print_error (); } if (device && !*device) { - *device = grub_xasprintf ("tftp,%s", bp->server_name); + *device = grub_xasprintf ("tftp,%s", server_name); grub_print_error (); } } - if (size > OFFSET_OF (boot_file, bp) && path) + if (boot_file) { - *path = grub_strndup (bp->boot_file, sizeof (bp->boot_file)); - grub_print_error (); - if (*path) + grub_env_set_net_property (name, "boot_file", boot_file, boot_file_len); + if (path) { - char *slash; - slash = grub_strrchr (*path, '/'); - if (slash) - *slash = 0; - else - **path = 0; + *path = grub_strndup (boot_file, boot_file_len); + grub_print_error (); + if (*path) + { + char *slash; + slash = grub_strrchr (*path, '/'); + if (slash) + *slash = 0; + else + **path = 0; + } } } diff --git a/include/grub/net.h b/include/grub/net.h index a1138f5d4..f7b546446 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -460,6 +460,8 @@ enum GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, GRUB_NET_DHCP_OVERLOAD = 52, + GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, + GRUB_NET_DHCP_BOOTFILE_NAME = 67, GRUB_NET_BOOTP_END = 0xff }; From 5a365fed87eb61d8d85cc196a7865197d25a5f61 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:14 +0000 Subject: [PATCH 0949/1167] net/dhcp: Allow receiving DHCP OFFER and ACK packets In respone to a BOOTREQUEST packet a BOOTP server would answer with a BOOTREPLY packet, which ends the conversation for good. DHCP uses a 4-way handshake, where the initial server respone is an OFFER, which has to be answered with REQUEST by the client again, only to be completed by an ACKNOWLEDGE packet from the server. Teach the grub_net_process_dhcp() function to deal with OFFER packets, and treat ACK packets the same es BOOTREPLY packets. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 80 +++++++++++++++++++++++++++++++++++-------- include/grub/net.h | 5 +++ 2 files changed, 71 insertions(+), 14 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index bfde6ef10..d0482a7d5 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -30,6 +30,21 @@ enum GRUB_DHCP_OPT_OVERLOAD_FILE = 1, GRUB_DHCP_OPT_OVERLOAD_SNAME = 2, }; +enum +{ + GRUB_DHCP_MESSAGE_UNKNOWN, + GRUB_DHCP_MESSAGE_DISCOVER, + GRUB_DHCP_MESSAGE_OFFER, + GRUB_DHCP_MESSAGE_REQUEST, + GRUB_DHCP_MESSAGE_DECLINE, + GRUB_DHCP_MESSAGE_ACK, + GRUB_DHCP_MESSAGE_NAK, + GRUB_DHCP_MESSAGE_RELEASE, + GRUB_DHCP_MESSAGE_INFORM, +}; + +/* Max timeout when waiting for BOOTP/DHCP reply */ +#define GRUB_DHCP_MAX_PACKET_TIMEOUT 32 #define GRUB_BOOTP_MAX_OPTIONS_SIZE 64 @@ -443,22 +458,59 @@ grub_net_process_dhcp (struct grub_net_buff *nb, struct grub_net_card *card = iface->card; const struct grub_net_bootp_packet *bp = (const struct grub_net_bootp_packet *) nb->data; grub_size_t size = nb->tail - nb->data; + const grub_uint8_t *opt; + grub_uint8_t opt_len, type; + grub_uint32_t srv_id = 0; - name = grub_xasprintf ("%s:dhcp", card->name); - if (!name) - { - grub_print_error (); - return; - } - grub_net_configure_by_dhcp_ack (name, card, 0, bp, size, 0, 0, 0); - grub_free (name); - if (grub_errno) - grub_print_error (); + opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_MESSAGE_TYPE, &opt_len); + if (opt && opt_len == 1) + type = *opt; else - if (grub_memcmp (iface->name, card->name, grub_strlen (card->name)) == 0 && - grub_memcmp (iface->name + grub_strlen (card->name), - ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0) - grub_net_network_level_interface_unregister (iface); + type = GRUB_DHCP_MESSAGE_UNKNOWN; + + opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_SERVER_IDENTIFIER, &opt_len); + if (opt && opt_len == sizeof (srv_id)) + srv_id = grub_get_unaligned32 (opt); + + /* + * If we received BOOTP reply or DHCPACK, proceed with configuration. + * Otherwise store offered address and server id for later processing + * of DHCPACK. + * xid and srv_id are stored in network order so do not need conversion. + */ + if ((!iface->srv_id && type == GRUB_DHCP_MESSAGE_UNKNOWN) + || (iface->srv_id && type == GRUB_DHCP_MESSAGE_ACK + && bp->ident == iface->xid + && srv_id == iface->srv_id)) + { + name = grub_xasprintf ("%s:dhcp", card->name); + if (!name) + { + grub_print_error (); + return; + } + grub_net_configure_by_dhcp_ack (name, card, 0, bp, size, 0, 0, 0); + grub_free (name); + if (grub_errno) + grub_print_error (); + else + grub_net_network_level_interface_unregister (iface); + } + else if (!iface->srv_id && type == GRUB_DHCP_MESSAGE_OFFER && srv_id) + { + iface->srv_id = srv_id; + iface->my_ip = bp->your_ip; + /* Reset retransmission timer */ + iface->dhcp_tmo = iface->dhcp_tmo_left = 1; + } + else if (iface->srv_id && type == GRUB_DHCP_MESSAGE_NAK + && bp->ident == iface->xid + && srv_id == iface->srv_id) + { + iface->xid = iface->srv_id = iface->my_ip = 0; + /* Reset retransmission timer */ + iface->dhcp_tmo = iface->dhcp_tmo_left = 1; + } } static char diff --git a/include/grub/net.h b/include/grub/net.h index f7b546446..68a9f1311 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -292,6 +292,9 @@ struct grub_net_network_level_interface struct grub_net_bootp_packet *dhcp_ack; grub_size_t dhcp_acklen; grub_uint16_t vlantag; + grub_uint32_t xid; /* DHCPv4 transaction id */ + grub_uint32_t srv_id; /* DHCPv4 server_identifier */ + grub_uint32_t my_ip; /* DHCPv4 offered IP address */ unsigned dhcp_tmo_left; /* DHCPv4 running retransmission timeout */ unsigned dhcp_tmo; /* DHCPv4 current retransmission timeout */ void *data; @@ -460,6 +463,8 @@ enum GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, GRUB_NET_DHCP_OVERLOAD = 52, + GRUB_NET_DHCP_MESSAGE_TYPE = 53, + GRUB_NET_DHCP_SERVER_IDENTIFIER = 54, GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, GRUB_NET_DHCP_BOOTFILE_NAME = 67, GRUB_NET_BOOTP_END = 0xff From 5a4f9d5c04c0566c572697974b9798d62292c29f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:15 +0000 Subject: [PATCH 0950/1167] net/dhcp: Actually send out DHCPv4 DISCOVER and REQUEST messages Even though we were parsing some DHCP options sent by the server, so far we are only using the BOOTP 2-way handshake, even when talking to a DHCP server. Change this by actually sending out DHCP DISCOVER packets instead of the generic (mostly empty) BOOTP BOOTREQUEST packets. A pure BOOTP server would ignore the extra DHCP options in the DISCOVER packet and would just reply with a BOOTREPLY packet, which we also handle in the code. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 120 +++++++++++++++++++++++++++++++++++++++++- include/grub/net.h | 2 + 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index d0482a7d5..63763aaab 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,6 +25,48 @@ #include #include +struct grub_dhcp_discover_options +{ + grub_uint8_t magic[4]; + struct + { + grub_uint8_t code; + grub_uint8_t len; + grub_uint8_t data; + } GRUB_PACKED message_type; + grub_uint8_t end; +} GRUB_PACKED; + +struct grub_dhcp_request_options +{ + grub_uint8_t magic[4]; + struct + { + grub_uint8_t code; + grub_uint8_t len; + grub_uint8_t data; + } GRUB_PACKED message_type; + struct + { + grub_uint8_t type; + grub_uint8_t len; + grub_uint32_t data; + } GRUB_PACKED server_identifier; + struct + { + grub_uint8_t type; + grub_uint8_t len; + grub_uint32_t data; + } GRUB_PACKED requested_ip; + struct + { + grub_uint8_t type; + grub_uint8_t len; + grub_uint8_t data[7]; + } GRUB_PACKED parameter_request; + grub_uint8_t end; +} GRUB_PACKED; + enum { GRUB_DHCP_OPT_OVERLOAD_FILE = 1, @@ -43,6 +85,8 @@ enum GRUB_DHCP_MESSAGE_INFORM, }; +#define GRUB_BOOTP_MAX_OPTIONS_SIZE 64 + /* Max timeout when waiting for BOOTP/DHCP reply */ #define GRUB_DHCP_MAX_PACKET_TIMEOUT 32 @@ -386,6 +430,64 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) grub_net_network_level_address_t target; grub_net_link_level_address_t ll_target; + static struct grub_dhcp_discover_options discover_options = + { + { + GRUB_NET_BOOTP_RFC1048_MAGIC_0, + GRUB_NET_BOOTP_RFC1048_MAGIC_1, + GRUB_NET_BOOTP_RFC1048_MAGIC_2, + GRUB_NET_BOOTP_RFC1048_MAGIC_3, + }, + { + GRUB_NET_DHCP_MESSAGE_TYPE, + sizeof (discover_options.message_type.data), + GRUB_DHCP_MESSAGE_DISCOVER, + }, + GRUB_NET_BOOTP_END, + }; + + static struct grub_dhcp_request_options request_options = + { + { + GRUB_NET_BOOTP_RFC1048_MAGIC_0, + GRUB_NET_BOOTP_RFC1048_MAGIC_1, + GRUB_NET_BOOTP_RFC1048_MAGIC_2, + GRUB_NET_BOOTP_RFC1048_MAGIC_3, + }, + { + GRUB_NET_DHCP_MESSAGE_TYPE, + sizeof (request_options.message_type.data), + GRUB_DHCP_MESSAGE_REQUEST, + }, + { + GRUB_NET_DHCP_SERVER_IDENTIFIER, + sizeof (request_options.server_identifier.data), + 0, + }, + { + GRUB_NET_DHCP_REQUESTED_IP_ADDRESS, + sizeof (request_options.requested_ip.data), + 0, + }, + { + GRUB_NET_DHCP_PARAMETER_REQUEST_LIST, + sizeof (request_options.parameter_request.data), + { + GRUB_NET_BOOTP_NETMASK, + GRUB_NET_BOOTP_ROUTER, + GRUB_NET_BOOTP_DNS, + GRUB_NET_BOOTP_DOMAIN, + GRUB_NET_BOOTP_HOSTNAME, + GRUB_NET_BOOTP_ROOT_PATH, + GRUB_NET_BOOTP_EXTENSIONS_PATH, + }, + }, + GRUB_NET_BOOTP_END, + }; + + COMPILE_TIME_ASSERT (sizeof (discover_options) <= GRUB_BOOTP_MAX_OPTIONS_SIZE); + COMPILE_TIME_ASSERT (sizeof (request_options) <= GRUB_BOOTP_MAX_OPTIONS_SIZE); + nb = grub_netbuff_alloc (sizeof (*pack) + GRUB_BOOTP_MAX_OPTIONS_SIZE + 128); if (!nb) return grub_errno; @@ -399,6 +501,19 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) goto out; grub_memset (nb->data, 0, GRUB_BOOTP_MAX_OPTIONS_SIZE); + if (!iface->srv_id) + { + grub_memcpy (nb->data, &discover_options, sizeof (discover_options)); + } + else + { + struct grub_dhcp_request_options *ro = (struct grub_dhcp_request_options *) nb->data; + + grub_memcpy (nb->data, &request_options, sizeof (request_options)); + /* my_ip and srv_id are stored in network order so do not need conversion. */ + grub_set_unaligned32 (&ro->server_identifier.data, iface->srv_id); + grub_set_unaligned32 (&ro->requested_ip.data, iface->my_ip); + } err = grub_netbuff_push (nb, sizeof (*pack)); if (err) @@ -416,7 +531,10 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) t = 0; } pack->seconds = grub_cpu_to_be16 (t); - pack->ident = grub_cpu_to_be32 (t); + if (!iface->srv_id) + iface->xid = pack->ident = grub_cpu_to_be32 (t); + else + pack->ident = iface->xid; grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, 6); diff --git a/include/grub/net.h b/include/grub/net.h index 68a9f1311..4a9069a14 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -462,9 +462,11 @@ enum GRUB_NET_BOOTP_DOMAIN = 0x0f, GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, + GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, GRUB_NET_DHCP_OVERLOAD = 52, GRUB_NET_DHCP_MESSAGE_TYPE = 53, GRUB_NET_DHCP_SERVER_IDENTIFIER = 54, + GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55, GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, GRUB_NET_DHCP_BOOTFILE_NAME = 67, GRUB_NET_BOOTP_END = 0xff From 5bc41db756c5b342aa22fc95508bde105e05a095 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 Mar 2019 15:14:16 +0000 Subject: [PATCH 0951/1167] net/dhcp: Add explicit net_dhcp command Mostly for cosmetic reasons, we add a "net_dhcp" command, which is (at the moment) identical to the existing "net_bootp" command. Both actually trigger a DHCP handshake now, and both should be able to deal with pure BOOTP servers. We could think about dropping the DHCP options from the initial DISCOVER packet when the user issues the net_bootp command, but it's unclear whether this is really useful, as both protocols should be able to coexist. Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 63763aaab..04cfbb045 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -864,7 +864,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), return err; } -static grub_command_t cmd_getdhcp, cmd_bootp; +static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; void grub_bootp_init (void) @@ -872,6 +872,9 @@ grub_bootp_init (void) cmd_bootp = grub_register_command ("net_bootp", grub_cmd_bootp, N_("[CARD]"), N_("perform a bootp autoconfiguration")); + cmd_dhcp = grub_register_command ("net_dhcp", grub_cmd_bootp, + N_("[CARD]"), + N_("perform a DHCP autoconfiguration")); cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt, N_("VAR INTERFACE NUMBER DESCRIPTION"), N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value.")); @@ -882,4 +885,5 @@ grub_bootp_fini (void) { grub_unregister_command (cmd_getdhcp); grub_unregister_command (cmd_bootp); + grub_unregister_command (cmd_dhcp); } From 5dfa0afa169f915471d4d55f519a6f3b830e37ae Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 9 Mar 2019 14:37:17 +0000 Subject: [PATCH 0952/1167] getroot: Save/restore CWD more reliably on Unix Various GRUB utilities fail if the current directory doesn't exist, because grub_find_device() chdirs to a different directory and then fails when trying to chdir back. Gnulib's save-cwd module uses fchdir() instead when it can, avoiding this category of problem. Fixes Debian bug #918700. Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- bootstrap.conf | 1 + grub-core/osdep/unix/getroot.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 6781d25a7..988dda099 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -33,6 +33,7 @@ gnulib_modules=" progname realloc-gnu regex + save-cwd " gnulib_tool_option_extras="\ diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 3046e22cc..46d7116c6 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -34,6 +34,7 @@ #ifdef HAVE_LIMITS_H #include #endif + #include #include @@ -113,6 +114,8 @@ #include #endif +#include "save-cwd.h" + #if !defined (__GNU__) static void strip_extra_slashes (char *dir) @@ -352,7 +355,7 @@ char * grub_find_device (const char *dir, dev_t dev) { DIR *dp; - char *saved_cwd; + struct saved_cwd saved_cwd; struct dirent *ent; if (! dir) @@ -362,12 +365,17 @@ grub_find_device (const char *dir, dev_t dev) if (! dp) return 0; - saved_cwd = xgetcwd (); + if (save_cwd (&saved_cwd) < 0) + { + grub_util_error ("%s", _("cannot save the original directory")); + closedir (dp); + return 0; + } grub_util_info ("changing current directory to %s", dir); if (chdir (dir) < 0) { - free (saved_cwd); + free_cwd (&saved_cwd); closedir (dp); return 0; } @@ -410,11 +418,11 @@ grub_find_device (const char *dir, dev_t dev) if (res) { - if (chdir (saved_cwd) < 0) + if (restore_cwd (&saved_cwd) < 0) grub_util_error ("%s", _("cannot restore the original directory")); - free (saved_cwd); + free_cwd (&saved_cwd); closedir (dp); return res; } @@ -468,19 +476,19 @@ grub_find_device (const char *dir, dev_t dev) continue; } - if (chdir (saved_cwd) < 0) + if (restore_cwd (&saved_cwd) < 0) grub_util_error ("%s", _("cannot restore the original directory")); - free (saved_cwd); + free_cwd (&saved_cwd); closedir (dp); return res; } } - if (chdir (saved_cwd) < 0) + if (restore_cwd (&saved_cwd) < 0) grub_util_error ("%s", _("cannot restore the original directory")); - free (saved_cwd); + free_cwd (&saved_cwd); closedir (dp); return 0; } From 67580c0068b59d3049f8b7becd72b2bac5f988f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 14 Mar 2019 02:57:08 +0100 Subject: [PATCH 0953/1167] xen: Look for Xen notes in section headers too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror behaviour of ELF loader in libxc: first look for Xen notes in PT_NOTE segment, then in SHT_NOTE section and only then fallback to a section with __xen_guest name. This fixes loading PV kernels that Xen note have outside of PT_NOTE. While this may be result of a buggy linker script, loading such kernel directly works fine, so make it work with GRUB too. Specifically, this applies to binaries built from Unikraft. Signed-off-by: Marek Marczykowski-Górecki Reviewed-by: Daniel Kiper --- grub-core/loader/i386/xen_fileXX.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index fb66e66fe..6329ec010 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -344,6 +344,23 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi) s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize); stroff = s->sh_offset; + for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize); + s = (Elf_Shdr *) ((char *) s + shentsize)) + { + if (s->sh_type == SHT_NOTE) + { + err = parse_note (elf, xi, s->sh_offset, s->sh_size); + if (err) + goto cleanup; + } + } + + if (xi->has_note) + { + err = GRUB_ERR_NONE; + goto cleanup; + } + for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize); s = (Elf_Shdr *) ((char *) s + shentsize)) { From bcd29eea07221a7f1eb06825afba5e89b24dd7c1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 19 Mar 2019 10:26:18 +0000 Subject: [PATCH 0954/1167] posix_wrap: Flesh out posix_wrap/limits.h a little more In addition to what was already there, Gnulib's needs SCHAR_MIN, SCHAR_MAX, SHRT_MIN, INT_MIN, LONG_MIN, and LONG_MAX. Fixes build on CentOS 7. Reported-by: "Chen, Farrah" Signed-off-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/lib/posix_wrap/limits.h | 6 ++++++ include/grub/types.h | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h index 955295403..7217138ff 100644 --- a/grub-core/lib/posix_wrap/limits.h +++ b/grub-core/lib/posix_wrap/limits.h @@ -27,8 +27,14 @@ #define ULONG_MAX GRUB_ULONG_MAX #define SIZE_MAX GRUB_SIZE_MAX +#define SCHAR_MIN GRUB_SCHAR_MIN +#define SCHAR_MAX GRUB_SCHAR_MAX +#define SHRT_MIN GRUB_SHRT_MIN #define SHRT_MAX GRUB_SHRT_MAX +#define INT_MIN GRUB_INT_MIN #define INT_MAX GRUB_INT_MAX +#define LONG_MIN GRUB_LONG_MIN +#define LONG_MAX GRUB_LONG_MAX #define CHAR_BIT 8 diff --git a/include/grub/types.h b/include/grub/types.h index b93e48201..035a4b528 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -130,23 +130,26 @@ typedef grub_int32_t grub_ssize_t; # define PRIdGRUB_SSIZE "d" #endif +#define GRUB_SCHAR_MAX 127 +#define GRUB_SCHAR_MIN (-GRUB_SCHAR_MAX - 1) #define GRUB_UCHAR_MAX 0xFF #define GRUB_USHRT_MAX 65535 #define GRUB_SHRT_MAX 0x7fff +#define GRUB_SHRT_MIN (-GRUB_SHRT_MAX - 1) #define GRUB_UINT_MAX 4294967295U #define GRUB_INT_MAX 0x7fffffff -#define GRUB_INT32_MIN (-2147483647 - 1) +#define GRUB_INT_MIN (-GRUB_INT_MAX - 1) #define GRUB_INT32_MAX 2147483647 +#define GRUB_INT32_MIN (-GRUB_INT32_MAX - 1) #if GRUB_CPU_SIZEOF_LONG == 8 # define GRUB_ULONG_MAX 18446744073709551615UL # define GRUB_LONG_MAX 9223372036854775807L -# define GRUB_LONG_MIN (-9223372036854775807L - 1) #else # define GRUB_ULONG_MAX 4294967295UL # define GRUB_LONG_MAX 2147483647L -# define GRUB_LONG_MIN (-2147483647L - 1) #endif +# define GRUB_LONG_MIN (-GRUB_LONG_MAX - 1) typedef grub_uint64_t grub_properly_aligned_t; From 1bc2b481c4a2e2de771ee3b31436fe5bdaedbdd3 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 14 Mar 2019 16:18:31 +0100 Subject: [PATCH 0955/1167] verifiers: IA-64 fallout cleanup IA-64 fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility to verify kernel and modules command lines). Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/loader/ia64/efi/linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 639a1f379..7987fd1ba 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -505,8 +505,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), *p = '\0'; - err = grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE); - if (err) + if (grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE)) goto fail; boot_param->command_line = (grub_uint64_t) cmdline; From ee025e512fa8589145a9e6a71b56b9b635994c16 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 14 Mar 2019 19:45:17 +0100 Subject: [PATCH 0956/1167] verifiers: PowerPC fallout cleanup PowerPC fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility to verify kernel and modules command lines) and ca0a4f689 (verifiers: File type for fine-grained signature-verification controlling). Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/loader/powerpc/ieee1275/linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index c114e7df4..818b2a86d 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -270,7 +270,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - elf = grub_elf_open (argv[0]); + elf = grub_elf_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); if (! elf) goto out; @@ -303,7 +303,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* Create kernel command line. */ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); if (grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, - size)) + size, GRUB_VERIFY_KERNEL_CMDLINE)) goto out; out: From c7bdb8273cee393b0054f549b949818eb14b7f9a Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 18 Mar 2019 13:09:22 +0100 Subject: [PATCH 0957/1167] verifiers: MIPS fallout cleanup MIPS fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility to verify kernel and modules command lines). Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/loader/mips/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index e256c440f..7b723bf18 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -314,7 +314,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_memcpy (params, LINUX_IMAGE, sizeof (LINUX_IMAGE)); grub_create_loader_cmdline (argc, argv, params + sizeof (LINUX_IMAGE) - 1, - size); + size, GRUB_VERIFY_KERNEL_CMDLINE); #else linux_argv = extra; argv_off = (grub_uint8_t *) linux_argv - (grub_uint8_t *) playground; From e42b0d97ec3b012b68deda42b77712ac573e731c Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 18 Mar 2019 13:19:05 +0100 Subject: [PATCH 0958/1167] mips: Enable __clzsi2() This patch is similiar to commit e795b9011 (RISC-V: Add libgcc helpers for clz) but for MIPS target. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/kern/compiler-rt.c | 5 +++-- include/grub/compiler-rt.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index e10b6668c..33e08fe06 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -420,8 +420,7 @@ __aeabi_llsl (grub_uint64_t u, int b) #endif -#ifdef __riscv - +#if defined(__mips__) || defined(__riscv) /* Based on libgcc from gcc suite. */ int __clzsi2 (grub_uint32_t val) @@ -447,7 +446,9 @@ __clzsi2 (grub_uint32_t val) } return (i - val); } +#endif +#ifdef __riscv int __clzdi2 (grub_uint64_t val) { diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index e6a25c6ea..31c0fd750 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -110,10 +110,12 @@ EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); #endif -#ifdef __riscv +#if defined(__mips__) || defined(__riscv) int EXPORT_FUNC (__clzsi2) (grub_uint32_t val); +#endif +#ifdef __riscv int EXPORT_FUNC (__clzdi2) (grub_uint64_t val); #endif From 9dab2f51ea64c251f4a6ad8faece7dad2e72e6bc Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Tue, 19 Mar 2019 10:51:01 +0100 Subject: [PATCH 0959/1167] sparc: Enable __clzsi2() and __clzdi2() This patch is similiar to commit e795b9011 (RISC-V: Add libgcc helpers for clz) but for SPARC target. Signed-off-by: Daniel Kiper Reviewed-by: Ross Philipson --- grub-core/kern/compiler-rt.c | 4 ++-- include/grub/compiler-rt.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index 33e08fe06..a464200c6 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -420,7 +420,7 @@ __aeabi_llsl (grub_uint64_t u, int b) #endif -#if defined(__mips__) || defined(__riscv) +#if defined(__mips__) || defined(__riscv) || defined(__sparc__) /* Based on libgcc from gcc suite. */ int __clzsi2 (grub_uint32_t val) @@ -448,7 +448,7 @@ __clzsi2 (grub_uint32_t val) } #endif -#ifdef __riscv +#if defined(__riscv) || defined(__sparc__) int __clzdi2 (grub_uint64_t val) { diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index 31c0fd750..7591980b4 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -110,12 +110,12 @@ EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); #endif -#if defined(__mips__) || defined(__riscv) +#if defined(__mips__) || defined(__riscv) || defined(__sparc__) int EXPORT_FUNC (__clzsi2) (grub_uint32_t val); #endif -#ifdef __riscv +#if defined(__riscv) || defined(__sparc__) int EXPORT_FUNC (__clzdi2) (grub_uint64_t val); #endif From 4ff051880fc5d2aa431f049a52bffb5b405c5414 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 21:24:24 +0100 Subject: [PATCH 0960/1167] Support R_PPC_PLTREL24 It's emitted by clang 7. It's the same as R_PPC_REL24. Signed-off-by: Vladimir Serbinenko --- grub-core/kern/powerpc/dl.c | 4 +++- util/grub-module-verifier.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c index 3a7fa3ed3..cdd61b305 100644 --- a/grub-core/kern/powerpc/dl.c +++ b/grub-core/kern/powerpc/dl.c @@ -79,7 +79,8 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, max = rel + s->sh_size / s->sh_entsize; rel < max; rel++) - if (ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_REL24) + if (ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_REL24 + || ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_PLTREL24) (*tramp)++; } @@ -122,6 +123,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, *(Elf_Half *) addr = value; break; + case GRUB_ELF_R_PPC_PLTREL24: case GRUB_ELF_R_PPC_REL24: { Elf_Sword delta = value - (Elf_Word) addr; diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index 60e4d2c06..163529ca9 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -29,6 +29,7 @@ struct grub_module_verifier_arch archs[] = { GRUB_ELF_R_PPC_ADDR16_HA, GRUB_ELF_R_PPC_ADDR32, GRUB_ELF_R_PPC_REL32, + GRUB_ELF_R_PPC_PLTREL24, -1 } }, { "sparc64", 8, 1, EM_SPARCV9, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ From d900dfa985944e7f773490bba7e5159c89250dc3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 17:19:38 +0100 Subject: [PATCH 0961/1167] kern/emu/misc.c: Don't include config-util.h when running as GRUB_BUILD Signed-off-by: Vladimir Serbinenko --- grub-core/kern/emu/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 76661337f..65db79baa 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -16,7 +16,9 @@ * along with GRUB. If not, see . */ +#ifndef GRUB_BUILD #include +#endif #include #include From 3562536fd5e5cc3d40942f3e8ac53d4f0ee5c220 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 17:11:14 +0100 Subject: [PATCH 0962/1167] grub-mkimagexx: Fix RISCV error message Outputting a raw pointer doesn't match the format and is also useless. Output offset instead. Signed-off-by: Vladimir Serbinenko --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index c04f17d4e..a79034e7b 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1298,7 +1298,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, grub_uint32_t hi20, lo12; if (off != (grub_int32_t)off) - grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)target); + grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e)); hi20 = (off + 0x800) & 0xfffff000; lo12 = (off - hi20) & 0xfff; @@ -1337,7 +1337,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, grub_int32_t hi20; if (off != (grub_int32_t)off) - grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)target); + grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e)); hi20 = (off + 0x800) & 0xfffff000; *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20); From 384091967d25ad7fe2fc0930b11adb23974bfeb9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 17:07:00 +0100 Subject: [PATCH 0963/1167] Rename grub_disk members Otherwise it horribly clashes with gnulib when it's replacing open/write/read/close Signed-off-by: Vladimir Serbinenko --- grub-core/disk/arc/arcdisk.c | 10 +++++----- grub-core/disk/ata.c | 10 +++++----- grub-core/disk/cryptodisk.c | 12 ++++++------ grub-core/disk/diskfilter.c | 22 +++++++++++----------- grub-core/disk/efi/efidisk.c | 10 +++++----- grub-core/disk/host.c | 10 +++++----- grub-core/disk/i386/pc/biosdisk.c | 10 +++++----- grub-core/disk/ieee1275/nand.c | 10 +++++----- grub-core/disk/ieee1275/obdisk.c | 8 ++++---- grub-core/disk/ieee1275/ofdisk.c | 10 +++++----- grub-core/disk/loopback.c | 8 ++++---- grub-core/disk/memdisk.c | 10 +++++----- grub-core/disk/scsi.c | 10 +++++----- grub-core/disk/uboot/ubootdisk.c | 10 +++++----- grub-core/disk/xen/xendisk.c | 10 +++++----- grub-core/fs/cbfs.c | 10 +++++----- grub-core/fs/proc.c | 10 +++++----- grub-core/kern/disk.c | 28 ++++++++++++++-------------- grub-core/kern/emu/hostdisk.c | 10 +++++----- grub-core/lib/disk.c | 8 ++++---- include/grub/disk.h | 16 ++++++++-------- util/grub-install.c | 12 ++++++------ util/grub-probe.c | 16 ++++++++-------- 23 files changed, 135 insertions(+), 135 deletions(-) diff --git a/grub-core/disk/arc/arcdisk.c b/grub-core/disk/arc/arcdisk.c index 0cc1993e5..c94039a3d 100644 --- a/grub-core/disk/arc/arcdisk.c +++ b/grub-core/disk/arc/arcdisk.c @@ -296,11 +296,11 @@ static struct grub_disk_dev grub_arcdisk_dev = { .name = "arcdisk", .id = GRUB_DISK_DEVICE_ARCDISK_ID, - .iterate = grub_arcdisk_iterate, - .open = grub_arcdisk_open, - .close = grub_arcdisk_close, - .read = grub_arcdisk_read, - .write = grub_arcdisk_write, + .disk_iterate = grub_arcdisk_iterate, + .disk_open = grub_arcdisk_open, + .disk_close = grub_arcdisk_close, + .disk_read = grub_arcdisk_read, + .disk_write = grub_arcdisk_write, .next = 0 }; diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index 8ba4e5c50..685f33a19 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -510,11 +510,11 @@ static struct grub_disk_dev grub_atadisk_dev = { .name = "ATA", .id = GRUB_DISK_DEVICE_ATA_ID, - .iterate = grub_ata_iterate, - .open = grub_ata_open, - .close = grub_ata_close, - .read = grub_ata_read, - .write = grub_ata_write, + .disk_iterate = grub_ata_iterate, + .disk_open = grub_ata_open, + .disk_close = grub_ata_close, + .disk_read = grub_ata_read, + .disk_write = grub_ata_write, .next = 0 }; diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index bd60a66b3..5037768fc 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -1015,13 +1015,13 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) static struct grub_disk_dev grub_cryptodisk_dev = { .name = "cryptodisk", .id = GRUB_DISK_DEVICE_CRYPTODISK_ID, - .iterate = grub_cryptodisk_iterate, - .open = grub_cryptodisk_open, - .close = grub_cryptodisk_close, - .read = grub_cryptodisk_read, - .write = grub_cryptodisk_write, + .disk_iterate = grub_cryptodisk_iterate, + .disk_open = grub_cryptodisk_open, + .disk_close = grub_cryptodisk_close, + .disk_read = grub_cryptodisk_read, + .disk_write = grub_cryptodisk_write, #ifdef GRUB_UTIL - .memberlist = grub_cryptodisk_memberlist, + .disk_memberlist = grub_cryptodisk_memberlist, #endif .next = 0 }; diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 6f901c0ad..c3b578acf 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -228,9 +228,9 @@ scan_devices (const char *arname) for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++) for (p = grub_disk_dev_list; p; p = p->next) if (p->id != GRUB_DISK_DEVICE_DISKFILTER_ID - && p->iterate) + && p->disk_iterate) { - if ((p->iterate) (scan_disk_hook, NULL, pull)) + if ((p->disk_iterate) (scan_disk_hook, NULL, pull)) return; if (arname && is_lv_readable (find_lv (arname), 1)) return; @@ -311,9 +311,9 @@ grub_diskfilter_memberlist (grub_disk_t disk) for (pull = 0; pv && pull < GRUB_DISK_PULL_MAX; pull++) for (p = grub_disk_dev_list; pv && p; p = p->next) if (p->id != GRUB_DISK_DEVICE_DISKFILTER_ID - && p->iterate) + && p->disk_iterate) { - (p->iterate) (scan_disk_hook, NULL, pull); + (p->disk_iterate) (scan_disk_hook, NULL, pull); while (pv && pv->disk) pv = pv->next; } @@ -1325,14 +1325,14 @@ static struct grub_disk_dev grub_diskfilter_dev = { .name = "diskfilter", .id = GRUB_DISK_DEVICE_DISKFILTER_ID, - .iterate = grub_diskfilter_iterate, - .open = grub_diskfilter_open, - .close = grub_diskfilter_close, - .read = grub_diskfilter_read, - .write = grub_diskfilter_write, + .disk_iterate = grub_diskfilter_iterate, + .disk_open = grub_diskfilter_open, + .disk_close = grub_diskfilter_close, + .disk_read = grub_diskfilter_read, + .disk_write = grub_diskfilter_write, #ifdef GRUB_UTIL - .memberlist = grub_diskfilter_memberlist, - .raidname = grub_diskfilter_getname, + .disk_memberlist = grub_diskfilter_memberlist, + .disk_raidname = grub_diskfilter_getname, #endif .next = 0 }; diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 5d2400f66..0f132f559 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -627,11 +627,11 @@ static struct grub_disk_dev grub_efidisk_dev = { .name = "efidisk", .id = GRUB_DISK_DEVICE_EFIDISK_ID, - .iterate = grub_efidisk_iterate, - .open = grub_efidisk_open, - .close = grub_efidisk_close, - .read = grub_efidisk_read, - .write = grub_efidisk_write, + .disk_iterate = grub_efidisk_iterate, + .disk_open = grub_efidisk_open, + .disk_close = grub_efidisk_close, + .disk_read = grub_efidisk_read, + .disk_write = grub_efidisk_write, .next = 0 }; diff --git a/grub-core/disk/host.c b/grub-core/disk/host.c index 76ef1afb8..c151d225d 100644 --- a/grub-core/disk/host.c +++ b/grub-core/disk/host.c @@ -84,11 +84,11 @@ static struct grub_disk_dev grub_host_dev = /* The only important line in this file :-) */ .name = "host", .id = GRUB_DISK_DEVICE_HOST_ID, - .iterate = grub_host_iterate, - .open = grub_host_open, - .close = grub_host_close, - .read = grub_host_read, - .write = grub_host_write, + .disk_iterate = grub_host_iterate, + .disk_open = grub_host_open, + .disk_close = grub_host_close, + .disk_read = grub_host_read, + .disk_write = grub_host_write, .next = 0 }; diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index f0aadd111..8ca250c77 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -637,11 +637,11 @@ static struct grub_disk_dev grub_biosdisk_dev = { .name = "biosdisk", .id = GRUB_DISK_DEVICE_BIOSDISK_ID, - .iterate = grub_biosdisk_iterate, - .open = grub_biosdisk_open, - .close = grub_biosdisk_close, - .read = grub_biosdisk_read, - .write = grub_biosdisk_write, + .disk_iterate = grub_biosdisk_iterate, + .disk_open = grub_biosdisk_open, + .disk_close = grub_biosdisk_close, + .disk_read = grub_biosdisk_read, + .disk_write = grub_biosdisk_write, .next = 0 }; diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c index feffa8c4c..bcf3a06f4 100644 --- a/grub-core/disk/ieee1275/nand.c +++ b/grub-core/disk/ieee1275/nand.c @@ -223,11 +223,11 @@ static struct grub_disk_dev grub_nand_dev = { .name = "nand", .id = GRUB_DISK_DEVICE_NAND_ID, - .iterate = grub_nand_iterate, - .open = grub_nand_open, - .close = grub_nand_close, - .read = grub_nand_read, - .write = grub_nand_write, + .disk_iterate = grub_nand_iterate, + .disk_open = grub_nand_open, + .disk_close = grub_nand_close, + .disk_read = grub_nand_read, + .disk_write = grub_nand_write, .next = 0 }; diff --git a/grub-core/disk/ieee1275/obdisk.c b/grub-core/disk/ieee1275/obdisk.c index 877f65c9e..ec413c3fd 100644 --- a/grub-core/disk/ieee1275/obdisk.c +++ b/grub-core/disk/ieee1275/obdisk.c @@ -1047,10 +1047,10 @@ static struct grub_disk_dev grub_obdisk_dev = { .name = "obdisk", .id = GRUB_DISK_DEVICE_OBDISK_ID, - .iterate = grub_obdisk_iterate, - .open = grub_obdisk_open, - .close = grub_obdisk_close, - .read = grub_obdisk_read, + .disk_iterate = grub_obdisk_iterate, + .disk_open = grub_obdisk_open, + .disk_close = grub_obdisk_close, + .disk_read = grub_obdisk_read, }; void diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 235c0fe2c..f73257e66 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -615,11 +615,11 @@ static struct grub_disk_dev grub_ofdisk_dev = { .name = "ofdisk", .id = GRUB_DISK_DEVICE_OFDISK_ID, - .iterate = grub_ofdisk_iterate, - .open = grub_ofdisk_open, - .close = grub_ofdisk_close, - .read = grub_ofdisk_read, - .write = grub_ofdisk_write, + .disk_iterate = grub_ofdisk_iterate, + .disk_open = grub_ofdisk_open, + .disk_close = grub_ofdisk_close, + .disk_read = grub_ofdisk_read, + .disk_write = grub_ofdisk_write, .next = 0 }; diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index 9406d931c..cdf9123fa 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -222,10 +222,10 @@ static struct grub_disk_dev grub_loopback_dev = { .name = "loopback", .id = GRUB_DISK_DEVICE_LOOPBACK_ID, - .iterate = grub_loopback_iterate, - .open = grub_loopback_open, - .read = grub_loopback_read, - .write = grub_loopback_write, + .disk_iterate = grub_loopback_iterate, + .disk_open = grub_loopback_open, + .disk_read = grub_loopback_read, + .disk_write = grub_loopback_write, .next = 0 }; diff --git a/grub-core/disk/memdisk.c b/grub-core/disk/memdisk.c index e5ffc01bf..613779cf3 100644 --- a/grub-core/disk/memdisk.c +++ b/grub-core/disk/memdisk.c @@ -77,11 +77,11 @@ static struct grub_disk_dev grub_memdisk_dev = { .name = "memdisk", .id = GRUB_DISK_DEVICE_MEMDISK_ID, - .iterate = grub_memdisk_iterate, - .open = grub_memdisk_open, - .close = grub_memdisk_close, - .read = grub_memdisk_read, - .write = grub_memdisk_write, + .disk_iterate = grub_memdisk_iterate, + .disk_open = grub_memdisk_open, + .disk_close = grub_memdisk_close, + .disk_read = grub_memdisk_read, + .disk_write = grub_memdisk_write, .next = 0 }; diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index 4c6923f8b..70767cf00 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -747,11 +747,11 @@ static struct grub_disk_dev grub_scsi_dev = { .name = "scsi", .id = GRUB_DISK_DEVICE_SCSI_ID, - .iterate = grub_scsi_iterate, - .open = grub_scsi_open, - .close = grub_scsi_close, - .read = grub_scsi_read, - .write = grub_scsi_write, + .disk_iterate = grub_scsi_iterate, + .disk_open = grub_scsi_open, + .disk_close = grub_scsi_close, + .disk_read = grub_scsi_read, + .disk_write = grub_scsi_write, .next = 0 }; diff --git a/grub-core/disk/uboot/ubootdisk.c b/grub-core/disk/uboot/ubootdisk.c index 584a9cbdf..2d115a94d 100644 --- a/grub-core/disk/uboot/ubootdisk.c +++ b/grub-core/disk/uboot/ubootdisk.c @@ -286,11 +286,11 @@ uboot_disk_write (struct grub_disk *disk, static struct grub_disk_dev grub_ubootdisk_dev = { .name = "ubootdisk", .id = GRUB_DISK_DEVICE_UBOOTDISK_ID, - .iterate = uboot_disk_iterate, - .open = uboot_disk_open, - .close = uboot_disk_close, - .read = uboot_disk_read, - .write = uboot_disk_write, + .disk_iterate = uboot_disk_iterate, + .disk_open = uboot_disk_open, + .disk_close = uboot_disk_close, + .disk_read = uboot_disk_read, + .disk_write = uboot_disk_write, .next = 0 }; diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c index b18a9238d..48476cbbf 100644 --- a/grub-core/disk/xen/xendisk.c +++ b/grub-core/disk/xen/xendisk.c @@ -249,11 +249,11 @@ grub_virtdisk_write (grub_disk_t disk, grub_disk_addr_t sector, static struct grub_disk_dev grub_virtdisk_dev = { .name = "xen", .id = GRUB_DISK_DEVICE_XEN, - .iterate = grub_virtdisk_iterate, - .open = grub_virtdisk_open, - .close = grub_virtdisk_close, - .read = grub_virtdisk_read, - .write = grub_virtdisk_write, + .disk_iterate = grub_virtdisk_iterate, + .disk_open = grub_virtdisk_open, + .disk_close = grub_virtdisk_close, + .disk_read = grub_virtdisk_read, + .disk_write = grub_virtdisk_write, .next = 0 }; diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 0842701a6..a47e44656 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -328,11 +328,11 @@ static struct grub_disk_dev grub_cbfsdisk_dev = { .name = "cbfsdisk", .id = GRUB_DISK_DEVICE_CBFSDISK_ID, - .iterate = grub_cbfsdisk_iterate, - .open = grub_cbfsdisk_open, - .close = grub_cbfsdisk_close, - .read = grub_cbfsdisk_read, - .write = grub_cbfsdisk_write, + .disk_iterate = grub_cbfsdisk_iterate, + .disk_open = grub_cbfsdisk_open, + .disk_close = grub_cbfsdisk_close, + .disk_read = grub_cbfsdisk_read, + .disk_write = grub_cbfsdisk_write, .next = 0 }; diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c index 31f3aa9a4..5911c2eb5 100644 --- a/grub-core/fs/proc.c +++ b/grub-core/fs/proc.c @@ -172,11 +172,11 @@ grub_procfs_open (struct grub_file *file, const char *path) static struct grub_disk_dev grub_procfs_dev = { .name = "proc", .id = GRUB_DISK_DEVICE_PROCFS_ID, - .iterate = grub_procdev_iterate, - .open = grub_procdev_open, - .close = grub_procdev_close, - .read = grub_procdev_read, - .write = grub_procdev_write, + .disk_iterate = grub_procdev_iterate, + .disk_open = grub_procdev_open, + .disk_close = grub_procdev_close, + .disk_read = grub_procdev_read, + .disk_write = grub_procdev_write, .next = 0 }; diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c index 789f8c052..ffb09c8ee 100644 --- a/grub-core/kern/disk.c +++ b/grub-core/kern/disk.c @@ -223,7 +223,7 @@ grub_disk_open (const char *name) for (dev = grub_disk_dev_list; dev; dev = dev->next) { - if ((dev->open) (raw, disk) == GRUB_ERR_NONE) + if ((dev->disk_open) (raw, disk) == GRUB_ERR_NONE) break; else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE) grub_errno = GRUB_ERR_NONE; @@ -294,8 +294,8 @@ grub_disk_close (grub_disk_t disk) grub_partition_t part; grub_dprintf ("disk", "Closing `%s'.\n", disk->name); - if (disk->dev && disk->dev->close) - (disk->dev->close) (disk); + if (disk->dev && disk->dev->disk_close) + (disk->dev->disk_close) (disk); /* Reset the timer. */ grub_last_time = grub_get_time_ms (); @@ -341,10 +341,10 @@ grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector, < (disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS))) { grub_err_t err; - err = (disk->dev->read) (disk, transform_sector (disk, sector), - 1U << (GRUB_DISK_CACHE_BITS - + GRUB_DISK_SECTOR_BITS - - disk->log_sector_size), tmp_buf); + err = (disk->dev->disk_read) (disk, transform_sector (disk, sector), + 1U << (GRUB_DISK_CACHE_BITS + + GRUB_DISK_SECTOR_BITS + - disk->log_sector_size), tmp_buf); if (!err) { /* Copy it and store it in the disk cache. */ @@ -377,8 +377,8 @@ grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector, if (!tmp_buf) return grub_errno; - if ((disk->dev->read) (disk, transform_sector (disk, aligned_sector), - num, tmp_buf)) + if ((disk->dev->disk_read) (disk, transform_sector (disk, aligned_sector), + num, tmp_buf)) { grub_error_push (); grub_dprintf ("disk", "%s read failed\n", disk->name); @@ -483,11 +483,11 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector, { grub_disk_addr_t i; - err = (disk->dev->read) (disk, transform_sector (disk, sector), - agglomerate << (GRUB_DISK_CACHE_BITS - + GRUB_DISK_SECTOR_BITS - - disk->log_sector_size), - buf); + err = (disk->dev->disk_read) (disk, transform_sector (disk, sector), + agglomerate << (GRUB_DISK_CACHE_BITS + + GRUB_DISK_SECTOR_BITS + - disk->log_sector_size), + buf); if (err) return err; diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 87e3e2512..e9ec680cd 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -388,11 +388,11 @@ static struct grub_disk_dev grub_util_biosdisk_dev = { .name = "hostdisk", .id = GRUB_DISK_DEVICE_HOSTDISK_ID, - .iterate = grub_util_biosdisk_iterate, - .open = grub_util_biosdisk_open, - .close = grub_util_biosdisk_close, - .read = grub_util_biosdisk_read, - .write = grub_util_biosdisk_write, + .disk_iterate = grub_util_biosdisk_iterate, + .disk_open = grub_util_biosdisk_open, + .disk_close = grub_util_biosdisk_close, + .disk_read = grub_util_biosdisk_read, + .disk_write = grub_util_biosdisk_write, .next = 0 }; diff --git a/grub-core/lib/disk.c b/grub-core/lib/disk.c index 0f186883a..b4eb064a8 100644 --- a/grub-core/lib/disk.c +++ b/grub-core/lib/disk.c @@ -101,8 +101,8 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector, grub_disk_cache_invalidate (disk->dev->id, disk->id, sector); - if ((disk->dev->write) (disk, transform_sector (disk, sector), - 1, tmp_buf) != GRUB_ERR_NONE) + if ((disk->dev->disk_write) (disk, transform_sector (disk, sector), + 1, tmp_buf) != GRUB_ERR_NONE) { grub_free (tmp_buf); goto finish; @@ -130,8 +130,8 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector, << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS - disk->log_sector_size)); - if ((disk->dev->write) (disk, transform_sector (disk, sector), - n, buf) != GRUB_ERR_NONE) + if ((disk->dev->disk_write) (disk, transform_sector (disk, sector), + n, buf) != GRUB_ERR_NONE) goto finish; while (n--) diff --git a/include/grub/disk.h b/include/grub/disk.h index bd58b11d5..316659fee 100644 --- a/include/grub/disk.h +++ b/include/grub/disk.h @@ -77,26 +77,26 @@ struct grub_disk_dev enum grub_disk_dev_id id; /* Call HOOK with each device name, until HOOK returns non-zero. */ - int (*iterate) (grub_disk_dev_iterate_hook_t hook, void *hook_data, + int (*disk_iterate) (grub_disk_dev_iterate_hook_t hook, void *hook_data, grub_disk_pull_t pull); /* Open the device named NAME, and set up DISK. */ - grub_err_t (*open) (const char *name, struct grub_disk *disk); + grub_err_t (*disk_open) (const char *name, struct grub_disk *disk); /* Close the disk DISK. */ - void (*close) (struct grub_disk *disk); + void (*disk_close) (struct grub_disk *disk); /* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */ - grub_err_t (*read) (struct grub_disk *disk, grub_disk_addr_t sector, + grub_err_t (*disk_read) (struct grub_disk *disk, grub_disk_addr_t sector, grub_size_t size, char *buf); /* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */ - grub_err_t (*write) (struct grub_disk *disk, grub_disk_addr_t sector, + grub_err_t (*disk_write) (struct grub_disk *disk, grub_disk_addr_t sector, grub_size_t size, const char *buf); #ifdef GRUB_UTIL - struct grub_disk_memberlist *(*memberlist) (struct grub_disk *disk); - const char * (*raidname) (struct grub_disk *disk); + struct grub_disk_memberlist *(*disk_memberlist) (struct grub_disk *disk); + const char * (*disk_raidname) (struct grub_disk *disk); #endif /* The next disk device. */ @@ -187,7 +187,7 @@ grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data) for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++) for (p = grub_disk_dev_list; p; p = p->next) - if (p->iterate && (p->iterate) (hook, hook_data, pull)) + if (p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) return 1; return 0; diff --git a/util/grub-install.c b/util/grub-install.c index 264f9ecdc..2046c48c4 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -446,8 +446,8 @@ probe_mods (grub_disk_t disk) if (raid_level >= 0) { grub_install_push_module ("diskfilter"); - if (disk->dev->raidname) - grub_install_push_module (disk->dev->raidname (disk)); + if (disk->dev->disk_raidname) + grub_install_push_module (disk->dev->disk_raidname (disk)); } if (raid_level == 5) grub_install_push_module ("raid5rec"); @@ -455,8 +455,8 @@ probe_mods (grub_disk_t disk) grub_install_push_module ("raid6rec"); /* In case of LVM/RAID, check the member devices as well. */ - if (disk->dev->memberlist) - list = disk->dev->memberlist (disk); + if (disk->dev->disk_memberlist) + list = disk->dev->disk_memberlist (disk); while (list) { probe_mods (list->disk); @@ -514,9 +514,9 @@ probe_cryptodisk_uuid (grub_disk_t disk) grub_disk_memberlist_t list = NULL, tmp; /* In case of LVM/RAID, check the member devices as well. */ - if (disk->dev->memberlist) + if (disk->dev->disk_memberlist) { - list = disk->dev->memberlist (disk); + list = disk->dev->disk_memberlist (disk); } while (list) { diff --git a/util/grub-probe.c b/util/grub-probe.c index e45dbf9e0..2e44ec8f4 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -171,9 +171,9 @@ probe_partmap (grub_disk_t disk, char delim) grub_diskfilter_get_partmap (disk, do_print, &delim); /* In case of LVM/RAID, check the member devices as well. */ - if (disk->dev->memberlist) + if (disk->dev->disk_memberlist) { - list = disk->dev->memberlist (disk); + list = disk->dev->disk_memberlist (disk); } while (list) { @@ -229,9 +229,9 @@ probe_cryptodisk_uuid (grub_disk_t disk, char delim) grub_disk_memberlist_t list = NULL, tmp; /* In case of LVM/RAID, check the member devices as well. */ - if (disk->dev->memberlist) + if (disk->dev->disk_memberlist) { - list = disk->dev->memberlist (disk); + list = disk->dev->disk_memberlist (disk); } while (list) { @@ -272,8 +272,8 @@ probe_abstraction (grub_disk_t disk, char delim) grub_disk_memberlist_t list = NULL, tmp; int raid_level; - if (disk->dev->memberlist) - list = disk->dev->memberlist (disk); + if (disk->dev->disk_memberlist) + list = disk->dev->disk_memberlist (disk); while (list) { probe_abstraction (list->disk, delim); @@ -299,8 +299,8 @@ probe_abstraction (grub_disk_t disk, char delim) if (raid_level >= 0) { printf ("diskfilter%c", delim); - if (disk->dev->raidname) - printf ("%s%c", disk->dev->raidname (disk), delim); + if (disk->dev->disk_raidname) + printf ("%s%c", disk->dev->disk_raidname (disk), delim); } if (raid_level == 5) printf ("raid5rec%c", delim); From 98c3a1a76b183d1cbf684427b7e70f669a3d381b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 17:12:57 +0100 Subject: [PATCH 0964/1167] efi/tpm.h: Fix hash_log_extend_event definition. I didn't check the spec but pointer to address doesn't make much sense and doesn't match the code. Signed-off-by: Vladimir Serbinenko --- include/grub/efi/tpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h index 79c478832..3ea6b4de1 100644 --- a/include/grub/efi/tpm.h +++ b/include/grub/efi/tpm.h @@ -164,7 +164,7 @@ struct grub_efi_tpm2_protocol grub_efi_boolean_t * EventLogTruncated); grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol * this, grub_efi_uint64_t Flags, - grub_efi_physical_address_t * + grub_efi_physical_address_t DataToHash, grub_efi_uint64_t DataToHashLen, EFI_TCG2_EVENT *EfiTcgEvent); From c25a1c93c58831d5cf38ddb4c1ac48a4a8fbb71a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 25 Mar 2019 16:09:04 +0100 Subject: [PATCH 0965/1167] configure.ac: Use nostdlib when checking for nostdinc With clang nostdinc behaviour is influenced by nostdlib. Since we always add nostdlib, add it in test as well Reviewed-by: Daniel Kiper Signed-off-by: Vladimir Serbinenko --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 05d040cd6..2f53a5683 100644 --- a/configure.ac +++ b/configure.ac @@ -1395,7 +1395,7 @@ AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY) if test "$platform" != emu; then AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [ SAVED_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" + CPPFLAGS="$TARGET_CPPFLAGS -nostdlib -nostdinc -isystem `$TARGET_CC -print-file-name=include`" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include int va_arg_func (int fixed, va_list args);]], [[]])], From 18fd1007e3a812f50347945cc3dcd7c8c7e104bb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 16:06:18 +0100 Subject: [PATCH 0966/1167] POTFILES: Don't include gnulib in grub.pot They're translated as a separate project, so we don't want to submit them again. Reviewed-by: Daniel Kiper Signed-off-by: Vladimir Serbinenko --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index d9df5f9be..ef43270fc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -13,7 +13,7 @@ fi export LC_COLLATE=C unset LC_ALL -find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' |sort > po/POTFILES.in +find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' |sort > po/POTFILES.in find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in echo "Importing unicode..." From 16910a8cb9ae0748fc8a779bac26e3423dc72aaf Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 16:07:47 +0100 Subject: [PATCH 0967/1167] efi/tpm.c: Add missing casts Without those casts we get a warning about implicit conversion of pointer to integer. Signed-off-by: Vladimir Serbinenko --- grub-core/commands/efi/tpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index 7475fd87b..32909c192 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -245,7 +245,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, grub_memcpy (event->Event, description, event->EventSize); algorithm = TCG_ALG_SHA; - status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, + status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size, algorithm, event, &eventnum, &lastevent); switch (status) @@ -295,7 +295,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1; grub_memcpy (event->Event, description, grub_strlen (description) + 1); - status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, + status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf, (grub_uint64_t) size, event); switch (status) From f91e4d163314c2faaceebf4a82119d88499f09a7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Mar 2019 16:13:11 +0100 Subject: [PATCH 0968/1167] Propagate GNU_PRINTF from gnulib vfprintf gnulib now replaces vfprintf and hence its format becomes GNU_PRINTF format This also fixes matching definitions to always use GNU format Reviewed-by: Daniel Kiper Signed-off-by: Vladimir Serbinenko --- include/grub/emu/misc.h | 14 +++++--------- include/grub/err.h | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index 59b8b35fc..ce464cfd0 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -43,22 +44,17 @@ char *grub_make_system_path_relative_to_its_root (const char *path) int grub_util_device_is_mapped (const char *dev); -#ifdef __MINGW32__ -#define GRUB_HOST_PRIuLONG_LONG "I64u" -#define GRUB_HOST_PRIxLONG_LONG "I64x" -#else #define GRUB_HOST_PRIuLONG_LONG "llu" #define GRUB_HOST_PRIxLONG_LONG "llx" -#endif void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; -char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT; +char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; -void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); -void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); -void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn)); +void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn)); grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); diff --git a/include/grub/err.h b/include/grub/err.h index 1590c688e..24ba9f5f5 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -21,6 +21,7 @@ #define GRUB_ERR_HEADER 1 #include +#include #define GRUB_MAX_ERRMSG 256 @@ -91,6 +92,6 @@ int EXPORT_FUNC(grub_error_pop) (void); void EXPORT_FUNC(grub_print_error) (void); extern int EXPORT_VAR(grub_err_printed_errors); int grub_err_printf (const char *fmt, ...) - __attribute__ ((format (__printf__, 1, 2))); + __attribute__ ((format (GNU_PRINTF, 1, 2))); #endif /* ! GRUB_ERR_HEADER */ From 5635e799fd7e14a8435f60f163706270c2109041 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Tue, 26 Mar 2019 10:47:16 +0100 Subject: [PATCH 0969/1167] ieee1275: Include a.out header in assembly of sparc64 boot loader Recent versions of binutils dropped support for the a.out and COFF formats on sparc64 targets. Since the boot loader on sparc64 is supposed to be an a.out binary and the a.out header entries are rather simple to calculate in our case, we just write the header ourselves instead of relying on external tools to do that. Signed-off-by: John Paul Adrian Glaubitz Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 16 +++++++++++---- grub-core/boot/sparc64/ieee1275/boot.S | 28 +++++++++++++++++++++++--- include/grub/sparc64/ieee1275/boot.h | 3 +-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 43ed42191..474a63e68 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -425,8 +425,14 @@ image = { i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)'; i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big'; - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000'; + /* The entry point for a.out binaries on sparc64 starts + at 0x4000. Since we are writing the 32 bytes long a.out + header in the assembly code ourselves, we need to tell + the linker to adjust the start of the text segment to + 0x4000 - 0x20 = 0x3fe0. + */ + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0'; + sparc64_ieee1275_objcopyflags = '-O binary'; objcopyflags = '-O binary'; enable = i386_pc; @@ -455,8 +461,10 @@ image = { i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00'; sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S; - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big'; - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000'; + + /* See comment for sparc64_ieee1275_ldflags above. */ + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0'; + sparc64_ieee1275_objcopyflags = '-O binary'; sparc64_ieee1275_cppflags = '-DCDBOOT=1'; objcopyflags = '-O binary'; diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 9ea9b4e06..374928ed2 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -21,6 +21,24 @@ .text .align 4 + /* + * We're writing the a.out header ourselves as newer + * upstream versions of binutils no longer support + * the a.out format on sparc64. + * + * The boot loader fits into 512 bytes with 32 bytes + * used for the a.out header, hence the text segment + * size is 512 - 32. There is no data segment and no + * code relocation, thus those fields remain zero. + */ + .word 0x1030107 /* Magic number. */ + .word 512 - GRUB_BOOT_AOUT_HEADER_SIZE /* Size of text segment. */ + .word 0 /* Size of initialized data. */ + .word 0 /* Size of uninitialized data. */ + .word 0 /* Size of symbol table || checksum. */ + .word _start /* Entry point. */ + .word 0 /* Size of text relocation. */ + .word 0 /* Size of data relocation. */ .globl _start _start: /* OF CIF entry point arrives in %o4 */ @@ -40,10 +58,14 @@ pic_base: * * After loading in that block we will execute it by jumping to the * load address plus the size of the prepended A.OUT header (32 bytes). + * + * Since this assembly code includes the 32 bytes long a.out header, + * we need to move the actual code entry point forward by the size + * of the a.out header, i.e. += GRUB_BOOT_AOUT_HEADER_SIZE. */ - .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + GRUB_BOOT_AOUT_HEADER_SIZE boot_path: - .org GRUB_BOOT_MACHINE_KERNEL_BYTE + .org GRUB_BOOT_MACHINE_KERNEL_BYTE + GRUB_BOOT_AOUT_HEADER_SIZE boot_path_end: kernel_byte: .xword (2 << 9) kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR @@ -52,7 +74,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #define boot_path_end (_start + 1024) #include - .org 8 + .org 8 + GRUB_BOOT_AOUT_HEADER_SIZE kernel_byte: .xword (2 << 9) kernel_size: .word 512 kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h index 02d53f28e..cc5a941e3 100644 --- a/include/grub/sparc64/ieee1275/boot.h +++ b/include/grub/sparc64/ieee1275/boot.h @@ -46,8 +46,7 @@ #define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80 -#define GRUB_BOOT_MACHINE_CODE_END \ - (0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE) +#define GRUB_BOOT_MACHINE_CODE_END 0x1fc #define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200 From 63d568ed2e909ae9b33424700a2fa15be402a570 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Tue, 26 Mar 2019 11:21:56 +0100 Subject: [PATCH 0970/1167] ieee1275: Fix path reference in comment of sparc64 boot loader code Signed-off-by: John Paul Adrian Glaubitz Reviewed-by: Daniel Kiper --- grub-core/boot/sparc64/ieee1275/boot.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 374928ed2..ff8a79d3b 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -48,7 +48,7 @@ pic_base: #ifndef CDBOOT /* The offsets to these locations are defined by the - * GRUB_BOOT_MACHINE_foo macros in include/grub/sparc/ieee1275/boot.h, + * GRUB_BOOT_MACHINE_foo macros in include/grub/sparc64/ieee1275/boot.h, * and grub-setup uses this to patch these next three values as needed. * * The boot_path will be the OF device path of the partition where the From 4dace5f60eac8b91c2e82a3fce8a2e3d1f004f1c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 25 Mar 2019 17:43:18 +0100 Subject: [PATCH 0971/1167] clang: Pair -Qn with -Qunused-arguments. When assembling module wirh clang -Qn ends up on command line but later ignored To avoid it breaking the compile, add -Qunused-arguments. Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2f53a5683..8578d01b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1228,12 +1228,12 @@ if test "x$target_cpu" = xarm; then fi AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [ - CFLAGS="$TARGET_CFLAGS -Qn -Werror" + CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_qn=yes], [grub_cv_target_cc_qn=no])]) if test "x$grub_cv_target_cc_qn" = xyes; then - TARGET_CFLAGS="$TARGET_CFLAGS -Qn" + TARGET_CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments" fi # From 3c65959673e24fc803071d131018eedaacc42ac8 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 28 Mar 2019 14:32:31 -0600 Subject: [PATCH 0972/1167] efidisk: Write to NULL pointer ldp Function grub_efi_find_last_device_path() may return constant NULL when called from find_parent_device(). Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/disk/efi/efidisk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 0f132f559..961c1552b 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -129,6 +129,9 @@ find_parent_device (struct grub_efidisk_data *devices, return 0; ldp = grub_efi_find_last_device_path (dp); + if (! ldp) + return 0; + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); From 4fff586386c54773e518e7f51eab19e6265a056d Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 28 Mar 2019 15:26:36 -0600 Subject: [PATCH 0973/1167] efidisk: NULL pointer dereference in is_child() Function grub_efi_find_last_device() path may return NULL when called from is_child(). Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/disk/efi/efidisk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 961c1552b..78ab2d21a 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -162,6 +162,9 @@ is_child (struct grub_efidisk_data *child, return 0; ldp = grub_efi_find_last_device_path (dp); + if (! ldp) + return 0; + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); From ffe392153895cb1341d38fa291f977e2707f62e6 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Thu, 28 Mar 2019 15:26:37 -0600 Subject: [PATCH 0974/1167] efidisk: NULL pointer dereference in grub_efidisk_get_device_name() Function grub_efi_find_last_device_path() may return NULL when called from grub_efidisk_get_device_name(). Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- grub-core/disk/efi/efidisk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 78ab2d21a..9e20af70e 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -836,6 +836,9 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) { grub_efi_device_path_t *dup_ldp; dup_ldp = grub_efi_find_last_device_path (dup_dp); + if (! dup_ldp) + break; + if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) From e683cfb0cf59fd2dcaa3bb61b3c8ec5e1a09cd37 Mon Sep 17 00:00:00 2001 From: Andrew Jeddeloh Date: Fri, 29 Mar 2019 16:09:54 +0100 Subject: [PATCH 0975/1167] loader/i386/linux: Calculate the setup_header length Previously the setup_header length was just assumed to be the size of the linux_kernel_params struct. The linux x86 32-bit boot protocol says that the end of the linux_i386_kernel_header is at 0x202 + the byte value at 0x201 in the linux_i386_kernel_header. So, calculate the size of the header using the end of the linux_i386_kernel_header, rather than assume it is the size of the linux_kernel_params struct. Additionally, add some required members to the linux_kernel_params struct and align the content of linux_i386_kernel_header struct with it. New members naming was taken directly from Linux kernel source. linux_kernel_params and linux_i386_kernel_header structs require more cleanup. However, this is not urgent, so, let's do this after release. Just in case... Signed-off-by: Andrew Jeddeloh Signed-off-by: Daniel Kiper Reviewed-by: Vladimir Serbinenko Reviewed-by: Ross Philipson --- grub-core/loader/i386/linux.c | 16 +++++++++++++++- include/grub/i386/linux.h | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index b6015913b..d0501e229 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -767,7 +767,21 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), linux_params.kernel_alignment = (1 << align); linux_params.ps_mouse = linux_params.padding10 = 0; - len = sizeof (linux_params) - sizeof (lh); + /* + * The Linux 32-bit boot protocol defines the setup header end + * to be at 0x202 + the byte value at 0x201. + */ + len = 0x202 + *((char *) &linux_params.jump + 1); + + /* Verify the struct is big enough so we do not write past the end. */ + if (len > (char *) &linux_params.edd_mbr_sig_buffer - (char *) &linux_params) { + grub_error (GRUB_ERR_BAD_OS, "Linux setup header too big"); + goto fail; + } + + /* We've already read lh so there is no need to read it second time. */ + len -= sizeof(lh); + if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) { if (!grub_errno) diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index a96059311..ce30e7fb0 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -46,6 +46,9 @@ #define VIDEO_CAPABILITY_SKIP_QUIRKS (1 << 0) #define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit. */ +/* Maximum number of MBR signatures to store. */ +#define EDD_MBR_SIG_MAX 16 + #ifdef __x86_64__ #define GRUB_LINUX_EFI_SIGNATURE \ @@ -142,6 +145,7 @@ struct linux_i386_kernel_header grub_uint64_t setup_data; grub_uint64_t pref_address; grub_uint32_t init_size; + grub_uint32_t handover_offset; } GRUB_PACKED; /* Boot parameters for Linux based on 2.6.12. This is used by the setup @@ -273,6 +277,7 @@ struct linux_kernel_params grub_uint8_t padding9[0x1f1 - 0x1e9]; + /* Linux setup header copy - BEGIN. */ grub_uint8_t setup_sects; /* The size of the setup in sectors */ grub_uint16_t root_flags; /* If the root is mounted readonly */ grub_uint16_t syssize; /* obsolete */ @@ -311,9 +316,14 @@ struct linux_kernel_params grub_uint32_t payload_offset; grub_uint32_t payload_length; grub_uint64_t setup_data; - grub_uint8_t pad2[120]; /* 258 */ - struct grub_e820_mmap e820_map[(0x400 - 0x2d0) / 20]; /* 2d0 */ + grub_uint64_t pref_address; + grub_uint32_t init_size; + grub_uint32_t handover_offset; + /* Linux setup header copy - END. */ + grub_uint8_t _pad7[40]; + grub_uint32_t edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 290 */ + struct grub_e820_mmap e820_map[(0x400 - 0x2d0) / 20]; /* 2d0 */ } GRUB_PACKED; #endif /* ! ASM_FILE */ From fa20550f168dd637ad413d48967fb18622b9a3c1 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 29 Mar 2019 16:11:04 +0100 Subject: [PATCH 0976/1167] docs/grub-dev: Change comments rules Current comments forms are annoying, so, some of them are disallowed starting from now. New rules are more flexible and mostly aligned with, e.g., Linux kernel comments rules. Signed-off-by: Daniel Kiper Reviewed-by: Vladimir Serbinenko --- docs/grub-dev.texi | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 53eb52c42..862a677e0 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -183,38 +183,44 @@ If a macro is global, its name must be prefixed with GRUB_ and must consist of o @section Comments All comments shall be C-style comments, of the form @samp{/* @dots{} */}. - -Comments shall be placed only on a line by themselves. They shall not be placed together with code, variable declarations, or other non-comment entities. A comment should be placed immediately preceding the entity it describes. +A comment can be placed immediately preceding the entity it describes or it +can be placed together with code, variable declarations, or other non-comment +entities. However, it is recommended to not mix various forms especially in +types/structs descriptions. Acceptable: @example -/* The page # that is the front buffer. */ +/* The page # that is the front buffer. */ int displayed_page; -/* The page # that is the back buffer. */ -int render_page; @end example -Unacceptable: @example -int displayed_page; /* The page # that is the front buffer. */ -int render_page; /* The page # that is the back buffer. */ +int render_page; /* The page # that is the back buffer. */ @end example @node Multi-Line Comments @section Multi-Line Comments -Comments spanning multiple lines shall be formatted with all lines after the first aligned with the first line. - -Asterisk characters should not be repeated a the start of each subsequent line. +Comments spanning multiple lines shall be formatted with all lines after the +first aligned with the first line. Asterisk characters should be repeated at +the start of each subsequent line. Acceptable: @example -/* This is a comment - which spans multiple lines. - It is long. */ +/* + * This is a comment + * which spans multiple lines. + * It is long. + */ @end example Unacceptable: +@example +/* This is a comment + which spans multiple lines. + It is long. */ +@end example + @example /* * This is a comment @@ -222,7 +228,16 @@ Unacceptable: * It is long. */ @end example -The opening @samp{/*} and closing @samp{*/} should be placed together on a line with text. +@example +/* This is a comment + * which spans multiple lines. + * It is long. + */ +@end example + +In particular first unacceptable form makes comment difficult to distinguish +from the code itself. Especially if it contains the code snippets and/or is +long. So, its usage is disallowed. @node Finding your way around @chapter Finding your way around From 0f1b648b4531cb5ae94fbeaba3fe37e496fbcad4 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 2 Apr 2019 09:40:31 -0700 Subject: [PATCH 0977/1167] ieee1275: NULL pointer dereference in grub_ieee1275_encode_devname() Function grub_strndup() may return NULL, this is called from function grub_ieee1275_get_devname() which is then called from function grub_ieee1275_encode_devname() to set device. The device variable could then be used with a NULL pointer. Signed-off-by: Eric Snowberg Reviewed-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/openfw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index 62929d983..4d493ab76 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -479,6 +479,9 @@ grub_ieee1275_encode_devname (const char *path) char *optr; const char *iptr; + if (! device) + return 0; + encoding = grub_malloc (sizeof ("ieee1275/") + 2 * grub_strlen (device) + sizeof (",XXXXXXXXXXXX")); if (!encoding) From c6725996a950b5237c1374dfe5d88862420e118c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 26 Mar 2019 14:56:59 +0100 Subject: [PATCH 0978/1167] A workaround for clang problem assembling startup_raw.S Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- grub-core/boot/i386/pc/startup_raw.S | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 8bce7985c..28974821e 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -118,7 +118,16 @@ LOCAL (codestart): #include "../../../kern/i386/realmode.S" +/* + * + * This is a workaround for clang adding a section containing only .addrsig + * Since clang itself is unable to assemble this pseudo-opcode, just replace + * it with .text + * + */ +#define addrsig text #include +#undef addrsig .text From ad4bfeec5ca4cc8479e9353c530a7e77f76d26bd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 Apr 2019 07:24:24 +0200 Subject: [PATCH 0979/1167] Change fs functions to add fs_ prefix This avoid conflict with gnulib Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- grub-core/commands/ls.c | 4 ++-- grub-core/commands/macbless.c | 4 ++-- grub-core/commands/nativedisk.c | 2 +- grub-core/commands/pgp.c | 2 +- grub-core/commands/probe.c | 8 ++++---- grub-core/commands/search.c | 4 ++-- grub-core/commands/test.c | 6 +++--- grub-core/commands/verifiers.c | 4 ++-- grub-core/commands/wildcard.c | 4 ++-- grub-core/fs/affs.c | 12 ++++++------ grub-core/fs/bfs.c | 12 ++++++------ grub-core/fs/btrfs.c | 14 +++++++------- grub-core/fs/cbfs.c | 8 ++++---- grub-core/fs/cpio_common.c | 8 ++++---- grub-core/fs/ext2.c | 14 +++++++------- grub-core/fs/f2fs.c | 12 ++++++------ grub-core/fs/fat.c | 12 ++++++------ grub-core/fs/hfs.c | 14 +++++++------- grub-core/fs/hfsplus.c | 14 +++++++------- grub-core/fs/iso9660.c | 14 +++++++------- grub-core/fs/jfs.c | 12 ++++++------ grub-core/fs/minix.c | 8 ++++---- grub-core/fs/nilfs2.c | 14 +++++++------- grub-core/fs/ntfs.c | 12 ++++++------ grub-core/fs/proc.c | 8 ++++---- grub-core/fs/reiserfs.c | 12 ++++++------ grub-core/fs/romfs.c | 10 +++++----- grub-core/fs/sfs.c | 10 +++++----- grub-core/fs/squash4.c | 10 +++++----- grub-core/fs/tar.c | 8 ++++---- grub-core/fs/udf.c | 12 ++++++------ grub-core/fs/ufs.c | 14 +++++++------- grub-core/fs/xfs.c | 12 ++++++------ grub-core/fs/zfs/zfs.c | 16 ++++++++-------- grub-core/io/bufio.c | 10 +++++----- grub-core/io/gzio.c | 10 +++++----- grub-core/io/lzopio.c | 10 +++++----- grub-core/io/offset.c | 10 +++++----- grub-core/io/xzio.c | 10 +++++----- grub-core/kern/corecmd.c | 2 +- grub-core/kern/emu/hostfs.c | 10 +++++----- grub-core/kern/file.c | 8 ++++---- grub-core/kern/fs.c | 14 +++++++------- grub-core/lib/xzembed/xz.h | 1 + grub-core/loader/i386/bsd.c | 4 ++-- grub-core/loader/xnu.c | 4 ++-- grub-core/net/net.c | 14 +++++++------- grub-core/normal/completion.c | 2 +- grub-core/normal/misc.c | 12 ++++++------ include/grub/fs.h | 16 ++++++++-------- util/grub-fstest.c | 4 ++-- util/grub-install.c | 4 ++-- util/grub-mount.c | 4 ++-- util/grub-probe.c | 8 ++++---- util/setup.c | 6 +++--- 55 files changed, 247 insertions(+), 246 deletions(-) diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index 2cdb2acc5..5b7491aa4 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -221,9 +221,9 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) }; if (longlist) - (fs->dir) (dev, path, print_files_long, &ctx); + (fs->fs_dir) (dev, path, print_files_long, &ctx); else - (fs->dir) (dev, path, print_files, &ctx); + (fs->fs_dir) (dev, path, print_files, &ctx); if (grub_errno == GRUB_ERR_BAD_FILE_TYPE && path[grub_strlen (path) - 1] != '/') diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index 18efa1a84..85cefd0f7 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -159,12 +159,12 @@ grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel) *tail = 0; ctx.dirname = tail + 1; - (fs->dir) (dev, *path == 0 ? "/" : path, find_inode, &ctx); + (fs->fs_dir) (dev, *path == 0 ? "/" : path, find_inode, &ctx); } else { ctx.dirname = path + 1; - (fs->dir) (dev, "/", find_inode, &ctx); + (fs->fs_dir) (dev, "/", find_inode, &ctx); } if (!ctx.found) { diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index 87a9845fe..699447d11 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -109,7 +109,7 @@ get_uuid (const char *name, char **uuid, int getnative) grub_device_close (dev); return grub_errno; } - if (!fs->uuid || fs->uuid (dev, uuid) || !*uuid) + if (!fs->fs_uuid || fs->fs_uuid (dev, uuid) || !*uuid) { grub_device_close (dev); diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c index d39846d8c..bbf6871fe 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -934,7 +934,7 @@ pseudo_read (struct grub_file *file, char *buf, grub_size_t len) struct grub_fs pseudo_fs = { .name = "pseudo", - .read = pseudo_read + .fs_read = pseudo_read }; struct grub_file_verifier grub_pubkey_verifier = diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index cf2793e1d..95d272287 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -113,10 +113,10 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) if (state[4].set) { char *uuid; - if (! fs->uuid) + if (! fs->fs_uuid) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("%s does not support UUIDs"), fs->name); - err = fs->uuid (dev, &uuid); + err = fs->fs_uuid (dev, &uuid); if (err) return err; if (! uuid) @@ -134,11 +134,11 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) if (state[5].set) { char *label; - if (! fs->label) + if (! fs->fs_label) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("filesystem `%s' does not support labels"), fs->name); - err = fs->label (dev, &label); + err = fs->fs_label (dev, &label); if (err) return err; if (! label) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index ddda6e7c5..ed090b3af 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -103,9 +103,9 @@ iterate_device (const char *name, void *data) fs = grub_fs_probe (dev); #ifdef DO_SEARCH_FS_UUID -#define read_fn uuid +#define read_fn fs_uuid #else -#define read_fn label +#define read_fn fs_label #endif if (fs && fs->read_fn) diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index 13c6ed953..4e929e045 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -133,15 +133,15 @@ get_fileinfo (char *path, struct test_parse_ctx *ctx) /* Fetch writing time. */ ctx->file_info.mtimeset = 0; - if (fs->mtime) + if (fs->fs_mtime) { - if (! fs->mtime (dev, &ctx->file_info.mtime)) + if (! fs->fs_mtime (dev, &ctx->file_info.mtime)) ctx->file_info.mtimeset = 1; grub_errno = GRUB_ERR_NONE; } } else - (fs->dir) (dev, path, find_file, ctx); + (fs->fs_dir) (dev, path, find_file, ctx); grub_device_close (dev); grub_free (path); diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c index c638d5f43..0dde48182 100644 --- a/grub-core/commands/verifiers.c +++ b/grub-core/commands/verifiers.c @@ -71,8 +71,8 @@ verified_close (struct grub_file *file) struct grub_fs verified_fs = { .name = "verified_read", - .read = verified_read, - .close = verified_close + .fs_read = verified_read, + .fs_close = verified_close }; static grub_file_t diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index 9b4e72766..4a106ca04 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -370,7 +370,7 @@ match_files (const char *prefix, const char *suffix, const char *end, else path = ctx.dir; - if (fs->dir (dev, path, match_files_iter, &ctx)) + if (fs->fs_dir (dev, path, match_files_iter, &ctx)) goto fail; grub_free (ctx.dir); @@ -452,7 +452,7 @@ check_file (const char *dir, const char *basename) else path = dir; - fs->dir (dev, path[0] ? path : "/", check_file_iter, &ctx); + fs->fs_dir (dev, path[0] ? path : "/", check_file_iter, &ctx); if (grub_errno == 0 && basename[0] == 0) ctx.found = 1; diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index f673897e0..6b6a2bc91 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -685,12 +685,12 @@ grub_affs_mtime (grub_device_t device, grub_int32_t *t) static struct grub_fs grub_affs_fs = { .name = "affs", - .dir = grub_affs_dir, - .open = grub_affs_open, - .read = grub_affs_read, - .close = grub_affs_close, - .label = grub_affs_label, - .mtime = grub_affs_mtime, + .fs_dir = grub_affs_dir, + .fs_open = grub_affs_open, + .fs_read = grub_affs_read, + .fs_close = grub_affs_close, + .fs_label = grub_affs_label, + .fs_mtime = grub_affs_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 0, diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c index d2b490bce..47dbe2011 100644 --- a/grub-core/fs/bfs.c +++ b/grub-core/fs/bfs.c @@ -1082,13 +1082,13 @@ static struct grub_fs grub_bfs_fs = { #else .name = "bfs", #endif - .dir = grub_bfs_dir, - .open = grub_bfs_open, - .read = grub_bfs_read, - .close = grub_bfs_close, - .label = grub_bfs_label, + .fs_dir = grub_bfs_dir, + .fs_open = grub_bfs_open, + .fs_read = grub_bfs_read, + .fs_close = grub_bfs_close, + .fs_label = grub_bfs_label, #ifndef MODE_AFS - .uuid = grub_bfs_uuid, + .fs_uuid = grub_bfs_uuid, #endif #ifdef GRUB_UTIL .reserved_first_sector = 1, diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 3d6d11ec5..48bd3d04a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -2172,14 +2172,14 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), static struct grub_fs grub_btrfs_fs = { .name = "btrfs", - .dir = grub_btrfs_dir, - .open = grub_btrfs_open, - .read = grub_btrfs_read, - .close = grub_btrfs_close, - .uuid = grub_btrfs_uuid, - .label = grub_btrfs_label, + .fs_dir = grub_btrfs_dir, + .fs_open = grub_btrfs_open, + .fs_read = grub_btrfs_read, + .fs_close = grub_btrfs_close, + .fs_uuid = grub_btrfs_uuid, + .fs_label = grub_btrfs_label, #ifdef GRUB_UTIL - .embed = grub_btrfs_embed, + .fs_embed = grub_btrfs_embed, .reserved_first_sector = 1, .blocklist_install = 0, #endif diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index a47e44656..857bea991 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -375,10 +375,10 @@ fini_cbfsdisk (void) static struct grub_fs grub_cbfs_fs = { .name = "cbfs", - .dir = grub_cbfs_dir, - .open = grub_cbfs_open, - .read = grub_cbfs_read, - .close = grub_cbfs_close, + .fs_dir = grub_cbfs_dir, + .fs_open = grub_cbfs_open, + .fs_read = grub_cbfs_read, + .fs_close = grub_cbfs_close, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 0, diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index 50fea47d1..ed134d931 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -233,10 +233,10 @@ grub_cpio_close (grub_file_t file) static struct grub_fs grub_cpio_fs = { .name = FSNAME, - .dir = grub_cpio_dir, - .open = grub_cpio_open, - .read = grub_cpio_read, - .close = grub_cpio_close, + .fs_dir = grub_cpio_dir, + .fs_open = grub_cpio_open, + .fs_read = grub_cpio_read, + .fs_close = grub_cpio_close, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 0, diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index b8ad75a0f..9b389802a 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -1072,13 +1072,13 @@ grub_ext2_mtime (grub_device_t device, grub_int32_t *tm) static struct grub_fs grub_ext2_fs = { .name = "ext2", - .dir = grub_ext2_dir, - .open = grub_ext2_open, - .read = grub_ext2_read, - .close = grub_ext2_close, - .label = grub_ext2_label, - .uuid = grub_ext2_uuid, - .mtime = grub_ext2_mtime, + .fs_dir = grub_ext2_dir, + .fs_open = grub_ext2_open, + .fs_read = grub_ext2_read, + .fs_close = grub_ext2_close, + .fs_label = grub_ext2_label, + .fs_uuid = grub_ext2_uuid, + .fs_mtime = grub_ext2_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c index 1cad2615f..644653dbe 100644 --- a/grub-core/fs/f2fs.c +++ b/grub-core/fs/f2fs.c @@ -1289,12 +1289,12 @@ grub_f2fs_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_f2fs_fs = { .name = "f2fs", - .dir = grub_f2fs_dir, - .open = grub_f2fs_open, - .read = grub_f2fs_read, - .close = grub_f2fs_close, - .label = grub_f2fs_label, - .uuid = grub_f2fs_uuid, + .fs_dir = grub_f2fs_dir, + .fs_open = grub_f2fs_open, + .fs_read = grub_f2fs_read, + .fs_close = grub_f2fs_close, + .fs_label = grub_f2fs_label, + .fs_uuid = grub_f2fs_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 0, diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 8d8dc35ce..d544e0af1 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -1229,12 +1229,12 @@ static struct grub_fs grub_fat_fs = #else .name = "fat", #endif - .dir = grub_fat_dir, - .open = grub_fat_open, - .read = grub_fat_read, - .close = grub_fat_close, - .label = grub_fat_label, - .uuid = grub_fat_uuid, + .fs_dir = grub_fat_dir, + .fs_open = grub_fat_open, + .fs_read = grub_fat_read, + .fs_close = grub_fat_close, + .fs_label = grub_fat_label, + .fs_uuid = grub_fat_uuid, #ifdef GRUB_UTIL #ifdef MODE_EXFAT /* ExFAT BPB is 30 larger than FAT32 one. */ diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index fc3683178..ac0a40990 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1417,13 +1417,13 @@ grub_hfs_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_hfs_fs = { .name = "hfs", - .dir = grub_hfs_dir, - .open = grub_hfs_open, - .read = grub_hfs_read, - .close = grub_hfs_close, - .label = grub_hfs_label, - .uuid = grub_hfs_uuid, - .mtime = grub_hfs_mtime, + .fs_dir = grub_hfs_dir, + .fs_open = grub_hfs_open, + .fs_read = grub_hfs_read, + .fs_close = grub_hfs_close, + .fs_label = grub_hfs_label, + .fs_uuid = grub_hfs_uuid, + .fs_mtime = grub_hfs_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 21159e858..73ae95fbc 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -1078,13 +1078,13 @@ grub_hfsplus_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_hfsplus_fs = { .name = "hfsplus", - .dir = grub_hfsplus_dir, - .open = grub_hfsplus_open, - .read = grub_hfsplus_read, - .close = grub_hfsplus_close, - .label = grub_hfsplus_label, - .mtime = grub_hfsplus_mtime, - .uuid = grub_hfsplus_uuid, + .fs_dir = grub_hfsplus_dir, + .fs_open = grub_hfsplus_open, + .fs_read = grub_hfsplus_read, + .fs_close = grub_hfsplus_close, + .fs_label = grub_hfsplus_label, + .fs_mtime = grub_hfsplus_mtime, + .fs_uuid = grub_hfsplus_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index c9c8374bf..49c0c632b 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -1099,13 +1099,13 @@ grub_iso9660_mtime (grub_device_t device, grub_int32_t *timebuf) static struct grub_fs grub_iso9660_fs = { .name = "iso9660", - .dir = grub_iso9660_dir, - .open = grub_iso9660_open, - .read = grub_iso9660_read, - .close = grub_iso9660_close, - .label = grub_iso9660_label, - .uuid = grub_iso9660_uuid, - .mtime = grub_iso9660_mtime, + .fs_dir = grub_iso9660_dir, + .fs_open = grub_iso9660_open, + .fs_read = grub_iso9660_read, + .fs_close = grub_iso9660_close, + .fs_label = grub_iso9660_label, + .fs_uuid = grub_iso9660_uuid, + .fs_mtime = grub_iso9660_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index aab3e8c7b..09bc5608d 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -930,12 +930,12 @@ grub_jfs_label (grub_device_t device, char **label) static struct grub_fs grub_jfs_fs = { .name = "jfs", - .dir = grub_jfs_dir, - .open = grub_jfs_open, - .read = grub_jfs_read, - .close = grub_jfs_close, - .label = grub_jfs_label, - .uuid = grub_jfs_uuid, + .fs_dir = grub_jfs_dir, + .fs_open = grub_jfs_open, + .fs_read = grub_jfs_read, + .fs_close = grub_jfs_close, + .fs_label = grub_jfs_label, + .fs_uuid = grub_jfs_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index d451b3426..d0d08363c 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -687,10 +687,10 @@ static struct grub_fs grub_minix_fs = .name = "minix", #endif #endif - .dir = grub_minix_dir, - .open = grub_minix_open, - .read = grub_minix_read, - .close = grub_minix_close, + .fs_dir = grub_minix_dir, + .fs_open = grub_minix_open, + .fs_read = grub_minix_read, + .fs_close = grub_minix_close, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c index 598a2a55b..7ed148d3b 100644 --- a/grub-core/fs/nilfs2.c +++ b/grub-core/fs/nilfs2.c @@ -1192,13 +1192,13 @@ grub_nilfs2_mtime (grub_device_t device, grub_int32_t * tm) static struct grub_fs grub_nilfs2_fs = { .name = "nilfs2", - .dir = grub_nilfs2_dir, - .open = grub_nilfs2_open, - .read = grub_nilfs2_read, - .close = grub_nilfs2_close, - .label = grub_nilfs2_label, - .uuid = grub_nilfs2_uuid, - .mtime = grub_nilfs2_mtime, + .fs_dir = grub_nilfs2_dir, + .fs_open = grub_nilfs2_open, + .fs_read = grub_nilfs2_read, + .fs_close = grub_nilfs2_close, + .fs_label = grub_nilfs2_label, + .fs_uuid = grub_nilfs2_uuid, + .fs_mtime = grub_nilfs2_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 0, diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 6f8468862..fc4e1f678 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -1212,12 +1212,12 @@ grub_ntfs_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_ntfs_fs = { .name = "ntfs", - .dir = grub_ntfs_dir, - .open = grub_ntfs_open, - .read = grub_ntfs_read, - .close = grub_ntfs_close, - .label = grub_ntfs_label, - .uuid = grub_ntfs_uuid, + .fs_dir = grub_ntfs_dir, + .fs_open = grub_ntfs_open, + .fs_read = grub_ntfs_read, + .fs_close = grub_ntfs_close, + .fs_label = grub_ntfs_label, + .fs_uuid = grub_ntfs_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c index 5911c2eb5..5f516502d 100644 --- a/grub-core/fs/proc.c +++ b/grub-core/fs/proc.c @@ -183,10 +183,10 @@ static struct grub_disk_dev grub_procfs_dev = { static struct grub_fs grub_procfs_fs = { .name = "procfs", - .dir = grub_procfs_dir, - .open = grub_procfs_open, - .read = grub_procfs_read, - .close = grub_procfs_close, + .fs_dir = grub_procfs_dir, + .fs_open = grub_procfs_open, + .fs_read = grub_procfs_read, + .fs_close = grub_procfs_close, .next = 0 }; diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index 39736f63c..af6a226a7 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -1402,12 +1402,12 @@ grub_reiserfs_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_reiserfs_fs = { .name = "reiserfs", - .dir = grub_reiserfs_dir, - .open = grub_reiserfs_open, - .read = grub_reiserfs_read, - .close = grub_reiserfs_close, - .label = grub_reiserfs_label, - .uuid = grub_reiserfs_uuid, + .fs_dir = grub_reiserfs_dir, + .fs_open = grub_reiserfs_open, + .fs_read = grub_reiserfs_read, + .fs_close = grub_reiserfs_close, + .fs_label = grub_reiserfs_label, + .fs_uuid = grub_reiserfs_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/romfs.c b/grub-core/fs/romfs.c index 2e3544408..d97b8fbb8 100644 --- a/grub-core/fs/romfs.c +++ b/grub-core/fs/romfs.c @@ -461,11 +461,11 @@ grub_romfs_label (grub_device_t device, char **label) static struct grub_fs grub_romfs_fs = { .name = "romfs", - .dir = grub_romfs_dir, - .open = grub_romfs_open, - .read = grub_romfs_read, - .close = grub_romfs_close, - .label = grub_romfs_label, + .fs_dir = grub_romfs_dir, + .fs_open = grub_romfs_open, + .fs_read = grub_romfs_read, + .fs_close = grub_romfs_close, + .fs_label = grub_romfs_label, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 0, diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c index 57b8d8da6..50c1fe72f 100644 --- a/grub-core/fs/sfs.c +++ b/grub-core/fs/sfs.c @@ -741,11 +741,11 @@ grub_sfs_label (grub_device_t device, char **label) static struct grub_fs grub_sfs_fs = { .name = "sfs", - .dir = grub_sfs_dir, - .open = grub_sfs_open, - .read = grub_sfs_read, - .close = grub_sfs_close, - .label = grub_sfs_label, + .fs_dir = grub_sfs_dir, + .fs_open = grub_sfs_open, + .fs_read = grub_sfs_read, + .fs_close = grub_sfs_close, + .fs_label = grub_sfs_label, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 1, diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c index 2c967c65a..95d5c1e1f 100644 --- a/grub-core/fs/squash4.c +++ b/grub-core/fs/squash4.c @@ -995,11 +995,11 @@ grub_squash_mtime (grub_device_t dev, grub_int32_t *tm) static struct grub_fs grub_squash_fs = { .name = "squash4", - .dir = grub_squash_dir, - .open = grub_squash_open, - .read = grub_squash_read, - .close = grub_squash_close, - .mtime = grub_squash_mtime, + .fs_dir = grub_squash_dir, + .fs_open = grub_squash_open, + .fs_read = grub_squash_read, + .fs_close = grub_squash_close, + .fs_mtime = grub_squash_mtime, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 0, diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c index 39bf197aa..7d63e0c99 100644 --- a/grub-core/fs/tar.c +++ b/grub-core/fs/tar.c @@ -324,10 +324,10 @@ grub_cpio_close (grub_file_t file) static struct grub_fs grub_cpio_fs = { .name = "tarfs", - .dir = grub_cpio_dir, - .open = grub_cpio_open, - .read = grub_cpio_read, - .close = grub_cpio_close, + .fs_dir = grub_cpio_dir, + .fs_open = grub_cpio_open, + .fs_read = grub_cpio_read, + .fs_close = grub_cpio_close, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 0, diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 00a16098b..dc8b6e2d1 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -1345,12 +1345,12 @@ grub_udf_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_udf_fs = { .name = "udf", - .dir = grub_udf_dir, - .open = grub_udf_open, - .read = grub_udf_read, - .close = grub_udf_close, - .label = grub_udf_label, - .uuid = grub_udf_uuid, + .fs_dir = grub_udf_dir, + .fs_open = grub_udf_open, + .fs_read = grub_udf_read, + .fs_close = grub_udf_close, + .fs_label = grub_udf_label, + .fs_uuid = grub_udf_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 1, .blocklist_install = 1, diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 293f027aa..fca46baa1 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -875,13 +875,13 @@ static struct grub_fs grub_ufs_fs = .name = "ufs1", #endif #endif - .dir = grub_ufs_dir, - .open = grub_ufs_open, - .read = grub_ufs_read, - .close = grub_ufs_close, - .label = grub_ufs_label, - .uuid = grub_ufs_uuid, - .mtime = grub_ufs_mtime, + .fs_dir = grub_ufs_dir, + .fs_open = grub_ufs_open, + .fs_read = grub_ufs_read, + .fs_close = grub_ufs_close, + .fs_label = grub_ufs_label, + .fs_uuid = grub_ufs_uuid, + .fs_mtime = grub_ufs_mtime, /* FIXME: set reserved_first_sector. */ #ifdef GRUB_UTIL .blocklist_install = 1, diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 3b00c744e..96ffecbfc 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -1137,12 +1137,12 @@ grub_xfs_uuid (grub_device_t device, char **uuid) static struct grub_fs grub_xfs_fs = { .name = "xfs", - .dir = grub_xfs_dir, - .open = grub_xfs_open, - .read = grub_xfs_read, - .close = grub_xfs_close, - .label = grub_xfs_label, - .uuid = grub_xfs_uuid, + .fs_dir = grub_xfs_dir, + .fs_open = grub_xfs_open, + .fs_read = grub_xfs_read, + .fs_close = grub_xfs_close, + .fs_label = grub_xfs_label, + .fs_uuid = grub_xfs_uuid, #ifdef GRUB_UTIL .reserved_first_sector = 0, .blocklist_install = 1, diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 6e1fff9e9..2f72e42bf 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -4348,15 +4348,15 @@ grub_zfs_embed (grub_device_t device __attribute__ ((unused)), static struct grub_fs grub_zfs_fs = { .name = "zfs", - .dir = grub_zfs_dir, - .open = grub_zfs_open, - .read = grub_zfs_read, - .close = grub_zfs_close, - .label = zfs_label, - .uuid = zfs_uuid, - .mtime = zfs_mtime, + .fs_dir = grub_zfs_dir, + .fs_open = grub_zfs_open, + .fs_read = grub_zfs_read, + .fs_close = grub_zfs_close, + .fs_label = zfs_label, + .fs_uuid = zfs_uuid, + .fs_mtime = zfs_mtime, #ifdef GRUB_UTIL - .embed = grub_zfs_embed, + .fs_embed = grub_zfs_embed, .reserved_first_sector = 1, .blocklist_install = 0, #endif diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index 21c14c31a..a458c3aca 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -205,10 +205,10 @@ grub_bufio_close (grub_file_t file) static struct grub_fs grub_bufio_fs = { .name = "bufio", - .dir = 0, - .open = 0, - .read = grub_bufio_read, - .close = grub_bufio_close, - .label = 0, + .fs_dir = 0, + .fs_open = 0, + .fs_read = grub_bufio_read, + .fs_close = grub_bufio_close, + .fs_label = 0, .next = 0 }; diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 7760d8b97..6208a9763 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1389,11 +1389,11 @@ grub_deflate_decompress (char *inbuf, grub_size_t insize, grub_off_t off, static struct grub_fs grub_gzio_fs = { .name = "gzio", - .dir = 0, - .open = 0, - .read = grub_gzio_read, - .close = grub_gzio_close, - .label = 0, + .fs_dir = 0, + .fs_open = 0, + .fs_read = grub_gzio_read, + .fs_close = grub_gzio_close, + .fs_label = 0, .next = 0 }; diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c index 84edf6dd2..30144857d 100644 --- a/grub-core/io/lzopio.c +++ b/grub-core/io/lzopio.c @@ -531,11 +531,11 @@ grub_lzopio_close (grub_file_t file) static struct grub_fs grub_lzopio_fs = { .name = "lzopio", - .dir = 0, - .open = 0, - .read = grub_lzopio_read, - .close = grub_lzopio_close, - .label = 0, + .fs_dir = 0, + .fs_open = 0, + .fs_read = grub_lzopio_read, + .fs_close = grub_lzopio_close, + .fs_label = 0, .next = 0 }; diff --git a/grub-core/io/offset.c b/grub-core/io/offset.c index ec8e23208..7e2db4a3a 100644 --- a/grub-core/io/offset.c +++ b/grub-core/io/offset.c @@ -52,11 +52,11 @@ grub_offset_close (grub_file_t file) static struct grub_fs grub_offset_fs = { .name = "offset", - .dir = 0, - .open = 0, - .read = grub_offset_read, - .close = grub_offset_close, - .label = 0, + .fs_dir = 0, + .fs_open = 0, + .fs_read = grub_offset_read, + .fs_close = grub_offset_close, + .fs_label = 0, .next = 0 }; diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index 42afeedcd..516c4dfca 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -327,11 +327,11 @@ grub_xzio_close (grub_file_t file) static struct grub_fs grub_xzio_fs = { .name = "xzio", - .dir = 0, - .open = 0, - .read = grub_xzio_read, - .close = grub_xzio_close, - .label = 0, + .fs_dir = 0, + .fs_open = 0, + .fs_read = grub_xzio_read, + .fs_close = grub_xzio_close, + .fs_label = 0, .next = 0 }; diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c index d9412a316..fc54f43f2 100644 --- a/grub-core/kern/corecmd.c +++ b/grub-core/kern/corecmd.c @@ -155,7 +155,7 @@ grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)), } else if (fs) { - (fs->dir) (dev, path, grub_mini_print_files, NULL); + (fs->fs_dir) (dev, path, grub_mini_print_files, NULL); grub_xputs ("\n"); grub_refresh (); } diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c index 7b28c001f..cee70413d 100644 --- a/grub-core/kern/emu/hostfs.c +++ b/grub-core/kern/emu/hostfs.c @@ -176,11 +176,11 @@ grub_hostfs_label (grub_device_t device __attribute ((unused)), static struct grub_fs grub_hostfs_fs = { .name = "hostfs", - .dir = grub_hostfs_dir, - .open = grub_hostfs_open, - .read = grub_hostfs_read, - .close = grub_hostfs_close, - .label = grub_hostfs_label, + .fs_dir = grub_hostfs_dir, + .fs_open = grub_hostfs_open, + .fs_read = grub_hostfs_read, + .fs_close = grub_hostfs_close, + .fs_label = grub_hostfs_label, .next = 0 }; diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 643154237..58454458c 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -107,7 +107,7 @@ grub_file_open (const char *name, enum grub_file_type type) goto fail; } - if ((file->fs->open) (file, file_name) != GRUB_ERR_NONE) + if ((file->fs->fs_open) (file, file_name) != GRUB_ERR_NONE) goto fail; file->name = grub_strdup (name); @@ -177,7 +177,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) file->read_hook_data = file; file->progress_offset = file->offset; } - res = (file->fs->read) (file, buf, len); + res = (file->fs->fs_read) (file, buf, len); file->read_hook = read_hook; file->read_hook_data = read_hook_data; if (res > 0) @@ -189,8 +189,8 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) grub_err_t grub_file_close (grub_file_t file) { - if (file->fs->close) - (file->fs->close) (file); + if (file->fs->fs_close) + (file->fs->fs_close) (file); if (file->device) grub_device_close (file->device); diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c index 9085895b6..2b85f4950 100644 --- a/grub-core/kern/fs.c +++ b/grub-core/kern/fs.c @@ -64,13 +64,13 @@ grub_fs_probe (grub_device_t device) if (grub_strcmp (p->name, "btrfs") == 0) { char *label = 0; - p->uuid (device, &label); + p->fs_uuid (device, &label); if (label) grub_free (label); } else #endif - (p->dir) (device, "/", probe_dummy_iter, NULL); + (p->fs_dir) (device, "/", probe_dummy_iter, NULL); if (grub_errno == GRUB_ERR_NONE) return p; @@ -94,7 +94,7 @@ grub_fs_probe (grub_device_t device) { p = grub_fs_list; - (p->dir) (device, "/", probe_dummy_iter, NULL); + (p->fs_dir) (device, "/", probe_dummy_iter, NULL); if (grub_errno == GRUB_ERR_NONE) { count--; @@ -243,9 +243,9 @@ grub_fs_blocklist_read (grub_file_t file, char *buf, grub_size_t len) struct grub_fs grub_fs_blocklist = { .name = "blocklist", - .dir = 0, - .open = grub_fs_blocklist_open, - .read = grub_fs_blocklist_read, - .close = 0, + .fs_dir = 0, + .fs_open = grub_fs_blocklist_open, + .fs_read = grub_fs_blocklist_read, + .fs_close = 0, .next = 0 }; diff --git a/grub-core/lib/xzembed/xz.h b/grub-core/lib/xzembed/xz.h index fe7158bb2..f7b32d800 100644 --- a/grub-core/lib/xzembed/xz.h +++ b/grub-core/lib/xzembed/xz.h @@ -24,6 +24,7 @@ #ifndef XZ_H #define XZ_H +#include #include #include #include diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index c26edb4a9..3730ed382 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -580,9 +580,9 @@ freebsd_get_zfs (void) fs = grub_fs_probe (dev); if (!fs) return; - if (!fs->uuid || grub_strcmp (fs->name, "zfs") != 0) + if (!fs->fs_uuid || grub_strcmp (fs->name, "zfs") != 0) return; - err = fs->uuid (dev, &uuid); + err = fs->fs_uuid (dev, &uuid); if (err) return; if (!uuid) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index ff66be4bf..7f74d1d6f 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1102,7 +1102,7 @@ grub_xnu_scan_dir_for_kexts (char *dirname, const char *osbundlerequired, path++; if (fs) - (fs->dir) (dev, path, grub_xnu_scan_dir_for_kexts_load, &ctx); + (fs->fs_dir) (dev, path, grub_xnu_scan_dir_for_kexts_load, &ctx); grub_device_close (dev); } grub_free (device_name); @@ -1201,7 +1201,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired, /* Look at the directory. */ if (fs) - (fs->dir) (dev, path, grub_xnu_load_kext_from_dir_load, &ctx); + (fs->fs_dir) (dev, path, grub_xnu_load_kext_from_dir_load, &ctx); if (ctx.plistname && grub_xnu_check_os_bundle_required (ctx.plistname, osbundlerequired, &binsuffix)) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 10773fc34..d5d726a31 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1706,13 +1706,13 @@ grub_net_fs_read (grub_file_t file, char *buf, grub_size_t len) static struct grub_fs grub_net_fs = { .name = "netfs", - .dir = grub_net_fs_dir, - .open = grub_net_fs_open, - .read = grub_net_fs_read, - .close = grub_net_fs_close, - .label = NULL, - .uuid = NULL, - .mtime = NULL, + .fs_dir = grub_net_fs_dir, + .fs_open = grub_net_fs_open, + .fs_read = grub_net_fs_read, + .fs_close = grub_net_fs_close, + .fs_label = NULL, + .fs_uuid = NULL, + .fs_mtime = NULL, }; static grub_err_t diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c index 2c9b9e931..596102848 100644 --- a/grub-core/normal/completion.c +++ b/grub-core/normal/completion.c @@ -287,7 +287,7 @@ complete_file (void) dirfile[1] = '\0'; /* Iterate the directory. */ - (fs->dir) (dev, dir, iterate_dir, NULL); + (fs->fs_dir) (dev, dir, iterate_dir, NULL); grub_free (dir); diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c index 38f91b9b9..435cd9234 100644 --- a/grub-core/normal/misc.c +++ b/grub-core/normal/misc.c @@ -119,10 +119,10 @@ grub_normal_print_device_info (const char *name) if (grub_strcmp (fsname, "ext2") == 0) fsname = "ext*"; grub_printf_ (N_("Filesystem type %s"), fsname); - if (fs->label) + if (fs->fs_label) { char *label; - (fs->label) (dev, &label); + (fs->fs_label) (dev, &label); if (grub_errno == GRUB_ERR_NONE) { if (label && grub_strlen (label)) @@ -134,11 +134,11 @@ grub_normal_print_device_info (const char *name) } grub_errno = GRUB_ERR_NONE; } - if (fs->mtime) + if (fs->fs_mtime) { grub_int32_t tm; struct grub_datetime datetime; - (fs->mtime) (dev, &tm); + (fs->fs_mtime) (dev, &tm); if (grub_errno == GRUB_ERR_NONE) { grub_unixtime2datetime (tm, &datetime); @@ -154,10 +154,10 @@ grub_normal_print_device_info (const char *name) } grub_errno = GRUB_ERR_NONE; } - if (fs->uuid) + if (fs->fs_uuid) { char *uuid; - (fs->uuid) (dev, &uuid); + (fs->fs_uuid) (dev, &uuid); if (grub_errno == GRUB_ERR_NONE) { if (uuid && grub_strlen (uuid)) diff --git a/include/grub/fs.h b/include/grub/fs.h index 5678c60c2..302e48d4b 100644 --- a/include/grub/fs.h +++ b/include/grub/fs.h @@ -58,34 +58,34 @@ struct grub_fs const char *name; /* Call HOOK with each file under DIR. */ - grub_err_t (*dir) (grub_device_t device, const char *path, + grub_err_t (*fs_dir) (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, void *hook_data); /* Open a file named NAME and initialize FILE. */ - grub_err_t (*open) (struct grub_file *file, const char *name); + grub_err_t (*fs_open) (struct grub_file *file, const char *name); /* Read LEN bytes data from FILE into BUF. */ - grub_ssize_t (*read) (struct grub_file *file, char *buf, grub_size_t len); + grub_ssize_t (*fs_read) (struct grub_file *file, char *buf, grub_size_t len); /* Close the file FILE. */ - grub_err_t (*close) (struct grub_file *file); + grub_err_t (*fs_close) (struct grub_file *file); /* Return the label of the device DEVICE in LABEL. The label is returned in a grub_malloc'ed buffer and should be freed by the caller. */ - grub_err_t (*label) (grub_device_t device, char **label); + grub_err_t (*fs_label) (grub_device_t device, char **label); /* Return the uuid of the device DEVICE in UUID. The uuid is returned in a grub_malloc'ed buffer and should be freed by the caller. */ - grub_err_t (*uuid) (grub_device_t device, char **uuid); + grub_err_t (*fs_uuid) (grub_device_t device, char **uuid); /* Get writing time of filesystem. */ - grub_err_t (*mtime) (grub_device_t device, grub_int32_t *timebuf); + grub_err_t (*fs_mtime) (grub_device_t device, grub_int32_t *timebuf); #ifdef GRUB_UTIL /* Determine sectors available for embedding. */ - grub_err_t (*embed) (grub_device_t device, unsigned int *nsectors, + grub_err_t (*fs_embed) (grub_device_t device, unsigned int *nsectors, unsigned int max_nsectors, grub_embed_type_t embed_type, grub_disk_addr_t **sectors); diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 7074e8e41..f14e02d97 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -470,9 +470,9 @@ fstest (int n) fs = grub_fs_probe (dev); if (!fs) grub_util_error ("%s", grub_errmsg); - if (!fs->uuid) + if (!fs->fs_uuid) grub_util_error ("%s", _("couldn't retrieve UUID")); - if (fs->uuid (dev, &uuid)) + if (fs->fs_uuid (dev, &uuid)) grub_util_error ("%s", grub_errmsg); if (!uuid) grub_util_error ("%s", _("couldn't retrieve UUID")); diff --git a/util/grub-install.c b/util/grub-install.c index 2046c48c4..8a55ad4b8 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1378,8 +1378,8 @@ main (int argc, char *argv[]) { char *uuid = NULL; /* generic method (used on coreboot and ata mod). */ - if (!force_file_id && grub_fs->uuid && grub_fs->uuid (grub_dev, - &uuid)) + if (!force_file_id + && grub_fs->fs_uuid && grub_fs->fs_uuid (grub_dev, &uuid)) { grub_print_error (); grub_errno = 0; diff --git a/util/grub-mount.c b/util/grub-mount.c index e32b502e7..d7be2a427 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -190,7 +190,7 @@ fuse_getattr (const char *path, struct stat *st) } /* It's the whole device. */ - (fs->dir) (dev, path2, fuse_getattr_find_file, &ctx); + (fs->fs_dir) (dev, path2, fuse_getattr_find_file, &ctx); grub_free (path2); if (!ctx.file_exists) @@ -352,7 +352,7 @@ fuse_readdir (const char *path, void *buf, && pathname[grub_strlen (pathname) - 1] == '/') pathname[grub_strlen (pathname) - 1] = 0; - (fs->dir) (dev, pathname, fuse_readdir_call_fill, &ctx); + (fs->fs_dir) (dev, pathname, fuse_readdir_call_fill, &ctx); free (pathname); grub_errno = GRUB_ERR_NONE; return 0; diff --git a/util/grub-probe.c b/util/grub-probe.c index 2e44ec8f4..81d27eead 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -446,10 +446,10 @@ probe (const char *path, char **device_names, char delim) else if (print == PRINT_FS_UUID) { char *uuid; - if (! fs->uuid) + if (! fs->fs_uuid) grub_util_error (_("%s does not support UUIDs"), fs->name); - if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE) + if (fs->fs_uuid (dev, &uuid) != GRUB_ERR_NONE) grub_util_error ("%s", grub_errmsg); printf ("%s", uuid); @@ -458,11 +458,11 @@ probe (const char *path, char **device_names, char delim) else if (print == PRINT_FS_LABEL) { char *label; - if (! fs->label) + if (! fs->fs_label) grub_util_error (_("filesystem `%s' does not support labels"), fs->name); - if (fs->label (dev, &label) != GRUB_ERR_NONE) + if (fs->fs_label (dev, &label) != GRUB_ERR_NONE) grub_util_error ("%s", grub_errmsg); printf ("%s", label); diff --git a/util/setup.c b/util/setup.c index 92a5af9ba..6f88f3cc4 100644 --- a/util/setup.c +++ b/util/setup.c @@ -491,7 +491,7 @@ SETUP (const char *dir, goto unable_to_embed; } - if (fs && !fs->embed) + if (fs && !fs->fs_embed) { grub_util_warn (_("File system `%s' doesn't support embedding"), fs->name); @@ -529,8 +529,8 @@ SETUP (const char *dir, err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec, GRUB_EMBED_PCBIOS, §ors); else - err = fs->embed (dest_dev, &nsec, maxsec, - GRUB_EMBED_PCBIOS, §ors); + err = fs->fs_embed (dest_dev, &nsec, maxsec, + GRUB_EMBED_PCBIOS, §ors); if (!err && nsec < core_sectors) { err = grub_error (GRUB_ERR_OUT_OF_RANGE, From 94d9926a664014007130796616210b68e421d54a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 8 Apr 2019 07:30:56 +0200 Subject: [PATCH 0980/1167] Release 2.04~rc1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8578d01b7..08b518fcc 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.03],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.04~rc1],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From acc726f812a907ee70f9ee6f8d29c1d9c57c73e1 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 12 Apr 2019 12:50:04 +0200 Subject: [PATCH 0981/1167] x86/msr: Fix build with older GCC versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some older GCC versions produce following error when x86 MSR modules are build: In file included from commands/i386/rdmsr.c:29:0: ../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes] extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id) ^ cc1: all warnings being treated as errors This happens due to lack of support for a such usage of extern keyword in older GCCs. Additionally, this usage is not consistent with the rest of codebase. So, replace it with static keyword. Additionally, fix incorrect coding style. Reported-by: Eric Snowberg Reported-by: adrian15 Signed-off-by: Daniel Kiper Reviewed-by: Vladimir 'phcoder' Serbinenko Reviewed-by: Eric Snowberg Tested-by: adrian15 --- include/grub/i386/rdmsr.h | 3 ++- include/grub/i386/wrmsr.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/grub/i386/rdmsr.h b/include/grub/i386/rdmsr.h index bddb7bbbb..c0a0c717a 100644 --- a/include/grub/i386/rdmsr.h +++ b/include/grub/i386/rdmsr.h @@ -24,7 +24,8 @@ * Accessing a reserved or unimplemented MSR address results in a GP#. */ -extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id) +static inline grub_uint64_t +grub_msr_read (grub_uint32_t msr_id) { grub_uint32_t low, high; diff --git a/include/grub/i386/wrmsr.h b/include/grub/i386/wrmsr.h index e14d7807f..dea60aed1 100644 --- a/include/grub/i386/wrmsr.h +++ b/include/grub/i386/wrmsr.h @@ -24,7 +24,8 @@ * Accessing a reserved or unimplemented MSR address results in a GP#. */ -extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value) +static inline void +grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value) { grub_uint32_t low = msr_value, high = msr_value >> 32; From bc58fded5074d139ab61aa510fdcbbcefa304c77 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 17 Apr 2019 07:12:56 +0200 Subject: [PATCH 0982/1167] efi: Avoid NULL dereference if FilePath is NULL The UEFI specification allows LoadImage() to be called with a memory location only and without a device path. In this case FilePath will not be set in the EFI_LOADED_IMAGE_PROTOCOL. So in function grub_efi_get_filename() the device path argument may be NULL. As we cannot determine the device path in this case just return NULL from the function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/kern/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 708581fcb..84e68cf31 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -327,6 +327,9 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) grub_size_t filesize = 0; grub_efi_device_path_t *dp; + if (!dp0) + return NULL; + dp = dp0; while (1) From 7ea474c68847757d4c67ffc67f7d714b77c41578 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:02 +0800 Subject: [PATCH 0983/1167] cpio: Disable gcc9 -Waddress-of-packed-member Disable the -Wadress-of-packaed-member diagnostic for the grub_cpio_find_file function since the result is found to be false postive. Any pointers to member of the 'struct head hd' is aligned even if the structure is packed without paddings. [ 59s] In file included from ../grub-core/fs/cpio.c:51: [ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file': [ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE (hd.filesize)); [ 59s] | ~~^~~~~~~~~ [ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime)); [ 59s] | ~~^~~~~~ [ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode)); [ 59s] | ~~^~~~~ [ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize)); [ 59s] | ~~^~~~~~~~~ [ 59s] In file included from ../grub-core/fs/cpio_be.c:51: [ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file': [ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE (hd.filesize)); [ 59s] | ~~^~~~~~~~~ [ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime)); [ 59s] | ~~^~~~~~ [ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode)); [ 59s] | ~~^~~~~ [ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize)); [ 59s] | ~~^~~~~~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/fs/cpio_common.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index ed134d931..4e885d623 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -36,6 +36,11 @@ struct grub_archelp_data grub_off_t size; }; +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif + static grub_err_t grub_cpio_find_file (struct grub_archelp_data *data, char **name, grub_int32_t *mtime, grub_uint32_t *mode) @@ -96,6 +101,10 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, return GRUB_ERR_NONE; } +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif + static char * grub_cpio_get_link_target (struct grub_archelp_data *data) { From 4f4128defdec0958f7a38736e2c9be2368a5a6da Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:03 +0800 Subject: [PATCH 0984/1167] jfs: Disable gcc9 -Waddress-of-packed-member Disable the -Wadress-of-packaed-member diagnostic for the grub_jfs_getent function since the result is found to be false postive. The leaf is read into memory as continous chunks in size of 32 bytes and the pointer to its base is aligned, which also guarentee its member leaf->namepart is aligned. [ 60s] ../grub-core/fs/jfs.c: In function 'grub_jfs_getent': [ 60s] ../grub-core/fs/jfs.c:557:44: error: taking address of packed member of 'struct grub_jfs_leaf_dirent' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 60s] 557 | le_to_cpu16_copy (filename + strpos, leaf->namepart, len < diro->data->namecomponentlen ? len [ 60s] | ~~~~^~~~~~~~~~ [ 60s] ../grub-core/fs/jfs.c:570:48: error: taking address of packed member of 'struct grub_jfs_leaf_next_dirent' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 60s] 570 | le_to_cpu16_copy (filename + strpos, next_leaf->namepart, len < 15 ? len : 15); [ 60s] | ~~~~~~~~~^~~~~~~~~~ [ 60s] cc1: all warnings being treated as errors Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/fs/jfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index 09bc5608d..d5a6d6527 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -505,6 +505,10 @@ le_to_cpu16_copy (grub_uint16_t *out, grub_uint16_t *in, grub_size_t len) *out++ = grub_le_to_cpu16 (*in++); } +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif /* Read in the next dirent from the directory described by DIRO. */ static grub_err_t @@ -582,6 +586,9 @@ grub_jfs_getent (struct grub_jfs_diropen *diro) return 0; } +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif /* Read LEN bytes from the file described by DATA starting with byte POS. Return the amount of read bytes in READ. */ From 0e49748fad8e036d9875785e57c577214e699941 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:04 +0800 Subject: [PATCH 0985/1167] hfs: Fix gcc9 error -Waddress-of-packed-member Simply adds the missing packed attribute to 'struct grub_hfs_extent'. [ 83s] ../grub-core/fs/hfs.c: In function 'grub_hfs_iterate_records': [ 83s] ../grub-core/fs/hfs.c:699:9: error: taking address of packed member of 'struct grub_hfs_sblock' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 83s] 699 | ? (&data->sblock.catalog_recs) [ 83s] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 83s] ../grub-core/fs/hfs.c:700:9: error: taking address of packed member of 'struct grub_hfs_sblock' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 83s] 700 | : (&data->sblock.extent_recs)); [ 83s] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- include/grub/hfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/hfs.h b/include/grub/hfs.h index d935f5005..e27993c42 100644 --- a/include/grub/hfs.h +++ b/include/grub/hfs.h @@ -29,7 +29,7 @@ struct grub_hfs_extent /* The first physical block. */ grub_uint16_t first_block; grub_uint16_t count; -}; +} GRUB_PACKED; /* HFS stores extents in groups of 3. */ typedef struct grub_hfs_extent grub_hfs_datarecord_t[3]; From 621024090b7729c8c698c8ab916d792846d20818 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:05 +0800 Subject: [PATCH 0986/1167] hfsplus: Fix gcc9 error with -Waddress-of-packed-member The catkey->name could be unaligned since the address of 'void* record' is calculated as offset in bytes to a malloc buffer. The fix is using aligned buffer allocated by grub_malloc for holding the UTF16 string copied from catkey->name. And use that buffer as argument for grub_utf16_to_utf8 to convert to UTF8 strings. In addition, using a new copy of buffer rather than catkey->name itself for processing the endianess conversion, we can also get rid of the hunk restoring byte order of catkey->name to what it was previously. [ 59s] ../grub-core/fs/hfsplus.c: In function 'list_nodes': [ 59s] ../grub-core/fs/hfsplus.c:738:57: error: taking address of packed member of 'struct grub_hfsplus_catkey' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 738 | *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, [ 59s] | ~~~~~~^~~~~~ [ 59s] ../grub-core/fs/hfsplus.c: In function 'grub_hfsplus_label': [ 59s] ../grub-core/fs/hfsplus.c:1019:57: error: taking address of packed member of 'struct grub_hfsplus_catkey' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 59s] 1019 | *grub_utf16_to_utf8 ((grub_uint8_t *) (*label), catkey->name, [ 59s] | ~~~~~~^~~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/fs/hfsplus.c | 57 +++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 73ae95fbc..54786bb1c 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -661,6 +661,7 @@ list_nodes (void *record, void *hook_arg) char *filename; int i; struct grub_fshelp_node *node; + grub_uint16_t *keyname; struct grub_hfsplus_catfile *fileinfo; enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN; struct list_nodes_ctx *ctx = hook_arg; @@ -719,32 +720,34 @@ list_nodes (void *record, void *hook_arg) if (! filename) return 0; + keyname = grub_malloc (grub_be_to_cpu16 (catkey->namelen) * sizeof (*keyname)); + if (!keyname) + { + grub_free (filename); + return 0; + } + /* Make sure the byte order of the UTF16 string is correct. */ for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++) { - catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); + keyname[i] = grub_be_to_cpu16 (catkey->name[i]); - if (catkey->name[i] == '/') - catkey->name[i] = ':'; + if (keyname[i] == '/') + keyname[i] = ':'; /* If the name is obviously invalid, skip this node. */ - if (catkey->name[i] == 0) + if (keyname[i] == 0) { + grub_free (keyname); grub_free (filename); return 0; } } - *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, + *grub_utf16_to_utf8 ((grub_uint8_t *) filename, keyname, grub_be_to_cpu16 (catkey->namelen)) = '\0'; - /* Restore the byte order to what it was previously. */ - for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++) - { - if (catkey->name[i] == ':') - catkey->name[i] = '/'; - catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); - } + grub_free (keyname); /* hfs+ is case insensitive. */ if (! ctx->dir->data->case_sensitive) @@ -975,6 +978,7 @@ grub_hfsplus_label (grub_device_t device, char **label) grub_disk_t disk = device->disk; struct grub_hfsplus_catkey *catkey; int i, label_len; + grub_uint16_t *label_name; struct grub_hfsplus_key_internal intern; struct grub_hfsplus_btnode *node = NULL; grub_disk_addr_t ptr = 0; @@ -1003,22 +1007,41 @@ grub_hfsplus_label (grub_device_t device, char **label) grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr); label_len = grub_be_to_cpu16 (catkey->namelen); + label_name = grub_malloc (label_len * sizeof (*label_name)); + if (!label_name) + { + grub_free (node); + grub_free (data); + return grub_errno; + } + for (i = 0; i < label_len; i++) { - catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); + label_name[i] = grub_be_to_cpu16 (catkey->name[i]); /* If the name is obviously invalid, skip this node. */ - if (catkey->name[i] == 0) - return 0; + if (label_name[i] == 0) + { + grub_free (label_name); + grub_free (node); + grub_free (data); + return 0; + } } *label = grub_malloc (label_len * GRUB_MAX_UTF8_PER_UTF16 + 1); if (! *label) - return grub_errno; + { + grub_free (label_name); + grub_free (node); + grub_free (data); + return grub_errno; + } - *grub_utf16_to_utf8 ((grub_uint8_t *) (*label), catkey->name, + *grub_utf16_to_utf8 ((grub_uint8_t *) (*label), label_name, label_len) = '\0'; + grub_free (label_name); grub_free (node); grub_free (data); From 0b1bf3932f1b1700d3c8a997e4850fb9a013569d Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:06 +0800 Subject: [PATCH 0987/1167] acpi: Fix gcc9 error -Waddress-of-packed-member Simply adds the missing packed attribute to 'struct grub_acpi_madt'. [ 233s] ../../grub-core/commands/lsacpi.c: In function 'disp_acpi_xsdt_table': [ 233s] ../../grub-core/commands/lsacpi.c:201:27: error: converting a packed 'struct grub_acpi_table_header' pointer (alignment 1) to a 'struct grub_acpi_madt' pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 233s] 201 | disp_madt_table ((struct grub_acpi_madt *) t); [ 233s] | ^~~~~~~~~~~~~~ [ 233s] In file included from ../../grub-core/commands/lsacpi.c:23: [ 233s] ../../include/grub/acpi.h:50:8: note: defined here [ 233s] 50 | struct grub_acpi_table_header [ 233s] | ^~~~~~~~~~~~~~~~~~~~~~ [ 233s] ../../include/grub/acpi.h:90:8: note: defined here [ 233s] 90 | struct grub_acpi_madt [ 233s] | ^~~~~~~~~~~~~~ [ 233s] ../../grub-core/commands/lsacpi.c: In function 'disp_acpi_rsdt_table': [ 233s] ../../grub-core/commands/lsacpi.c:225:27: error: converting a packed 'struct grub_acpi_table_header' pointer (alignment 1) to a 'struct grub_acpi_madt' pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 233s] 225 | disp_madt_table ((struct grub_acpi_madt *) t); [ 233s] | ^~~~~~~~~~~~~~ [ 233s] In file included from ../../grub-core/commands/lsacpi.c:23: [ 233s] ../../include/grub/acpi.h:50:8: note: defined here [ 233s] 50 | struct grub_acpi_table_header [ 233s] | ^~~~~~~~~~~~~~~~~~~~~~ [ 233s] ../../include/grub/acpi.h:90:8: note: defined here [ 233s] 90 | struct grub_acpi_madt [ 233s] | ^~~~~~~~~~~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- include/grub/acpi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 66148f684..84f49487d 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -93,7 +93,7 @@ struct grub_acpi_madt grub_uint32_t lapic_addr; grub_uint32_t flags; struct grub_acpi_madt_entry_header entries[0]; -}; +} GRUB_PACKED; enum { From 85e08e174e15c497c4387c16e92243e6ed05feb6 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:07 +0800 Subject: [PATCH 0988/1167] usbtest: Disable gcc9 -Waddress-of-packed-member Disable the -Wadress-of-packaed-member diagnostic for the grub_usb_get_string function since the result is false postive. The descstrp->str is found to be aligned in the buffer allocated for 'struct grub_usb_desc_str'. [ 229s] ../../grub-core/commands/usbtest.c: In function 'grub_usb_get_string': [ 229s] ../../grub-core/commands/usbtest.c:104:58: error: taking address of packed member of 'struct grub_usb_desc_str' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 229s] 104 | *grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, [ 229s] | ~~~~~~~~^~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/commands/usbtest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c index 01cdca934..2c6d93fe6 100644 --- a/grub-core/commands/usbtest.c +++ b/grub-core/commands/usbtest.c @@ -63,6 +63,11 @@ static const char *usb_devspeed[] = "High" }; +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif + static grub_usb_err_t grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid, char **string) @@ -108,6 +113,10 @@ grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid, return GRUB_USB_ERR_NONE; } +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif + static void usb_print_str (const char *description, grub_usb_device_t dev, int idx) { From 4868e17507dfebf2894079ad6b4876e612706f30 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:08 +0800 Subject: [PATCH 0989/1167] chainloader: Fix gcc9 error -Waddress-of-packed-member The address of fp->path_name could be unaligned since seeking into the device path buffer for a given node could end in byte boundary. The fix is using aligned buffer allocated by grub_malloc for receiving the converted UTF16 string by grub_utf8_to_utf16 and also the processing after. The resulting string then gets copied to fp->path_name. [ 243s] ../../grub-core/loader/efi/chainloader.c: In function 'copy_file_path': [ 243s] ../../grub-core/loader/efi/chainloader.c:136:32: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 243s] 136 | size = grub_utf8_to_utf16 (fp->path_name, len * GRUB_MAX_UTF16_PER_UTF8, [ 243s] | ~~^~~~~~~~~~~ [ 243s] ../../grub-core/loader/efi/chainloader.c:138:12: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 243s] 138 | for (p = fp->path_name; p < fp->path_name + size; p++) [ 243s] | ^~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/loader/efi/chainloader.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index f706b1ac3..cd92ea3f2 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -110,21 +110,27 @@ static void copy_file_path (grub_efi_file_path_device_path_t *fp, const char *str, grub_efi_uint16_t len) { - grub_efi_char16_t *p; + grub_efi_char16_t *p, *path_name; grub_efi_uint16_t size; fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; - size = grub_utf8_to_utf16 (fp->path_name, len * GRUB_MAX_UTF16_PER_UTF8, + path_name = grub_malloc (len * GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); + if (!path_name) + return; + + size = grub_utf8_to_utf16 (path_name, len * GRUB_MAX_UTF16_PER_UTF8, (const grub_uint8_t *) str, len, 0); - for (p = fp->path_name; p < fp->path_name + size; p++) + for (p = path_name; p < path_name + size; p++) if (*p == '/') *p = '\\'; + grub_memcpy (fp->path_name, path_name, size * sizeof (*fp->path_name)); /* File Path is NULL terminated */ fp->path_name[size++] = '\0'; fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); + grub_free (path_name); } static grub_efi_device_path_t * From 4dd4ceec023111a4ccf69f8de6fa0885c6847a35 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 Apr 2019 17:14:09 +0800 Subject: [PATCH 0990/1167] efi: Fix gcc9 error -Waddress-of-packed-member The address of fp->path_name could be unaligned since seeking into the device path buffer for a given node could end in byte boundary. The fix is allocating aligned buffer by grub_malloc for holding the UTF16 string copied from fp->path_name, and after using that buffer as argument for grub_utf16_to_utf8 to convert it to UTF8 string. [ 255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_get_filename': [ 255s] ../../grub-core/kern/efi/efi.c:410:60: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 255s] 410 | p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len); [ 255s] | ~~^~~~~~~~~~~ [ 255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_print_device_path': [ 255s] ../../grub-core/kern/efi/efi.c:900:33: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member] [ 255s] 900 | *grub_utf16_to_utf8 (buf, fp->path_name, [ 255s] | ~~^~~~~~~~~~~ Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/kern/efi/efi.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 84e68cf31..6e1ceb905 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -372,6 +372,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) { grub_efi_file_path_device_path_t *fp; grub_efi_uint16_t len; + grub_efi_char16_t *dup_name; *p++ = '/'; @@ -382,7 +383,16 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) while (len > 0 && fp->path_name[len - 1] == 0) len--; - p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len); + dup_name = grub_malloc (len * sizeof (*dup_name)); + if (!dup_name) + { + grub_free (name); + return NULL; + } + p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, + grub_memcpy (dup_name, fp->path_name, len * sizeof (*dup_name)), + len); + grub_free (dup_name); } dp = GRUB_EFI_NEXT_DEVICE_PATH (dp); @@ -812,9 +822,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) fp = (grub_efi_file_path_device_path_t *) dp; buf = grub_malloc ((len - 4) * 2 + 1); if (buf) - *grub_utf16_to_utf8 (buf, fp->path_name, + { + grub_efi_char16_t *dup_name = grub_malloc (len - 4); + if (!dup_name) + { + grub_errno = GRUB_ERR_NONE; + grub_printf ("/File((null))"); + grub_free (buf); + break; + } + *grub_utf16_to_utf8 (buf, grub_memcpy (dup_name, fp->path_name, len - 4), (len - 4) / sizeof (grub_efi_char16_t)) - = '\0'; + = '\0'; + grub_free (dup_name); + } else grub_errno = GRUB_ERR_NONE; grub_printf ("/File(%s)", buf); From 1ce93f944df0a71439a996076f2bee8c496af89d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 30 Apr 2019 22:43:56 +0200 Subject: [PATCH 0991/1167] arm: Move trampolines into code section When creating T32->A32 transition jumps, the relocation code in grub will generate trampolines. These trampolines live in the .data section of our PE binary which means they are not marked as executable. This misbehavior was unmasked by commit a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary") which made the X/NX boundary more obvious because everything became page aligned. To put things into proper order, let's move the arm trampolines into the .text section instead. That way everyone knows they are executable. Fixes: a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary") Reported-by: Julien ROBIN Reported-by: Leif Lindholm Signed-off-by: Alexander Graf Tested-by: Julien ROBIN Reviewed-by: Leif Lindholm Tested-by: Leif Lindholm Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a79034e7b..470fbf4dd 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -2197,6 +2197,21 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, } } +#ifdef MKIMAGE_ELF32 + if (image_target->elf_target == EM_ARM) + { + grub_size_t tramp; + + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); + + tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize, + smd->num_sections, image_target); + + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); + } +#endif + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; @@ -2210,23 +2225,6 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, smd, image_target); -#ifdef MKIMAGE_ELF32 - if (image_target->elf_target == EM_ARM) - { - grub_size_t tramp; - layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, - image_target->section_align) - image_target->vaddr_offset; - - layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - - tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize, - smd->num_sections, image_target); - - layout->tramp_off = layout->kernel_size; - layout->kernel_size += ALIGN_UP (tramp, 16); - } -#endif - layout->bss_start = layout->kernel_size; layout->end = layout->kernel_size; From ce946603cf4b6ea0f990412e633085d8c71e1b29 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 30 Apr 2019 22:43:57 +0200 Subject: [PATCH 0992/1167] arm: Align section alignment with manual relocation offset code The arm relocation code has a manual special case for EFI binaries to add the natural alignment to its own relocation awareness. Since commit a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary") we changed that alignment from 0x400 to 0x1000 bytes. Reflect the change in that branch that we forgot as well. This fixes running 32bit arm grub efi binaries for me again. Fixes: a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary") Reported-by: Heinrich Schuchardt Reported-by: Steve McIntyre Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper Tested-by: Julien ROBIN Reviewed-by: Leif Lindholm Tested-by: Leif Lindholm Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 470fbf4dd..bc087c2b5 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1137,7 +1137,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, (int) sym_addr, (int) sym_addr); /* Data will be naturally aligned */ if (image_target->id == IMAGE_EFI) - sym_addr += 0x400; + sym_addr += GRUB_PE32_SECTION_ALIGNMENT; *target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr); } break; From a06b079a360618ff6c83bc2014045a5ac0c9d072 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 17 May 2019 17:00:19 +0800 Subject: [PATCH 0993/1167] f2fs: Fix gcc9 error -Werror=maybe-uninitialized The function grub_get_node_path() could return uninitialized offset with level == 0 if the block is greater than direct_index + 2 * direct_blks + 2 * indirect_blks + dindirect_blks. The uninitialized offset is then used by function grub_f2fs_get_block() because level == 0 is valid and meaningful return to be processed. The fix is to set level = -1 as return value by grub_get_node_path() to signify an error that the input block cannot be handled. Any caller should therefore check level is negative or not before processing the output. Reported-by: Neil MacLeod Signed-off-by: Michael Chang Tested-by: Neil MacLeod Reviewed-by: Daniel Kiper --- grub-core/fs/f2fs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c index 644653dbe..bb28b291b 100644 --- a/grub-core/fs/f2fs.c +++ b/grub-core/fs/f2fs.c @@ -702,7 +702,7 @@ grub_get_node_path (struct grub_f2fs_inode *inode, grub_uint32_t block, grub_uint32_t dindirect_blks = indirect_blks * NIDS_PER_BLOCK; grub_uint32_t direct_index = DEF_ADDRS_PER_INODE; int n = 0; - int level = 0; + int level = -1; if (inode->i_inline & F2FS_INLINE_XATTR) direct_index -= F2FS_INLINE_XATTR_ADDRS; @@ -712,6 +712,7 @@ grub_get_node_path (struct grub_f2fs_inode *inode, grub_uint32_t block, if (block < direct_index) { offset[n] = block; + level = 0; goto got; } @@ -860,6 +861,10 @@ grub_f2fs_get_block (grub_fshelp_node_t node, grub_disk_addr_t block_ofs) int level, i; level = grub_get_node_path (inode, block_ofs, offset, noffset); + + if (level < 0) + return -1; + if (level == 0) return grub_le_to_cpu32 (inode->i_addr[offset[0]]); From 4ff34fefe4d99bc9511c0d9d64aacb79908d2b1c Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Tue, 14 May 2019 11:40:55 +0300 Subject: [PATCH 0994/1167] grub-mkconfig: Use -c instead of --printf for stat "--printf" only works with the stat variant provided by coreutils. With busybox, stat will fail with the following error: stat: unrecognized option '--printf=%T' Usage: stat [OPTIONS] FILE... Signed-off-by: Ovidiu Panait Reviewed-by: Daniel Kiper --- util/grub-mkconfig.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 33332360e..9f477ff05 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -145,7 +145,7 @@ GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_u GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`" if [ x"$GRUB_FS" = xunknown ]; then - GRUB_FS="$(stat -f --printf=%T / || echo unknown)" + GRUB_FS="$(stat -f -c %T / || echo unknown)" fi # Provide a default set of stock linux early initrd images. From afd6ad42971cfdb97f6dc6d0f21336d830773810 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Mon, 29 Apr 2019 13:57:02 -0400 Subject: [PATCH 0995/1167] video: skip 'text' gfxpayload if not supported, to fallback to default On UEFI, 'text' gfxpayload is not supported, but we still reach parse_modespec() with it, which will obviously fail. Fortunately, whatever gfxpayload is set, we still still have the 'auto' default to fall back to. Allow getting to this fallback by not trying to parse 'text' as a modespec. This is because 'text' correctly doesn't parse as a modespec, and ought to have been ignored before we got to that point, just like it is immediately picked if we're running on a system where 'text' is a supported video mode. Bug: https://savannah.gnu.org/bugs/index.php?56217 Signed-off-by: Mathieu Trudel-Lapierre Reviewed-by: Daniel Kiper --- grub-core/video/video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/video/video.c b/grub-core/video/video.c index f252663c1..983424107 100644 --- a/grub-core/video/video.c +++ b/grub-core/video/video.c @@ -663,6 +663,8 @@ grub_video_set_mode (const char *modestring, return GRUB_ERR_NONE; } + else + continue; } err = parse_modespec (current_mode, &width, &height, &depth); From 53e70d30cf0d18e6c28bab0ab8d223a90d3e1b46 Mon Sep 17 00:00:00 2001 From: Vincent Legoll Date: Sun, 28 Apr 2019 01:21:49 +0200 Subject: [PATCH 0996/1167] grub-mkrescue: Fix error message about the wrong command having failed: mformat instead of mcopy Signed-off-by: Vincent Legoll Reviewed-by: Daniel Kiper --- util/grub-mkrescue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 21e5ce4e4..ce2cbc4f1 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -815,7 +815,7 @@ main (int argc, char *argv[]) grub_util_error ("`%s` invocation failed\n", "mformat"); rv = grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL }); if (rv != 0) - grub_util_error ("`%s` invocation failed\n", "mformat"); + grub_util_error ("`%s` invocation failed\n", "mcopy"); xorriso_push ("--efi-boot"); xorriso_push ("efi.img"); xorriso_push ("-efi-boot-part"); From 8e8723a6be548874fe40086a7dc467b5c8fe619b Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Wed, 29 May 2019 08:34:55 +0200 Subject: [PATCH 0997/1167] f2fs: Disable gcc9 -Waddress-of-packed-member MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Disable the -Wadress-of-packaed-member diagnostic for the grub_f2fs_label function since the result is found to be false postive. A pointer to the 'volume_name' member of 'struct grub_f2fs_superblock' is guaranteed to be aligned as the offset of 'volume_name' within the struct is dividable by the natural alignment on both 32- and 64-bit targets. grub-core/fs/f2fs.c: In function ‘grub_f2fs_label’: grub-core/fs/f2fs.c:1253:60: error: taking address of packed member of ‘struct grub_f2fs_superblock’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 1253 | *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name); | ~~~~~~~~~~~~^~~~~~~~~~~~ cc1: all warnings being treated as errors Reported-by: Neil MacLeod Signed-off-by: John Paul Adrian Glaubitz Tested-by: Neil MacLeod Reviewed-by: Daniel Kiper --- grub-core/fs/f2fs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c index bb28b291b..8a9992ca9 100644 --- a/grub-core/fs/f2fs.c +++ b/grub-core/fs/f2fs.c @@ -1240,6 +1240,11 @@ grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le) return out_buf; } +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif + static grub_err_t grub_f2fs_label (grub_device_t device, char **label) { @@ -1260,6 +1265,10 @@ grub_f2fs_label (grub_device_t device, char **label) return grub_errno; } +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif + static grub_err_t grub_f2fs_uuid (grub_device_t device, char **uuid) { From 5610734770fa421cd479e43368f91d16d2eb2a8c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 25 Mar 2019 16:24:50 +0100 Subject: [PATCH 0998/1167] hostfs: #undef open and close. Unlike in case of disks in this case it's just a single place, so it's easier to just #undef Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- grub-core/kern/emu/hostfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c index cee70413d..cb532105e 100644 --- a/grub-core/kern/emu/hostfs.c +++ b/grub-core/kern/emu/hostfs.c @@ -173,6 +173,9 @@ grub_hostfs_label (grub_device_t device __attribute ((unused)), return GRUB_ERR_NONE; } +#undef open +#undef close + static struct grub_fs grub_hostfs_fs = { .name = "hostfs", From 4e7b5bb3be69633ed860cb74b0ef2c84a839523d Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 6 Jun 2019 10:13:00 +0100 Subject: [PATCH 0999/1167] ia64: build fix in cache.h Add IA64 to the architectures excluding a declaration for grub_arch_sync_dma_caches(). IA64 does not include any of the source files that require the function, but was overlooked for d8901e3ba115 ("cache: Fix compilation for ppc, sparc and arm64"). Add it to the list of excluding architectures in order to not get missing symbol errors when running grub-mkimage. Reported-by: Alexander Graf Signed-off-by: Leif Lindholm Tested-by: John Paul Adrian Glaubitz Reviewed-by: Daniel Kiper --- include/grub/cache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/grub/cache.h b/include/grub/cache.h index ccfa717e6..7aa8d7933 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -34,7 +34,8 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); #endif #ifndef GRUB_MACHINE_EMU -#if defined (__aarch64__) || defined (__powerpc__) || defined (__sparc__) +#if defined (__aarch64__) || defined (__ia64__) || defined (__powerpc__) || \ + defined (__sparc__) #elif defined (__i386__) || defined (__x86_64__) static inline void From ff999c803e1bcd3aa00fd3c95b9f4fe3a958eecc Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Wed, 19 Jun 2019 17:13:23 -0600 Subject: [PATCH 1000/1167] docs: Bootstrap changes required for older distros Some older distros do not contain gettext 0.18. Document the workaround to use the bootstrap utility on these systems. Signed-off-by: Eric Snowberg Reviewed-by: Daniel Kiper --- docs/grub-dev.texi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 862a677e0..ee389fd83 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -511,6 +511,40 @@ To add a new Gnulib module or remove one that is no longer needed, change @code{gnulib_modules} in @file{bootstrap.conf}. Again, run @kbd{./bootstrap} and whatever else you need to make sure it works. +Bootstrapping from an older distribution containing gettext version < 0.18.3, +will require a patch similar to this to be applied first before running the +@command{./bootstrap} utility: + +@example +diff --git a/bootstrap.conf b/bootstrap.conf +index 988dda0..a3193a9 100644 +--- a/bootstrap.conf ++++ b/bootstrap.conf +@@ -67,7 +67,7 @@ SKIP_PO=t +buildreq="\ +autoconf 2.63 +automake 1.11 +-gettext 0.18.3 ++gettext 0.17 +git 1.5.5 +tar - +" +diff --git a/configure.ac b/configure.ac +index 08b518f..99f5b36 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -362,7 +362,7 @@ AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no) + +AC_GNU_SOURCE +AM_GNU_GETTEXT([external]) +-AM_GNU_GETTEXT_VERSION([0.18.3]) ++AM_GNU_GETTEXT_VERSION([0.17]) +AC_SYS_LARGEFILE + +# Identify characteristics of the host architecture. + +@end example + @node Porting @chapter Porting From f9811a92e6d4c0579f989f3d6dcc66e8fb35cb09 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 20 Jun 2019 10:36:42 +0200 Subject: [PATCH 1001/1167] docs: Document workaround for grub-mkrescue with older MacBooks Add a description of the workaround for firmware of older MacBooks which stalls with a grub-mkrescue ISO image for x86_64-efi target on an USB stick. Signed-off-by: Thomas Schmitt Reviewed-by: Daniel Kiper --- docs/grub.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 308b25074..87795075a 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -6131,6 +6131,7 @@ Required files are: @menu * GRUB only offers a rescue shell:: +* Firmware stalls instead of booting GRUB:: @end menu @@ -6201,6 +6202,17 @@ support has not yet been added to GRUB. @end itemize +@node Firmware stalls instead of booting GRUB +@section Firmware stalls instead of booting GRUB + +The EFI implementation of some older MacBook laptops stalls when it gets +presented a grub-mkrescue ISO image for x86_64-efi target on an USB stick. +Affected are models of year 2010 or earlier. Workaround is to zeroize the +bytes 446 to 461 of the EFI partition, where mformat has put a partition table +entry which claims partition start at block 0. This change will not hamper +bootability on other machines. + + @node Invoking grub-install @chapter Invoking grub-install From 2a2e10c1b39672de3d5da037a50d5c371f49b40d Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 1 Jul 2019 13:19:25 +0200 Subject: [PATCH 1002/1167] Release 2.04 Signed-off-by: Daniel Kiper --- NEWS | 18 ++++++++++++++++++ configure.ac | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2ebd54e78..e7ca7fb3f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,21 @@ +New in 2.04: + +* GCC 8 and 9 support. +* Gnulib integration overhaul. +* RISC-V support. +* Xen PVH support. +* Native UEFI secure boot support. +* UEFI TPM driver. +* New IEEE 1275 obdisk driver. +* Btrfs RAID 5 and RIAD 6 support. +* PARTUUID support. +* VLAN support. +* Native DHCP support. +* Many ARM and ARM64 fixes. +* Many SPARC fixes. +* Many IEEE 1275 fixes. +* ...and tons of other fixes and cleanups... + New in 2.02: * New/improved filesystem and disk support: diff --git a/configure.ac b/configure.ac index 08b518fcc..7656f2434 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.04~rc1],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.04],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From 26094f52419d1bc9eb7e02e4ec81a7ccffc960f0 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 5 Jul 2019 11:30:53 +0200 Subject: [PATCH 1003/1167] Bump version to 2.05 Signed-off-by: Daniel Kiper --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7656f2434..629627cba 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.04],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.05],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From f2b9083f859c7dbf44a7a8e96ee0cf202f9a4187 Mon Sep 17 00:00:00 2001 From: Jacob Kroon Date: Wed, 15 May 2019 21:04:43 +0200 Subject: [PATCH 1004/1167] probe: Support probing for partition UUID with --part-uuid Linux supports root=PARTUUID= boot argument, so add support for probing it. Compared to the fs UUID, the partition UUID does not change when reformatting a partition. For now, only disks using a GPT partition table are supported. Signed-off-by: Jacob Kroon Reviewed-by: Paul Menzel Reviewed-by: Daniel Kiper --- docs/grub.texi | 4 +++- grub-core/commands/probe.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index 87795075a..11a0e9ad8 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4771,9 +4771,11 @@ a rest. @node probe @subsection probe -@deffn Command probe [@option{--set} var] @option{--driver}|@option{--partmap}|@option{--fs}|@option{--fs-uuid}|@option{--label} device +@deffn Command probe [@option{--set} var] @option{--driver}|@option{--partmap}|@option{--fs}|@option{--fs-uuid}|@option{--label}|@option{--part-uuid} device Retrieve device information. If option @option{--set} is given, assign result to variable @var{var}, otherwise print information on the screen. + +The option @option{--part-uuid} is currently only implemented for GPT-formatted disks. @end deffn diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index 95d272287..d2e7f662e 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ static const struct grub_arg_option options[] = {"fs", 'f', 0, N_("Determine filesystem type."), 0, 0}, {"fs-uuid", 'u', 0, N_("Determine filesystem UUID."), 0, 0}, {"label", 'l', 0, N_("Determine filesystem label."), 0, 0}, + {"part-uuid", 0, 0, N_("Determine partition UUID."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -98,6 +100,38 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) grub_device_close (dev); return GRUB_ERR_NONE; } + if (state[6].set) + { + /* AAAABBBB-CCCC-DDDD-EEEE-FFFFFFFFFFFF + null terminator */ + char val[37] = "none"; + if (dev->disk && dev->disk->partition && + grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) + { + struct grub_gpt_partentry entry; + struct grub_partition *p = dev->disk->partition; + grub_disk_t disk = grub_disk_open(dev->disk->name); + if (!disk) + return grub_errno; + if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry)) + return grub_errno; + grub_disk_close(disk); + grub_gpt_part_guid_t *guid = &entry.guid; + grub_snprintf (val, sizeof(val), + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + grub_le_to_cpu32 (guid->data1), + grub_le_to_cpu16 (guid->data2), + grub_le_to_cpu16 (guid->data3), + guid->data4[0], guid->data4[1], guid->data4[2], + guid->data4[3], guid->data4[4], guid->data4[5], + guid->data4[6], guid->data4[7]); + } + if (state[0].set) + grub_env_set (state[0].arg, val); + else + grub_printf ("%s", val); + grub_device_close (dev); + return GRUB_ERR_NONE; + } fs = grub_fs_probe (dev); if (! fs) return grub_errno; From 2d55ffecbb966d3e42023729d8bbf3c21c59e049 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 4 Jun 2019 12:39:16 +0100 Subject: [PATCH 1005/1167] configure: Disable arm movw/movt relocations for GCC When building for arm, we already disable movw/movt relocations for clang, since they are incompatible with PE. When building with bare metal GCC toolchains (like the one used in the travis ci scripts), we end up with these relocations again. So add an additional test for the '-mword-relocations' flag used by GCC. Reported-by: Alexander Graf Signed-off-by: Leif Lindholm Reviewed-by: Daniel Kiper --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 629627cba..23c555c26 100644 --- a/configure.ac +++ b/configure.ac @@ -1198,7 +1198,8 @@ if test "x$target_cpu" = xarm; then AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [ grub_cv_target_cc_mno_movt=no for cand in "-mno-movt" \ - "-mllvm -arm-use-movt=0"; do + "-mllvm -arm-use-movt=0" \ + "-mword-relocations"; do if test x"$grub_cv_target_cc_mno_movt" != xno ; then break fi From 2bf40e9e5be9808b17852e688eead87acff14420 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 26 Jun 2019 16:50:03 +0200 Subject: [PATCH 1006/1167] RISC-V: Fix computation of pc-relative relocation offset The offset calculation was missing the relocation addend. Signed-off-by: Andreas Schwab Tested-by: Chester Lin Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index bc087c2b5..d16ec63a1 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, grub_uint32_t *t32 = (grub_uint32_t *) target; grub_uint16_t *t16 = (grub_uint16_t *) target; grub_uint8_t *t8 = (grub_uint8_t *) target; - grub_int64_t off = (long)sym_addr - target_section_addr - offset - - image_target->vaddr_offset; + grub_int64_t off; /* * Instructions and instruction encoding are documented in the RISC-V @@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, */ sym_addr += addend; + off = sym_addr - target_section_addr - offset - image_target->vaddr_offset; switch (ELF_R_TYPE (info)) { From dabdfa1c6a80639197d05f683a445fa8615517fe Mon Sep 17 00:00:00 2001 From: David Michael Date: Fri, 5 Jul 2019 07:45:59 -0400 Subject: [PATCH 1007/1167] verifiers: Blocklist fallout cleanup Blocklist fallout cleanup after commit 5c6f9bc15 (generic/blocklist: Fix implicit declaration of function grub_file_filter_disable_compression()). Signed-off-by: David Michael Reviewed-by: Daniel Kiper --- grub-core/osdep/generic/blocklist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/generic/blocklist.c b/grub-core/osdep/generic/blocklist.c index ea2a511b6..2d9040302 100644 --- a/grub-core/osdep/generic/blocklist.c +++ b/grub-core/osdep/generic/blocklist.c @@ -59,7 +59,7 @@ grub_install_get_blocklist (grub_device_t root_dev, grub_disk_cache_invalidate_all (); - file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | FILE_TYPE_NO_DECOMPRESS); + file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | GRUB_FILE_TYPE_NO_DECOMPRESS); if (file) { if (grub_file_size (file) != core_size) @@ -116,7 +116,7 @@ grub_install_get_blocklist (grub_device_t root_dev, grub_file_t file; /* Now read the core image to determine where the sectors are. */ - file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | FILE_TYPE_NO_DECOMPRESS); + file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | GRUB_FILE_TYPE_NO_DECOMPRESS); if (! file) grub_util_error ("%s", grub_errmsg); From 261df54f170c6d87258eb37ef17d62690720696b Mon Sep 17 00:00:00 2001 From: David Michael Date: Fri, 5 Jul 2019 08:47:02 -0400 Subject: [PATCH 1008/1167] lsefisystab: Define SMBIOS3 entry point structures for EFI This adds the GUID and includes it in lsefisystab output. Signed-off-by: David Michael Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/efi/lsefisystab.c | 1 + include/grub/efi/api.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index df1030221..7c039c509 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -48,6 +48,7 @@ static const struct guid_mapping guid_mappings[] = { GRUB_EFI_MPS_TABLE_GUID, "MPS"}, { GRUB_EFI_SAL_TABLE_GUID, "SAL"}, { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"}, + { GRUB_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"}, { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"}, { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"}, { GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"}, diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index addcbfa8f..576074384 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -314,6 +314,11 @@ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } +#define GRUB_EFI_SMBIOS3_TABLE_GUID \ + { 0xf2fd1544, 0x9794, 0x4a2c, \ + { 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \ + } + #define GRUB_EFI_SAL_TABLE_GUID \ { 0xeb9d2d32, 0x2d88, 0x11d3, \ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ From 688023cd0ac4c985fd0e2ec477fcf1ec33a0e49c Mon Sep 17 00:00:00 2001 From: David Michael Date: Fri, 5 Jul 2019 08:47:09 -0400 Subject: [PATCH 1009/1167] smbios: Add a module for retrieving SMBIOS information The following are two use cases from Rajat Jain : 1) We have a board that boots Linux and this board itself can be plugged into one of different chassis types. We need to pass different parameters to the kernel based on the "CHASSIS_TYPE" information that is passed by the bios in the DMI/SMBIOS tables. 2) We may have a USB stick that can go into multiple boards, and the exact kernel to be loaded depends on the machine information (PRODUCT_NAME etc) passed via the DMI. Signed-off-by: David Michael Reviewed-by: Daniel Kiper --- docs/grub.texi | 75 ++++++ grub-core/Makefile.core.def | 15 ++ grub-core/commands/efi/smbios.c | 61 +++++ grub-core/commands/i386/pc/smbios.c | 52 ++++ grub-core/commands/smbios.c | 374 +++++++++++++++++++++++++++ grub-core/efiemu/i386/pc/cfgtables.c | 15 +- include/grub/smbios.h | 69 +++++ 7 files changed, 650 insertions(+), 11 deletions(-) create mode 100644 grub-core/commands/efi/smbios.c create mode 100644 grub-core/commands/i386/pc/smbios.c create mode 100644 grub-core/commands/smbios.c create mode 100644 include/grub/smbios.h diff --git a/docs/grub.texi b/docs/grub.texi index 11a0e9ad8..3d50b16ba 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3944,6 +3944,7 @@ you forget a command, you can run the command @command{help} * sha256sum:: Compute or check SHA256 hash * sha512sum:: Compute or check SHA512 hash * sleep:: Wait for a specified number of seconds +* smbios:: Retrieve SMBIOS information * source:: Read a configuration file in same context * test:: Check file types and compare values * true:: Do nothing, successfully @@ -5085,6 +5086,80 @@ if timeout was interrupted by @key{ESC}. @end deffn +@node smbios +@subsection smbios + +@deffn Command smbios @ + [@option{--type} @var{type}] @ + [@option{--handle} @var{handle}] @ + [@option{--match} @var{match}] @ + (@option{--get-byte} | @option{--get-word} | @option{--get-dword} | @ + @option{--get-qword} | @option{--get-string} | @option{--get-uuid}) @ + @var{offset} @ + [@option{--set} @var{variable}] +Retrieve SMBIOS information. + +The @command{smbios} command returns the value of a field in an SMBIOS +structure. The following options determine which structure to select. + +@itemize @bullet +@item +Specifying @option{--type} will select structures with a matching +@var{type}. The type can be any integer from 0 to 255. +@item +Specifying @option{--handle} will select structures with a matching +@var{handle}. The handle can be any integer from 0 to 65535. +@item +Specifying @option{--match} will select structure number @var{match} in the +filtered list of structures; e.g. @code{smbios --type 4 --match 2} will select +the second Process Information (Type 4) structure. The list is always ordered +the same as the hardware's SMBIOS table. The match number must be a positive +integer. If unspecified, the first matching structure will be selected. +@end itemize + +The remaining options determine which field in the selected SMBIOS structure to +return. Only one of these options may be specified at a time. + +@itemize @bullet +@item +When given @option{--get-byte}, return the value of the byte +at @var{offset} bytes into the selected SMBIOS structure. +It will be formatted as an unsigned decimal integer. +@item +When given @option{--get-word}, return the value of the word (two bytes) +at @var{offset} bytes into the selected SMBIOS structure. +It will be formatted as an unsigned decimal integer. +@item +When given @option{--get-dword}, return the value of the dword (four bytes) +at @var{offset} bytes into the selected SMBIOS structure. +It will be formatted as an unsigned decimal integer. +@item +When given @option{--get-qword}, return the value of the qword (eight bytes) +at @var{offset} bytes into the selected SMBIOS structure. +It will be formatted as an unsigned decimal integer. +@item +When given @option{--get-string}, return the string with its index found +at @var{offset} bytes into the selected SMBIOS structure. +@item +When given @option{--get-uuid}, return the value of the UUID (sixteen bytes) +at @var{offset} bytes into the selected SMBIOS structure. +It will be formatted as lower-case hyphenated hexadecimal digits, with the +first three fields as little-endian, and the rest printed byte-by-byte. +@end itemize + +The default action is to print the value of the requested field to the console, +but a variable name can be specified with @option{--set} to store the value +instead of printing it. + +For example, this will store and then display the system manufacturer's name. + +@example +smbios --type 1 --get-string 4 --set system_manufacturer +echo $system_manufacturer +@end example +@end deffn + + @node source @subsection source diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 474a63e68..269370417 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1097,6 +1097,21 @@ module = { common = commands/sleep.c; }; +module = { + name = smbios; + + common = commands/smbios.c; + efi = commands/efi/smbios.c; + i386_pc = commands/i386/pc/smbios.c; + i386_coreboot = commands/i386/pc/smbios.c; + i386_multiboot = commands/i386/pc/smbios.c; + + enable = efi; + enable = i386_pc; + enable = i386_coreboot; + enable = i386_multiboot; +}; + module = { name = suspend; ieee1275 = commands/ieee1275/suspend.c; diff --git a/grub-core/commands/efi/smbios.c b/grub-core/commands/efi/smbios.c new file mode 100644 index 000000000..75202d5aa --- /dev/null +++ b/grub-core/commands/efi/smbios.c @@ -0,0 +1,61 @@ +/* smbios.c - get smbios tables. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include +#include +#include +#include + +struct grub_smbios_eps * +grub_machine_smbios_get_eps (void) +{ + unsigned i; + static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + { + grub_efi_packed_guid_t *guid = + &grub_efi_system_table->configuration_table[i].vendor_guid; + + if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t))) + return (struct grub_smbios_eps *) + grub_efi_system_table->configuration_table[i].vendor_table; + } + + return 0; +} + +struct grub_smbios_eps3 * +grub_machine_smbios_get_eps3 (void) +{ + unsigned i; + static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + { + grub_efi_packed_guid_t *guid = + &grub_efi_system_table->configuration_table[i].vendor_guid; + + if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t))) + return (struct grub_smbios_eps3 *) + grub_efi_system_table->configuration_table[i].vendor_table; + } + + return 0; +} diff --git a/grub-core/commands/i386/pc/smbios.c b/grub-core/commands/i386/pc/smbios.c new file mode 100644 index 000000000..069d66367 --- /dev/null +++ b/grub-core/commands/i386/pc/smbios.c @@ -0,0 +1,52 @@ +/* smbios.c - get smbios tables. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include +#include +#include + +struct grub_smbios_eps * +grub_machine_smbios_get_eps (void) +{ + grub_uint8_t *ptr; + + grub_dprintf ("smbios", "Looking for SMBIOS EPS. Scanning BIOS\n"); + + for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) + if (grub_memcmp (ptr, "_SM_", 4) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps)) == 0) + return (struct grub_smbios_eps *) ptr; + + return 0; +} + +struct grub_smbios_eps3 * +grub_machine_smbios_get_eps3 (void) +{ + grub_uint8_t *ptr; + + grub_dprintf ("smbios", "Looking for SMBIOS3 EPS. Scanning BIOS\n"); + + for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) + if (grub_memcmp (ptr, "_SM3_", 5) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps3)) == 0) + return (struct grub_smbios_eps3 *) ptr; + + return 0; +} diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c new file mode 100644 index 000000000..7a6a391fc --- /dev/null +++ b/grub-core/commands/smbios.c @@ -0,0 +1,374 @@ +/* smbios.c - retrieve smbios information. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */ +static struct { + grub_addr_t start; + grub_addr_t end; + grub_uint16_t structures; +} table_desc; + +static grub_extcmd_t cmd; + +/* Locate the SMBIOS entry point structure depending on the hardware. */ +struct grub_smbios_eps * +grub_smbios_get_eps (void) +{ + static struct grub_smbios_eps *eps = NULL; + + if (eps != NULL) + return eps; + + eps = grub_machine_smbios_get_eps (); + + return eps; +} + +/* Locate the SMBIOS3 entry point structure depending on the hardware. */ +static struct grub_smbios_eps3 * +grub_smbios_get_eps3 (void) +{ + static struct grub_smbios_eps3 *eps = NULL; + + if (eps != NULL) + return eps; + + eps = grub_machine_smbios_get_eps3 (); + + return eps; +} + +/* + * These functions convert values from the various SMBIOS structure field types + * into a string formatted to be returned to the user. They expect that the + * structure and offset were already validated. When the requested data is + * successfully retrieved and formatted, the pointer to the string is returned; + * otherwise, NULL is returned on failure. Don't free the result. + */ + +static const char * +grub_smbios_format_byte (const grub_uint8_t *structure, grub_uint8_t offset) +{ + static char buffer[sizeof ("255")]; + + grub_snprintf (buffer, sizeof (buffer), "%u", structure[offset]); + + return (const char *)buffer; +} + +static const char * +grub_smbios_format_word (const grub_uint8_t *structure, grub_uint8_t offset) +{ + static char buffer[sizeof ("65535")]; + + grub_uint16_t value = grub_get_unaligned16 (structure + offset); + grub_snprintf (buffer, sizeof (buffer), "%u", value); + + return (const char *)buffer; +} + +static const char * +grub_smbios_format_dword (const grub_uint8_t *structure, grub_uint8_t offset) +{ + static char buffer[sizeof ("4294967295")]; + + grub_uint32_t value = grub_get_unaligned32 (structure + offset); + grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT32_T, value); + + return (const char *)buffer; +} + +static const char * +grub_smbios_format_qword (const grub_uint8_t *structure, grub_uint8_t offset) +{ + static char buffer[sizeof ("18446744073709551615")]; + + grub_uint64_t value = grub_get_unaligned64 (structure + offset); + grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT64_T, value); + + return (const char *)buffer; +} + +static const char * +grub_smbios_get_string (const grub_uint8_t *structure, grub_uint8_t offset) +{ + const grub_uint8_t *ptr = structure + structure[1]; + const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end; + const grub_uint8_t referenced_string_number = structure[offset]; + grub_uint8_t i; + + /* A string referenced with zero is interpreted as unset. */ + if (referenced_string_number == 0) + return NULL; + + /* Search the string set. */ + for (i = 1; *ptr != 0 && ptr < table_end; i++) + if (i == referenced_string_number) + { + const char *str = (const char *)ptr; + while (*ptr++ != 0) + if (ptr >= table_end) + return NULL; /* The string isn't terminated. */ + return str; + } + else + while (*ptr++ != 0 && ptr < table_end); + + /* The string number is greater than the number of strings in the set. */ + return NULL; +} + +static const char * +grub_smbios_format_uuid (const grub_uint8_t *structure, grub_uint8_t offset) +{ + static char buffer[sizeof ("ffffffff-ffff-ffff-ffff-ffffffffffff")]; + const grub_uint8_t *f = structure + offset; /* little-endian fields */ + const grub_uint8_t *g = f + 8; /* byte-by-byte fields */ + + grub_snprintf (buffer, sizeof (buffer), + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x-%02x%02x%02x%02x%02x%02x", + f[3], f[2], f[1], f[0], f[5], f[4], f[7], f[6], + g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7]); + + return (const char *)buffer; +} + +/* List the field formatting functions and the number of bytes they need. */ +static const struct { + const char *(*format) (const grub_uint8_t *structure, grub_uint8_t offset); + grub_uint8_t field_length; +} field_extractors[] = { + {grub_smbios_format_byte, 1}, + {grub_smbios_format_word, 2}, + {grub_smbios_format_dword, 4}, + {grub_smbios_format_qword, 8}, + {grub_smbios_get_string, 1}, + {grub_smbios_format_uuid, 16} +}; + +/* List command options, with structure field getters ordered as above. */ +#define FIRST_GETTER_OPT (3) +#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors)) + +static const struct grub_arg_option options[] = { + {"type", 't', 0, N_("Match structures with the given type."), + N_("type"), ARG_TYPE_INT}, + {"handle", 'h', 0, N_("Match structures with the given handle."), + N_("handle"), ARG_TYPE_INT}, + {"match", 'm', 0, N_("Select a structure when several match."), + N_("match"), ARG_TYPE_INT}, + {"get-byte", 'b', 0, N_("Get the byte's value at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"get-word", 'w', 0, N_("Get two bytes' value at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"get-dword", 'd', 0, N_("Get four bytes' value at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"get-qword", 'q', 0, N_("Get eight bytes' value at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"get-string", 's', 0, N_("Get the string specified at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"get-uuid", 'u', 0, N_("Get the UUID's value at the given offset."), + N_("offset"), ARG_TYPE_INT}, + {"set", '\0', 0, N_("Store the value in the given variable name."), + N_("variable"), ARG_TYPE_STRING}, + {0, 0, 0, 0, 0, 0} +}; + +/* + * Return a matching SMBIOS structure. + * + * This method can use up to three criteria for selecting a structure: + * - The "type" field (use -1 to ignore) + * - The "handle" field (use -1 to ignore) + * - Which to return if several match (use 0 to ignore) + * + * The return value is a pointer to the first matching structure. If no + * structures match the given parameters, NULL is returned. + */ +static const grub_uint8_t * +grub_smbios_match_structure (const grub_int16_t type, + const grub_int32_t handle, + const grub_uint16_t match) +{ + const grub_uint8_t *ptr = (const grub_uint8_t *)table_desc.start; + const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end; + grub_uint16_t structures = table_desc.structures; + grub_uint16_t structure_count = 0; + grub_uint16_t matches = 0; + + while (ptr < table_end + && ptr[1] >= 4 /* Valid structures include the 4-byte header. */ + && (structure_count++ < structures || structures == 0)) + { + grub_uint16_t structure_handle = grub_get_unaligned16 (ptr + 2); + grub_uint8_t structure_type = ptr[0]; + + if ((handle < 0 || handle == structure_handle) + && (type < 0 || type == structure_type) + && (match == 0 || match == ++matches)) + return ptr; + else + { + ptr += ptr[1]; + while ((*ptr++ != 0 || *ptr++ != 0) && ptr < table_end); + } + + if (structure_type == GRUB_SMBIOS_TYPE_END_OF_TABLE) + break; + } + + return NULL; +} + +static grub_err_t +grub_cmd_smbios (grub_extcmd_context_t ctxt, + int argc __attribute__ ((unused)), + char **argv __attribute__ ((unused))) +{ + struct grub_arg_list *state = ctxt->state; + + grub_int16_t type = -1; + grub_int32_t handle = -1; + grub_uint16_t match = 0; + grub_uint8_t offset = 0; + + const grub_uint8_t *structure; + const char *value; + grub_int32_t option; + grub_int8_t field_type = -1; + grub_uint8_t i; + + if (table_desc.start == 0) + return grub_error (GRUB_ERR_IO, + N_("the SMBIOS entry point structure was not found")); + + /* Read the given filtering options. */ + if (state[0].set) + { + option = grub_strtol (state[0].arg, NULL, 0); + if (option < 0 || option > 255) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("the type must be between 0 and 255")); + type = (grub_int16_t)option; + } + if (state[1].set) + { + option = grub_strtol (state[1].arg, NULL, 0); + if (option < 0 || option > 65535) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("the handle must be between 0 and 65535")); + handle = (grub_int32_t)option; + } + if (state[2].set) + { + option = grub_strtol (state[2].arg, NULL, 0); + if (option <= 0 || option > 65535) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("the match must be a positive integer")); + match = (grub_uint16_t)option; + } + + /* Determine the data type of the structure field to retrieve. */ + for (i = 0; i < ARRAY_SIZE(field_extractors); i++) + if (state[FIRST_GETTER_OPT + i].set) + { + if (field_type >= 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("only one --get option is usable at a time")); + field_type = i; + } + + /* Require a choice of a structure field to return. */ + if (field_type < 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("one of the --get options is required")); + + /* Locate a matching SMBIOS structure. */ + structure = grub_smbios_match_structure (type, handle, match); + if (structure == NULL) + return grub_error (GRUB_ERR_IO, + N_("no structure matched the given options")); + + /* Ensure the requested byte offset is inside the structure. */ + option = grub_strtol (state[FIRST_GETTER_OPT + field_type].arg, NULL, 0); + if (option < 0 || option >= structure[1]) + return grub_error (GRUB_ERR_OUT_OF_RANGE, + N_("the given offset is outside the structure")); + + /* Ensure the requested data type at the offset is inside the structure. */ + offset = (grub_uint8_t)option; + if (offset + field_extractors[field_type].field_length > structure[1]) + return grub_error (GRUB_ERR_OUT_OF_RANGE, + N_("the field ends outside the structure")); + + /* Format the requested structure field into a readable string. */ + value = field_extractors[field_type].format (structure, offset); + if (value == NULL) + return grub_error (GRUB_ERR_IO, + N_("failed to retrieve the structure field")); + + /* Store or print the formatted value. */ + if (state[SETTER_OPT].set) + grub_env_set (state[SETTER_OPT].arg, value); + else + grub_printf ("%s\n", value); + + return GRUB_ERR_NONE; +} + +GRUB_MOD_INIT(smbios) +{ + struct grub_smbios_eps3 *eps3; + struct grub_smbios_eps *eps; + + if ((eps3 = grub_smbios_get_eps3 ())) + { + table_desc.start = (grub_addr_t)eps3->table_address; + table_desc.end = table_desc.start + eps3->maximum_table_length; + table_desc.structures = 0; /* SMBIOS3 drops the structure count. */ + } + else if ((eps = grub_smbios_get_eps ())) + { + table_desc.start = (grub_addr_t)eps->intermediate.table_address; + table_desc.end = table_desc.start + eps->intermediate.table_length; + table_desc.structures = eps->intermediate.structures; + } + + cmd = grub_register_extcmd ("smbios", grub_cmd_smbios, 0, + N_("[-t type] [-h handle] [-m match] " + "(-b|-w|-d|-q|-s|-u) offset " + "[--set variable]"), + N_("Retrieve SMBIOS information."), options); +} + +GRUB_MOD_FINI(smbios) +{ + grub_unregister_extcmd (cmd); +} diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386/pc/cfgtables.c index 492c07c46..e5fffb7d4 100644 --- a/grub-core/efiemu/i386/pc/cfgtables.c +++ b/grub-core/efiemu/i386/pc/cfgtables.c @@ -22,11 +22,11 @@ #include #include #include +#include grub_err_t grub_machine_efiemu_init_tables (void) { - grub_uint8_t *ptr; void *table; grub_err_t err; grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID; @@ -57,17 +57,10 @@ grub_machine_efiemu_init_tables (void) if (err) return err; } - - for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; - ptr += 16) - if (grub_memcmp (ptr, "_SM_", 4) == 0 - && grub_byte_checksum (ptr, *(ptr + 5)) == 0) - break; - - if (ptr < (grub_uint8_t *) 0x100000) + table = grub_smbios_get_eps (); + if (table) { - grub_dprintf ("efiemu", "Registering SMBIOS\n"); - err = grub_efiemu_register_configuration_table (smbios, 0, 0, ptr); + err = grub_efiemu_register_configuration_table (smbios, 0, 0, table); if (err) return err; } diff --git a/include/grub/smbios.h b/include/grub/smbios.h new file mode 100644 index 000000000..15ec260b3 --- /dev/null +++ b/include/grub/smbios.h @@ -0,0 +1,69 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#ifndef GRUB_SMBIOS_HEADER +#define GRUB_SMBIOS_HEADER 1 + +#include +#include + +#define GRUB_SMBIOS_TYPE_END_OF_TABLE ((grub_uint8_t)127) + +struct grub_smbios_ieps +{ + grub_uint8_t anchor[5]; /* "_DMI_" */ + grub_uint8_t checksum; + grub_uint16_t table_length; + grub_uint32_t table_address; + grub_uint16_t structures; + grub_uint8_t revision; +} GRUB_PACKED; + +struct grub_smbios_eps +{ + grub_uint8_t anchor[4]; /* "_SM_" */ + grub_uint8_t checksum; + grub_uint8_t length; /* 0x1f */ + grub_uint8_t version_major; + grub_uint8_t version_minor; + grub_uint16_t maximum_structure_size; + grub_uint8_t revision; + grub_uint8_t formatted[5]; + struct grub_smbios_ieps intermediate; +} GRUB_PACKED; + +struct grub_smbios_eps3 +{ + grub_uint8_t anchor[5]; /* "_SM3_" */ + grub_uint8_t checksum; + grub_uint8_t length; /* 0x18 */ + grub_uint8_t version_major; + grub_uint8_t version_minor; + grub_uint8_t docrev; + grub_uint8_t revision; + grub_uint8_t reserved; + grub_uint32_t maximum_table_length; + grub_uint64_t table_address; +} GRUB_PACKED; + +extern struct grub_smbios_eps *grub_machine_smbios_get_eps (void); +extern struct grub_smbios_eps3 *grub_machine_smbios_get_eps3 (void); + +extern struct grub_smbios_eps *EXPORT_FUNC (grub_smbios_get_eps) (void); + +#endif /* ! GRUB_SMBIOS_HEADER */ From 15cfd02b74e862bda20626a6e4e2f8a1d201733a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 6 Jul 2019 11:11:02 +0200 Subject: [PATCH 1010/1167] lsefisystab: Add support for device tree table The device tree may passed by the firmware as UEFI configuration table. Let lsefisystab display a short text and not only the GUID for the device tree. Here is an example output: grub> lsefisystab Address: 0xbff694d8 Signature: 5453595320494249 revision: 00020046 Vendor: Das U-Boot, Version=20190700 2 tables: 0xbe741000 eb9d2d31-2d88-11d3-9a160090273fc14d SMBIOS 0x87f00000 b1b621d5-f19c-41a5-830bd9152c69aae0 DEVICE TREE Signed-off-by: Heinrich Schuchardt Reviewed-by: Leif Lindholm Reviewed-by: Daniel Kiper --- grub-core/commands/efi/lsefisystab.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index 7c039c509..902788250 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -40,6 +40,7 @@ static const struct guid_mapping guid_mappings[] = { GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID, "CRC32 GUIDED SECTION EXTRACTION"}, { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"}, + { GRUB_EFI_DEVICE_TREE_GUID, "DEVICE TREE"}, { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"}, { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}, { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"}, From 8f6843ce60b461d630439d07e577074c64511048 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 9 Jul 2019 17:46:25 +0200 Subject: [PATCH 1011/1167] configure: Add -fno-ident when available MinGW for i386-pc without this option generates a .rdata$zzz symbol that is page-aligned and hence lzma_decompress no longer fits in its allocated space. Additionally, MinGW with -fno-ident also saves a bit of space in modules. In case of other compilers we already strip the relevant sections, so, this option has no effect. More info can be found at https://github.com/msys2/MINGW-packages/issues/21 Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 23c555c26..e07ba4b56 100644 --- a/configure.ac +++ b/configure.ac @@ -999,6 +999,17 @@ if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" fi +# Do not generate .ident sections. +AC_CACHE_CHECK([whether -fno-ident works], [grub_cv_cc_fno_ident], [ + CFLAGS="$TARGET_CFLAGS -fno-ident" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_ident=yes], + [grub_cv_cc_fno_ident=no]) +]) + +if test "x$grub_cv_cc_fno_ident" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-ident" +fi CFLAGS="$TARGET_CFLAGS" From 4e75b2ae313b13b5bfb54cc5e5c53368d6eb2a08 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 18 Jul 2019 14:31:55 +0200 Subject: [PATCH 1012/1167] [PATCH] sparc64: Fix BIOS Boot Partition support Currently, gpt_offset is uninitialised when using a BIOS Boot Partition but is used unconditionally inside save_blocklists. Instead, ensure it is always initialised to 0 (note that there is already separate code to do the equivalent adjustment after we call save_blocklists on this code path). This patch has been tested on a T5-2 LDOM. Signed-off-by: James Clarke Tested-by: John Paul Adrian Glaubitz Reviewed-by: Vladimir Serbinenko Reviewed-by: Eric Snowberg --- util/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- util/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index 6f88f3cc4..3be88aae1 100644 --- a/util/setup.c +++ b/util/setup.c @@ -270,6 +270,9 @@ SETUP (const char *dir, #ifdef GRUB_SETUP_BIOS bl.current_segment = GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4); +#endif +#ifdef GRUB_SETUP_SPARC64 + bl.gpt_offset = 0; #endif bl.last_length = 0; @@ -730,7 +733,6 @@ unable_to_embed: #ifdef GRUB_SETUP_SPARC64 { grub_partition_t container = root_dev->disk->partition; - bl.gpt_offset = 0; if (grub_strstr (container->partmap->name, "gpt")) bl.gpt_offset = grub_partition_get_start (container); From 3ea9bc3c06f7b86ef4e478f376fba97e6352d823 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Wed, 21 Aug 2019 16:58:34 +0100 Subject: [PATCH 1013/1167] docs: Document newly introduced net_dhcp command Commit 5bc41db756c5 ("net/dhcp: Add explicit net_dhcp command") introduced the new command "net_dhcp", which (for now) is an alias for the existing "net_bootp". Unfortunately the TEXI documentation was not adjusted accordingly. Rename the existing paragraph about net_bootp to read net_dhcp instead, and make the net_bootp stanza point to this new command. On the way add the newly parsed TFTP_SERVER_NAME and BOOTFILE_NAME packets to the list of supported DHCP options. Fixes bug: https://savannah.gnu.org/bugs/?56725 Reported-by: Heinrich Schuchardt Signed-off-by: Andre Przywara Reviewed-by: Daniel Kiper --- docs/grub.texi | 71 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 3d50b16ba..5ac61c09d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5365,10 +5365,11 @@ This command is only available on AArch64 systems. * net_add_addr:: Add a network address * net_add_dns:: Add a DNS server * net_add_route:: Add routing entry -* net_bootp:: Perform a bootp autoconfiguration +* net_bootp:: Perform a bootp/DHCP autoconfiguration * net_del_addr:: Remove IP address from interface * net_del_dns:: Remove a DNS server * net_del_route:: Remove a route entry +* net_dhcp:: Perform a DHCP autoconfiguration * net_get_dhcp_option:: Retrieve DHCP options * net_ipv6_autoconf:: Perform IPv6 autoconfiguration * net_ls_addr:: List interfaces @@ -5415,8 +5416,44 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}). @subsection net_bootp @deffn Command net_bootp [@var{card}] +Alias for net_dhcp, for compatibility with older Grub versions. Will perform +the same DHCP handshake with potential fallback to BOOTP as the net_dhcp +command (@pxref{net_dhcp}). + +@end deffn + + +@node net_del_addr +@subsection net_del_addr + +@deffn Command net_del_addr @var{interface} +Remove configured @var{interface} with associated address. +@end deffn + + +@node net_del_dns +@subsection net_del_dns + +@deffn Command net_del_dns @var{address} +Remove @var{address} from list of servers used during name lookup. +@end deffn + + +@node net_del_route +@subsection net_del_route + +@deffn Command net_del_route @var{shortname} +Remove route entry identified by @var{shortname}. +@end deffn + + +@node net_dhcp +@subsection net_dhcp + +@deffn Command net_dhcp [@var{card}] Perform configuration of @var{card} using DHCP protocol. If no card name -is specified, try to configure all existing cards. If configuration was +is specified, try to configure all existing cards. +Falls back to the BOOTP protocol, if needed. If configuration was successful, interface with name @var{card}@samp{:dhcp} and configured address is added to @var{card}. @comment If server provided gateway information in @@ -5443,35 +5480,17 @@ Sets environment variable @samp{net_}@var{}@samp{_dhcp_rootpath} @item 18 (Extensions Path) Sets environment variable @samp{net_}@var{}@samp{_dhcp_extensionspath} (@pxref{net_@var{}_extensionspath}) to the value of option. +@item 66 (TFTP Server Name) +Sets environment variable @samp{net_}@var{}@samp{_dhcp_server_name} +(@pxref{net_@var{}_dhcp_server_name}) to the value of option. +@item 67 (Filename) +Sets environment variable @samp{net_}@var{}@samp{_boot_file} +(@pxref{net_@var{}_boot_file}) to the value of option. @end table @end deffn -@node net_del_addr -@subsection net_del_addr - -@deffn Command net_del_addr @var{interface} -Remove configured @var{interface} with associated address. -@end deffn - - -@node net_del_dns -@subsection net_del_dns - -@deffn Command net_del_dns @var{address} -Remove @var{address} from list of servers used during name lookup. -@end deffn - - -@node net_del_route -@subsection net_del_route - -@deffn Command net_del_route @var{shortname} -Remove route entry identified by @var{shortname}. -@end deffn - - @node net_get_dhcp_option @subsection net_get_dhcp_option From fc085f7f1860cb864aa61bb3f248a970565a9055 Mon Sep 17 00:00:00 2001 From: Gustavo Luiz Duarte Date: Tue, 17 Sep 2019 17:44:58 +0200 Subject: [PATCH 1014/1167] net: Fix crash on http Don't free file->data on receiving FIN flag since it is used all over without checking. http_close() will be called later to free that memory. Fixes bug: https://bugzilla.redhat.com/show_bug.cgi?id=860834 Signed-off-by: Gustavo Luiz Duarte Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- grub-core/net/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c index 5aa4ad3be..ec3647f9a 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -392,7 +392,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) data->sock = grub_net_tcp_open (file->device->net->server, HTTP_PORT, http_receive, - http_err, http_err, + http_err, NULL, file); if (!data->sock) { From ab2e53c8a196a595e50f1c836bf756b9db1ae68d Mon Sep 17 00:00:00 2001 From: Marcel Kolaja Date: Tue, 17 Sep 2019 17:47:36 +0200 Subject: [PATCH 1015/1167] grub-mkconfig: Honor a symlink when generating configuration by grub-mkconfig Honor a symlink when generating configuration by grub-mkconfig, so that the -o option follows it rather than overwriting it with a regular file. Signed-off-by: Marcel Kolaja Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- util/grub-mkconfig.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 9f477ff05..523d4e029 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -287,7 +287,8 @@ and /etc/grub.d/* files or please file a bug report with exit 1 else # none of the children aborted with error, install the new grub.cfg - mv -f ${grub_cfg}.new ${grub_cfg} + cat ${grub_cfg}.new > ${grub_cfg} + rm -f ${grub_cfg}.new fi fi From f9e28d250a76a73041663616a9e660d8f7f3ac11 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 17 Sep 2019 17:50:58 +0200 Subject: [PATCH 1016/1167] gitattributes: Mark po/exclude.pot as binary so git won't try to diff nonprintables Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..33ffaa404 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +po/exclude.pot binary From a57977b5faf800ac68f7dfe6b84138208c7e6072 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 19 Sep 2019 09:39:04 +0200 Subject: [PATCH 1017/1167] RISC-V: Add __clzdi2 symbol This is needed for the zstd module build for riscv64-emu. Signed-off-by: Andreas Schwab Reviewed-by: Daniel Kiper --- configure.ac | 2 +- include/grub/compiler-rt-emu.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e07ba4b56..7d74eba66 100644 --- a/configure.ac +++ b/configure.ac @@ -1370,7 +1370,7 @@ fi # Check for libgcc symbols if test x"$platform" = xemu; then -AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) +AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) fi if test "x$TARGET_APPLE_LINKER" = x1 ; then diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h index b21425d9e..fde620ac1 100644 --- a/include/grub/compiler-rt-emu.h +++ b/include/grub/compiler-rt-emu.h @@ -74,6 +74,11 @@ unsigned EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); #endif +#ifdef HAVE___CLZDI2 +int +EXPORT_FUNC (__clzdi2) (grub_uint64_t x); +#endif + #ifdef HAVE___AEABI_UIDIV grub_uint32_t EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); From 11268841e2e0130a862d15fce86d42cd6501bb49 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 15 Aug 2019 16:55:13 +0200 Subject: [PATCH 1018/1167] grub-install: Define default platform for RISC-V Signed-off-by: Andreas Schwab Reviewed-by: Daniel Kiper Reviewed-by: Alexander Graf --- util/grub-install.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/grub-install.c b/util/grub-install.c index 8a55ad4b8..8970b73aa 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -324,6 +324,14 @@ get_default_platform (void) return "arm64-efi"; #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) return grub_install_get_default_x86_platform (); +#elif defined (__riscv) +#if __riscv_xlen == 32 + return "riscv32-efi"; +#elif __riscv_xlen == 64 + return "riscv64-efi"; +#else + return NULL; +#endif #else return NULL; #endif From ff3e91be9cc3d6f040a7f47fac0db1c93f80a9a8 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 23 Aug 2019 12:00:30 +0100 Subject: [PATCH 1019/1167] grub-mkconfig: Fix typo in --help output The short form of "--version" that grub-mkconfig accepts is "-V", not "-v". Fixes Debian bug #935504. Signed-off-by: Colin Watson Reviewed-by: Vladimir 'phcoder' Serbinenko Reviewed-by: Daniel Kiper --- util/grub-mkconfig.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 523d4e029..a6ce375ed 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -59,7 +59,7 @@ usage () { echo print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" echo gettext "Report bugs to ."; echo } From c7cb11b2198a07098143ecc67b19497ba25df28f Mon Sep 17 00:00:00 2001 From: Nicholas Vinson Date: Mon, 30 Sep 2019 08:27:59 -0400 Subject: [PATCH 1020/1167] probe: Support probing for msdos PARTUUID Extend partition UUID probing support in GRUB core to display pseudo partition UUIDs for MBR (MSDOS) partitions. Signed-off-by: Nicholas Vinson Reviewed-by: Daniel Kiper --- grub-core/commands/probe.c | 43 +++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index d2e7f662e..573bdf603 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -32,6 +32,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -104,26 +105,40 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) { /* AAAABBBB-CCCC-DDDD-EEEE-FFFFFFFFFFFF + null terminator */ char val[37] = "none"; - if (dev->disk && dev->disk->partition && - grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) + if (dev->disk && dev->disk->partition) { - struct grub_gpt_partentry entry; struct grub_partition *p = dev->disk->partition; grub_disk_t disk = grub_disk_open(dev->disk->name); + if (!disk) return grub_errno; - if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry)) - return grub_errno; + if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) + { + struct grub_gpt_partentry entry; + grub_gpt_part_guid_t *guid; + + if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry)) + return grub_errno; + guid = &entry.guid; + grub_snprintf (val, sizeof(val), + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + grub_le_to_cpu32 (guid->data1), + grub_le_to_cpu16 (guid->data2), + grub_le_to_cpu16 (guid->data3), + guid->data4[0], guid->data4[1], guid->data4[2], + guid->data4[3], guid->data4[4], guid->data4[5], + guid->data4[6], guid->data4[7]); + } + else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0) + { + grub_uint32_t nt_disk_sig; + + if (grub_disk_read(disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + sizeof(nt_disk_sig), &nt_disk_sig) == 0) + grub_snprintf (val, sizeof(val), "%08x-%02x", + grub_le_to_cpu32(nt_disk_sig), 1 + p->number); + } grub_disk_close(disk); - grub_gpt_part_guid_t *guid = &entry.guid; - grub_snprintf (val, sizeof(val), - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - grub_le_to_cpu32 (guid->data1), - grub_le_to_cpu16 (guid->data2), - grub_le_to_cpu16 (guid->data3), - guid->data4[0], guid->data4[1], guid->data4[2], - guid->data4[3], guid->data4[4], guid->data4[5], - guid->data4[6], guid->data4[7]); } if (state[0].set) grub_env_set (state[0].arg, val); From ee4bd79ef28e6fa4a68bb51c31a5e67a7cbf01ea Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Mon, 30 Sep 2019 17:00:16 +0200 Subject: [PATCH 1021/1167] templates: Fix bad test on GRUB_DISABLE_SUBMENU The GRUB_DISABLE_SUBMENU option is different than the others in the sense that it has to be set to "y" instead of "true" to be enabled. That causes a lot of confusion to users, some may wrongly set it to "true" expecting that will work the same than with most options, and some may set it to "yes" since for other options the value to set is a word and not a single character. This patch changes all the grub.d scripts using the GRUB_DISABLE_SUBMENU option, so they check if it was set to "true" instead of "y", making it consistent with all the other options. But to keep backward compatibility for users that set the option to "y" in /etc/default/grub file, keep testing for this value. And also do it for "yes", since it is a common mistake made by users caused by this option being inconsistent with the others. Signed-off-by: Prarit Bhargava Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- docs/grub.texi | 2 +- util/grub.d/10_hurd.in | 10 +++++++++- util/grub.d/10_kfreebsd.in | 10 +++++++++- util/grub.d/10_linux.in | 10 +++++++++- util/grub.d/10_netbsd.in | 10 +++++++++- util/grub.d/20_linux_xen.in | 10 +++++++++- util/grub.d/30_os-prober.in | 10 +++++++++- 7 files changed, 55 insertions(+), 7 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 5ac61c09d..d788efe44 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1495,7 +1495,7 @@ Normally, @command{grub-mkconfig} will generate top level menu entry for the kernel with highest version number and put all other found kernels or alternative menu entries for recovery mode in submenu. For entries returned by @command{os-prober} first entry will be put on top level and all others -in submenu. If this option is set to @samp{y}, flat menu with all entries +in submenu. If this option is set to @samp{true}, flat menu with all entries on top level will be generated instead. Changing this option will require changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback}) and @samp{default} (@pxref{default}) environment variables as well as saved diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 59a9a48a2..3663d360e 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -156,7 +156,15 @@ is_top_level=true while [ "x$kernels" != "x" ] ; do kernel=`version_find_latest $kernels` - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then hurd_entry "$kernel" simple submenu_indentation="$grub_tab" diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index 9d8e8fd85..199b20e16 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -214,7 +214,15 @@ while [ "x$list" != "x" ] ; do module_dir_rel=$(make_system_path_relative_to_its_root $module_dir) fi - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then kfreebsd_entry "${OS}" "${version}" simple submenu_indentation="$grub_tab" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 4532266be..e8b01c0d0 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -261,7 +261,15 @@ while [ "x$list" != "x" ] ; do fi fi - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then linux_entry "${OS}" "${version}" simple \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 874f59969..dc0cd1b17 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -157,7 +157,15 @@ for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do gettext_printf "Found NetBSD kernel: %s\n" "$k" >&2 - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then netbsd_entry "knetbsd" "$k" simple "${GRUB_CMDLINE_NETBSD_DEFAULT}" submenu_indentation="$grub_tab" diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 96179ea61..391942a59 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -288,7 +288,15 @@ while [ "x${xen_list}" != "x" ] ; do fi fi - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then linux_entry "${OS}" "${version}" "${xen_version}" simple \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 515a68c7a..cf42f55e8 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -234,7 +234,15 @@ EOF prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)" fi - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + # The GRUB_DISABLE_SUBMENU option used to be different than others since it was + # mentioned in the documentation that has to be set to 'y' instead of 'true' to + # enable it. This caused a lot of confusion to users that set the option to 'y', + # 'yes' or 'true'. This was fixed but all of these values must be supported now. + if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = xy ]; then + GRUB_DISABLE_SUBMENU="true" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then cat << EOF menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { EOF From 33203ca3484717712b54e199c46ae8a818374284 Mon Sep 17 00:00:00 2001 From: Michael Bideau Date: Wed, 2 Oct 2019 23:48:10 +0200 Subject: [PATCH 1022/1167] at_keyboard: Fix unreliable key presses This patch fixes an issue that prevented the at_keyboard module to work (for me). The cause was a bad/wrong return value in the grub_at_keyboard_getkey() function in grub-core/term/at_keyboard.c file at line 237. My symptoms were to have an unresponsive keyboard. Keys needed to be pressed 10x and more to effectively be printed sometimes generating multiple key presses (after 1 or 2 sec of no printing). It was very problematic when typing passphrase in early stage (with GRUB_ENABLE_CRYPTODISK). When switched to "console" terminal input keyboard worked perfectly. It also worked great with the GRUB 2.02 packaged by Debian (2.02+dfsg1-20). It was not an output issue but an input one. I've managed to analyze the issue and found that it came from the commit 216950a4e (at_keyboard: Split protocol from controller code.). Three lines where moved from the fetch_key() function in grub-core/term/at_keyboard.c file to the beginning of grub_at_keyboard_getkey() function (same file). However, returning -1 made sense when it happened in fetch_key() function but not anymore in grub_at_keyboard_getkey() function which should return GRUB_TERM_NO_KEY. I think it was just an incomplete cut-paste missing a small manual correction. Let's fix it. Note: Commit message updated by Daniel Kiper. Signed-off-by: Michael Bideau Reviewed-by: Daniel Kiper --- grub-core/term/at_keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index f0a986eb1..597111077 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -234,7 +234,7 @@ grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) return GRUB_TERM_NO_KEY; if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) - return -1; + return GRUB_TERM_NO_KEY; at_key = grub_inb (KEYBOARD_REG_DATA); old_led = ps2_state.led_status; From b78d570a3656c0e70be1dbe5b908c08467603e4e Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 22 Oct 2019 10:44:28 +0200 Subject: [PATCH 1023/1167] templates: Add GRUB_DISABLE_UUID The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to set the root kernel command line parameter and the $root GRUB environment variable. The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable to "true", but there is currently no way to disable the latter. The generated grub config uses the search command with the --fs-uuid option to find the device that has to be set as $root, i.e: search --no-floppy --fs-uuid --set=root ... This is usually more reliable but in some cases it may not be appropriate, so this patch introduces a new GRUB_DISABLE_UUID variable that can be used to disable searching for the $root device by filesystem UUID. When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=compatibility_hint option. When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false". That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux. Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper Reviewed-by: Nicholas Vinson --- docs/grub.texi | 9 +++++++++ util/grub-mkconfig.in | 10 ++++++++++ util/grub-mkconfig_lib.in | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index d788efe44..c25ab7a5f 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option to @samp{false}. If this option is set to @samp{true}, disable the generation of recovery mode menu entries. +@item GRUB_DISABLE_UUID +Normally, @command{grub-mkconfig} will generate menu entries that use +universally-unique identifiers (UUIDs) to identify various filesystems to +search for files. This is usually more reliable, but in some cases it may +not be appropriate. To disable this use of UUIDs, set this option to +@samp{true}. Setting this option to @samp{true}, will also set the options +@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to +@samp{true}, unless they have been explicilty set to @samp{false}. + @item GRUB_VIDEO_BACKEND If graphical video support is required, either because the @samp{gfxterm} graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index a6ce375ed..d3e879b8e 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi +if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then + if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then + GRUB_DISABLE_LINUX_UUID="true" + fi + if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then + GRUB_DISABLE_LINUX_PARTUUID="true" + fi +fi + # XXX: should this be deprecated at some point? if [ "x${GRUB_TERMINAL}" != "x" ] ; then GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}" @@ -224,6 +233,7 @@ export GRUB_DEFAULT \ GRUB_TERMINAL_INPUT \ GRUB_TERMINAL_OUTPUT \ GRUB_SERIAL_COMMAND \ + GRUB_DISABLE_UUID \ GRUB_DISABLE_LINUX_UUID \ GRUB_DISABLE_LINUX_PARTUUID \ GRUB_DISABLE_RECOVERY \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 0f801cab3..3e12b2c0e 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -156,7 +156,7 @@ prepare_grub_to_access_device () if [ "x$fs_hint" != x ]; then echo "set root='$fs_hint'" fi - if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then + if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= echo "if [ x\$feature_platform_search_hint = xy ]; then" echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" @@ -173,7 +173,7 @@ grub_get_device_id () IFS=' ' device="$1" - if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then + if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then echo "$fs_uuid"; else echo $device |sed 's, ,_,g' From 28a7e597de0d5584f65e36f9588ff9041936e617 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 16 Oct 2019 23:03:06 -0400 Subject: [PATCH 1024/1167] grub-mkconfig: Use portable "command -v" to detect installed programs The "which" utility is not guaranteed to be installed either, and if it is, its behavior is not portable either. Conversely, the "command -v" shell builtin is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere. Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 11-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh. A side benefit of using the POSIX portable option is that it requires neither an external disk executable, nor (because unlike "which", the exit code is reliable) a subshell fork. This therefore represents a mild speedup. Signed-off-by: Eli Schwartz Reviewed-by: Daniel Kiper --- util/grub-mkconfig_lib.in | 2 +- util/grub.d/30_os-prober.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 3e12b2c0e..2d80f14bf 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -34,7 +34,7 @@ if test "x$grub_mkrelpath" = x; then grub_mkrelpath="${bindir}/@grub_mkrelpath@" fi -if which gettext >/dev/null 2>/dev/null; then +if command -v gettext >/dev/null; then : else gettext () { diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index cf42f55e8..1b91c102f 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -30,7 +30,7 @@ if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then exit 0 fi -if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then +if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/null ; then # missing os-prober and/or linux-boot-prober exit 0 fi From 42acdd3b405c44d08439a3bbfdbd3466049d172d Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 5 Nov 2019 09:19:26 +0000 Subject: [PATCH 1025/1167] hostdisk: Set linux file descriptor to O_CLOEXEC as default We are often bothered by this sort of lvm warning while running grub-install every now and then: File descriptor 4 (/dev/vda1) leaked on vgs invocation. Parent PID 1991: /usr/sbin/grub2-install The requirement related to the warning is dictated in the lvm man page: "On invocation, lvm requires that only the standard file descriptors stdin, stdout and stderr are available. If others are found, they get closed and messages are issued warning about the leak. This warning can be suppressed by setting the environment variable LVM_SUPPRESS_FD_WARNINGS." While it could be disabled through settings, most Linux distributions seem to enable it by default and the justification provided by the developer looks to be valid to me: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466138#15 Rather than trying to close and reopen the file descriptor to the same file multiple times, which is rather cumbersome, for the sake of no vgs invocation could happen in between. This patch enables the close-on-exec flag (O_CLOEXEC) for new file descriptor returned by the open() system call, making it closed thus not inherited by the child process forked and executed by the exec() family of functions. Fixes Debian bug #466138. Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/osdep/linux/hostdisk.c | 3 +++ grub-core/osdep/unix/hostdisk.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 8b92f8528..da62f924e 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -366,6 +366,9 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f #ifdef O_BINARY flags |= O_BINARY; #endif +#ifdef O_CLOEXEC + flags |= O_CLOEXEC; +#endif /* Linux has a bug that the disk cache for a whole disk is not consistent with the one for a partition of the disk. */ diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index 91150969b..3a00d7451 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -164,6 +164,9 @@ grub_util_fd_open (const char *os_dev, int flags) #ifdef O_BINARY flags |= O_BINARY; #endif +#ifdef O_CLOEXEC + flags |= O_CLOEXEC; +#endif return open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR); } From 5e5a15872d9e5e7d62a38de426aa35f2b91c2140 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 5 Nov 2019 09:20:22 +0000 Subject: [PATCH 1026/1167] grub-editenv: Warn a user against editing environment block The environment block is a preallocated 1024-byte file which serves as persistent storage for environment variables. It has its own format which is sensitive to corruption if an editor does not know how to process it. Besides that the editor may inadvertently change grubenv file size and/or make it sparse which can lead to unexpected results. This patch adds a message to the grubenv file to warn a user against editing it by tools other than grub-editenv. Signed-off-by: Michael Chang Reviewed-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- util/editenv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/util/editenv.c b/util/editenv.c index eb2d0c03a..81f68bd10 100644 --- a/util/editenv.c +++ b/util/editenv.c @@ -30,13 +30,13 @@ #include #define DEFAULT_ENVBLK_SIZE 1024 +#define GRUB_ENVBLK_MESSAGE "# WARNING: Do not edit this file by tools other than "PACKAGE"-editenv!!!\n" void grub_util_create_envblk_file (const char *name) { FILE *fp; - char *buf; - char *namenew; + char *buf, *pbuf, *namenew; buf = xmalloc (DEFAULT_ENVBLK_SIZE); @@ -46,9 +46,13 @@ grub_util_create_envblk_file (const char *name) grub_util_error (_("cannot open `%s': %s"), namenew, strerror (errno)); - memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1); - memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#', - DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1); + pbuf = buf; + memcpy (pbuf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1); + pbuf += sizeof (GRUB_ENVBLK_SIGNATURE) - 1; + memcpy (pbuf, GRUB_ENVBLK_MESSAGE, sizeof (GRUB_ENVBLK_MESSAGE) - 1); + pbuf += sizeof (GRUB_ENVBLK_MESSAGE) - 1; + memset (pbuf , '#', + DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) - sizeof (GRUB_ENVBLK_MESSAGE) + 2); if (fwrite (buf, 1, DEFAULT_ENVBLK_SIZE, fp) != DEFAULT_ENVBLK_SIZE) grub_util_error (_("cannot write to `%s': %s"), namenew, From e2c09aed97e8e71efa083e21ef365c92c36e3185 Mon Sep 17 00:00:00 2001 From: Lenny Szubowicz Date: Thu, 31 Oct 2019 11:33:39 +0100 Subject: [PATCH 1027/1167] tftp: Normalize slashes in TFTP paths Some TFTP servers do not handle multiple consecutive slashes correctly. This patch avoids sending TFTP requests with non-normalized paths. Signed-off-by: Lenny Szubowicz Signed-off-by: Mark Salter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- grub-core/net/tftp.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 7d90bf66e..b26d2ed7a 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -300,6 +300,26 @@ destroy_pq (tftp_data_t data) grub_priority_queue_destroy (data->pq); } +/* + * Create a normalized copy of the filename. Compress any string of consecutive + * forward slashes to a single forward slash. + */ +static void +grub_normalize_filename (char *normalized, const char *filename) +{ + char *dest = normalized; + const char *src = filename; + + while (*src != '\0') + { + if (src[0] == '/' && src[1] == '/') + src++; + else + *dest++ = *src++; + } + *dest = '\0'; +} + static grub_err_t tftp_open (struct grub_file *file, const char *filename) { @@ -337,9 +357,14 @@ tftp_open (struct grub_file *file, const char *filename) rrqlen = 0; tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); - grub_strcpy (rrq, filename); - rrqlen += grub_strlen (filename) + 1; - rrq += grub_strlen (filename) + 1; + + /* + * Copy and normalize the filename to work-around issues on some TFTP + * servers when file names are being matched for remapping. + */ + grub_normalize_filename (rrq, filename); + rrqlen += grub_strlen (rrq) + 1; + rrq += grub_strlen (rrq) + 1; grub_strcpy (rrq, "octet"); rrqlen += grub_strlen ("octet") + 1; From 495781f5ed1b48bf27f16c53940d6700c181c74c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 4 Nov 2019 17:23:22 +0100 Subject: [PATCH 1028/1167] btrfs: Add support for new RAID1C34 profiles New 3- and 4-copy variants of RAID1 were merged into Linux kernel 5.5. Add the two new profiles to the list of recognized ones. As this builds on the same code as RAID1, only the redundancy level needs to be adjusted, the rest is done by the existing code. Signed-off-by: David Sterba Reviewed-by: Daniel Kiper --- grub-core/fs/btrfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 48bd3d04a..63f9657a6 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -136,6 +136,8 @@ struct grub_btrfs_chunk_item #define GRUB_BTRFS_CHUNK_TYPE_RAID10 0x40 #define GRUB_BTRFS_CHUNK_TYPE_RAID5 0x80 #define GRUB_BTRFS_CHUNK_TYPE_RAID6 0x100 +#define GRUB_BTRFS_CHUNK_TYPE_RAID1C3 0x200 +#define GRUB_BTRFS_CHUNK_TYPE_RAID1C4 0x400 grub_uint8_t dummy2[0xc]; grub_uint16_t nstripes; grub_uint16_t nsubstripes; @@ -964,14 +966,19 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, csize = (stripen + 1) * stripe_length - off; break; } + case GRUB_BTRFS_CHUNK_TYPE_RAID1C4: + redundancy++; + /* fall through */ + case GRUB_BTRFS_CHUNK_TYPE_RAID1C3: + redundancy++; + /* fall through */ case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED: case GRUB_BTRFS_CHUNK_TYPE_RAID1: { - grub_dprintf ("btrfs", "RAID1\n"); + grub_dprintf ("btrfs", "RAID1 (copies: %d)\n", ++redundancy); stripen = 0; stripe_offset = off; csize = grub_le_to_cpu64 (chunk->size) - off; - redundancy = 2; break; } case GRUB_BTRFS_CHUNK_TYPE_RAID0: From b53a2f2c66dd249233a25112da38c5b526d86c82 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Mon, 2 Dec 2019 18:29:39 +0100 Subject: [PATCH 1029/1167] loader/i386/linux: Fix an underflow in the setup_header length calculation Recent work around x86 Linux kernel loader revealed an underflow in the setup_header length calculation and another related issue. Both lead to the memory overwrite and later machine crash. Currently when the GRUB copies the setup_header into the linux_params (struct boot_params, traditionally known as "zero page") it assumes the setup_header size as sizeof(linux_i386_kernel_header/lh). This is incorrect. It should use the value calculated accordingly to the Linux kernel boot protocol. Otherwise in case of pretty old kernel, to be exact Linux kernel boot protocol, the GRUB may write more into linux_params than it was expected to. Fortunately this is not very big issue. Though it has to be fixed. However, there is also an underflow which is grave. It happens when sizeof(linux_i386_kernel_header/lh) > "real size of the setup_header". Then len value wraps around and grub_file_read() reads whole kernel into the linux_params overwriting memory past it. This leads to the GRUB memory allocator breakage and finally to its crash during boot. The patch fixes both issues. Additionally, it moves the code not related to grub_memset(linux_params)/grub_memcpy(linux_params)/grub_file_read(linux_params) section outside of it to not confuse the reader. Fixes: e683cfb0cf5 (loader/i386/linux: Calculate the setup_header length) Signed-off-by: Daniel Kiper Reviewed-by: Javier Martinez Canillas Reviewed-by: Ross Philipson Reviewed-by: Krystian Hebel --- grub-core/loader/i386/linux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index d0501e229..ee95cd374 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -761,17 +761,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; grub_memset (&linux_params, 0, sizeof (linux_params)); - grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1); - - linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR; - linux_params.kernel_alignment = (1 << align); - linux_params.ps_mouse = linux_params.padding10 = 0; /* * The Linux 32-bit boot protocol defines the setup header end * to be at 0x202 + the byte value at 0x201. */ - len = 0x202 + *((char *) &linux_params.jump + 1); + len = 0x202 + *((char *) &lh.jump + 1); /* Verify the struct is big enough so we do not write past the end. */ if (len > (char *) &linux_params.edd_mbr_sig_buffer - (char *) &linux_params) { @@ -779,10 +774,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } + grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, len - 0x1F1); + /* We've already read lh so there is no need to read it second time. */ len -= sizeof(lh); - if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) + if ((len > 0) && + (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len)) { if (!grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), @@ -790,6 +788,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } + linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR; + linux_params.kernel_alignment = (1 << align); + linux_params.ps_mouse = linux_params.padding10 = 0; linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; /* These two are used (instead of cmd_line_ptr) by older versions of Linux, From 7e28ca82bbc85a89ab7c976cd7580a8daa259846 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Tue, 10 Dec 2019 13:04:05 +0100 Subject: [PATCH 1030/1167] docs: Export "superusers" variable to apply to submenus Signed-off-by: Paul Menzel Reviewed-by: Daniel Kiper --- docs/grub.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index c25ab7a5f..08d699d49 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5717,7 +5717,8 @@ the GRUB command line, edit menu entries, and execute any menu entry. If @samp{superusers} is set, then use of the command line and editing of menu entries are automatically restricted to superusers. Setting @samp{superusers} to empty string effectively disables both access to CLI and editing of menu -entries. +entries. Note: The environment variable needs to be exported to also affect +the section defined by the @samp{submenu} command (@pxref{submenu}). Other users may be allowed to execute specific menu entries by giving a list of usernames (as above) using the @option{--users} option to the From 0f3f5b7c13fa9b677a64cf11f20eca0f850a2b20 Mon Sep 17 00:00:00 2001 From: Lukasz Hawrylko Date: Mon, 16 Dec 2019 11:15:55 +0100 Subject: [PATCH 1031/1167] multiboot2: Set min address for mbi allocation to 0x1000 In some cases GRUB2 allocates multiboot2 structure at 0 address, that is a confusing behavior. Consumers of that structure can have internal NULL-checks that will throw an error when get a pointer to data allocated at address 0. To prevent that, define min address for mbi allocation on x86 and x86_64 platforms. Signed-off-by: Lukasz Hawrylko Reviewed-by: Daniel Kiper --- grub-core/loader/multiboot_mbi2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 53da78615..18e766c7b 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -48,6 +48,12 @@ #define HAS_VGA_TEXT 0 #endif +#if defined (__i386__) || defined (__x86_64__) +#define MBI_MIN_ADDR 0x1000 +#else +#define MBI_MIN_ADDR 0 +#endif + struct module { struct module *next; @@ -708,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target) COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, - 0, 0xffffffff - bufsize, + MBI_MIN_ADDR, 0xffffffff - bufsize, bufsize, MULTIBOOT_TAG_ALIGN, GRUB_RELOCATOR_PREFERENCE_NONE, 1); if (err) From 528938d503088ce0e2fe7d83f8f711efefaed0fd Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:34 +0100 Subject: [PATCH 1032/1167] json: Import upstream jsmn-1.1.0 The upcoming support for LUKS2 encryption will require a JSON parser to decode all parameters required for decryption of a drive. As there is currently no other tool that requires JSON, and as gnulib does not provide a parser, we need to introduce a new one into the code base. The backend for the JSON implementation is going to be the jsmn library [1]. It has several benefits that make it a very good fit for inclusion in GRUB: - It is licensed under MIT. - It is written in C89. - It has no dependencies, not even libc. - It is small with only about 500 lines of code. - It doesn't do any dynamic memory allocation. - It is testen on x86, amd64, ARM and AVR. The library itself comes as a single header, only, that contains both declarations and definitions. The exposed interface is kind of simplistic, though, and does not provide any convenience features whatsoever. Thus there will be a separate interface provided by GRUB around this parser that is going to be implemented in the following commit. This change only imports jsmn.h from tag v1.1.0 and adds it unmodified to a new json module with the following command: curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \ -o grub-core/lib/json/jsmn.h Upstream jsmn commit hash: fdcef3ebf886fa210d14956d3c068a653e76a24e Upstream jsmn commit name: Modernize (#149), 2019-04-20 [1]: https://github.com/zserge/jsmn Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- docs/grub-dev.texi | 14 ++ grub-core/Makefile.core.def | 5 + grub-core/lib/json/jsmn.h | 468 ++++++++++++++++++++++++++++++++++++ grub-core/lib/json/json.c | 23 ++ 4 files changed, 510 insertions(+) create mode 100644 grub-core/lib/json/jsmn.h create mode 100644 grub-core/lib/json/json.c diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index ee389fd83..df2350be0 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -490,6 +490,7 @@ to update it. @menu * Gnulib:: +* jsmn:: @end menu @node Gnulib @@ -545,6 +546,19 @@ AC_SYS_LARGEFILE @end example +@node jsmn +@section jsmn + +jsmn is a minimalistic JSON parser which is implemented in a single header file +@file{jsmn.h}. To import a different version of the jsmn parser, you may simply +download the @file{jsmn.h} header from the desired tag or commit to the target +directory: + +@example +curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \ + -o grub-core/lib/json/jsmn.h +@end example + @node Porting @chapter Porting diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 269370417..037de4023 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1176,6 +1176,11 @@ module = { common = disk/cryptodisk.c; }; +module = { + name = json; + common = lib/json/json.c; +}; + module = { name = luks; common = disk/luks.c; diff --git a/grub-core/lib/json/jsmn.h b/grub-core/lib/json/jsmn.h new file mode 100644 index 000000000..b95368a20 --- /dev/null +++ b/grub-core/lib/json/jsmn.h @@ -0,0 +1,468 @@ +/* + * MIT License + * + * Copyright (c) 2010 Serge Zaitsev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef JSMN_H +#define JSMN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef JSMN_STATIC +#define JSMN_API static +#else +#define JSMN_API extern +#endif + +/** + * JSON type identifier. Basic types are: + * o Object + * o Array + * o String + * o Other primitive: number, boolean (true/false) or null + */ +typedef enum { + JSMN_UNDEFINED = 0, + JSMN_OBJECT = 1, + JSMN_ARRAY = 2, + JSMN_STRING = 3, + JSMN_PRIMITIVE = 4 +} jsmntype_t; + +enum jsmnerr { + /* Not enough tokens were provided */ + JSMN_ERROR_NOMEM = -1, + /* Invalid character inside JSON string */ + JSMN_ERROR_INVAL = -2, + /* The string is not a full JSON packet, more bytes expected */ + JSMN_ERROR_PART = -3 +}; + +/** + * JSON token description. + * type type (object, array, string etc.) + * start start position in JSON data string + * end end position in JSON data string + */ +typedef struct { + jsmntype_t type; + int start; + int end; + int size; +#ifdef JSMN_PARENT_LINKS + int parent; +#endif +} jsmntok_t; + +/** + * JSON parser. Contains an array of token blocks available. Also stores + * the string being parsed now and current position in that string. + */ +typedef struct { + unsigned int pos; /* offset in the JSON string */ + unsigned int toknext; /* next token to allocate */ + int toksuper; /* superior token node, e.g. parent object or array */ +} jsmn_parser; + +/** + * Create JSON parser over an array of tokens + */ +JSMN_API void jsmn_init(jsmn_parser *parser); + +/** + * Run JSON parser. It parses a JSON data string into and array of tokens, each + * describing + * a single JSON object. + */ +JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, + jsmntok_t *tokens, const unsigned int num_tokens); + +#ifndef JSMN_HEADER +/** + * Allocates a fresh unused token from the token pool. + */ +static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, + const size_t num_tokens) { + jsmntok_t *tok; + if (parser->toknext >= num_tokens) { + return NULL; + } + tok = &tokens[parser->toknext++]; + tok->start = tok->end = -1; + tok->size = 0; +#ifdef JSMN_PARENT_LINKS + tok->parent = -1; +#endif + return tok; +} + +/** + * Fills token type and boundaries. + */ +static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type, + const int start, const int end) { + token->type = type; + token->start = start; + token->end = end; + token->size = 0; +} + +/** + * Fills next available token with JSON primitive. + */ +static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, + const size_t len, jsmntok_t *tokens, + const size_t num_tokens) { + jsmntok_t *token; + int start; + + start = parser->pos; + + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + switch (js[parser->pos]) { +#ifndef JSMN_STRICT + /* In strict mode primitive must be followed by "," or "}" or "]" */ + case ':': +#endif + case '\t': + case '\r': + case '\n': + case ' ': + case ',': + case ']': + case '}': + goto found; + } + if (js[parser->pos] < 32 || js[parser->pos] >= 127) { + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } +#ifdef JSMN_STRICT + /* In strict mode primitive must be followed by a comma/object/array */ + parser->pos = start; + return JSMN_ERROR_PART; +#endif + +found: + if (tokens == NULL) { + parser->pos--; + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); +#ifdef JSMN_PARENT_LINKS + token->parent = parser->toksuper; +#endif + parser->pos--; + return 0; +} + +/** + * Fills next token with JSON string. + */ +static int jsmn_parse_string(jsmn_parser *parser, const char *js, + const size_t len, jsmntok_t *tokens, + const size_t num_tokens) { + jsmntok_t *token; + + int start = parser->pos; + + parser->pos++; + + /* Skip starting quote */ + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c = js[parser->pos]; + + /* Quote: end of string */ + if (c == '\"') { + if (tokens == NULL) { + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos); +#ifdef JSMN_PARENT_LINKS + token->parent = parser->toksuper; +#endif + return 0; + } + + /* Backslash: Quoted symbol expected */ + if (c == '\\' && parser->pos + 1 < len) { + int i; + parser->pos++; + switch (js[parser->pos]) { + /* Allowed escaped symbols */ + case '\"': + case '/': + case '\\': + case 'b': + case 'f': + case 'r': + case 'n': + case 't': + break; + /* Allows escaped symbol \uXXXX */ + case 'u': + parser->pos++; + for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; + i++) { + /* If it isn't a hex character we have an error */ + if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ + (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ + (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ + parser->pos = start; + return JSMN_ERROR_INVAL; + } + parser->pos++; + } + parser->pos--; + break; + /* Unexpected symbol */ + default: + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } + } + parser->pos = start; + return JSMN_ERROR_PART; +} + +/** + * Parse JSON string and fill tokens. + */ +JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, + jsmntok_t *tokens, const unsigned int num_tokens) { + int r; + int i; + jsmntok_t *token; + int count = parser->toknext; + + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c; + jsmntype_t type; + + c = js[parser->pos]; + switch (c) { + case '{': + case '[': + count++; + if (tokens == NULL) { + break; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + return JSMN_ERROR_NOMEM; + } + if (parser->toksuper != -1) { + jsmntok_t *t = &tokens[parser->toksuper]; +#ifdef JSMN_STRICT + /* In strict mode an object or array can't become a key */ + if (t->type == JSMN_OBJECT) { + return JSMN_ERROR_INVAL; + } +#endif + t->size++; +#ifdef JSMN_PARENT_LINKS + token->parent = parser->toksuper; +#endif + } + token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); + token->start = parser->pos; + parser->toksuper = parser->toknext - 1; + break; + case '}': + case ']': + if (tokens == NULL) { + break; + } + type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); +#ifdef JSMN_PARENT_LINKS + if (parser->toknext < 1) { + return JSMN_ERROR_INVAL; + } + token = &tokens[parser->toknext - 1]; + for (;;) { + if (token->start != -1 && token->end == -1) { + if (token->type != type) { + return JSMN_ERROR_INVAL; + } + token->end = parser->pos + 1; + parser->toksuper = token->parent; + break; + } + if (token->parent == -1) { + if (token->type != type || parser->toksuper == -1) { + return JSMN_ERROR_INVAL; + } + break; + } + token = &tokens[token->parent]; + } +#else + for (i = parser->toknext - 1; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + if (token->type != type) { + return JSMN_ERROR_INVAL; + } + parser->toksuper = -1; + token->end = parser->pos + 1; + break; + } + } + /* Error if unmatched closing bracket */ + if (i == -1) { + return JSMN_ERROR_INVAL; + } + for (; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + parser->toksuper = i; + break; + } + } +#endif + break; + case '\"': + r = jsmn_parse_string(parser, js, len, tokens, num_tokens); + if (r < 0) { + return r; + } + count++; + if (parser->toksuper != -1 && tokens != NULL) { + tokens[parser->toksuper].size++; + } + break; + case '\t': + case '\r': + case '\n': + case ' ': + break; + case ':': + parser->toksuper = parser->toknext - 1; + break; + case ',': + if (tokens != NULL && parser->toksuper != -1 && + tokens[parser->toksuper].type != JSMN_ARRAY && + tokens[parser->toksuper].type != JSMN_OBJECT) { +#ifdef JSMN_PARENT_LINKS + parser->toksuper = tokens[parser->toksuper].parent; +#else + for (i = parser->toknext - 1; i >= 0; i--) { + if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { + if (tokens[i].start != -1 && tokens[i].end == -1) { + parser->toksuper = i; + break; + } + } + } +#endif + } + break; +#ifdef JSMN_STRICT + /* In strict mode primitives are: numbers and booleans */ + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 't': + case 'f': + case 'n': + /* And they must not be keys of the object */ + if (tokens != NULL && parser->toksuper != -1) { + const jsmntok_t *t = &tokens[parser->toksuper]; + if (t->type == JSMN_OBJECT || + (t->type == JSMN_STRING && t->size != 0)) { + return JSMN_ERROR_INVAL; + } + } +#else + /* In non-strict mode every unquoted value is a primitive */ + default: +#endif + r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); + if (r < 0) { + return r; + } + count++; + if (parser->toksuper != -1 && tokens != NULL) { + tokens[parser->toksuper].size++; + } + break; + +#ifdef JSMN_STRICT + /* Unexpected char in strict mode */ + default: + return JSMN_ERROR_INVAL; +#endif + } + } + + if (tokens != NULL) { + for (i = parser->toknext - 1; i >= 0; i--) { + /* Unmatched opened object or array */ + if (tokens[i].start != -1 && tokens[i].end == -1) { + return JSMN_ERROR_PART; + } + } + } + + return count; +} + +/** + * Creates a new parser based over a given buffer with an array of tokens + * available. + */ +JSMN_API void jsmn_init(jsmn_parser *parser) { + parser->pos = 0; + parser->toknext = 0; + parser->toksuper = -1; +} + +#endif /* JSMN_HEADER */ + +#ifdef __cplusplus +} +#endif + +#endif /* JSMN_H */ diff --git a/grub-core/lib/json/json.c b/grub-core/lib/json/json.c new file mode 100644 index 000000000..2bddd8c46 --- /dev/null +++ b/grub-core/lib/json/json.c @@ -0,0 +1,23 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include + +#include "jsmn.h" + +GRUB_MOD_LICENSE ("GPLv3"); From c6a84545a3c21369bb2685fdbe3cd895733dedbd Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:35 +0100 Subject: [PATCH 1033/1167] json: Implement wrapping interface While the newly added jsmn library provides the parsing interface, it does not provide any kind of interface to act on parsed tokens. Instead, the caller is expected to handle pointer arithmetics inside of the token array in order to extract required information. While simple, this requires users to know some of the inner workings of the library and is thus quite an unintuitive interface. This commit adds a new interface on top of the jsmn parser that provides convenience functions to retrieve values from the parsed json type, grub_json_t. Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- grub-core/lib/json/json.c | 244 ++++++++++++++++++++++++++++++++++++++ grub-core/lib/json/json.h | 122 +++++++++++++++++++ 2 files changed, 366 insertions(+) create mode 100644 grub-core/lib/json/json.h diff --git a/grub-core/lib/json/json.c b/grub-core/lib/json/json.c index 2bddd8c46..412f26f17 100644 --- a/grub-core/lib/json/json.c +++ b/grub-core/lib/json/json.c @@ -17,7 +17,251 @@ */ #include +#include +#define JSMN_STATIC #include "jsmn.h" +#include "json.h" GRUB_MOD_LICENSE ("GPLv3"); + +grub_err_t +grub_json_parse (grub_json_t **out, char *string, grub_size_t string_len) +{ + grub_json_t *json = NULL; + jsmn_parser parser; + grub_err_t ret = GRUB_ERR_NONE; + int jsmn_ret; + + if (!string) + return GRUB_ERR_BAD_ARGUMENT; + + json = grub_zalloc (sizeof (*json)); + if (!json) + return GRUB_ERR_OUT_OF_MEMORY; + json->string = string; + + /* + * Parse the string twice: first to determine how many tokens + * we need to allocate, second to fill allocated tokens. + */ + jsmn_init (&parser); + jsmn_ret = jsmn_parse (&parser, string, string_len, NULL, 0); + if (jsmn_ret <= 0) + { + ret = GRUB_ERR_BAD_ARGUMENT; + goto err; + } + + json->tokens = grub_malloc (sizeof (jsmntok_t) * jsmn_ret); + if (!json->tokens) + { + ret = GRUB_ERR_OUT_OF_MEMORY; + goto err; + } + + jsmn_init (&parser); + jsmn_ret = jsmn_parse (&parser, string, string_len, json->tokens, jsmn_ret); + if (jsmn_ret <= 0) + { + ret = GRUB_ERR_BAD_ARGUMENT; + goto err; + } + + *out = json; + + err: + if (ret && json) + { + grub_free (json->string); + grub_free (json->tokens); + grub_free (json); + } + return ret; +} + +void +grub_json_free (grub_json_t *json) +{ + if (json) + { + grub_free (json->tokens); + grub_free (json); + } +} + +grub_err_t +grub_json_getsize (grub_size_t *out, const grub_json_t *json) +{ + int size; + + size = ((jsmntok_t *)json->tokens)[json->idx].size; + if (size < 0) + return GRUB_ERR_OUT_OF_RANGE; + + *out = (grub_size_t) size; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_json_gettype (grub_json_type_t *out, const grub_json_t *json) +{ + switch (((jsmntok_t *)json->tokens)[json->idx].type) + { + case JSMN_OBJECT: + *out = GRUB_JSON_OBJECT; + break; + case JSMN_ARRAY: + *out = GRUB_JSON_ARRAY; + break; + case JSMN_STRING: + *out = GRUB_JSON_STRING; + break; + case JSMN_PRIMITIVE: + *out = GRUB_JSON_PRIMITIVE; + break; + default: + return GRUB_ERR_BAD_ARGUMENT; + } + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_json_getchild (grub_json_t *out, const grub_json_t *parent, grub_size_t n) +{ + grub_size_t offset = 1, size; + jsmntok_t *p; + + if (grub_json_getsize (&size, parent) || n >= size) + return GRUB_ERR_OUT_OF_RANGE; + + /* + * Skip the first n children. For each of the children, we need + * to skip their own potential children (e.g. if it's an + * array), as well. We thus add the children's size to n on + * each iteration. + */ + p = &((jsmntok_t *)parent->tokens)[parent->idx]; + while (n--) + n += p[offset++].size; + + out->string = parent->string; + out->tokens = parent->tokens; + out->idx = parent->idx + offset; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_json_getvalue (grub_json_t *out, const grub_json_t *parent, const char *key) +{ + grub_json_type_t type; + grub_size_t i, size; + + if (grub_json_gettype (&type, parent) || type != GRUB_JSON_OBJECT) + return GRUB_ERR_BAD_ARGUMENT; + + if (grub_json_getsize (&size, parent)) + return GRUB_ERR_BAD_ARGUMENT; + + for (i = 0; i < size; i++) + { + grub_json_t child; + const char *s; + + if (grub_json_getchild (&child, parent, i) || + grub_json_getstring (&s, &child, NULL) || + grub_strcmp (s, key) != 0) + continue; + + return grub_json_getchild (out, &child, 0); + } + + return GRUB_ERR_FILE_NOT_FOUND; +} + +static grub_err_t +get_value (grub_json_type_t *out_type, const char **out_string, const grub_json_t *parent, const char *key) +{ + const grub_json_t *p = parent; + grub_json_t child; + grub_err_t ret; + jsmntok_t *tok; + + if (key) + { + ret = grub_json_getvalue (&child, parent, key); + if (ret) + return ret; + p = &child; + } + + tok = &((jsmntok_t *) p->tokens)[p->idx]; + p->string[tok->end] = '\0'; + + *out_string = p->string + tok->start; + + return grub_json_gettype (out_type, p); +} + +grub_err_t +grub_json_getstring (const char **out, const grub_json_t *parent, const char *key) +{ + grub_json_type_t type; + const char *value; + grub_err_t ret; + + ret = get_value (&type, &value, parent, key); + if (ret) + return ret; + if (type != GRUB_JSON_STRING) + return GRUB_ERR_BAD_ARGUMENT; + + *out = value; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_json_getuint64 (grub_uint64_t *out, const grub_json_t *parent, const char *key) +{ + grub_json_type_t type; + const char *value; + char *end; + grub_err_t ret; + + ret = get_value (&type, &value, parent, key); + if (ret) + return ret; + if (type != GRUB_JSON_STRING && type != GRUB_JSON_PRIMITIVE) + return GRUB_ERR_BAD_ARGUMENT; + + grub_errno = GRUB_ERR_NONE; + *out = grub_strtoul (value, &end, 10); + if (grub_errno != GRUB_ERR_NONE || *end) + return GRUB_ERR_BAD_NUMBER; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_json_getint64 (grub_int64_t *out, const grub_json_t *parent, const char *key) +{ + grub_json_type_t type; + const char *value; + char *end; + grub_err_t ret; + + ret = get_value (&type, &value, parent, key); + if (ret) + return ret; + if (type != GRUB_JSON_STRING && type != GRUB_JSON_PRIMITIVE) + return GRUB_ERR_BAD_ARGUMENT; + + grub_errno = GRUB_ERR_NONE; + *out = grub_strtol (value, &end, 10); + if (grub_errno != GRUB_ERR_NONE || *end) + return GRUB_ERR_BAD_NUMBER; + + return GRUB_ERR_NONE; +} diff --git a/grub-core/lib/json/json.h b/grub-core/lib/json/json.h new file mode 100644 index 000000000..358e4bca3 --- /dev/null +++ b/grub-core/lib/json/json.h @@ -0,0 +1,122 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#ifndef GRUB_JSON_JSON_H +#define GRUB_JSON_JSON_H 1 + +#include + +enum grub_json_type +{ + /* Unordered collection of key-value pairs. */ + GRUB_JSON_OBJECT, + /* Ordered list of zero or more values. */ + GRUB_JSON_ARRAY, + /* Zero or more Unicode characters. */ + GRUB_JSON_STRING, + /* Number, boolean or empty value. */ + GRUB_JSON_PRIMITIVE, + /* Invalid token. */ + GRUB_JSON_UNDEFINED, +}; +typedef enum grub_json_type grub_json_type_t; + +struct grub_json +{ + void *tokens; + char *string; + grub_size_t idx; +}; +typedef struct grub_json grub_json_t; + +/* + * Parse a JSON-encoded string. Note that the string passed to + * this function will get modified on subsequent calls to + * grub_json_get*(). Returns the root object of the parsed JSON + * object, which needs to be free'd via grub_json_free(). + */ +extern grub_err_t EXPORT_FUNC(grub_json_parse) (grub_json_t **out, + char *string, + grub_size_t string_len); + +/* + * Free the structure and its contents. The string passed to + * grub_json_parse() will not be free'd. + */ +extern void EXPORT_FUNC(grub_json_free) (grub_json_t *json); + +/* + * Get the child count of a valid grub_json_t instance. Children + * are present for arrays, objects (dicts) and keys of a dict. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getsize) (grub_size_t *out, + const grub_json_t *json); + +/* Get the type of a valid grub_json_t instance. */ +extern grub_err_t EXPORT_FUNC(grub_json_gettype) (grub_json_type_t *out, + const grub_json_t *json); + +/* + * Get n'th child of a valid object, array or key. Will return an + * error if no such child exists. The result does not need to be + * free'd. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getchild) (grub_json_t *out, + const grub_json_t *parent, + grub_size_t n); + +/* + * Get value of key from a valid grub_json_t instance. The result + * does not need to be free'd. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getvalue) (grub_json_t *out, + const grub_json_t *parent, + const char *key); + +/* + * Get the string representation of a valid grub_json_t instance. + * If a key is given and parent is a JSON object, this function + * will return the string value of a child mapping to the key. + * If no key is given, it will return the string value of the + * parent itself. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getstring) (const char **out, + const grub_json_t *parent, + const char *key); + +/* + * Get the uint64 representation of a valid grub_json_t instance. + * Returns an error if the value pointed to by `parent` cannot be + * converted to an uint64. See grub_json_getstring() for details + * on the key parameter. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getuint64) (grub_uint64_t *out, + const grub_json_t *parent, + const char *key); + +/* + * Get the int64 representation of a valid grub_json_t instance. + * Returns an error if the value pointed to by `parent` cannot be + * converted to an int64. See grub_json_getstring() for + * details on the key parameter. + */ +extern grub_err_t EXPORT_FUNC(grub_json_getint64) (grub_int64_t *out, + const grub_json_t *parent, + const char *key); + +#endif From 9fbdec2f6b4fa8b549daa4d49134d1fe89d95ef9 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:36 +0100 Subject: [PATCH 1034/1167] bootstrap: Add gnulib's base64 module The upcoming support for LUKS2 disc encryption requires us to include a parser for base64-encoded data, as it is used to represent salts and digests. As gnulib already has code to decode such data, we can just add it to the boostrapping configuration in order to make it available in GRUB. The gnulib module makes use of booleans via the header. As GRUB does not provide any POSIX wrapper header for this, but instead implements support for bool in , we need to patch base64.h to not use anymore. We unfortunately cannot include instead, as it would then use gnulib's internal header while compiling the gnulib object but our own when including it in a GRUB module. Because of this, the patch replaces the include with a direct typedef. A second fix is required to make available _GL_ATTRIBUTE_CONST, which is provided by the configure script. As base64.h does not include , it is thus not available and results in a compile error. This is fixed by adding an include of . Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- bootstrap.conf | 3 ++- conf/Makefile.extra-dist | 1 + grub-core/lib/gnulib-patches/fix-base64.patch | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 grub-core/lib/gnulib-patches/fix-base64.patch diff --git a/bootstrap.conf b/bootstrap.conf index 988dda099..22b908f36 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -23,6 +23,7 @@ GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263 # directly. gnulib_modules=" argp + base64 error fnmatch getdelim @@ -78,7 +79,7 @@ cp -a INSTALL INSTALL.grub bootstrap_post_import_hook () { set -e - for patchname in fix-null-deref fix-width no-abort; do + for patchname in fix-base64 fix-null-deref fix-width no-abort; do patch -d grub-core/lib/gnulib -p2 \ < "grub-core/lib/gnulib-patches/$patchname.patch" done diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 46c4e95e2..32b217853 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -28,6 +28,7 @@ EXTRA_DIST += grub-core/gensymlist.sh EXTRA_DIST += grub-core/genemuinit.sh EXTRA_DIST += grub-core/genemuinitheader.sh +EXTRA_DIST += grub-core/lib/gnulib-patches/fix-base64.patch EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch b/grub-core/lib/gnulib-patches/fix-base64.patch new file mode 100644 index 000000000..e075b6fab --- /dev/null +++ b/grub-core/lib/gnulib-patches/fix-base64.patch @@ -0,0 +1,23 @@ +diff --git a/lib/base64.h b/lib/base64.h +index 9cd0183b8..a2aaa2d4a 100644 +--- a/lib/base64.h ++++ b/lib/base64.h +@@ -18,11 +18,16 @@ + #ifndef BASE64_H + # define BASE64_H + ++/* Get _GL_ATTRIBUTE_CONST */ ++# include ++ + /* Get size_t. */ + # include + +-/* Get bool. */ +-# include ++#ifndef GRUB_POSIX_BOOL_DEFINED ++typedef enum { false = 0, true = 1 } bool; ++#define GRUB_POSIX_BOOL_DEFINED 1 ++#endif + + # ifdef __cplusplus + extern "C" { From 5324c335b1b1c1cdf40753d94360ec5debd8a46f Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:37 +0100 Subject: [PATCH 1035/1167] afsplitter: Move into its own module While the AFSplitter code is currently used only by the luks module, upcoming support for luks2 will add a second module that depends on it. To avoid any linker errors when adding the code to both modules because of duplicated symbols, this commit moves it into its own standalone module afsplitter as a preparatory step. Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 6 +++++- grub-core/disk/AFSplitter.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 037de4023..db346a9f4 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1181,10 +1181,14 @@ module = { common = lib/json/json.c; }; +module = { + name = afsplitter; + common = disk/AFSplitter.c; +}; + module = { name = luks; common = disk/luks.c; - common = disk/AFSplitter.c; }; module = { diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c index f5a8ddc61..249163ff0 100644 --- a/grub-core/disk/AFSplitter.c +++ b/grub-core/disk/AFSplitter.c @@ -21,9 +21,12 @@ */ #include +#include #include #include +GRUB_MOD_LICENSE ("GPLv2+"); + gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst, grub_size_t blocksize, grub_size_t blocknumbers); From dd3f49b106497416d4da557e8d583e1e9d6f2357 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:38 +0100 Subject: [PATCH 1036/1167] luks: Move configuration of ciphers into cryptodisk The luks module contains quite a lot of logic to parse cipher and cipher-mode strings like aes-xts-plain64 into constants to apply them to the grub_cryptodisk_t structure. This code will be required by the upcoming luks2 module, as well, which is why this commit moves it into its own function grub_cryptodisk_setcipher in the cryptodisk module. While the strings are probably rather specific to the LUKS modules, it certainly does make sense that the cryptodisk module houses code to set up its own internal ciphers instead of hosting that code in the luks module. Except for necessary adjustments around error handling, this commit does an exact move of the cipher configuration logic from luks.c to cryptodisk.c. Any behavior changes are unintentional. Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- grub-core/disk/cryptodisk.c | 163 ++++++++++++++++++++++++++++++- grub-core/disk/luks.c | 190 +++--------------------------------- include/grub/cryptodisk.h | 3 + 3 files changed, 181 insertions(+), 175 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 5037768fc..1897acc4b 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2007,2010,2011 Free Software Foundation, Inc. + * Copyright (C) 2003,2007,2010,2011,2019 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 @@ -404,6 +404,167 @@ grub_cryptodisk_decrypt (struct grub_cryptodisk *dev, return grub_cryptodisk_endecrypt (dev, data, len, sector, 0); } +grub_err_t +grub_cryptodisk_setcipher (grub_cryptodisk_t crypt, const char *ciphername, const char *ciphermode) +{ + const char *cipheriv = NULL; + grub_crypto_cipher_handle_t cipher = NULL, secondary_cipher = NULL; + grub_crypto_cipher_handle_t essiv_cipher = NULL; + const gcry_md_spec_t *essiv_hash = NULL; + const struct gcry_cipher_spec *ciph; + grub_cryptodisk_mode_t mode; + grub_cryptodisk_mode_iv_t mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64; + int benbi_log = 0; + grub_err_t ret = GRUB_ERR_NONE; + + ciph = grub_crypto_lookup_cipher_by_name (ciphername); + if (!ciph) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s isn't available", + ciphername); + goto err; + } + + /* Configure the cipher used for the bulk data. */ + cipher = grub_crypto_cipher_open (ciph); + if (!cipher) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s could not be initialized", + ciphername); + goto err; + } + + /* Configure the cipher mode. */ + if (grub_strcmp (ciphermode, "ecb") == 0) + { + mode = GRUB_CRYPTODISK_MODE_ECB; + mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; + cipheriv = NULL; + } + else if (grub_strcmp (ciphermode, "plain") == 0) + { + mode = GRUB_CRYPTODISK_MODE_CBC; + mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; + cipheriv = NULL; + } + else if (grub_memcmp (ciphermode, "cbc-", sizeof ("cbc-") - 1) == 0) + { + mode = GRUB_CRYPTODISK_MODE_CBC; + cipheriv = ciphermode + sizeof ("cbc-") - 1; + } + else if (grub_memcmp (ciphermode, "pcbc-", sizeof ("pcbc-") - 1) == 0) + { + mode = GRUB_CRYPTODISK_MODE_PCBC; + cipheriv = ciphermode + sizeof ("pcbc-") - 1; + } + else if (grub_memcmp (ciphermode, "xts-", sizeof ("xts-") - 1) == 0) + { + mode = GRUB_CRYPTODISK_MODE_XTS; + cipheriv = ciphermode + sizeof ("xts-") - 1; + secondary_cipher = grub_crypto_cipher_open (ciph); + if (!secondary_cipher) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Secondary cipher %s isn't available", + secondary_cipher); + goto err; + } + if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", + cipher->cipher->blocksize); + goto err; + } + if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", + secondary_cipher->cipher->blocksize); + goto err; + } + } + else if (grub_memcmp (ciphermode, "lrw-", sizeof ("lrw-") - 1) == 0) + { + mode = GRUB_CRYPTODISK_MODE_LRW; + cipheriv = ciphermode + sizeof ("lrw-") - 1; + if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d", + cipher->cipher->blocksize); + goto err; + } + } + else + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown cipher mode: %s", + ciphermode); + goto err; + } + + if (cipheriv == NULL) + ; + else if (grub_memcmp (cipheriv, "plain", sizeof ("plain") - 1) == 0) + mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; + else if (grub_memcmp (cipheriv, "plain64", sizeof ("plain64") - 1) == 0) + mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64; + else if (grub_memcmp (cipheriv, "benbi", sizeof ("benbi") - 1) == 0) + { + if (cipher->cipher->blocksize & (cipher->cipher->blocksize - 1) + || cipher->cipher->blocksize == 0) + grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d", + cipher->cipher->blocksize); + /* FIXME should we return an error here? */ + for (benbi_log = 0; + (cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE; + benbi_log++); + mode_iv = GRUB_CRYPTODISK_MODE_IV_BENBI; + } + else if (grub_memcmp (cipheriv, "null", sizeof ("null") - 1) == 0) + mode_iv = GRUB_CRYPTODISK_MODE_IV_NULL; + else if (grub_memcmp (cipheriv, "essiv:", sizeof ("essiv:") - 1) == 0) + { + const char *hash_str = cipheriv + 6; + + mode_iv = GRUB_CRYPTODISK_MODE_IV_ESSIV; + + /* Configure the hash and cipher used for ESSIV. */ + essiv_hash = grub_crypto_lookup_md_by_name (hash_str); + if (!essiv_hash) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, + "Couldn't load %s hash", hash_str); + goto err; + } + essiv_cipher = grub_crypto_cipher_open (ciph); + if (!essiv_cipher) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, + "Couldn't load %s cipher", ciphername); + goto err; + } + } + else + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s", + cipheriv); + goto err; + } + + crypt->cipher = cipher; + crypt->benbi_log = benbi_log; + crypt->mode = mode; + crypt->mode_iv = mode_iv; + crypt->secondary_cipher = secondary_cipher; + crypt->essiv_cipher = essiv_cipher; + crypt->essiv_hash = essiv_hash; + +err: + if (ret) + { + grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); + } + return ret; +} + gcry_err_code_t grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t keysize) { diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 86c50c612..410cd6f84 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2007,2010,2011 Free Software Foundation, Inc. + * Copyright (C) 2003,2007,2010,2011,2019 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 @@ -75,15 +75,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, char uuid[sizeof (header.uuid) + 1]; char ciphername[sizeof (header.cipherName) + 1]; char ciphermode[sizeof (header.cipherMode) + 1]; - char *cipheriv = NULL; char hashspec[sizeof (header.hashSpec) + 1]; - grub_crypto_cipher_handle_t cipher = NULL, secondary_cipher = NULL; - grub_crypto_cipher_handle_t essiv_cipher = NULL; - const gcry_md_spec_t *hash = NULL, *essiv_hash = NULL; - const struct gcry_cipher_spec *ciph; - grub_cryptodisk_mode_t mode; - grub_cryptodisk_mode_iv_t mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64; - int benbi_log = 0; grub_err_t err; if (check_boot) @@ -126,183 +118,33 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, grub_memcpy (hashspec, header.hashSpec, sizeof (header.hashSpec)); hashspec[sizeof (header.hashSpec)] = 0; - ciph = grub_crypto_lookup_cipher_by_name (ciphername); - if (!ciph) - { - grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s isn't available", - ciphername); + newdev = grub_zalloc (sizeof (struct grub_cryptodisk)); + if (!newdev) return NULL; - } - - /* Configure the cipher used for the bulk data. */ - cipher = grub_crypto_cipher_open (ciph); - if (!cipher) - return NULL; - - if (grub_be_to_cpu32 (header.keyBytes) > 1024) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d", - grub_be_to_cpu32 (header.keyBytes)); - grub_crypto_cipher_close (cipher); - return NULL; - } - - /* Configure the cipher mode. */ - if (grub_strcmp (ciphermode, "ecb") == 0) - { - mode = GRUB_CRYPTODISK_MODE_ECB; - mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; - cipheriv = NULL; - } - else if (grub_strcmp (ciphermode, "plain") == 0) - { - mode = GRUB_CRYPTODISK_MODE_CBC; - mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; - cipheriv = NULL; - } - else if (grub_memcmp (ciphermode, "cbc-", sizeof ("cbc-") - 1) == 0) - { - mode = GRUB_CRYPTODISK_MODE_CBC; - cipheriv = ciphermode + sizeof ("cbc-") - 1; - } - else if (grub_memcmp (ciphermode, "pcbc-", sizeof ("pcbc-") - 1) == 0) - { - mode = GRUB_CRYPTODISK_MODE_PCBC; - cipheriv = ciphermode + sizeof ("pcbc-") - 1; - } - else if (grub_memcmp (ciphermode, "xts-", sizeof ("xts-") - 1) == 0) - { - mode = GRUB_CRYPTODISK_MODE_XTS; - cipheriv = ciphermode + sizeof ("xts-") - 1; - secondary_cipher = grub_crypto_cipher_open (ciph); - if (!secondary_cipher) - { - grub_crypto_cipher_close (cipher); - return NULL; - } - if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", - cipher->cipher->blocksize); - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (secondary_cipher); - return NULL; - } - if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) - { - grub_crypto_cipher_close (cipher); - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", - secondary_cipher->cipher->blocksize); - grub_crypto_cipher_close (secondary_cipher); - return NULL; - } - } - else if (grub_memcmp (ciphermode, "lrw-", sizeof ("lrw-") - 1) == 0) - { - mode = GRUB_CRYPTODISK_MODE_LRW; - cipheriv = ciphermode + sizeof ("lrw-") - 1; - if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d", - cipher->cipher->blocksize); - grub_crypto_cipher_close (cipher); - return NULL; - } - } - else - { - grub_crypto_cipher_close (cipher); - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown cipher mode: %s", - ciphermode); - return NULL; - } - - if (cipheriv == NULL); - else if (grub_memcmp (cipheriv, "plain", sizeof ("plain") - 1) == 0) - mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN; - else if (grub_memcmp (cipheriv, "plain64", sizeof ("plain64") - 1) == 0) - mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64; - else if (grub_memcmp (cipheriv, "benbi", sizeof ("benbi") - 1) == 0) - { - if (cipher->cipher->blocksize & (cipher->cipher->blocksize - 1) - || cipher->cipher->blocksize == 0) - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d", - cipher->cipher->blocksize); - /* FIXME should we return an error here? */ - for (benbi_log = 0; - (cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE; - benbi_log++); - mode_iv = GRUB_CRYPTODISK_MODE_IV_BENBI; - } - else if (grub_memcmp (cipheriv, "null", sizeof ("null") - 1) == 0) - mode_iv = GRUB_CRYPTODISK_MODE_IV_NULL; - else if (grub_memcmp (cipheriv, "essiv:", sizeof ("essiv:") - 1) == 0) - { - char *hash_str = cipheriv + 6; - - mode_iv = GRUB_CRYPTODISK_MODE_IV_ESSIV; - - /* Configure the hash and cipher used for ESSIV. */ - essiv_hash = grub_crypto_lookup_md_by_name (hash_str); - if (!essiv_hash) - { - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (secondary_cipher); - grub_error (GRUB_ERR_FILE_NOT_FOUND, - "Couldn't load %s hash", hash_str); - return NULL; - } - essiv_cipher = grub_crypto_cipher_open (ciph); - if (!essiv_cipher) - { - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (secondary_cipher); - return NULL; - } - } - else - { - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (secondary_cipher); - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s", - cipheriv); - return NULL; - } + newdev->offset = grub_be_to_cpu32 (header.payloadOffset); + newdev->source_disk = NULL; + newdev->log_sector_size = 9; + newdev->total_length = grub_disk_get_size (disk) - newdev->offset; + grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid)); + newdev->modname = "luks"; /* Configure the hash used for the AF splitter and HMAC. */ - hash = grub_crypto_lookup_md_by_name (hashspec); - if (!hash) + newdev->hash = grub_crypto_lookup_md_by_name (hashspec); + if (!newdev->hash) { - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (essiv_cipher); - grub_crypto_cipher_close (secondary_cipher); + grub_free (newdev); grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", hashspec); return NULL; } - newdev = grub_zalloc (sizeof (struct grub_cryptodisk)); - if (!newdev) + err = grub_cryptodisk_setcipher (newdev, ciphername, ciphermode); + if (err) { - grub_crypto_cipher_close (cipher); - grub_crypto_cipher_close (essiv_cipher); - grub_crypto_cipher_close (secondary_cipher); + grub_free (newdev); return NULL; } - newdev->cipher = cipher; - newdev->offset = grub_be_to_cpu32 (header.payloadOffset); - newdev->source_disk = NULL; - newdev->benbi_log = benbi_log; - newdev->mode = mode; - newdev->mode_iv = mode_iv; - newdev->secondary_cipher = secondary_cipher; - newdev->essiv_cipher = essiv_cipher; - newdev->essiv_hash = essiv_hash; - newdev->hash = hash; - newdev->log_sector_size = 9; - newdev->total_length = grub_disk_get_size (disk) - newdev->offset; - grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid)); - newdev->modname = "luks"; + COMPILE_TIME_ASSERT (sizeof (newdev->uuid) >= sizeof (uuid)); return newdev; } diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index 32f564ae0..e1b21e785 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -130,6 +130,9 @@ grub_cryptodisk_dev_unregister (grub_cryptodisk_dev_t cr) #define FOR_CRYPTODISK_DEVS(var) FOR_LIST_ELEMENTS((var), (grub_cryptodisk_list)) +grub_err_t +grub_cryptodisk_setcipher (grub_cryptodisk_t crypt, const char *ciphername, const char *ciphermode); + gcry_err_code_t grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t keysize); From 365e0cc3e7e44151c14dd29514c2f870b49f9755 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 27 Dec 2019 16:18:39 +0100 Subject: [PATCH 1037/1167] disk: Implement support for LUKS2 With cryptsetup 2.0, a new version of LUKS was introduced that breaks compatibility with the previous version due to various reasons. GRUB currently lacks any support for LUKS2, making it impossible to decrypt disks encrypted with that version. This commit implements support for this new format. Note that LUKS1 and LUKS2 are quite different data formats. While they do share the same disk signature in the first few bytes, representation of encryption parameters is completely different between both versions. While the former version one relied on a single binary header, only, LUKS2 uses the binary header only in order to locate the actual metadata which is encoded in JSON. Furthermore, the new data format is a lot more complex to allow for more flexible setups, like e.g. having multiple encrypted segments and other features that weren't previously possible. Because of this, it was decided that it doesn't make sense to keep both LUKS1 and LUKS2 support in the same module and instead to implement it in two different modules luks and luks2. The proposed support for LUKS2 is able to make use of the metadata to decrypt such disks. Note though that in the current version, only the PBKDF2 key derival function is supported. This can mostly attributed to the fact that the libgcrypt library currently has no support for either Argon2i or Argon2id, which are the remaining KDFs supported by LUKS2. It wouldn't have been much of a problem to bundle those algorithms with GRUB itself, but it was decided against that in order to keep down the number of patches required for initial LUKS2 support. Adding it in the future would be trivial, given that the code structure is already in place. Signed-off-by: Patrick Steinhardt Reviewed-by: Daniel Kiper --- Makefile.util.def | 4 +- docs/grub.texi | 5 +- grub-core/Makefile.core.def | 8 + grub-core/disk/luks2.c | 678 ++++++++++++++++++++++++++++++++++++ 4 files changed, 692 insertions(+), 3 deletions(-) create mode 100644 grub-core/disk/luks2.c diff --git a/Makefile.util.def b/Makefile.util.def index 969d32f00..94336392b 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -3,7 +3,7 @@ AutoGen definitions Makefile.tpl; library = { name = libgrubkern.a; cflags = '$(CFLAGS_GNULIB)'; - cppflags = '$(CPPFLAGS_GNULIB)'; + cppflags = '$(CPPFLAGS_GNULIB) -I$(srcdir)/grub-core/lib/json'; common = util/misc.c; common = grub-core/kern/command.c; @@ -36,7 +36,9 @@ library = { common = grub-core/kern/misc.c; common = grub-core/kern/partition.c; common = grub-core/lib/crypto.c; + common = grub-core/lib/json/json.c; common = grub-core/disk/luks.c; + common = grub-core/disk/luks2.c; common = grub-core/disk/geli.c; common = grub-core/disk/cryptodisk.c; common = grub-core/disk/AFSplitter.c; diff --git a/docs/grub.texi b/docs/grub.texi index 08d699d49..1b25466c7 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4211,8 +4211,9 @@ is requested interactively. Option @var{device} configures specific grub device with specified @var{uuid}; option @option{-a} configures all detected encrypted devices; option @option{-b} configures all geli containers that have boot flag set. -GRUB suports devices encrypted using LUKS and geli. Note that necessary modules (@var{luks} and @var{geli}) have to be loaded manually before this command can -be used. +GRUB suports devices encrypted using LUKS, LUKS2 and geli. Note that necessary +modules (@var{luks}, @var{luks2} and @var{geli}) have to be loaded manually +before this command can be used. @end deffn diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index db346a9f4..a0507a1fa 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1191,6 +1191,14 @@ module = { common = disk/luks.c; }; +module = { + name = luks2; + common = disk/luks2.c; + common = lib/gnulib/base64.c; + cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; + cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json'; +}; + module = { name = geli; common = disk/geli.c; diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c new file mode 100644 index 000000000..49ee9c862 --- /dev/null +++ b/grub-core/disk/luks2.c @@ -0,0 +1,678 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2019 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +#define LUKS_MAGIC_1ST "LUKS\xBA\xBE" +#define LUKS_MAGIC_2ND "SKUL\xBA\xBE" + +#define MAX_PASSPHRASE 256 + +enum grub_luks2_kdf_type +{ + LUKS2_KDF_TYPE_ARGON2I, + LUKS2_KDF_TYPE_PBKDF2 +}; +typedef enum grub_luks2_kdf_type grub_luks2_kdf_type_t; + +/* On disk LUKS header */ +struct grub_luks2_header +{ + char magic[6]; + grub_uint16_t version; + grub_uint64_t hdr_size; + grub_uint64_t seqid; + char label[48]; + char csum_alg[32]; + grub_uint8_t salt[64]; + char uuid[40]; + char subsystem[48]; + grub_uint64_t hdr_offset; + char _padding[184]; + grub_uint8_t csum[64]; + char _padding4096[7*512]; +} GRUB_PACKED; +typedef struct grub_luks2_header grub_luks2_header_t; + +struct grub_luks2_keyslot +{ + grub_int64_t key_size; + grub_int64_t priority; + struct + { + const char *encryption; + grub_uint64_t offset; + grub_uint64_t size; + grub_int64_t key_size; + } area; + struct + { + const char *hash; + grub_int64_t stripes; + } af; + struct + { + grub_luks2_kdf_type_t type; + const char *salt; + union + { + struct + { + grub_int64_t time; + grub_int64_t memory; + grub_int64_t cpus; + } argon2i; + struct + { + const char *hash; + grub_int64_t iterations; + } pbkdf2; + } u; + } kdf; +}; +typedef struct grub_luks2_keyslot grub_luks2_keyslot_t; + +struct grub_luks2_segment +{ + grub_uint64_t offset; + const char *size; + const char *encryption; + grub_int64_t sector_size; +}; +typedef struct grub_luks2_segment grub_luks2_segment_t; + +struct grub_luks2_digest +{ + /* Both keyslots and segments are interpreted as bitfields here */ + grub_uint64_t keyslots; + grub_uint64_t segments; + const char *salt; + const char *digest; + const char *hash; + grub_int64_t iterations; +}; +typedef struct grub_luks2_digest grub_luks2_digest_t; + +gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, + grub_uint8_t * dst, grub_size_t blocksize, + grub_size_t blocknumbers); + +static grub_err_t +luks2_parse_keyslot (grub_luks2_keyslot_t *out, const grub_json_t *keyslot) +{ + grub_json_t area, af, kdf; + const char *type; + + if (grub_json_getstring (&type, keyslot, "type")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid keyslot"); + else if (grub_strcmp (type, "luks2")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported keyslot type %s", type); + else if (grub_json_getint64 (&out->key_size, keyslot, "key_size")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing keyslot information"); + if (grub_json_getint64 (&out->priority, keyslot, "priority")) + out->priority = 1; + + if (grub_json_getvalue (&area, keyslot, "area") || + grub_json_getstring (&type, &area, "type")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid key area"); + else if (grub_strcmp (type, "raw")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported key area type: %s", type); + else if (grub_json_getuint64 (&out->area.offset, &area, "offset") || + grub_json_getuint64 (&out->area.size, &area, "size") || + grub_json_getstring (&out->area.encryption, &area, "encryption") || + grub_json_getint64 (&out->area.key_size, &area, "key_size")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing key area information"); + + if (grub_json_getvalue (&kdf, keyslot, "kdf") || + grub_json_getstring (&type, &kdf, "type") || + grub_json_getstring (&out->kdf.salt, &kdf, "salt")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid KDF"); + else if (!grub_strcmp (type, "argon2i") || !grub_strcmp (type, "argon2id")) + { + out->kdf.type = LUKS2_KDF_TYPE_ARGON2I; + if (grub_json_getint64 (&out->kdf.u.argon2i.time, &kdf, "time") || + grub_json_getint64 (&out->kdf.u.argon2i.memory, &kdf, "memory") || + grub_json_getint64 (&out->kdf.u.argon2i.cpus, &kdf, "cpus")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing Argon2i parameters"); + } + else if (!grub_strcmp (type, "pbkdf2")) + { + out->kdf.type = LUKS2_KDF_TYPE_PBKDF2; + if (grub_json_getstring (&out->kdf.u.pbkdf2.hash, &kdf, "hash") || + grub_json_getint64 (&out->kdf.u.pbkdf2.iterations, &kdf, "iterations")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing PBKDF2 parameters"); + } + else + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported KDF type %s", type); + + if (grub_json_getvalue (&af, keyslot, "af") || + grub_json_getstring (&type, &af, "type")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing or invalid area"); + if (grub_strcmp (type, "luks1")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported AF type %s", type); + if (grub_json_getint64 (&out->af.stripes, &af, "stripes") || + grub_json_getstring (&out->af.hash, &af, "hash")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing AF parameters"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +luks2_parse_segment (grub_luks2_segment_t *out, const grub_json_t *segment) +{ + const char *type; + + if (grub_json_getstring (&type, segment, "type")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid segment type"); + else if (grub_strcmp (type, "crypt")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported segment type %s", type); + + if (grub_json_getuint64 (&out->offset, segment, "offset") || + grub_json_getstring (&out->size, segment, "size") || + grub_json_getstring (&out->encryption, segment, "encryption") || + grub_json_getint64 (&out->sector_size, segment, "sector_size")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing segment parameters", type); + + return GRUB_ERR_NONE; +} + +static grub_err_t +luks2_parse_digest (grub_luks2_digest_t *out, const grub_json_t *digest) +{ + grub_json_t segments, keyslots, o; + grub_size_t i, size; + grub_uint64_t bit; + const char *type; + + if (grub_json_getstring (&type, digest, "type")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest type"); + else if (grub_strcmp (type, "pbkdf2")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported digest type %s", type); + + if (grub_json_getvalue (&segments, digest, "segments") || + grub_json_getvalue (&keyslots, digest, "keyslots") || + grub_json_getstring (&out->salt, digest, "salt") || + grub_json_getstring (&out->digest, digest, "digest") || + grub_json_getstring (&out->hash, digest, "hash") || + grub_json_getint64 (&out->iterations, digest, "iterations")) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing digest parameters"); + + if (grub_json_getsize (&size, &segments)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "Digest references no segments", type); + + for (i = 0; i < size; i++) + { + if (grub_json_getchild (&o, &segments, i) || + grub_json_getuint64 (&bit, &o, NULL)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid segment"); + out->segments |= (1 << bit); + } + + if (grub_json_getsize (&size, &keyslots)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "Digest references no keyslots", type); + + for (i = 0; i < size; i++) + { + if (grub_json_getchild (&o, &keyslots, i) || + grub_json_getuint64 (&bit, &o, NULL)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid keyslot"); + out->keyslots |= (1 << bit); + } + + return GRUB_ERR_NONE; +} + +static grub_err_t +luks2_get_keyslot (grub_luks2_keyslot_t *k, grub_luks2_digest_t *d, grub_luks2_segment_t *s, + const grub_json_t *root, grub_size_t i) +{ + grub_json_t keyslots, keyslot, digests, digest, segments, segment; + grub_size_t j, size; + grub_uint64_t idx; + + /* Get nth keyslot */ + if (grub_json_getvalue (&keyslots, root, "keyslots") || + grub_json_getchild (&keyslot, &keyslots, i) || + grub_json_getuint64 (&idx, &keyslot, NULL) || + grub_json_getchild (&keyslot, &keyslot, 0) || + luks2_parse_keyslot (k, &keyslot)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse keyslot %"PRIuGRUB_SIZE, i); + + /* Get digest that matches the keyslot. */ + if (grub_json_getvalue (&digests, root, "digests") || + grub_json_getsize (&size, &digests)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get digests"); + for (j = 0; j < size; j++) + { + if (grub_json_getchild (&digest, &digests, i) || + grub_json_getchild (&digest, &digest, 0) || + luks2_parse_digest (d, &digest)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse digest %"PRIuGRUB_SIZE, i); + + if ((d->keyslots & (1 << idx))) + break; + } + if (j == size) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No digest for keyslot %"PRIuGRUB_SIZE); + + /* Get segment that matches the digest. */ + if (grub_json_getvalue (&segments, root, "segments") || + grub_json_getsize (&size, &segments)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get segments"); + for (j = 0; j < size; j++) + { + if (grub_json_getchild (&segment, &segments, i) || + grub_json_getuint64 (&idx, &segment, NULL) || + grub_json_getchild (&segment, &segment, 0) || + luks2_parse_segment (s, &segment)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse segment %"PRIuGRUB_SIZE, i); + + if ((d->segments & (1 << idx))) + break; + } + if (j == size) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No segment for digest %"PRIuGRUB_SIZE); + + return GRUB_ERR_NONE; +} + +/* Determine whether to use primary or secondary header */ +static grub_err_t +luks2_read_header (grub_disk_t disk, grub_luks2_header_t *outhdr) +{ + grub_luks2_header_t primary, secondary, *header = &primary; + grub_err_t ret; + + /* Read the primary LUKS header. */ + ret = grub_disk_read (disk, 0, 0, sizeof (primary), &primary); + if (ret) + return ret; + + /* Look for LUKS magic sequence. */ + if (grub_memcmp (primary.magic, LUKS_MAGIC_1ST, sizeof (primary.magic)) || + grub_be_to_cpu16 (primary.version) != 2) + return GRUB_ERR_BAD_SIGNATURE; + + /* Read the secondary header. */ + ret = grub_disk_read (disk, 0, grub_be_to_cpu64 (primary.hdr_size), sizeof (secondary), &secondary); + if (ret) + return ret; + + /* Look for LUKS magic sequence. */ + if (grub_memcmp (secondary.magic, LUKS_MAGIC_2ND, sizeof (secondary.magic)) || + grub_be_to_cpu16 (secondary.version) != 2) + return GRUB_ERR_BAD_SIGNATURE; + + if (grub_be_to_cpu64 (primary.seqid) < grub_be_to_cpu64 (secondary.seqid)) + header = &secondary; + grub_memcpy (outhdr, header, sizeof (*header)); + + return GRUB_ERR_NONE; +} + +static grub_cryptodisk_t +luks2_scan (grub_disk_t disk, const char *check_uuid, int check_boot) +{ + grub_cryptodisk_t cryptodisk; + grub_luks2_header_t header; + + if (check_boot) + return NULL; + + if (luks2_read_header (disk, &header)) + { + grub_errno = GRUB_ERR_NONE; + return NULL; + } + + if (check_uuid && grub_strcasecmp (check_uuid, header.uuid) != 0) + return NULL; + + cryptodisk = grub_zalloc (sizeof (*cryptodisk)); + if (!cryptodisk) + return NULL; + + COMPILE_TIME_ASSERT (sizeof (cryptodisk->uuid) >= sizeof (header.uuid)); + + grub_memcpy (cryptodisk->uuid, header.uuid, sizeof (header.uuid)); + cryptodisk->modname = "luks2"; + return cryptodisk; +} + +static grub_err_t +luks2_verify_key (grub_luks2_digest_t *d, grub_uint8_t *candidate_key, + grub_size_t candidate_key_len) +{ + grub_uint8_t candidate_digest[GRUB_CRYPTODISK_MAX_KEYLEN]; + grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN], salt[GRUB_CRYPTODISK_MAX_KEYLEN]; + grub_size_t saltlen = sizeof (salt), digestlen = sizeof (digest); + const gcry_md_spec_t *hash; + gcry_err_code_t gcry_ret; + + /* Decode both digest and salt */ + if (!base64_decode (d->digest, grub_strlen (d->digest), (char *)digest, &digestlen)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest"); + if (!base64_decode (d->salt, grub_strlen (d->salt), (char *)salt, &saltlen)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest salt"); + + /* Configure the hash used for the digest. */ + hash = grub_crypto_lookup_md_by_name (d->hash); + if (!hash) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", d->hash); + + /* Calculate the candidate key's digest */ + gcry_ret = grub_crypto_pbkdf2 (hash, + candidate_key, candidate_key_len, + salt, saltlen, + d->iterations, + candidate_digest, digestlen); + if (gcry_ret) + return grub_crypto_gcry_error (gcry_ret); + + if (grub_memcmp (candidate_digest, digest, digestlen) != 0) + return grub_error (GRUB_ERR_ACCESS_DENIED, "Mismatching digests"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +luks2_decrypt_key (grub_uint8_t *out_key, + grub_disk_t disk, grub_cryptodisk_t crypt, + grub_luks2_keyslot_t *k, + const grub_uint8_t *passphrase, grub_size_t passphraselen) +{ + grub_uint8_t area_key[GRUB_CRYPTODISK_MAX_KEYLEN]; + grub_uint8_t salt[GRUB_CRYPTODISK_MAX_KEYLEN]; + grub_uint8_t *split_key = NULL; + grub_size_t saltlen = sizeof (salt); + char cipher[32], *p;; + const gcry_md_spec_t *hash; + gcry_err_code_t gcry_ret; + grub_err_t ret; + + if (!base64_decode (k->kdf.salt, grub_strlen (k->kdf.salt), + (char *)salt, &saltlen)) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid keyslot salt"); + goto err; + } + + /* Calculate the binary area key of the user supplied passphrase. */ + switch (k->kdf.type) + { + case LUKS2_KDF_TYPE_ARGON2I: + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Argon2 not supported"); + goto err; + case LUKS2_KDF_TYPE_PBKDF2: + hash = grub_crypto_lookup_md_by_name (k->kdf.u.pbkdf2.hash); + if (!hash) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", + k->kdf.u.pbkdf2.hash); + goto err; + } + + gcry_ret = grub_crypto_pbkdf2 (hash, (grub_uint8_t *) passphrase, + passphraselen, + salt, saltlen, + k->kdf.u.pbkdf2.iterations, + area_key, k->area.key_size); + if (gcry_ret) + { + ret = grub_crypto_gcry_error (gcry_ret); + goto err; + } + + break; + } + + /* Set up disk encryption parameters for the key area */ + grub_strncpy (cipher, k->area.encryption, sizeof (cipher)); + p = grub_memchr (cipher, '-', grub_strlen (cipher)); + if (!p) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid encryption"); + *p = '\0'; + + ret = grub_cryptodisk_setcipher (crypt, cipher, p + 1); + if (ret) + return ret; + + gcry_ret = grub_cryptodisk_setkey (crypt, area_key, k->area.key_size); + if (gcry_ret) + { + ret = grub_crypto_gcry_error (gcry_ret); + goto err; + } + + /* Read and decrypt the binary key area with the area key. */ + split_key = grub_malloc (k->area.size); + if (!split_key) + { + ret = grub_errno; + goto err; + } + + grub_errno = GRUB_ERR_NONE; + ret = grub_disk_read (disk, 0, k->area.offset, k->area.size, split_key); + if (ret) + { + grub_dprintf ("luks2", "Read error: %s\n", grub_errmsg); + goto err; + } + + gcry_ret = grub_cryptodisk_decrypt (crypt, split_key, k->area.size, 0); + if (gcry_ret) + { + ret = grub_crypto_gcry_error (gcry_ret); + goto err; + } + + /* Configure the hash used for anti-forensic merging. */ + hash = grub_crypto_lookup_md_by_name (k->af.hash); + if (!hash) + { + ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", + k->af.hash); + goto err; + } + + /* Merge the decrypted key material to get the candidate master key. */ + gcry_ret = AF_merge (hash, split_key, out_key, k->key_size, k->af.stripes); + if (gcry_ret) + { + ret = grub_crypto_gcry_error (gcry_ret); + goto err; + } + + grub_dprintf ("luks2", "Candidate key recovered\n"); + + err: + grub_free (split_key); + return ret; +} + +static grub_err_t +luks2_recover_key (grub_disk_t disk, + grub_cryptodisk_t crypt) +{ + grub_uint8_t candidate_key[GRUB_CRYPTODISK_MAX_KEYLEN]; + char passphrase[MAX_PASSPHRASE], cipher[32]; + char *json_header = NULL, *part = NULL, *ptr; + grub_size_t candidate_key_len = 0, i, size; + grub_luks2_header_t header; + grub_luks2_keyslot_t keyslot; + grub_luks2_digest_t digest; + grub_luks2_segment_t segment; + gcry_err_code_t gcry_ret; + grub_json_t *json = NULL, keyslots; + grub_err_t ret; + + ret = luks2_read_header (disk, &header); + if (ret) + return ret; + + json_header = grub_zalloc (grub_be_to_cpu64 (header.hdr_size) - sizeof (header)); + if (!json_header) + return GRUB_ERR_OUT_OF_MEMORY; + + /* Read the JSON area. */ + ret = grub_disk_read (disk, 0, grub_be_to_cpu64 (header.hdr_offset) + sizeof (header), + grub_be_to_cpu64 (header.hdr_size) - sizeof (header), json_header); + if (ret) + goto err; + + ptr = grub_memchr (json_header, 0, grub_be_to_cpu64 (header.hdr_size) - sizeof (header)); + if (!ptr) + goto err; + + ret = grub_json_parse (&json, json_header, grub_be_to_cpu64 (header.hdr_size)); + if (ret) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid LUKS2 JSON header"); + goto err; + } + + /* Get the passphrase from the user. */ + if (disk->partition) + part = grub_partition_get_name (disk->partition); + grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), disk->name, + disk->partition ? "," : "", part ? : "", + crypt->uuid); + if (!grub_password_get (passphrase, MAX_PASSPHRASE)) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied"); + goto err; + } + + if (grub_json_getvalue (&keyslots, json, "keyslots") || + grub_json_getsize (&size, &keyslots)) + { + ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get keyslots"); + goto err; + } + + /* Try all keyslot */ + for (i = 0; i < size; i++) + { + ret = luks2_get_keyslot (&keyslot, &digest, &segment, json, i); + if (ret) + goto err; + + if (keyslot.priority == 0) + { + grub_dprintf ("luks2", "Ignoring keyslot %"PRIuGRUB_SIZE" due to priority\n", i); + continue; + } + + grub_dprintf ("luks2", "Trying keyslot %"PRIuGRUB_SIZE"\n", i); + + /* Set up disk according to keyslot's segment. */ + crypt->offset = grub_divmod64 (segment.offset, segment.sector_size, NULL); + crypt->log_sector_size = sizeof (unsigned int) * 8 + - __builtin_clz ((unsigned int) segment.sector_size) - 1; + if (grub_strcmp (segment.size, "dynamic") == 0) + crypt->total_length = grub_disk_get_size (disk) - crypt->offset; + else + crypt->total_length = grub_strtoull (segment.size, NULL, 10); + + ret = luks2_decrypt_key (candidate_key, disk, crypt, &keyslot, + (const grub_uint8_t *) passphrase, grub_strlen (passphrase)); + if (ret) + { + grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" failed", i); + continue; + } + + ret = luks2_verify_key (&digest, candidate_key, keyslot.key_size); + if (ret) + { + grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE"\n", i); + continue; + } + + /* + * TRANSLATORS: It's a cryptographic key slot: one element of an array + * where each element is either empty or holds a key. + */ + grub_printf_ (N_("Slot %"PRIuGRUB_SIZE" opened\n"), i); + + candidate_key_len = keyslot.key_size; + break; + } + if (candidate_key_len == 0) + { + ret = grub_error (GRUB_ERR_ACCESS_DENIED, "Invalid passphrase"); + goto err; + } + + /* Set up disk cipher. */ + grub_strncpy (cipher, segment.encryption, sizeof (cipher)); + ptr = grub_memchr (cipher, '-', grub_strlen (cipher)); + if (!ptr) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid encryption"); + *ptr = '\0'; + + ret = grub_cryptodisk_setcipher (crypt, cipher, ptr + 1); + if (ret) + goto err; + + /* Set the master key. */ + gcry_ret = grub_cryptodisk_setkey (crypt, candidate_key, candidate_key_len); + if (gcry_ret) + { + ret = grub_crypto_gcry_error (gcry_ret); + goto err; + } + + err: + grub_free (part); + grub_free (json_header); + grub_json_free (json); + return ret; +} + +static struct grub_cryptodisk_dev luks2_crypto = { + .scan = luks2_scan, + .recover_key = luks2_recover_key +}; + +GRUB_MOD_INIT (luks2) +{ + grub_cryptodisk_dev_register (&luks2_crypto); +} + +GRUB_MOD_FINI (luks2) +{ + grub_cryptodisk_dev_unregister (&luks2_crypto); +} From e96e785580bf9f2e14edb244577ac412b95c5baf Mon Sep 17 00:00:00 2001 From: "C. Masloch" Date: Fri, 20 Dec 2019 16:04:21 +0100 Subject: [PATCH 1038/1167] freedos: Fix FreeDOS command booting large files (near or above 64 KiB) While testing the 86-DOS lDebug [1] booting from GRUB2, newer versions of the debugger would fail to load when booted using GRUB's freedos command. The behaviour observed in a qemu i386 machine was that the ROM-BIOS's boot load would start anew, instead of loading the selected debugger as kernel. It came to light that there was a size limit: Kernel files that were 58880 bytes (E600h) long or shorter succeeded to boot, while files that were 64000 bytes or longer failed in the manner described. Eventually it turned out that the relocator16 stub succeeded whenever it was placed completely within the first 64 KiB of the Low Memory Area. The chunk for the relocator is allocated with a minimum address of 0x8010 and a maximum address just below 0xA0000 [2]. That means if the kernel is, for instance, E600h bytes long, then the kernel will be allocated memory starting at 00600h (the fixed FreeDOS kernel load address) up to E600h + 00600h = 0EC00h, which leaves 1400h (5120) bytes for the relocator to stay in the first 64 KiB. If the kernel is 64000 bytes (FA00h) long, then the relocator must go to FA00h + 00600h = 10000h at least which is outside the first 64 KiB. The problem is that the relocator16 initialises the DS register with a "pseudo real mode" descriptor, which is defined with a segment limit of 64 KiB and a segment base of zero. After that, the relocator addressed parts of itself (implicitly) using the DS register, with an offset from ESI, which holds the linear address of the relocator's base [3]. With the larger kernel files this would lead to accessing data beyond the 64 KiB segment limit, presumably leading to a fault and perhaps a subsequent triple-fault or such. This patch fixes the relocator to set the segment base of the descriptors to the base address of the relocator; then, the subsequent accesses to the relocator's variables are done without the ESI register as an index. This does not interfere with the relocator's or its target's normal operation; the segment limits are still loaded with 64 KiB and all the segment bases are subsequently reset by the relocator anyway. Current versions of the debugger to test are uploaded to [4]. The file ldebugnh.com (LZ4-compressed and built with -D_EXTHELP=0) at 58368 bytes loads successfully, whereas ldebug.com at 64000 bytes fails. Loading one of these files requires setting root to a FAT FS partition and using the freedos command to specify the file as kernel: set root='(hd0,msdos1)' freedos /ldebug.com boot Booting the file using the multiboot command (which uses a WIP entrypoint of the debugger) works, as it does not use GRUB's relocator16 but instead includes a loader in the kernel itself, which drops it back to 86 Mode. [1]: https://hg.ulukai.org/ecm/ldebug [2]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator.c?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n127 [3]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator16.S?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n97 [4]: https://ulukai.org/ecm/lDebug-5479a7988d21-nohelp.zip Signed-off-by: C. Masloch Reviewed-by: Daniel Kiper --- grub-core/lib/i386/relocator16.S | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relocator16.S index 371a2ed69..e9238119b 100644 --- a/grub-core/lib/i386/relocator16.S +++ b/grub-core/lib/i386/relocator16.S @@ -38,15 +38,21 @@ VARIABLE(grub_relocator16_start) #ifdef __APPLE__ LOCAL(cs_base_bytes12_offset) = LOCAL (cs_base_bytes12) - LOCAL (base) LOCAL(cs_base_byte3_offset) = LOCAL (cs_base_byte3) - LOCAL (base) + LOCAL(ds_base_bytes12_offset) = LOCAL (ds_base_bytes12) - LOCAL (base) + LOCAL(ds_base_byte3_offset) = LOCAL (ds_base_byte3) - LOCAL (base) movl %esi, %eax movw %ax, (LOCAL(cs_base_bytes12_offset)) (RSI, 1) + movw %ax, (LOCAL(ds_base_bytes12_offset)) (RSI, 1) shrl $16, %eax movb %al, (LOCAL (cs_base_byte3_offset)) (RSI, 1) + movb %al, (LOCAL (ds_base_byte3_offset)) (RSI, 1) #else movl %esi, %eax movw %ax, (LOCAL (cs_base_bytes12) - LOCAL (base)) (RSI, 1) + movw %ax, (LOCAL (ds_base_bytes12) - LOCAL (base)) (RSI, 1) shrl $16, %eax movb %al, (LOCAL (cs_base_byte3) - LOCAL (base)) (RSI, 1) + movb %al, (LOCAL (ds_base_byte3) - LOCAL (base)) (RSI, 1) #endif RELOAD_GDT @@ -88,15 +94,15 @@ VARIABLE(grub_relocator16_start) LOCAL(segment_offset) = LOCAL (segment) - LOCAL (base) LOCAL(idt_offset) = LOCAL(relocator16_idt) - LOCAL (base) LOCAL(cont2_offset) = LOCAL (cont2) - LOCAL(base) - movw %ax, LOCAL(segment_offset) (%esi, 1) - lidt LOCAL(idt_offset) (%esi, 1) + movw %ax, (LOCAL(segment_offset)) + lidt (LOCAL(idt_offset)) /* jump to a 16 bit segment */ ljmp $PSEUDO_REAL_CSEG, $(LOCAL(cont2_offset)) #else - movw %ax, (LOCAL (segment) - LOCAL (base)) (%esi, 1) + movw %ax, (LOCAL (segment) - LOCAL (base)) - lidt (EXT_C(grub_relocator16_idt) - LOCAL (base)) (%esi, 1) + lidt (EXT_C(grub_relocator16_idt) - LOCAL (base)) /* jump to a 16 bit segment */ ljmp $PSEUDO_REAL_CSEG, $(LOCAL (cont2) - LOCAL(base)) @@ -311,11 +317,17 @@ LOCAL(cs_base_byte3): .byte 0x9E, 0, 0 /* -- 16 bit real mode DS -- - * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present + * base = filled by code, limit 0x0FFFF (1 B Granularity), present * type = 16 bit data read/write, DPL = 0 */ - .word 0xFFFF, 0 - .byte 0, 0x92, 0, 0 + .word 0xFFFF +LOCAL(ds_base_bytes12): + .word 0 +LOCAL(ds_base_byte3): + .byte 0 + + .byte 0x92, 0, 0 + LOCAL(gdt_end): #ifdef __APPLE__ From 598de14d9340137cd7c7a099e8ed53d97f1f68a0 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 27 Jan 2020 15:01:16 -0500 Subject: [PATCH 1039/1167] squash4: Fix an uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc says: grub-core/fs/squash4.c: In function ‘direct_read’: grub-core/fs/squash4.c:868:10: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 868 | if (err) | ^ cc1: all warnings being treated as errors This patch initializes it to GRUB_ERR_NONE. Signed-off-by: Peter Jones Reviewed-by: Daniel Kiper --- grub-core/fs/squash4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c index 95d5c1e1f..82704f966 100644 --- a/grub-core/fs/squash4.c +++ b/grub-core/fs/squash4.c @@ -746,7 +746,7 @@ direct_read (struct grub_squash_data *data, struct grub_squash_cache_inode *ino, grub_off_t off, char *buf, grub_size_t len) { - grub_err_t err; + grub_err_t err = GRUB_ERR_NONE; grub_off_t cumulated_uncompressed_size = 0; grub_uint64_t a = 0; grub_size_t i; From 3165efcfc24dab1cad5a5c2f5e7578bd876e6b52 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 20 Jan 2020 15:07:49 +0100 Subject: [PATCH 1040/1167] minilzo: Update to minilzo-2.08 This patch updates the miniLZO library to a newer version, which among other things fixes "CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow" that is present in the current used in GRUB. It also updates the "GRUB Developers Manual", to mention that the library is used and describes the process to update it to a newer release when needed. Resolves: http://savannah.gnu.org/bugs/?42635 Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- docs/grub-dev.texi | 20 + grub-core/lib/minilzo/lzoconf.h | 216 +- grub-core/lib/minilzo/lzodefs.h | 2582 ++++++++++++++------ grub-core/lib/minilzo/minilzo.c | 4059 +++++++++++++++++++++---------- grub-core/lib/minilzo/minilzo.h | 21 +- 5 files changed, 4769 insertions(+), 2129 deletions(-) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index df2350be0..837873094 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -491,6 +491,7 @@ to update it. @menu * Gnulib:: * jsmn:: +* minilzo:: @end menu @node Gnulib @@ -559,6 +560,25 @@ curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \ -o grub-core/lib/json/jsmn.h @end example +@node minilzo +@section minilzo + +miniLZO is a very lightweight subset of the LZO library intended for easy +inclusion in other projects. It is generated automatically from the LZO +source code and contains the most important LZO functions. + +To upgrade to a new version of the miniLZO library, download the release +tarball and copy the files into the target directory: + +@example +curl -L -O http://www.oberhumer.com/opensource/lzo/download/minilzo-2.08.tar.gz +tar -zxf minilzo-2.08.tar.gz +rm minilzo-2.08/testmini.c +rm -r grub-core/lib/minilzo/* +cp minilzo-2.08/*.[hc] grub-core/lib/minilzo +rm -r minilzo-2.08* +@end example + @node Porting @chapter Porting diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h index 1d0fe14fc..61be29c5d 100644 --- a/grub-core/lib/minilzo/lzoconf.h +++ b/grub-core/lib/minilzo/lzoconf.h @@ -2,22 +2,7 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -44,9 +29,9 @@ #ifndef __LZOCONF_H_INCLUDED #define __LZOCONF_H_INCLUDED 1 -#define LZO_VERSION 0x2050 -#define LZO_VERSION_STRING "2.05" -#define LZO_VERSION_DATE "Apr 23 2011" +#define LZO_VERSION 0x2080 +#define LZO_VERSION_STRING "2.08" +#define LZO_VERSION_DATE "Jun 29 2014" /* internal Autoconf configuration file - only used when building LZO */ #if defined(LZO_HAVE_CONFIG_H) @@ -63,7 +48,7 @@ #if !defined(CHAR_BIT) || (CHAR_BIT != 8) # error "invalid CHAR_BIT" #endif -#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) +#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) # error "check your compiler installation" #endif #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) @@ -85,14 +70,6 @@ extern "C" { // some core defines ************************************************************************/ -#if !defined(LZO_UINT32_C) -# if (UINT_MAX < LZO_0xffffffffL) -# define LZO_UINT32_C(c) c ## UL -# else -# define LZO_UINT32_C(c) ((c) + 0U) -# endif -#endif - /* memory checkers */ #if !defined(__LZO_CHECKER) # if defined(__BOUNDS_CHECKING_ON) @@ -111,28 +88,31 @@ extern "C" { // integral and pointer types ************************************************************************/ -/* lzo_uint should match size_t */ +/* lzo_uint must match size_t */ #if !defined(LZO_UINT_MAX) -# if defined(LZO_ABI_LLP64) /* WIN64 */ -# if defined(LZO_OS_WIN64) +# if (LZO_ABI_LLP64) +# if (LZO_OS_WIN64) typedef unsigned __int64 lzo_uint; typedef __int64 lzo_int; # else - typedef unsigned long long lzo_uint; - typedef long long lzo_int; + typedef lzo_ullong_t lzo_uint; + typedef lzo_llong_t lzo_int; # endif +# define LZO_SIZEOF_LZO_UINT 8 # define LZO_UINT_MAX 0xffffffffffffffffull # define LZO_INT_MAX 9223372036854775807LL # define LZO_INT_MIN (-1LL - LZO_INT_MAX) -# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ +# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ typedef unsigned int lzo_uint; typedef int lzo_int; +# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT # define LZO_UINT_MAX UINT_MAX # define LZO_INT_MAX INT_MAX # define LZO_INT_MIN INT_MIN # elif (ULONG_MAX >= LZO_0xffffffffL) typedef unsigned long lzo_uint; typedef long lzo_int; +# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG # define LZO_UINT_MAX ULONG_MAX # define LZO_INT_MAX LONG_MAX # define LZO_INT_MIN LONG_MIN @@ -141,63 +121,22 @@ extern "C" { # endif #endif -/* Integral types with 32 bits or more. */ -#if !defined(LZO_UINT32_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint32; - typedef int lzo_int32; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint32; - typedef long lzo_int32; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif -#endif - -/* Integral types with exactly 64 bits. */ -#if !defined(LZO_UINT64_MAX) -# if (LZO_UINT_MAX >= LZO_0xffffffffL) -# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) -# define lzo_uint64 lzo_uint -# define lzo_int64 lzo_int -# define LZO_UINT64_MAX LZO_UINT_MAX -# define LZO_INT64_MAX LZO_INT_MAX -# define LZO_INT64_MIN LZO_INT_MIN -# endif -# elif (ULONG_MAX >= LZO_0xffffffffL) -# if ((((ULONG_MAX) >> 31) >> 31) == 3) - typedef unsigned long lzo_uint64; - typedef long lzo_int64; -# define LZO_UINT64_MAX ULONG_MAX -# define LZO_INT64_MAX LONG_MAX -# define LZO_INT64_MIN LONG_MIN -# endif -# endif -#endif - -/* The larger type of lzo_uint and lzo_uint32. */ -#if (LZO_UINT_MAX >= LZO_UINT32_MAX) +/* The larger type of lzo_uint and lzo_uint32_t. */ +#if (LZO_SIZEOF_LZO_UINT >= 4) # define lzo_xint lzo_uint #else -# define lzo_xint lzo_uint32 +# define lzo_xint lzo_uint32_t #endif -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL /*empty*/ -# elif defined(LZO_HAVE_MM_HUGE_PTR) -# define __LZO_MMODEL_HUGE 1 -# define __LZO_MMODEL __huge -# else -# define __LZO_MMODEL /*empty*/ -# endif +typedef int lzo_bool; + +/* sanity checks */ +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) + +#ifndef __LZO_MMODEL +#define __LZO_MMODEL /*empty*/ #endif /* no typedef here because of const-pointer issues */ @@ -206,21 +145,52 @@ extern "C" { #define lzo_voidp void __LZO_MMODEL * #define lzo_shortp short __LZO_MMODEL * #define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#if defined(LZO_UINT64_MAX) -#define lzo_uint64p lzo_uint64 __LZO_MMODEL * -#define lzo_int64p lzo_int64 __LZO_MMODEL * -#endif -#define lzo_uintp lzo_uint __LZO_MMODEL * #define lzo_intp lzo_int __LZO_MMODEL * +#define lzo_uintp lzo_uint __LZO_MMODEL * #define lzo_xintp lzo_xint __LZO_MMODEL * #define lzo_voidpp lzo_voidp __LZO_MMODEL * #define lzo_bytepp lzo_bytep __LZO_MMODEL * -/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -#define lzo_byte unsigned char __LZO_MMODEL -typedef int lzo_bool; +#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * +#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * +#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * +#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * +#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * +#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * +#if defined(lzo_int64_t) +#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * +#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * +#endif + +/* Older LZO versions used to support ancient systems and memory models + * like 16-bit MSDOS with __huge pointers and Cray PVP, but these + * obsolete configurations are not supported any longer. + */ +#if defined(__LZO_MMODEL_HUGE) +#error "__LZO_MMODEL_HUGE is unsupported" +#endif +#if (LZO_MM_PVP) +#error "LZO_MM_PVP is unsupported" +#endif +#if (LZO_SIZEOF_INT < 4) +#error "LZO_SIZEOF_INT < 4 is unsupported" +#endif +#if (__LZO_UINTPTR_T_IS_POINTER) +#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) +/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should + * work but have not received much testing lately, so be strict here. + */ +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) /*********************************************************************** @@ -315,7 +285,7 @@ struct lzo_callback_t /* a progress indicator callback function (set to 0 to disable) */ lzo_progress_func_t nprogress; - /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress + /* INFO: the first parameter "self" of the nalloc/nfree/nprogress * callbacks points back to this struct, so you are free to store * some extra info in the following variables. */ lzo_voidp user1; @@ -343,6 +313,9 @@ struct lzo_callback_t #define LZO_E_INPUT_NOT_CONSUMED (-8) #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ #define LZO_E_INVALID_ARGUMENT (-10) +#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ +#define LZO_E_OUTPUT_NOT_CONSUMED (-12) +#define LZO_E_INTERNAL_ERROR (-99) #ifndef lzo_sizeof_dict_t @@ -356,7 +329,7 @@ struct lzo_callback_t * compiler's view of various types are consistent. */ #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ - (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ + (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ (int)sizeof(lzo_callback_t)) LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); @@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) lzo_memset(lzo_voidp buf, int c, lzo_uint len); /* checksum functions */ -LZO_EXTERN(lzo_uint32) - lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(lzo_uint32) - lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(const lzo_uint32p) +LZO_EXTERN(lzo_uint32_t) + lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); +LZO_EXTERN(lzo_uint32_t) + lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); +LZO_EXTERN(const lzo_uint32_tp) lzo_get_crc32_table(void); /* misc. */ LZO_EXTERN(int) _lzo_config_check(void); -typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; -typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; -typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; +typedef union { + lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; + void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; +#if defined(lzo_int64_t) + lzo_uint64_t a10; +#endif +} lzo_align_t; /* align a char pointer on a boundary that is a multiple of 'size' */ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); @@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); /*********************************************************************** -// deprecated macros - only for backward compatibility with LZO v1.xx +// deprecated macros - only for backward compatibility ************************************************************************/ +/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ +#define lzo_byte unsigned char +/* deprecated type names */ +#define lzo_int32 lzo_int32_t +#define lzo_uint32 lzo_uint32_t +#define lzo_int32p lzo_int32_t __LZO_MMODEL * +#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * +#define LZO_INT32_MAX LZO_INT32_C(2147483647) +#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) +#if defined(lzo_int64_t) +#define lzo_int64 lzo_int64_t +#define lzo_uint64 lzo_uint64_t +#define lzo_int64p lzo_int64_t __LZO_MMODEL * +#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * +#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) +#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) +#endif +/* deprecated types */ +typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; +typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; + #if defined(LZO_CFG_COMPAT) #define __LZOCONF_H 1 @@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); #endif /* already included */ -/* vim:set ts=4 et: */ +/* vim:set ts=4 sw=4 et: */ diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h index 0e40e332a..f4ae9487e 100644 --- a/grub-core/lib/minilzo/lzodefs.h +++ b/grub-core/lib/minilzo/lzodefs.h @@ -2,22 +2,7 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -47,12 +32,6 @@ #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif -#if defined(__IBMCPP__) && !defined(__IBMC__) -# define __IBMC__ __IBMCPP__ -#endif -#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) -# define __INTEL_COMPILER __ICL -#endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif @@ -61,19 +40,30 @@ # define __LONG_MAX__ 9223372036854775807L # endif #endif -#if defined(__INTEL_COMPILER) && defined(__linux__) +#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) +#if defined(__ARMCC_VERSION) +# pragma diag_suppress 193 +#elif defined(__clang__) && defined(__clang_minor__) +# pragma clang diagnostic ignored "-Wundef" +#elif defined(__INTEL_COMPILER) # pragma warning(disable: 193) -#endif -#if defined(__KEIL__) && defined(__C166__) +#elif defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 -#elif 0 && defined(__C251__) -# pragma warning disable = 322 -#endif -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -# if (_MSC_VER >= 1300) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) +# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) +# pragma GCC diagnostic ignored "-Wundef" +# endif +#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +# if ((_MSC_VER-0) >= 1300) # pragma warning(disable: 4668) # endif #endif +#endif +#if 0 && defined(__POCC__) && defined(_WIN32) +# if (__POCC__ >= 400) +# pragma warn(disable: 2216) +# endif +#endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 @@ -82,13 +72,29 @@ #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif -#if 0 -#define LZO_0xffffL 0xfffful -#define LZO_0xffffffffL 0xfffffffful -#else -#define LZO_0xffffL 65535ul -#define LZO_0xffffffffL 4294967295ul +#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) +#ifndef _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE 1 #endif +#ifndef _CRT_NONSTDC_NO_WARNINGS +#define _CRT_NONSTDC_NO_WARNINGS 1 +#endif +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS 1 +#endif +#endif +#if 0 +#define LZO_0xffffUL 0xfffful +#define LZO_0xffffffffUL 0xfffffffful +#else +#define LZO_0xffffUL 65535ul +#define LZO_0xffffffffUL 4294967295ul +#endif +#define LZO_0xffffL LZO_0xffffUL +#define LZO_0xffffffffL LZO_0xffffffffUL #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif @@ -103,6 +109,13 @@ # error "your preprocessor is broken 4" #endif #endif +#if defined(__COUNTER__) +# ifndef LZO_CFG_USE_COUNTER +# define LZO_CFG_USE_COUNTER 1 +# endif +#else +# undef LZO_CFG_USE_COUNTER +#endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) @@ -233,14 +246,31 @@ #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) +#define LZO_PP_CONCAT0() /*empty*/ +#define LZO_PP_CONCAT1(a) a #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f +#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g +#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() +#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) +#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) +#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) +#define LZO_PP_EMPTY /*empty*/ +#define LZO_PP_EMPTY0() /*empty*/ +#define LZO_PP_EMPTY1(a) /*empty*/ +#define LZO_PP_EMPTY2(a,b) /*empty*/ +#define LZO_PP_EMPTY3(a,b,c) /*empty*/ +#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ +#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ +#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ +#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) @@ -248,12 +278,16 @@ #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f +#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) +#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) +#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) #endif -#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) +#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 @@ -263,9 +297,13 @@ # endif #endif #if defined(__cplusplus) -# define LZO_EXTERN_C extern "C" +# define LZO_EXTERN_C extern "C" +# define LZO_EXTERN_C_BEGIN extern "C" { +# define LZO_EXTERN_C_END } #else -# define LZO_EXTERN_C extern +# define LZO_EXTERN_C extern +# define LZO_EXTERN_C_BEGIN /*empty*/ +# define LZO_EXTERN_C_END /*empty*/ #endif #if !defined(__LZO_OS_OVERRIDE) #if (LZO_OS_FREESTANDING) @@ -366,12 +404,12 @@ #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" -#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" -#elif (defined(__mips__) && defined(__psp__)) +#elif defined(__mips__) && defined(__psp__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" @@ -399,9 +437,18 @@ # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" -# elif defined(__APPLE__) || defined(__MACOS__) -# define LZO_OS_POSIX_MACOSX 1 -# define LZO_INFO_OS_POSIX "macosx" +# elif defined(__APPLE__) && defined(__MACH__) +# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) +# define LZO_OS_POSIX_DARWIN 1040 +# define LZO_INFO_OS_POSIX "darwin_iphone" +# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) +# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# define LZO_INFO_OS_POSIX "darwin" +# else +# define LZO_OS_POSIX_DARWIN 1 +# define LZO_INFO_OS_POSIX "darwin" +# endif +# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" @@ -436,18 +483,18 @@ #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) @@ -463,59 +510,65 @@ # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) -# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) +# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ -#elif defined(__INTEL_COMPILER) -# define LZO_CC_INTELC 1 +# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# endif +#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) +# define LZO_CC_INTELC __INTEL_COMPILER # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) -# if defined(_WIN32) || defined(_WIN64) -# define LZO_CC_SYNTAX_MSC 1 -# else -# define LZO_CC_SYNTAX_GNUC 1 +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_INTELC_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) -#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif +# define LZO_CC_ARMCC __ARMCC_VERSION +# define LZO_INFO_CC "ARM C Compiler" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) -# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) +# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) # else -# define LZO_CC_CLANG_CLANG 0x010000L +# define LZO_CC_CLANG 0x010000L +# endif +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_CLANG_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif -# define LZO_CC_CLANG LZO_CC_CLANG_GNUC # define LZO_INFO_CC "clang" # define LZO_INFO_CCVER __VERSION__ #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_LLVM LZO_CC_LLVM_GNUC # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ -#elif defined(__GNUC__) && defined(__VERSION__) -# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# elif defined(__GNUC_MINOR__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# else -# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -# endif -# define LZO_INFO_CC "gcc" -# define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" +#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) +# define LZO_CC_ARMCC __ARMCC_VERSION +# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION +# define LZO_INFO_CC "ARM C Compiler" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" @@ -540,10 +593,23 @@ # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) +#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) +# define LZO_CC_GHS 1 +# define LZO_INFO_CC "Green Hills C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_GHS_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# endif #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" +#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) +# define LZO_CC_HPACC __HP_aCC +# define LZO_INFO_CC "HP aCC" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" @@ -552,10 +618,14 @@ # else # define LZO_INFO_CCVER "unknown" # endif -#elif defined(__IBMC__) -# define LZO_CC_IBMC 1 +#elif defined(__IBMC__) && ((__IBMC__-0) > 0) +# define LZO_CC_IBMC __IBMC__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) +#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) +# define LZO_CC_IBMC __IBMCPP__ +# define LZO_INFO_CC "IBM C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" @@ -572,16 +642,8 @@ # else # define LZO_INFO_CCVER "unknown" # endif -#elif defined(_MSC_VER) -# define LZO_CC_MSC 1 -# define LZO_INFO_CC "Microsoft C" -# if defined(_MSC_FULL_VER) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -# endif -#elif defined(__MWERKS__) -# define LZO_CC_MWERKS 1 +#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) +# define LZO_CC_MWERKS __MWERKS__ # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) @@ -592,6 +654,15 @@ # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) +#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) +# else +# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" +# endif +# define LZO_INFO_CC "Portland Group PGI C" #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" @@ -606,7 +677,7 @@ # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_C)+0 > 0) +# if ((__SUNPRO_C-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else @@ -615,7 +686,7 @@ # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_CC)+0 > 0) +# if ((__SUNPRO_CC-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else @@ -641,16 +712,46 @@ #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" -# if (__ZTC__ == 0x310) +# if ((__ZTC__-0) == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif +#elif defined(__GNUC__) && defined(__VERSION__) +# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# elif defined(__GNUC_MINOR__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) +# else +# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +# endif +# define LZO_INFO_CC "gcc" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_MSC _MSC_VER +# define LZO_INFO_CC "Microsoft C" +# if defined(_MSC_FULL_VER) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +# else +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +# endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif +#if (LZO_CC_GNUC) && defined(__OPEN64__) +# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) +# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) +# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC +# endif +#endif +#if (LZO_CC_GNUC) && defined(__PCC__) +# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) +# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) +# define LZO_CC_PCC_GNUC LZO_CC_GNUC +# endif +#endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif @@ -668,8 +769,10 @@ # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 -# define LZO_ARCH_IA16 1 # define LZO_INFO_ARCH "i086" +#elif defined(__aarch64__) +# define LZO_ARCH_ARM64 1 +# define LZO_INFO_ARCH "arm64" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" @@ -685,10 +788,10 @@ # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 -# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) +# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" -# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) +# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" @@ -806,53 +909,147 @@ # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) -# error "FIXME - missing WIN32 define for CPU architecture" +# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) -# error "FIXME - missing WIN64 define for CPU architecture" +# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #endif -#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) -# error "this should not happen" +#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) +# define LZO_ARCH_X64 1 +#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_AMD64 1 #endif -#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) -# error "this should not happen" +#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) +# define LZO_ARCH_AARCH64 1 +#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_ARM64 1 +#endif +#if (LZO_ARCH_I386 && !LZO_ARCH_X86) +# define LZO_ARCH_X86 1 +#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_I386 1 +#endif +#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) +# error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif -#if !defined(__LZO_MM_OVERRIDE) +#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) +# if !defined(LZO_TARGET_FEATURE_SSE2) +# if defined(__SSE2__) +# define LZO_TARGET_FEATURE_SSE2 1 +# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) +# define LZO_TARGET_FEATURE_SSE2 1 +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_SSSE3) +# if (LZO_TARGET_FEATURE_SSE2) +# if defined(__SSSE3__) +# define LZO_TARGET_FEATURE_SSSE3 1 +# elif defined(_MSC_VER) && defined(__AVX__) +# define LZO_TARGET_FEATURE_SSSE3 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_SSE4_2) +# if (LZO_TARGET_FEATURE_SSSE3) +# if defined(__SSE4_2__) +# define LZO_TARGET_FEATURE_SSE4_2 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_AVX) +# if (LZO_TARGET_FEATURE_SSSE3) +# if defined(__AVX__) +# define LZO_TARGET_FEATURE_AVX 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_AVX2) +# if (LZO_TARGET_FEATURE_AVX) +# if defined(__AVX2__) +# define LZO_TARGET_FEATURE_AVX2 1 +# endif +# endif +# endif +#endif +#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM) +# if !defined(LZO_TARGET_FEATURE_NEON) +# if defined(__ARM_NEON__) +# define LZO_TARGET_FEATURE_NEON 1 +# endif +# endif +#elif (LZO_ARCH_ARM64) +# if !defined(LZO_TARGET_FEATURE_NEON) +# if 1 +# define LZO_TARGET_FEATURE_NEON 1 +# endif +# endif +#endif +#if 0 +#elif !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 @@ -879,7 +1076,7 @@ #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else -# error "unknown memory model" +# error "unknown LZO_ARCH_I086 memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 @@ -902,10 +1099,10 @@ #endif #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # elif (LZO_CC_ZORTECHC) # else -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #ifdef __cplusplus @@ -937,7 +1134,7 @@ extern "C" { #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) -# error "FIXME - C166 __MODEL__" +# error "FIXME - LZO_ARCH_C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) @@ -951,11 +1148,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - C166 __MODEL__" +# error "FIXME - LZO_ARCH_C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) -# error "FIXME - MCS251 __MODEL__" +# error "FIXME - LZO_ARCH_MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) @@ -967,11 +1164,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - MCS251 __MODEL__" +# error "FIXME - LZO_ARCH_MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) -# error "FIXME - MCS51 __MODEL__" +# error "FIXME - LZO_ARCH_MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) @@ -983,7 +1180,7 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - MCS51 __MODEL__" +# error "FIXME - LZO_ARCH_MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 @@ -1010,567 +1207,156 @@ extern "C" { # error "unknown memory model" #endif #endif -#if defined(SIZEOF_SHORT) -# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -#endif -#if defined(SIZEOF_INT) -# define LZO_SIZEOF_INT (SIZEOF_INT) -#endif -#if defined(SIZEOF_LONG) -# define LZO_SIZEOF_LONG (SIZEOF_LONG) -#endif -#if defined(SIZEOF_LONG_LONG) -# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -#endif -#if defined(SIZEOF___INT16) -# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -#endif -#if defined(SIZEOF___INT32) -# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -#endif -#if defined(SIZEOF___INT64) -# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -#endif -#if defined(SIZEOF_VOID_P) -# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -#endif -#if defined(SIZEOF_SIZE_T) -# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -#endif -#if defined(SIZEOF_PTRDIFF_T) -# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -#endif -#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -#if !defined(LZO_SIZEOF_SHORT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_SHORT 8 -# elif (USHRT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,7) == 1) -# define LZO_SIZEOF_SHORT 1 -# elif (__LZO_LSR(USHRT_MAX,15) == 1) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,31) == 1) -# define LZO_SIZEOF_SHORT 4 -# elif (__LZO_LSR(USHRT_MAX,63) == 1) -# define LZO_SIZEOF_SHORT 8 -# elif (__LZO_LSR(USHRT_MAX,127) == 1) -# define LZO_SIZEOF_SHORT 16 -# else -# error "LZO_SIZEOF_SHORT" -# endif -#endif -#if !defined(LZO_SIZEOF_INT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_INT 8 -# elif (UINT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_INT 2 -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,7) == 1) -# define LZO_SIZEOF_INT 1 -# elif (__LZO_LSR(UINT_MAX,15) == 1) -# define LZO_SIZEOF_INT 2 -# elif (__LZO_LSR(UINT_MAX,31) == 1) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,63) == 1) -# define LZO_SIZEOF_INT 8 -# elif (__LZO_LSR(UINT_MAX,127) == 1) -# define LZO_SIZEOF_INT 16 -# else -# error "LZO_SIZEOF_INT" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG) -# if (ULONG_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,7) == 1) -# define LZO_SIZEOF_LONG 1 -# elif (__LZO_LSR(ULONG_MAX,15) == 1) -# define LZO_SIZEOF_LONG 2 -# elif (__LZO_LSR(ULONG_MAX,31) == 1) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,63) == 1) -# define LZO_SIZEOF_LONG 8 -# elif (__LZO_LSR(ULONG_MAX,127) == 1) -# define LZO_SIZEOF_LONG 16 -# else -# error "LZO_SIZEOF_LONG" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -# if (LZO_CC_GNUC >= 0x030300ul) -# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -# define LZO_SIZEOF_LONG_LONG 4 -# endif -# endif -# endif -#endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -#if (LZO_ARCH_I086 && LZO_CC_DMC) -#elif (LZO_CC_CILLY) && defined(__GNUC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_SIZEOF_LONG_LONG 8 -#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_OS_WIN64 || defined(_WIN64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define LZO_SIZEOF_LONG_LONG 8 -#endif -#endif -#endif -#if defined(__cplusplus) && (LZO_CC_GNUC) -# if (LZO_CC_GNUC < 0x020800ul) -# undef LZO_SIZEOF_LONG_LONG -# endif -#endif -#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -# undef LZO_SIZEOF_LONG_LONG -#endif -#if !defined(LZO_SIZEOF_VOID_P) -#if (LZO_ARCH_I086) -# define __LZO_WORDSIZE 2 -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -# define LZO_SIZEOF_VOID_P 2 -# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -# define LZO_SIZEOF_VOID_P 4 -# else -# error "LZO_MM" -# endif -#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) -# define __LZO_WORDSIZE 1 -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_H8300) -# if defined(__NORMAL_MODE__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 2 -# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 4 -# else -# define __LZO_WORDSIZE 2 -# define LZO_SIZEOF_VOID_P 2 -# endif -# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -# endif -#elif (LZO_ARCH_M16C) -# define __LZO_WORDSIZE 2 -# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -# define LZO_SIZEOF_VOID_P 4 -# else -# define LZO_SIZEOF_VOID_P 2 -# endif -#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 4 -#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_OS_OS400 || defined(__OS400__)) -# define __LZO_WORDSIZE LZO_SIZEOF_LONG -# define LZO_SIZEOF_VOID_P 16 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_VOID_P 8 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_ARCH_SPU) -# if 0 -# define __LZO_WORDSIZE 16 -# endif -# define LZO_SIZEOF_VOID_P 4 -#else -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -#endif -#endif -#if !defined(LZO_WORDSIZE) -# if defined(__LZO_WORDSIZE) -# define LZO_WORDSIZE __LZO_WORDSIZE -# else -# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -# endif -#endif -#if !defined(LZO_SIZEOF_SIZE_T) -#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -# define LZO_SIZEOF_SIZE_T 2 -#else -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -#endif -#endif -#if !defined(LZO_SIZEOF_PTRDIFF_T) -#if (LZO_ARCH_I086) -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -# define LZO_SIZEOF_PTRDIFF_T 4 -# else -# define LZO_SIZEOF_PTRDIFF_T 2 -# endif -# else -# error "LZO_MM" -# endif -#else -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -#endif -#endif -#if (LZO_ABI_NEUTRAL_ENDIAN) -# undef LZO_ABI_BIG_ENDIAN -# undef LZO_ABI_LITTLE_ENDIAN -#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -# define LZO_ABI_BIG_ENDIAN 1 -#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -# if (__LITTLE_ENDIAN__ == 1) -# define LZO_ABI_LITTLE_ENDIAN 1 -# else -# define LZO_ABI_BIG_ENDIAN 1 -# endif -#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#endif -#endif -#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -# error "this should not happen" -#endif -#if (LZO_ABI_BIG_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "be" -#elif (LZO_ABI_LITTLE_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "le" -#elif (LZO_ABI_NEUTRAL_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "neutral" -#endif -#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_I8LP16 1 -# define LZO_INFO_ABI_PM "i8lp16" -#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_ILP16 1 -# define LZO_INFO_ABI_PM "ilp16" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_ILP32 1 -# define LZO_INFO_ABI_PM "ilp32" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -# define LZO_ABI_LLP64 1 -# define LZO_INFO_ABI_PM "llp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_LP64 1 -# define LZO_INFO_ABI_PM "lp64" -#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_ILP64 1 -# define LZO_INFO_ABI_PM "ilp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_IP32L64 1 -# define LZO_INFO_ABI_PM "ip32l64" -#endif -#if !defined(__LZO_LIBC_OVERRIDE) -#if (LZO_LIBC_NAKED) -# define LZO_INFO_LIBC "naked" -#elif (LZO_LIBC_FREESTANDING) -# define LZO_INFO_LIBC "freestanding" -#elif (LZO_LIBC_MOSTLY_FREESTANDING) -# define LZO_INFO_LIBC "mfreestanding" -#elif (LZO_LIBC_ISOC90) -# define LZO_INFO_LIBC "isoc90" -#elif (LZO_LIBC_ISOC99) -# define LZO_INFO_LIBC "isoc99" -#elif defined(__dietlibc__) -# define LZO_LIBC_DIETLIBC 1 -# define LZO_INFO_LIBC "dietlibc" -#elif defined(_NEWLIB_VERSION) -# define LZO_LIBC_NEWLIB 1 -# define LZO_INFO_LIBC "newlib" -#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -# if defined(__UCLIBC_SUBLEVEL__) -# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -# else -# define LZO_LIBC_UCLIBC 0x00090bL -# endif -# define LZO_INFO_LIBC "uclibc" -#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -# define LZO_INFO_LIBC "glibc" -#elif (LZO_CC_MWERKS) && defined(__MSL__) -# define LZO_LIBC_MSL __MSL__ -# define LZO_INFO_LIBC "msl" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_LIBC_ISOC90 1 -# define LZO_INFO_LIBC "isoc90" -#else -# define LZO_LIBC_DEFAULT 1 -# define LZO_INFO_LIBC "default" -#endif -#endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_gnuc_extension__ __extension__ +#elif (LZO_CC_IBMC >= 600) # define __lzo_gnuc_extension__ __extension__ #else +#endif +#endif +#if !defined(__lzo_gnuc_extension__) # define __lzo_gnuc_extension__ /*empty*/ #endif -#endif -#if !defined(__lzo_ua_volatile) -# define __lzo_ua_volatile volatile -#endif -#if !defined(__lzo_alignof) -#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_alignof(e) __alignof(e) -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_alignof(e) __alignof__(e) -#endif -#endif -#if defined(__lzo_alignof) -# define __lzo_HAVE_alignof 1 -#endif -#if !defined(__lzo_constructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_constructor __attribute__((__constructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_constructor __attribute__((__constructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_constructor __attribute__((__constructor__)) -#endif -#endif -#if defined(__lzo_constructor) -# define __lzo_HAVE_constructor 1 -#endif -#if !defined(__lzo_destructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_destructor __attribute__((__destructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_destructor __attribute__((__destructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_destructor __attribute__((__destructor__)) -#endif -#endif -#if defined(__lzo_destructor) -# define __lzo_HAVE_destructor 1 -#endif -#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -# error "this should not happen" -#endif -#if !defined(__lzo_inline) -#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -#elif defined(__cplusplus) -# define __lzo_inline inline -#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -# define __lzo_inline __inline -#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_inline __inline__ -#elif (LZO_CC_DMC) -# define __lzo_inline __inline -#elif (LZO_CC_INTELC) -# define __lzo_inline __inline -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -# define __lzo_inline __inline -#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -# define __lzo_inline __inline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_inline __inline__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define __lzo_inline inline -#endif -#endif -#if defined(__lzo_inline) -# define __lzo_HAVE_inline 1 -#else -# define __lzo_inline /*empty*/ -#endif -#if !defined(__lzo_forceinline) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#endif -#endif -#if defined(__lzo_forceinline) -# define __lzo_HAVE_forceinline 1 -#else -# define __lzo_forceinline /*empty*/ -#endif -#if !defined(__lzo_noinline) -#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -# define __lzo_noinline __attribute__((__noinline__,__used__)) -#elif (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -# if defined(__cplusplus) +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 +# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 +# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 # else -# define __lzo_noinline __declspec(noinline) +# define LZO_CFG_USE_NEW_STYLE_CASTS 1 # endif -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_noinline __attribute__((__noinline__)) #endif +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif -#if defined(__lzo_noinline) -# define __lzo_HAVE_noinline 1 -#else -# define __lzo_noinline /*empty*/ +#if !defined(__cplusplus) +# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# undef LZO_CFG_USE_NEW_STYLE_CASTS +# endif +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif -#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -# error "this should not happen" +#if !defined(LZO_REINTERPRET_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) +# endif #endif -#if !defined(__lzo_noreturn) -#if (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_noreturn __declspec(noreturn) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_noreturn __declspec(noreturn) +#if !defined(LZO_REINTERPRET_CAST) +# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) #endif +#if !defined(LZO_STATIC_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_STATIC_CAST(t,e) (static_cast (e)) +# endif #endif -#if defined(__lzo_noreturn) -# define __lzo_HAVE_noreturn 1 -#else -# define __lzo_noreturn /*empty*/ +#if !defined(LZO_STATIC_CAST) +# define LZO_STATIC_CAST(t,e) ((t) (e)) #endif -#if !defined(__lzo_nothrow) -#if (LZO_CC_GNUC >= 0x030300ul) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) +#if !defined(LZO_STATIC_CAST2) +# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) #endif +#if !defined(LZO_UNCONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNCONST_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) +# endif #endif -#if defined(__lzo_nothrow) -# define __lzo_HAVE_nothrow 1 -#else -# define __lzo_nothrow /*empty*/ +#if !defined(LZO_UNCONST_CAST) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) #endif -#if !defined(__lzo_restrict) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -# define __lzo_restrict __restrict +#if !defined(LZO_UNCONST_VOLATILE_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) +# endif #endif +#if !defined(LZO_UNCONST_VOLATILE_CAST) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) #endif -#if defined(__lzo_restrict) -# define __lzo_HAVE_restrict 1 -#else -# define __lzo_restrict /*empty*/ +#if !defined(LZO_UNVOLATILE_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) +# endif #endif -#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#if !defined(LZO_UNVOLATILE_CAST) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) #endif +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) +# endif #endif -#if defined(__lzo_likely) -# define __lzo_HAVE_likely 1 -#else -# define __lzo_likely(e) (e) +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) #endif -#if defined(__lzo_unlikely) -# define __lzo_HAVE_unlikely 1 -#else -# define __lzo_unlikely(e) (e) +#if !defined(LZO_PCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_PCAST(t,e) ((t) (e)) +# endif +#endif +#if !defined(LZO_PCAST) +# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) +#endif +#if !defined(LZO_CCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_CCAST(t,e) ((t) (e)) +# endif +#endif +#if !defined(LZO_CCAST) +# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) +#endif +#if !defined(LZO_ICONV) +# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(LZO_ICAST) +# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(LZO_ITRUNC) +# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(__lzo_cte) +# if (LZO_CC_MSC || LZO_CC_WATCOMC) +# define __lzo_cte(e) ((void)0,(e)) +# elif 1 +# define __lzo_cte(e) ((void)0,(e)) +# endif +#endif +#if !defined(__lzo_cte) +# define __lzo_cte(e) (e) +#endif +#if !defined(LZO_BLOCK_BEGIN) +# define LZO_BLOCK_BEGIN do { +# define LZO_BLOCK_END } while __lzo_cte(0) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else +# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) +# define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) -# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) @@ -1591,18 +1377,18 @@ extern "C" { # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) -# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} +# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) -# if (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -# define LZO_UNUSED_LABEL(l) if (0) goto l +# if (LZO_CC_CLANG >= 0x020800ul) +# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) +# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l # else -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) @@ -1614,39 +1400,488 @@ extern "C" { # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif -#if !defined(LZO_UNCONST_CAST) -# if 0 && defined(__cplusplus) -# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) -# else -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +#if !defined(__lzo_inline) +#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) +#elif defined(__cplusplus) +# define __lzo_inline inline +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) +# define __lzo_inline inline +#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) +# define __lzo_inline __inline +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_inline __inline__ +#elif (LZO_CC_DMC) +# define __lzo_inline __inline +#elif (LZO_CC_GHS) +# define __lzo_inline __inline__ +#elif (LZO_CC_IBMC >= 600) +# define __lzo_inline __inline__ +#elif (LZO_CC_INTELC) +# define __lzo_inline __inline +#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) +# define __lzo_inline __inline +#elif (LZO_CC_MSC && (_MSC_VER >= 900)) +# define __lzo_inline __inline +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_inline __inline__ +#endif +#endif +#if defined(__lzo_inline) +# ifndef __lzo_HAVE_inline +# define __lzo_HAVE_inline 1 # endif +#else +# define __lzo_inline /*empty*/ +#endif +#if !defined(__lzo_forceinline) +#if (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) +# define __lzo_forceinline __forceinline +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +# define __lzo_forceinline __forceinline +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#endif +#endif +#if defined(__lzo_forceinline) +# ifndef __lzo_HAVE_forceinline +# define __lzo_HAVE_forceinline 1 +# endif +#else +# define __lzo_forceinline __lzo_inline +#endif +#if !defined(__lzo_noinline) +#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) +# define __lzo_noinline __attribute__((__noinline__,__used__)) +#elif (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) +# define __lzo_noinline __declspec(noinline) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_noinline __declspec(noinline) +#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) +# if defined(__cplusplus) +# else +# define __lzo_noinline __declspec(noinline) +# endif +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_noinline __attribute__((__noinline__)) +#endif +#endif +#if defined(__lzo_noinline) +# ifndef __lzo_HAVE_noinline +# define __lzo_HAVE_noinline 1 +# endif +#else +# define __lzo_noinline /*empty*/ +#endif +#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +# error "unexpected configuration - check your compiler defines" +#endif +#if !defined(__lzo_static_inline) +#if (LZO_CC_IBMC) +# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline +#endif +#endif +#if !defined(__lzo_static_inline) +# define __lzo_static_inline static __lzo_inline +#endif +#if !defined(__lzo_static_forceinline) +#if (LZO_CC_IBMC) +# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline +#endif +#endif +#if !defined(__lzo_static_forceinline) +# define __lzo_static_forceinline static __lzo_forceinline +#endif +#if !defined(__lzo_static_noinline) +#if (LZO_CC_IBMC) +# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline +#endif +#endif +#if !defined(__lzo_static_noinline) +# define __lzo_static_noinline static __lzo_noinline +#endif +#if !defined(__lzo_c99_extern_inline) +#if defined(__GNUC_GNU_INLINE__) +# define __lzo_c99_extern_inline __lzo_inline +#elif defined(__GNUC_STDC_INLINE__) +# define __lzo_c99_extern_inline extern __lzo_inline +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) +# define __lzo_c99_extern_inline extern __lzo_inline +#endif +#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) +# define __lzo_c99_extern_inline __lzo_inline +#endif +#endif +#if defined(__lzo_c99_extern_inline) +# ifndef __lzo_HAVE_c99_extern_inline +# define __lzo_HAVE_c99_extern_inline 1 +# endif +#else +# define __lzo_c99_extern_inline /*empty*/ +#endif +#if !defined(__lzo_may_alias) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_CLANG >= 0x020900ul) +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 +# define __lzo_may_alias __attribute__((__may_alias__)) +#endif +#endif +#if defined(__lzo_may_alias) +# ifndef __lzo_HAVE_may_alias +# define __lzo_HAVE_may_alias 1 +# endif +#else +# define __lzo_may_alias /*empty*/ +#endif +#if !defined(__lzo_noreturn) +#if (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) +# define __lzo_noreturn __declspec(noreturn) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +# define __lzo_noreturn __declspec(noreturn) +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_noreturn __attribute__((__noreturn__)) +#endif +#endif +#if defined(__lzo_noreturn) +# ifndef __lzo_HAVE_noreturn +# define __lzo_HAVE_noreturn 1 +# endif +#else +# define __lzo_noreturn /*empty*/ +#endif +#if !defined(__lzo_nothrow) +#if (LZO_CC_GNUC >= 0x030300ul) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) +# define __lzo_nothrow __declspec(nothrow) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) +# define __lzo_nothrow __declspec(nothrow) +#endif +#endif +#if defined(__lzo_nothrow) +# ifndef __lzo_HAVE_nothrow +# define __lzo_HAVE_nothrow 1 +# endif +#else +# define __lzo_nothrow /*empty*/ +#endif +#if !defined(__lzo_restrict) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_IBMC >= 1210) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) +# define __lzo_restrict __restrict +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_restrict __restrict__ +#endif +#endif +#if defined(__lzo_restrict) +# ifndef __lzo_HAVE_restrict +# define __lzo_HAVE_restrict 1 +# endif +#else +# define __lzo_restrict /*empty*/ +#endif +#if !defined(__lzo_alignof) +#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_GHS) && !defined(__cplusplus) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_IBMC >= 600) +# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) +#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_alignof(e) __alignof(e) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_alignof(e) __alignof__(e) +#endif +#endif +#if defined(__lzo_alignof) +# ifndef __lzo_HAVE_alignof +# define __lzo_HAVE_alignof 1 +# endif +#endif +#if !defined(__lzo_struct_packed) +#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) +#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) +#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) +# define __lzo_struct_packed(s) struct s { +# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_struct_packed(s) struct s { +# define __lzo_struct_packed_end() } __attribute__((__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_IBMC >= 700) +# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { +# define __lzo_struct_packed_end() } __attribute__((__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { +# define __lzo_struct_packed_end() } __pragma(pack(pop)); +#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) +# define __lzo_struct_packed(s) _Packed struct s { +# define __lzo_struct_packed_end() }; +#endif +#endif +#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) +# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) +#endif +#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) +# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() +#endif +#if !defined(__lzo_byte_struct) +#if defined(__lzo_struct_packed) +# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() +# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() +#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); +# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); +#endif +#endif +#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) +# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) +#endif +#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) +#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) +#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_CILLY || LZO_CC_PCC) +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_struct_align16(s) struct __declspec(align(16)) s { +# define __lzo_struct_align16_end() }; +# define __lzo_struct_align32(s) struct __declspec(align(32)) s { +# define __lzo_struct_align32_end() }; +# define __lzo_struct_align64(s) struct __declspec(align(64)) s { +# define __lzo_struct_align64_end() }; +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_struct_align16(s) struct s { +# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); +# define __lzo_struct_align32(s) struct s { +# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); +# define __lzo_struct_align64(s) struct s { +# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); +#endif +#endif +#if !defined(__lzo_union_um) +#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) +#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) +#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_union_am(s) union s { +# define __lzo_union_am_end() } __lzo_may_alias; +# define __lzo_union_um(s) union s { +# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_IBMC >= 700) +# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { +# define __lzo_union_am_end() } __lzo_may_alias; +# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { +# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_union_um(s) __pragma(pack(push,1)) union s { +# define __lzo_union_um_end() } __pragma(pack(pop)); +#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) +# define __lzo_union_um(s) _Packed union s { +# define __lzo_union_um_end() }; +#endif +#endif +#if !defined(__lzo_union_am) +# define __lzo_union_am(s) union s { +# define __lzo_union_am_end() }; +#endif +#if !defined(__lzo_constructor) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_constructor __attribute__((__constructor__,__used__)) +#elif (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_constructor __attribute__((__constructor__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_constructor __attribute__((__constructor__,__used__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_constructor __attribute__((__constructor__)) +#endif +#endif +#if defined(__lzo_constructor) +# ifndef __lzo_HAVE_constructor +# define __lzo_HAVE_constructor 1 +# endif +#endif +#if !defined(__lzo_destructor) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_destructor __attribute__((__destructor__,__used__)) +#elif (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_destructor __attribute__((__destructor__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_destructor __attribute__((__destructor__,__used__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_destructor __attribute__((__destructor__)) +#endif +#endif +#if defined(__lzo_destructor) +# ifndef __lzo_HAVE_destructor +# define __lzo_HAVE_destructor 1 +# endif +#endif +#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +# error "unexpected configuration - check your compiler defines" +#endif +#if !defined(__lzo_likely) && !defined(__lzo_unlikely) +#if (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_IBMC >= 1010) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#endif +#endif +#if defined(__lzo_likely) +# ifndef __lzo_HAVE_likely +# define __lzo_HAVE_likely 1 +# endif +#else +# define __lzo_likely(e) (e) +#endif +#if defined(__lzo_unlikely) +# ifndef __lzo_HAVE_unlikely +# define __lzo_HAVE_unlikely 1 +# endif +#else +# define __lzo_unlikely(e) (e) +#endif +#if !defined(__lzo_static_unused_void_func) +# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) +# else +# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) +# endif +#endif +#if !defined(__lzo_loop_forever) +# if (LZO_CC_IBMC) +# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END +# else +# define __lzo_loop_forever() do { ; } while __lzo_cte(1) +# endif +#endif +#if !defined(__lzo_unreachable) +#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) +# define __lzo_unreachable() __builtin_unreachable(); +#elif (LZO_CC_GNUC >= 0x040500ul) +# define __lzo_unreachable() __builtin_unreachable(); +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 +# define __lzo_unreachable() __builtin_unreachable(); +#endif +#endif +#if defined(__lzo_unreachable) +# ifndef __lzo_HAVE_unreachable +# define __lzo_HAVE_unreachable 1 +# endif +#else +# if 0 +# define __lzo_unreachable() ((void)0); +# else +# define __lzo_unreachable() __lzo_loop_forever(); +# endif +#endif +#ifndef __LZO_CTA_NAME +#if (LZO_CFG_USE_COUNTER) +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) +#else +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) +#endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END +# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END # else -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} +# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} +# elif (LZO_CC_GNUC >= 0x040700ul) +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} # endif #endif +LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) +#if defined(__cplusplus) +extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) @@ -1710,6 +1945,7 @@ extern "C" { # define __lzo_cdecl_va __lzo_cdecl #endif #if !(LZO_CFG_NO_WINDOWS_H) +#if !defined(LZO_HAVE_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) @@ -1719,61 +1955,615 @@ extern "C" { # endif #endif #endif +#endif +#ifndef LZO_SIZEOF_SHORT +#if defined(SIZEOF_SHORT) +# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) +#elif defined(__SIZEOF_SHORT__) +# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) +#endif +#endif +#ifndef LZO_SIZEOF_INT +#if defined(SIZEOF_INT) +# define LZO_SIZEOF_INT (SIZEOF_INT) +#elif defined(__SIZEOF_INT__) +# define LZO_SIZEOF_INT (__SIZEOF_INT__) +#endif +#endif +#ifndef LZO_SIZEOF_LONG +#if defined(SIZEOF_LONG) +# define LZO_SIZEOF_LONG (SIZEOF_LONG) +#elif defined(__SIZEOF_LONG__) +# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) +#endif +#endif +#ifndef LZO_SIZEOF_LONG_LONG +#if defined(SIZEOF_LONG_LONG) +# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) +#elif defined(__SIZEOF_LONG_LONG__) +# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) +#endif +#endif +#ifndef LZO_SIZEOF___INT16 +#if defined(SIZEOF___INT16) +# define LZO_SIZEOF___INT16 (SIZEOF___INT16) +#endif +#endif +#ifndef LZO_SIZEOF___INT32 +#if defined(SIZEOF___INT32) +# define LZO_SIZEOF___INT32 (SIZEOF___INT32) +#endif +#endif +#ifndef LZO_SIZEOF___INT64 +#if defined(SIZEOF___INT64) +# define LZO_SIZEOF___INT64 (SIZEOF___INT64) +#endif +#endif +#ifndef LZO_SIZEOF_VOID_P +#if defined(SIZEOF_VOID_P) +# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) +#elif defined(__SIZEOF_POINTER__) +# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) +#endif +#endif +#ifndef LZO_SIZEOF_SIZE_T +#if defined(SIZEOF_SIZE_T) +# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) +#elif defined(__SIZEOF_SIZE_T__) +# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) +#endif +#endif +#ifndef LZO_SIZEOF_PTRDIFF_T +#if defined(SIZEOF_PTRDIFF_T) +# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) +#elif defined(__SIZEOF_PTRDIFF_T__) +# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) +#endif +#endif +#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +#if !defined(LZO_SIZEOF_SHORT) +# if (LZO_ARCH_CRAY_PVP) +# define LZO_SIZEOF_SHORT 8 +# elif (USHRT_MAX == LZO_0xffffL) +# define LZO_SIZEOF_SHORT 2 +# elif (__LZO_LSR(USHRT_MAX,7) == 1) +# define LZO_SIZEOF_SHORT 1 +# elif (__LZO_LSR(USHRT_MAX,15) == 1) +# define LZO_SIZEOF_SHORT 2 +# elif (__LZO_LSR(USHRT_MAX,31) == 1) +# define LZO_SIZEOF_SHORT 4 +# elif (__LZO_LSR(USHRT_MAX,63) == 1) +# define LZO_SIZEOF_SHORT 8 +# elif (__LZO_LSR(USHRT_MAX,127) == 1) +# define LZO_SIZEOF_SHORT 16 +# else +# error "LZO_SIZEOF_SHORT" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) +#if !defined(LZO_SIZEOF_INT) +# if (LZO_ARCH_CRAY_PVP) +# define LZO_SIZEOF_INT 8 +# elif (UINT_MAX == LZO_0xffffL) +# define LZO_SIZEOF_INT 2 +# elif (UINT_MAX == LZO_0xffffffffL) +# define LZO_SIZEOF_INT 4 +# elif (__LZO_LSR(UINT_MAX,7) == 1) +# define LZO_SIZEOF_INT 1 +# elif (__LZO_LSR(UINT_MAX,15) == 1) +# define LZO_SIZEOF_INT 2 +# elif (__LZO_LSR(UINT_MAX,31) == 1) +# define LZO_SIZEOF_INT 4 +# elif (__LZO_LSR(UINT_MAX,63) == 1) +# define LZO_SIZEOF_INT 8 +# elif (__LZO_LSR(UINT_MAX,127) == 1) +# define LZO_SIZEOF_INT 16 +# else +# error "LZO_SIZEOF_INT" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) +#if !defined(LZO_SIZEOF_LONG) +# if (ULONG_MAX == LZO_0xffffffffL) +# define LZO_SIZEOF_LONG 4 +# elif (__LZO_LSR(ULONG_MAX,7) == 1) +# define LZO_SIZEOF_LONG 1 +# elif (__LZO_LSR(ULONG_MAX,15) == 1) +# define LZO_SIZEOF_LONG 2 +# elif (__LZO_LSR(ULONG_MAX,31) == 1) +# define LZO_SIZEOF_LONG 4 +# elif (__LZO_LSR(ULONG_MAX,39) == 1) +# define LZO_SIZEOF_LONG 5 +# elif (__LZO_LSR(ULONG_MAX,63) == 1) +# define LZO_SIZEOF_LONG 8 +# elif (__LZO_LSR(ULONG_MAX,127) == 1) +# define LZO_SIZEOF_LONG 16 +# else +# error "LZO_SIZEOF_LONG" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) +#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +# if (LZO_CC_GNUC >= 0x030300ul) +# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) +# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +# define LZO_SIZEOF_LONG_LONG 4 +# endif +# endif +# endif +#endif +#endif +#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +#if (LZO_ARCH_I086 && LZO_CC_DMC) +#elif (LZO_CC_CILLY) && defined(__GNUC__) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_SIZEOF_LONG_LONG 8 +#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_OS_WIN64 || defined(_WIN64)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +# define LZO_SIZEOF___INT64 8 +#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define LZO_SIZEOF_LONG_LONG 8 +#endif +#endif +#endif +#if defined(__cplusplus) && (LZO_CC_GNUC) +# if (LZO_CC_GNUC < 0x020800ul) +# undef LZO_SIZEOF_LONG_LONG +# endif +#endif +#if (LZO_CFG_NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(__NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(_NO_LONGLONG) +# undef LZO_SIZEOF_LONG_LONG +#endif +#if !defined(LZO_WORDSIZE) #if (LZO_ARCH_ALPHA) -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 +# define LZO_WORDSIZE 8 #elif (LZO_ARCH_AMD64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# define LZO_OPT_UNALIGNED64 1 -#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -#elif (LZO_ARCH_ARM) -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_CRIS) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_I386) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# define LZO_WORDSIZE 8 +#elif (LZO_ARCH_AVR) +# define LZO_WORDSIZE 1 +#elif (LZO_ARCH_H8300) +# if defined(__NORMAL_MODE__) +# define LZO_WORDSIZE 4 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define LZO_WORDSIZE 4 +# else +# define LZO_WORDSIZE 2 +# endif +#elif (LZO_ARCH_I086) +# define LZO_WORDSIZE 2 #elif (LZO_ARCH_IA64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_WORDSIZE 8 +#elif (LZO_ARCH_M16C) +# define LZO_WORDSIZE 2 +#elif (LZO_ARCH_SPU) +# define LZO_WORDSIZE 4 +#elif (LZO_ARCH_Z80) +# define LZO_WORDSIZE 1 +#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define LZO_WORDSIZE 8 +#elif (LZO_OS_OS400 || defined(__OS400__)) +# define LZO_WORDSIZE 8 +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define LZO_WORDSIZE 8 +#endif +#endif +#if !defined(LZO_SIZEOF_VOID_P) +#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) +# define LZO_SIZEOF_VOID_P 4 +#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) +# define LZO_SIZEOF_VOID_P 8 +#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) +# define LZO_SIZEOF_VOID_P 8 +#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) +# define LZO_SIZEOF_VOID_P 8 +#elif (LZO_ARCH_AVR) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_ARCH_H8300) +# if defined(__NORMAL_MODE__) +# define LZO_SIZEOF_VOID_P 2 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define LZO_SIZEOF_VOID_P 4 +# else +# define LZO_SIZEOF_VOID_P 2 +# endif +# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +# endif +#elif (LZO_ARCH_I086) +# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +# define LZO_SIZEOF_VOID_P 2 +# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +# define LZO_SIZEOF_VOID_P 4 +# else +# error "invalid LZO_ARCH_I086 memory model" +# endif +#elif (LZO_ARCH_M16C) +# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +# define LZO_SIZEOF_VOID_P 4 +# else +# define LZO_SIZEOF_VOID_P 2 +# endif +#elif (LZO_ARCH_SPU) +# define LZO_SIZEOF_VOID_P 4 +#elif (LZO_ARCH_Z80) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define LZO_SIZEOF_VOID_P 4 +#elif (LZO_OS_OS400 || defined(__OS400__)) +# if defined(__LLP64_IFC__) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +# else +# define LZO_SIZEOF_VOID_P 16 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +# endif +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +#endif +#endif +#if !defined(LZO_SIZEOF_VOID_P) +# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) +#if !defined(LZO_SIZEOF_SIZE_T) +#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +# define LZO_SIZEOF_SIZE_T 2 +#endif +#endif +#if !defined(LZO_SIZEOF_SIZE_T) +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +#endif +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) +#endif +#if !defined(LZO_SIZEOF_PTRDIFF_T) +#if (LZO_ARCH_I086) +# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +# define LZO_SIZEOF_PTRDIFF_T 4 +# else +# define LZO_SIZEOF_PTRDIFF_T 2 +# endif +# else +# error "invalid LZO_ARCH_I086 memory model" +# endif +#endif +#endif +#if !defined(LZO_SIZEOF_PTRDIFF_T) +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +#endif +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) +#endif +#if !defined(LZO_WORDSIZE) +# define LZO_WORDSIZE LZO_SIZEOF_VOID_P +#endif +#if (LZO_ABI_NEUTRAL_ENDIAN) +# undef LZO_ABI_BIG_ENDIAN +# undef LZO_ABI_LITTLE_ENDIAN +#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +# define LZO_ABI_BIG_ENDIAN 1 +#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +# if (__LITTLE_ENDIAN__ == 1) +# define LZO_ABI_LITTLE_ENDIAN 1 +# else +# define LZO_ABI_BIG_ENDIAN 1 +# endif +#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) +# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" +# elif defined(__BIG_ENDIAN) +# define LZO_ABI_BIG_ENDIAN 1 +# else +# define LZO_ABI_LITTLE_ENDIAN 1 +# endif +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#endif +#endif +#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ABI_BIG_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "be" +#elif (LZO_ABI_LITTLE_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "le" +#elif (LZO_ABI_NEUTRAL_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "neutral" +#endif +#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +# define LZO_ABI_I8LP16 1 +# define LZO_INFO_ABI_PM "i8lp16" +#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +# define LZO_ABI_ILP16 1 +# define LZO_INFO_ABI_PM "ilp16" +#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_LP32 1 +# define LZO_INFO_ABI_PM "lp32" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_ILP32 1 +# define LZO_INFO_ABI_PM "ilp32" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +# define LZO_ABI_LLP64 1 +# define LZO_INFO_ABI_PM "llp64" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +# define LZO_ABI_LP64 1 +# define LZO_INFO_ABI_PM "lp64" +#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +# define LZO_ABI_ILP64 1 +# define LZO_INFO_ABI_PM "ilp64" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_IP32L64 1 +# define LZO_INFO_ABI_PM "ip32l64" +#endif +#if 0 +#elif !defined(__LZO_LIBC_OVERRIDE) +#if (LZO_LIBC_NAKED) +# define LZO_INFO_LIBC "naked" +#elif (LZO_LIBC_FREESTANDING) +# define LZO_INFO_LIBC "freestanding" +#elif (LZO_LIBC_MOSTLY_FREESTANDING) +# define LZO_INFO_LIBC "mfreestanding" +#elif (LZO_LIBC_ISOC90) +# define LZO_INFO_LIBC "isoc90" +#elif (LZO_LIBC_ISOC99) +# define LZO_INFO_LIBC "isoc99" +#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) +# define LZO_LIBC_ISOC90 1 +# define LZO_INFO_LIBC "isoc90" +#elif defined(__dietlibc__) +# define LZO_LIBC_DIETLIBC 1 +# define LZO_INFO_LIBC "dietlibc" +#elif defined(_NEWLIB_VERSION) +# define LZO_LIBC_NEWLIB 1 +# define LZO_INFO_LIBC "newlib" +#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +# if defined(__UCLIBC_SUBLEVEL__) +# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) +# else +# define LZO_LIBC_UCLIBC 0x00090bL +# endif +# define LZO_INFO_LIBC "uc" "libc" +#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) +# define LZO_INFO_LIBC "glibc" +#elif (LZO_CC_MWERKS) && defined(__MSL__) +# define LZO_LIBC_MSL __MSL__ +# define LZO_INFO_LIBC "msl" +#elif 1 && defined(__IAR_SYSTEMS_ICC__) +# define LZO_LIBC_ISOC90 1 +# define LZO_INFO_LIBC "isoc90" +#else +# define LZO_LIBC_DEFAULT 1 +# define LZO_INFO_LIBC "default" +#endif +#endif +#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +# define LZO_ASM_SYNTAX_MSC 1 +#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) +#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +# define LZO_ASM_SYNTAX_GNUC 1 +#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +# define LZO_ASM_SYNTAX_GNUC 1 +#elif (LZO_CC_GNUC) +# define LZO_ASM_SYNTAX_GNUC 1 +#endif +#if (LZO_ASM_SYNTAX_GNUC) +#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) +# define __LZO_ASM_CLOBBER "ax" +# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) +# define __LZO_ASM_CLOBBER "memory" +# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#else +# define __LZO_ASM_CLOBBER "cc", "memory" +# define __LZO_ASM_CLOBBER_LIST_CC : "cc" +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#endif +#endif +#if (LZO_ARCH_ALPHA) +# define LZO_OPT_AVOID_UINT_INDEX 1 +#elif (LZO_ARCH_AMD64) +# define LZO_OPT_AVOID_INT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +#elif (LZO_ARCH_ARM) +# if defined(__ARM_FEATURE_UNALIGNED) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# endif +#elif (LZO_ARCH_ARM64) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +#elif (LZO_ARCH_CRIS) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +#elif (LZO_ARCH_I386) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +#elif (LZO_ARCH_IA64) +# define LZO_OPT_AVOID_INT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 +# define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif # endif #elif (LZO_ARCH_MIPS) -# define LZO_OPT_AVOID_UINT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) -# define LZO_OPT_PREFER_PREINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_PREINC 1 +# define LZO_OPT_PREFER_PREDEC 1 # if (LZO_ABI_BIG_ENDIAN) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# if (LZO_WORDSIZE == 8) +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +# endif # endif #elif (LZO_ARCH_S390) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# if (LZO_SIZEOF_SIZE_T == 8) -# define LZO_OPT_UNALIGNED64 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# if (LZO_WORDSIZE == 8) +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif # endif #elif (LZO_ARCH_SH) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_OPT_PREFER_PREDEC 1 #endif #ifndef LZO_CFG_NO_INLINE_ASM -#if (LZO_CC_LLVM) +#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) +# define LZO_CFG_NO_INLINE_ASM 1 +#elif (LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif +#if (LZO_CFG_NO_INLINE_ASM) +# undef LZO_ASM_SYNTAX_MSC +# undef LZO_ASM_SYNTAX_GNUC +# undef __LZO_ASM_CLOBBER +# undef __LZO_ASM_CLOBBER_LIST_CC +# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY +# undef __LZO_ASM_CLOBBER_LIST_EMPTY +#endif #ifndef LZO_CFG_NO_UNALIGNED #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 @@ -1784,25 +2574,6 @@ extern "C" { # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif -#if (LZO_CFG_NO_INLINE_ASM) -#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -# define LZO_ASM_SYNTAX_MSC 1 -#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#endif -#if (LZO_ASM_SYNTAX_GNUC) -#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -# define __LZO_ASM_CLOBBER "ax" -#elif (LZO_CC_INTELC) -# define __LZO_ASM_CLOBBER "memory" -#else -# define __LZO_ASM_CLOBBER "cc", "memory" -#endif -#endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" @@ -1846,7 +2617,382 @@ extern "C" { #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER +#if !(LZO_CFG_SKIP_LZO_TYPES) +#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) +# error "missing defines for sizes" +#endif +#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) +# error "missing defines for sizes" +#endif +#if !defined(lzo_llong_t) +#if (LZO_SIZEOF_LONG_LONG+0 > 0) +__lzo_gnuc_extension__ typedef long long lzo_llong_t__; +__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; +# define lzo_llong_t lzo_llong_t__ +# define lzo_ullong_t lzo_ullong_t__ +#endif +#endif +#if !defined(lzo_int16e_t) +#if (LZO_SIZEOF_LONG == 2) +# define lzo_int16e_t long +# define lzo_uint16e_t unsigned long +#elif (LZO_SIZEOF_INT == 2) +# define lzo_int16e_t int +# define lzo_uint16e_t unsigned int +#elif (LZO_SIZEOF_SHORT == 2) +# define lzo_int16e_t short int +# define lzo_uint16e_t unsigned short int +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) + typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); + typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); +# define lzo_int16e_t lzo_int16e_hi_t__ +# define lzo_uint16e_t lzo_uint16e_hi_t__ +#elif (LZO_SIZEOF___INT16 == 2) +# define lzo_int16e_t __int16 +# define lzo_uint16e_t unsigned __int16 +#else +#endif +#endif +#if defined(lzo_int16e_t) +# define LZO_SIZEOF_LZO_INT16E_T 2 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) +#endif +#if !defined(lzo_int32e_t) +#if (LZO_SIZEOF_LONG == 4) +# define lzo_int32e_t long int +# define lzo_uint32e_t unsigned long int +#elif (LZO_SIZEOF_INT == 4) +# define lzo_int32e_t int +# define lzo_uint32e_t unsigned int +#elif (LZO_SIZEOF_SHORT == 4) +# define lzo_int32e_t short int +# define lzo_uint32e_t unsigned short int +#elif (LZO_SIZEOF_LONG_LONG == 4) +# define lzo_int32e_t lzo_llong_t +# define lzo_uint32e_t lzo_ullong_t +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) + typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); + typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); +# define lzo_int32e_t lzo_int32e_si_t__ +# define lzo_uint32e_t lzo_uint32e_si_t__ +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) + typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); + typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); +# define lzo_int32e_t lzo_int32e_si_t__ +# define lzo_uint32e_t lzo_uint32e_si_t__ +# define LZO_INT32_C(c) (c##LL) +# define LZO_UINT32_C(c) (c##ULL) +#elif (LZO_SIZEOF___INT32 == 4) +# define lzo_int32e_t __int32 +# define lzo_uint32e_t unsigned __int32 +#else +#endif +#endif +#if defined(lzo_int32e_t) +# define LZO_SIZEOF_LZO_INT32E_T 4 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) +#endif +#if !defined(lzo_int64e_t) +#if (LZO_SIZEOF___INT64 == 8) +# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) +# define LZO_CFG_TYPE_PREFER___INT64 1 +# endif +#endif +#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_int64e_t int +# define lzo_uint64e_t unsigned int +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG == 8) +# define lzo_int64e_t long int +# define lzo_uint64e_t unsigned long int +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG +#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) +# define lzo_int64e_t lzo_llong_t +# define lzo_uint64e_t lzo_ullong_t +# if (LZO_CC_BORLANDC) +# define LZO_INT64_C(c) ((c) + 0ll) +# define LZO_UINT64_C(c) ((c) + 0ull) +# elif 0 +# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) +# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) +# else +# define LZO_INT64_C(c) (c##LL) +# define LZO_UINT64_C(c) (c##ULL) +# endif +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG +#elif (LZO_SIZEOF___INT64 == 8) +# define lzo_int64e_t __int64 +# define lzo_uint64e_t unsigned __int64 +# if (LZO_CC_BORLANDC) +# define LZO_INT64_C(c) ((c) + 0i64) +# define LZO_UINT64_C(c) ((c) + 0ui64) +# else +# define LZO_INT64_C(c) (c##i64) +# define LZO_UINT64_C(c) (c##ui64) +# endif +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 +#else +#endif +#endif +#if defined(lzo_int64e_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) +#endif +#if !defined(lzo_int32l_t) +#if defined(lzo_int32e_t) +# define lzo_int32l_t lzo_int32e_t +# define lzo_uint32l_t lzo_uint32e_t +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T +#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_int32l_t int +# define lzo_uint32l_t unsigned int +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG >= 4) +# define lzo_int32l_t long int +# define lzo_uint32l_t unsigned long int +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG +#else +# error "lzo_int32l_t" +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) +#endif +#if !defined(lzo_int64l_t) +#if defined(lzo_int64e_t) +# define lzo_int64l_t lzo_int64e_t +# define lzo_uint64l_t lzo_uint64e_t +# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T +#else +#endif +#endif +#if defined(lzo_int64l_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) +#endif +#if !defined(lzo_int32f_t) +#if (LZO_SIZEOF_SIZE_T >= 8) +# define lzo_int32f_t lzo_int64l_t +# define lzo_uint32f_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T +#else +# define lzo_int32f_t lzo_int32l_t +# define lzo_uint32f_t lzo_uint32l_t +# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) +#endif +#if !defined(lzo_int64f_t) +#if defined(lzo_int64l_t) +# define lzo_int64f_t lzo_int64l_t +# define lzo_uint64f_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T +#else +#endif +#endif +#if defined(lzo_int64f_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) +#endif +#if !defined(lzo_intptr_t) +#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) +# define __LZO_INTPTR_T_IS_POINTER 1 + typedef char* lzo_intptr_t; + typedef char* lzo_uintptr_t; +# define lzo_intptr_t lzo_intptr_t +# define lzo_uintptr_t lzo_uintptr_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P +#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) + typedef __w64 int lzo_intptr_t; + typedef __w64 unsigned int lzo_uintptr_t; +# define lzo_intptr_t lzo_intptr_t +# define lzo_uintptr_t lzo_uintptr_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) +# define lzo_intptr_t short +# define lzo_uintptr_t unsigned short +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT +#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_intptr_t int +# define lzo_uintptr_t unsigned int +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) +# define lzo_intptr_t long +# define lzo_uintptr_t unsigned long +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG +#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) +# define lzo_intptr_t lzo_int64l_t +# define lzo_uintptr_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T +#else +# error "lzo_intptr_t" +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) +#endif +#if !defined(lzo_word_t) +#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) +#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) +# define lzo_word_t lzo_uintptr_t +# define lzo_sword_t lzo_intptr_t +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T +#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) +# define lzo_word_t unsigned long +# define lzo_sword_t long +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG +#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) +# define lzo_word_t unsigned int +# define lzo_sword_t int +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT +#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) +# define lzo_word_t unsigned short +# define lzo_sword_t short +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT +#elif (LZO_WORDSIZE == 1) +# define lzo_word_t unsigned char +# define lzo_sword_t signed char +# define LZO_SIZEOF_LZO_WORD_T 1 +#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) +# define lzo_word_t lzo_uint64l_t +# define lzo_sword_t lzo_int64l_t +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T +#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) +#if 0 + typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); + typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); +# define lzo_word_t lzo_word_t +# define lzo_sword_t lzo_sword_t +# define LZO_SIZEOF_LZO_WORD_T 16 +#endif +#else +# error "lzo_word_t" +#endif +#endif +#endif +#if 1 && defined(lzo_word_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) +#endif +#if 1 +#define lzo_int8_t signed char +#define lzo_uint8_t unsigned char +#define LZO_SIZEOF_LZO_INT8_T 1 +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) +#endif +#if defined(lzo_int16e_t) +#define lzo_int16_t lzo_int16e_t +#define lzo_uint16_t lzo_uint16e_t +#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) +#endif +#if defined(lzo_int32e_t) +#define lzo_int32_t lzo_int32e_t +#define lzo_uint32_t lzo_uint32e_t +#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) +#endif +#if defined(lzo_int64e_t) +#define lzo_int64_t lzo_int64e_t +#define lzo_uint64_t lzo_uint64e_t +#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) +#endif +#if 1 +#define lzo_int_least32_t lzo_int32l_t +#define lzo_uint_least32_t lzo_uint32l_t +#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) +#endif +#if defined(lzo_int64l_t) +#define lzo_int_least64_t lzo_int64l_t +#define lzo_uint_least64_t lzo_uint64l_t +#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) +#endif +#if 1 +#define lzo_int_fast32_t lzo_int32f_t +#define lzo_uint_fast32_t lzo_uint32f_t +#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) +#endif +#if defined(lzo_int64f_t) +#define lzo_int_fast64_t lzo_int64f_t +#define lzo_uint_fast64_t lzo_uint64f_t +#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) +#endif +#if !defined(LZO_INT16_C) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) +# define LZO_INT16_C(c) ((c) + 0) +# define LZO_UINT16_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) +# define LZO_INT16_C(c) ((c) + 0L) +# define LZO_UINT16_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 2) +# define LZO_INT16_C(c) (c) +# define LZO_UINT16_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 2) +# define LZO_INT16_C(c) (c##L) +# define LZO_UINT16_C(c) (c##UL) +# else +# error "LZO_INT16_C" +# endif +#endif +#if !defined(LZO_INT32_C) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) +# define LZO_INT32_C(c) ((c) + 0) +# define LZO_UINT32_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) +# define LZO_INT32_C(c) ((c) + 0L) +# define LZO_UINT32_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 4) +# define LZO_INT32_C(c) (c) +# define LZO_UINT32_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 4) +# define LZO_INT32_C(c) (c##L) +# define LZO_UINT32_C(c) (c##UL) +# elif (LZO_SIZEOF_LONG_LONG >= 4) +# define LZO_INT32_C(c) (c##LL) +# define LZO_UINT32_C(c) (c##ULL) +# else +# error "LZO_INT32_C" +# endif +#endif +#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) +# define LZO_INT64_C(c) ((c) + 0) +# define LZO_UINT64_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) +# define LZO_INT64_C(c) ((c) + 0L) +# define LZO_UINT64_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 8) +# define LZO_INT64_C(c) (c) +# define LZO_UINT64_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 8) +# define LZO_INT64_C(c) (c##L) +# define LZO_UINT64_C(c) (c##UL) +# else +# error "LZO_INT64_C" +# endif +#endif +#endif #endif /* already included */ -/* vim:set ts=4 et: */ +/* vim:set ts=4 sw=4 et: */ diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c index 25a1f68b3..ab2be5f4f 100644 --- a/grub-core/lib/minilzo/minilzo.c +++ b/grub-core/lib/minilzo/minilzo.c @@ -2,22 +2,7 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -67,12 +52,6 @@ #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif -#if defined(__IBMCPP__) && !defined(__IBMC__) -# define __IBMC__ __IBMCPP__ -#endif -#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) -# define __INTEL_COMPILER __ICL -#endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif @@ -81,19 +60,30 @@ # define __LONG_MAX__ 9223372036854775807L # endif #endif -#if defined(__INTEL_COMPILER) && defined(__linux__) +#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) +#if defined(__ARMCC_VERSION) +# pragma diag_suppress 193 +#elif defined(__clang__) && defined(__clang_minor__) +# pragma clang diagnostic ignored "-Wundef" +#elif defined(__INTEL_COMPILER) # pragma warning(disable: 193) -#endif -#if defined(__KEIL__) && defined(__C166__) +#elif defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 -#elif 0 && defined(__C251__) -# pragma warning disable = 322 -#endif -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -# if (_MSC_VER >= 1300) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) +# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) +# pragma GCC diagnostic ignored "-Wundef" +# endif +#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +# if ((_MSC_VER-0) >= 1300) # pragma warning(disable: 4668) # endif #endif +#endif +#if 0 && defined(__POCC__) && defined(_WIN32) +# if (__POCC__ >= 400) +# pragma warn(disable: 2216) +# endif +#endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 @@ -102,13 +92,29 @@ #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif -#if 0 -#define LZO_0xffffL 0xfffful -#define LZO_0xffffffffL 0xfffffffful -#else -#define LZO_0xffffL 65535ul -#define LZO_0xffffffffL 4294967295ul +#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) +#ifndef _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE 1 #endif +#ifndef _CRT_NONSTDC_NO_WARNINGS +#define _CRT_NONSTDC_NO_WARNINGS 1 +#endif +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS 1 +#endif +#endif +#if 0 +#define LZO_0xffffUL 0xfffful +#define LZO_0xffffffffUL 0xfffffffful +#else +#define LZO_0xffffUL 65535ul +#define LZO_0xffffffffUL 4294967295ul +#endif +#define LZO_0xffffL LZO_0xffffUL +#define LZO_0xffffffffL LZO_0xffffffffUL #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif @@ -123,6 +129,13 @@ # error "your preprocessor is broken 4" #endif #endif +#if defined(__COUNTER__) +# ifndef LZO_CFG_USE_COUNTER +# define LZO_CFG_USE_COUNTER 1 +# endif +#else +# undef LZO_CFG_USE_COUNTER +#endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) @@ -253,14 +266,31 @@ #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) +#define LZO_PP_CONCAT0() /*empty*/ +#define LZO_PP_CONCAT1(a) a #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f +#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g +#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() +#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) +#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) +#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) +#define LZO_PP_EMPTY /*empty*/ +#define LZO_PP_EMPTY0() /*empty*/ +#define LZO_PP_EMPTY1(a) /*empty*/ +#define LZO_PP_EMPTY2(a,b) /*empty*/ +#define LZO_PP_EMPTY3(a,b,c) /*empty*/ +#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ +#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ +#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ +#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) @@ -268,12 +298,16 @@ #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f +#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) +#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) +#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) #endif -#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) +#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 @@ -283,9 +317,13 @@ # endif #endif #if defined(__cplusplus) -# define LZO_EXTERN_C extern "C" +# define LZO_EXTERN_C extern "C" +# define LZO_EXTERN_C_BEGIN extern "C" { +# define LZO_EXTERN_C_END } #else -# define LZO_EXTERN_C extern +# define LZO_EXTERN_C extern +# define LZO_EXTERN_C_BEGIN /*empty*/ +# define LZO_EXTERN_C_END /*empty*/ #endif #if !defined(__LZO_OS_OVERRIDE) #if (LZO_OS_FREESTANDING) @@ -386,12 +424,12 @@ #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" -#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" -#elif (defined(__mips__) && defined(__psp__)) +#elif defined(__mips__) && defined(__psp__) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" @@ -419,9 +457,18 @@ # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" -# elif defined(__APPLE__) || defined(__MACOS__) -# define LZO_OS_POSIX_MACOSX 1 -# define LZO_INFO_OS_POSIX "macosx" +# elif defined(__APPLE__) && defined(__MACH__) +# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) +# define LZO_OS_POSIX_DARWIN 1040 +# define LZO_INFO_OS_POSIX "darwin_iphone" +# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) +# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# define LZO_INFO_OS_POSIX "darwin" +# else +# define LZO_OS_POSIX_DARWIN 1 +# define LZO_INFO_OS_POSIX "darwin" +# endif +# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" @@ -456,18 +503,18 @@ #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) @@ -483,59 +530,65 @@ # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) -# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) +# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ -#elif defined(__INTEL_COMPILER) -# define LZO_CC_INTELC 1 +# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# endif +#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) +# define LZO_CC_INTELC __INTEL_COMPILER # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) -# if defined(_WIN32) || defined(_WIN64) -# define LZO_CC_SYNTAX_MSC 1 -# else -# define LZO_CC_SYNTAX_GNUC 1 +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_INTELC_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) -#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif +# define LZO_CC_ARMCC __ARMCC_VERSION +# define LZO_INFO_CC "ARM C Compiler" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) -# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) +# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) # else -# define LZO_CC_CLANG_CLANG 0x010000L +# define LZO_CC_CLANG 0x010000L +# endif +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_CLANG_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # endif -# define LZO_CC_CLANG LZO_CC_CLANG_GNUC # define LZO_INFO_CC "clang" # define LZO_INFO_CCVER __VERSION__ #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) # if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) # else -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) # endif # define LZO_CC_LLVM LZO_CC_LLVM_GNUC # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ -#elif defined(__GNUC__) && defined(__VERSION__) -# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# elif defined(__GNUC_MINOR__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# else -# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -# endif -# define LZO_INFO_CC "gcc" -# define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" +#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) +# define LZO_CC_ARMCC __ARMCC_VERSION +# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION +# define LZO_INFO_CC "ARM C Compiler" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" @@ -560,10 +613,23 @@ # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) +#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) +# define LZO_CC_GHS 1 +# define LZO_INFO_CC "Green Hills C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) +# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_GHS_MSC _MSC_VER +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) +# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# endif #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" +#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) +# define LZO_CC_HPACC __HP_aCC +# define LZO_INFO_CC "HP aCC" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" @@ -572,10 +638,14 @@ # else # define LZO_INFO_CCVER "unknown" # endif -#elif defined(__IBMC__) -# define LZO_CC_IBMC 1 +#elif defined(__IBMC__) && ((__IBMC__-0) > 0) +# define LZO_CC_IBMC __IBMC__ # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) +#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) +# define LZO_CC_IBMC __IBMCPP__ +# define LZO_INFO_CC "IBM C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" @@ -592,16 +662,8 @@ # else # define LZO_INFO_CCVER "unknown" # endif -#elif defined(_MSC_VER) -# define LZO_CC_MSC 1 -# define LZO_INFO_CC "Microsoft C" -# if defined(_MSC_FULL_VER) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -# endif -#elif defined(__MWERKS__) -# define LZO_CC_MWERKS 1 +#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) +# define LZO_CC_MWERKS __MWERKS__ # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) @@ -612,6 +674,15 @@ # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) +#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) +# else +# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" +# endif +# define LZO_INFO_CC "Portland Group PGI C" #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" @@ -626,7 +697,7 @@ # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_C)+0 > 0) +# if ((__SUNPRO_C-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else @@ -635,7 +706,7 @@ # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_CC)+0 > 0) +# if ((__SUNPRO_CC-0) > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else @@ -661,16 +732,46 @@ #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" -# if (__ZTC__ == 0x310) +# if ((__ZTC__-0) == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif +#elif defined(__GNUC__) && defined(__VERSION__) +# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) +# elif defined(__GNUC_MINOR__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) +# else +# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +# endif +# define LZO_INFO_CC "gcc" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) +# define LZO_CC_MSC _MSC_VER +# define LZO_INFO_CC "Microsoft C" +# if defined(_MSC_FULL_VER) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +# else +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +# endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif +#if (LZO_CC_GNUC) && defined(__OPEN64__) +# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) +# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) +# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC +# endif +#endif +#if (LZO_CC_GNUC) && defined(__PCC__) +# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) +# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) +# define LZO_CC_PCC_GNUC LZO_CC_GNUC +# endif +#endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif @@ -688,8 +789,10 @@ # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 -# define LZO_ARCH_IA16 1 # define LZO_INFO_ARCH "i086" +#elif defined(__aarch64__) +# define LZO_ARCH_ARM64 1 +# define LZO_INFO_ARCH "arm64" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" @@ -705,10 +808,10 @@ # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 -# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) +# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" -# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) +# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" @@ -826,53 +929,147 @@ # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) -# error "FIXME - missing WIN32 define for CPU architecture" +# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) -# error "FIXME - missing WIN64 define for CPU architecture" +# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 #endif -#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) -# error "this should not happen" +#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) +# define LZO_ARCH_X64 1 +#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_AMD64 1 #endif -#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) -# error "this should not happen" +#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) +# define LZO_ARCH_AARCH64 1 +#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_ARM64 1 +#endif +#if (LZO_ARCH_I386 && !LZO_ARCH_X86) +# define LZO_ARCH_X86 1 +#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_I386 1 +#endif +#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) +# error "unexpected configuration - check your compiler defines" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif -#if !defined(__LZO_MM_OVERRIDE) +#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) +# if !defined(LZO_TARGET_FEATURE_SSE2) +# if defined(__SSE2__) +# define LZO_TARGET_FEATURE_SSE2 1 +# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) +# define LZO_TARGET_FEATURE_SSE2 1 +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_SSSE3) +# if (LZO_TARGET_FEATURE_SSE2) +# if defined(__SSSE3__) +# define LZO_TARGET_FEATURE_SSSE3 1 +# elif defined(_MSC_VER) && defined(__AVX__) +# define LZO_TARGET_FEATURE_SSSE3 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_SSE4_2) +# if (LZO_TARGET_FEATURE_SSSE3) +# if defined(__SSE4_2__) +# define LZO_TARGET_FEATURE_SSE4_2 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_AVX) +# if (LZO_TARGET_FEATURE_SSSE3) +# if defined(__AVX__) +# define LZO_TARGET_FEATURE_AVX 1 +# endif +# endif +# endif +# if !defined(LZO_TARGET_FEATURE_AVX2) +# if (LZO_TARGET_FEATURE_AVX) +# if defined(__AVX2__) +# define LZO_TARGET_FEATURE_AVX2 1 +# endif +# endif +# endif +#endif +#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ARCH_ARM) +# if !defined(LZO_TARGET_FEATURE_NEON) +# if defined(__ARM_NEON__) +# define LZO_TARGET_FEATURE_NEON 1 +# endif +# endif +#elif (LZO_ARCH_ARM64) +# if !defined(LZO_TARGET_FEATURE_NEON) +# if 1 +# define LZO_TARGET_FEATURE_NEON 1 +# endif +# endif +#endif +#if 0 +#elif !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 @@ -899,7 +1096,7 @@ #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else -# error "unknown memory model" +# error "unknown LZO_ARCH_I086 memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 @@ -922,10 +1119,10 @@ #endif #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # elif (LZO_CC_ZORTECHC) # else -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" # endif #endif #ifdef __cplusplus @@ -957,7 +1154,7 @@ extern "C" { #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) -# error "FIXME - C166 __MODEL__" +# error "FIXME - LZO_ARCH_C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) @@ -971,11 +1168,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - C166 __MODEL__" +# error "FIXME - LZO_ARCH_C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) -# error "FIXME - MCS251 __MODEL__" +# error "FIXME - LZO_ARCH_MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) @@ -987,11 +1184,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - MCS251 __MODEL__" +# error "FIXME - LZO_ARCH_MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) -# error "FIXME - MCS51 __MODEL__" +# error "FIXME - LZO_ARCH_MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) @@ -1003,7 +1200,7 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else -# error "FIXME - MCS51 __MODEL__" +# error "FIXME - LZO_ARCH_MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 @@ -1030,567 +1227,156 @@ extern "C" { # error "unknown memory model" #endif #endif -#if defined(SIZEOF_SHORT) -# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -#endif -#if defined(SIZEOF_INT) -# define LZO_SIZEOF_INT (SIZEOF_INT) -#endif -#if defined(SIZEOF_LONG) -# define LZO_SIZEOF_LONG (SIZEOF_LONG) -#endif -#if defined(SIZEOF_LONG_LONG) -# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -#endif -#if defined(SIZEOF___INT16) -# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -#endif -#if defined(SIZEOF___INT32) -# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -#endif -#if defined(SIZEOF___INT64) -# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -#endif -#if defined(SIZEOF_VOID_P) -# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -#endif -#if defined(SIZEOF_SIZE_T) -# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -#endif -#if defined(SIZEOF_PTRDIFF_T) -# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -#endif -#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -#if !defined(LZO_SIZEOF_SHORT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_SHORT 8 -# elif (USHRT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,7) == 1) -# define LZO_SIZEOF_SHORT 1 -# elif (__LZO_LSR(USHRT_MAX,15) == 1) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,31) == 1) -# define LZO_SIZEOF_SHORT 4 -# elif (__LZO_LSR(USHRT_MAX,63) == 1) -# define LZO_SIZEOF_SHORT 8 -# elif (__LZO_LSR(USHRT_MAX,127) == 1) -# define LZO_SIZEOF_SHORT 16 -# else -# error "LZO_SIZEOF_SHORT" -# endif -#endif -#if !defined(LZO_SIZEOF_INT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_INT 8 -# elif (UINT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_INT 2 -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,7) == 1) -# define LZO_SIZEOF_INT 1 -# elif (__LZO_LSR(UINT_MAX,15) == 1) -# define LZO_SIZEOF_INT 2 -# elif (__LZO_LSR(UINT_MAX,31) == 1) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,63) == 1) -# define LZO_SIZEOF_INT 8 -# elif (__LZO_LSR(UINT_MAX,127) == 1) -# define LZO_SIZEOF_INT 16 -# else -# error "LZO_SIZEOF_INT" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG) -# if (ULONG_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,7) == 1) -# define LZO_SIZEOF_LONG 1 -# elif (__LZO_LSR(ULONG_MAX,15) == 1) -# define LZO_SIZEOF_LONG 2 -# elif (__LZO_LSR(ULONG_MAX,31) == 1) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,63) == 1) -# define LZO_SIZEOF_LONG 8 -# elif (__LZO_LSR(ULONG_MAX,127) == 1) -# define LZO_SIZEOF_LONG 16 -# else -# error "LZO_SIZEOF_LONG" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -# if (LZO_CC_GNUC >= 0x030300ul) -# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -# define LZO_SIZEOF_LONG_LONG 4 -# endif -# endif -# endif -#endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -#if (LZO_ARCH_I086 && LZO_CC_DMC) -#elif (LZO_CC_CILLY) && defined(__GNUC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_SIZEOF_LONG_LONG 8 -#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_OS_WIN64 || defined(_WIN64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define LZO_SIZEOF_LONG_LONG 8 -#endif -#endif -#endif -#if defined(__cplusplus) && (LZO_CC_GNUC) -# if (LZO_CC_GNUC < 0x020800ul) -# undef LZO_SIZEOF_LONG_LONG -# endif -#endif -#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -# undef LZO_SIZEOF_LONG_LONG -#endif -#if !defined(LZO_SIZEOF_VOID_P) -#if (LZO_ARCH_I086) -# define __LZO_WORDSIZE 2 -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -# define LZO_SIZEOF_VOID_P 2 -# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -# define LZO_SIZEOF_VOID_P 4 -# else -# error "LZO_MM" -# endif -#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) -# define __LZO_WORDSIZE 1 -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_H8300) -# if defined(__NORMAL_MODE__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 2 -# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 4 -# else -# define __LZO_WORDSIZE 2 -# define LZO_SIZEOF_VOID_P 2 -# endif -# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -# endif -#elif (LZO_ARCH_M16C) -# define __LZO_WORDSIZE 2 -# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -# define LZO_SIZEOF_VOID_P 4 -# else -# define LZO_SIZEOF_VOID_P 2 -# endif -#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 4 -#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_OS_OS400 || defined(__OS400__)) -# define __LZO_WORDSIZE LZO_SIZEOF_LONG -# define LZO_SIZEOF_VOID_P 16 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_VOID_P 8 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_ARCH_SPU) -# if 0 -# define __LZO_WORDSIZE 16 -# endif -# define LZO_SIZEOF_VOID_P 4 -#else -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -#endif -#endif -#if !defined(LZO_WORDSIZE) -# if defined(__LZO_WORDSIZE) -# define LZO_WORDSIZE __LZO_WORDSIZE -# else -# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -# endif -#endif -#if !defined(LZO_SIZEOF_SIZE_T) -#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -# define LZO_SIZEOF_SIZE_T 2 -#else -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -#endif -#endif -#if !defined(LZO_SIZEOF_PTRDIFF_T) -#if (LZO_ARCH_I086) -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -# define LZO_SIZEOF_PTRDIFF_T 4 -# else -# define LZO_SIZEOF_PTRDIFF_T 2 -# endif -# else -# error "LZO_MM" -# endif -#else -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -#endif -#endif -#if (LZO_ABI_NEUTRAL_ENDIAN) -# undef LZO_ABI_BIG_ENDIAN -# undef LZO_ABI_LITTLE_ENDIAN -#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -# define LZO_ABI_BIG_ENDIAN 1 -#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -# if (__LITTLE_ENDIAN__ == 1) -# define LZO_ABI_LITTLE_ENDIAN 1 -# else -# define LZO_ABI_BIG_ENDIAN 1 -# endif -#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#endif -#endif -#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -# error "this should not happen" -#endif -#if (LZO_ABI_BIG_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "be" -#elif (LZO_ABI_LITTLE_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "le" -#elif (LZO_ABI_NEUTRAL_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "neutral" -#endif -#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_I8LP16 1 -# define LZO_INFO_ABI_PM "i8lp16" -#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_ILP16 1 -# define LZO_INFO_ABI_PM "ilp16" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_ILP32 1 -# define LZO_INFO_ABI_PM "ilp32" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -# define LZO_ABI_LLP64 1 -# define LZO_INFO_ABI_PM "llp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_LP64 1 -# define LZO_INFO_ABI_PM "lp64" -#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_ILP64 1 -# define LZO_INFO_ABI_PM "ilp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_IP32L64 1 -# define LZO_INFO_ABI_PM "ip32l64" -#endif -#if !defined(__LZO_LIBC_OVERRIDE) -#if (LZO_LIBC_NAKED) -# define LZO_INFO_LIBC "naked" -#elif (LZO_LIBC_FREESTANDING) -# define LZO_INFO_LIBC "freestanding" -#elif (LZO_LIBC_MOSTLY_FREESTANDING) -# define LZO_INFO_LIBC "mfreestanding" -#elif (LZO_LIBC_ISOC90) -# define LZO_INFO_LIBC "isoc90" -#elif (LZO_LIBC_ISOC99) -# define LZO_INFO_LIBC "isoc99" -#elif defined(__dietlibc__) -# define LZO_LIBC_DIETLIBC 1 -# define LZO_INFO_LIBC "dietlibc" -#elif defined(_NEWLIB_VERSION) -# define LZO_LIBC_NEWLIB 1 -# define LZO_INFO_LIBC "newlib" -#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -# if defined(__UCLIBC_SUBLEVEL__) -# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -# else -# define LZO_LIBC_UCLIBC 0x00090bL -# endif -# define LZO_INFO_LIBC "uclibc" -#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -# define LZO_INFO_LIBC "glibc" -#elif (LZO_CC_MWERKS) && defined(__MSL__) -# define LZO_LIBC_MSL __MSL__ -# define LZO_INFO_LIBC "msl" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_LIBC_ISOC90 1 -# define LZO_INFO_LIBC "isoc90" -#else -# define LZO_LIBC_DEFAULT 1 -# define LZO_INFO_LIBC "default" -#endif -#endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_gnuc_extension__ __extension__ +#elif (LZO_CC_IBMC >= 600) # define __lzo_gnuc_extension__ __extension__ #else +#endif +#endif +#if !defined(__lzo_gnuc_extension__) # define __lzo_gnuc_extension__ /*empty*/ #endif -#endif -#if !defined(__lzo_ua_volatile) -# define __lzo_ua_volatile volatile -#endif -#if !defined(__lzo_alignof) -#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_alignof(e) __alignof(e) -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_alignof(e) __alignof__(e) -#endif -#endif -#if defined(__lzo_alignof) -# define __lzo_HAVE_alignof 1 -#endif -#if !defined(__lzo_constructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_constructor __attribute__((__constructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_constructor __attribute__((__constructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_constructor __attribute__((__constructor__)) -#endif -#endif -#if defined(__lzo_constructor) -# define __lzo_HAVE_constructor 1 -#endif -#if !defined(__lzo_destructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_destructor __attribute__((__destructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_destructor __attribute__((__destructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_destructor __attribute__((__destructor__)) -#endif -#endif -#if defined(__lzo_destructor) -# define __lzo_HAVE_destructor 1 -#endif -#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -# error "this should not happen" -#endif -#if !defined(__lzo_inline) -#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -#elif defined(__cplusplus) -# define __lzo_inline inline -#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -# define __lzo_inline __inline -#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_inline __inline__ -#elif (LZO_CC_DMC) -# define __lzo_inline __inline -#elif (LZO_CC_INTELC) -# define __lzo_inline __inline -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -# define __lzo_inline __inline -#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -# define __lzo_inline __inline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_inline __inline__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define __lzo_inline inline -#endif -#endif -#if defined(__lzo_inline) -# define __lzo_HAVE_inline 1 -#else -# define __lzo_inline /*empty*/ -#endif -#if !defined(__lzo_forceinline) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#endif -#endif -#if defined(__lzo_forceinline) -# define __lzo_HAVE_forceinline 1 -#else -# define __lzo_forceinline /*empty*/ -#endif -#if !defined(__lzo_noinline) -#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -# define __lzo_noinline __attribute__((__noinline__,__used__)) -#elif (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -# if defined(__cplusplus) +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 +# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 +# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 # else -# define __lzo_noinline __declspec(noinline) +# define LZO_CFG_USE_NEW_STYLE_CASTS 1 # endif -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_noinline __attribute__((__noinline__)) #endif +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif -#if defined(__lzo_noinline) -# define __lzo_HAVE_noinline 1 -#else -# define __lzo_noinline /*empty*/ +#if !defined(__cplusplus) +# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# undef LZO_CFG_USE_NEW_STYLE_CASTS +# endif +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 #endif -#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -# error "this should not happen" +#if !defined(LZO_REINTERPRET_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) +# endif #endif -#if !defined(__lzo_noreturn) -#if (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_noreturn __declspec(noreturn) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_noreturn __declspec(noreturn) +#if !defined(LZO_REINTERPRET_CAST) +# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) #endif +#if !defined(LZO_STATIC_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_STATIC_CAST(t,e) (static_cast (e)) +# endif #endif -#if defined(__lzo_noreturn) -# define __lzo_HAVE_noreturn 1 -#else -# define __lzo_noreturn /*empty*/ +#if !defined(LZO_STATIC_CAST) +# define LZO_STATIC_CAST(t,e) ((t) (e)) #endif -#if !defined(__lzo_nothrow) -#if (LZO_CC_GNUC >= 0x030300ul) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) +#if !defined(LZO_STATIC_CAST2) +# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) #endif +#if !defined(LZO_UNCONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNCONST_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) +# endif #endif -#if defined(__lzo_nothrow) -# define __lzo_HAVE_nothrow 1 -#else -# define __lzo_nothrow /*empty*/ +#if !defined(LZO_UNCONST_CAST) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) #endif -#if !defined(__lzo_restrict) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -# define __lzo_restrict __restrict +#if !defined(LZO_UNCONST_VOLATILE_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) +# endif #endif +#if !defined(LZO_UNCONST_VOLATILE_CAST) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) #endif -#if defined(__lzo_restrict) -# define __lzo_HAVE_restrict 1 -#else -# define __lzo_restrict /*empty*/ +#if !defined(LZO_UNVOLATILE_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) +# endif #endif -#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#if !defined(LZO_UNVOLATILE_CAST) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) #endif +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) +# elif (LZO_HAVE_MM_HUGE_PTR) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) +# endif #endif -#if defined(__lzo_likely) -# define __lzo_HAVE_likely 1 -#else -# define __lzo_likely(e) (e) +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) #endif -#if defined(__lzo_unlikely) -# define __lzo_HAVE_unlikely 1 -#else -# define __lzo_unlikely(e) (e) +#if !defined(LZO_PCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_PCAST(t,e) ((t) (e)) +# endif +#endif +#if !defined(LZO_PCAST) +# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) +#endif +#if !defined(LZO_CCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_CCAST(t,e) ((t) (e)) +# endif +#endif +#if !defined(LZO_CCAST) +# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) +#endif +#if !defined(LZO_ICONV) +# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(LZO_ICAST) +# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(LZO_ITRUNC) +# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) +#endif +#if !defined(__lzo_cte) +# if (LZO_CC_MSC || LZO_CC_WATCOMC) +# define __lzo_cte(e) ((void)0,(e)) +# elif 1 +# define __lzo_cte(e) ((void)0,(e)) +# endif +#endif +#if !defined(__lzo_cte) +# define __lzo_cte(e) (e) +#endif +#if !defined(LZO_BLOCK_BEGIN) +# define LZO_BLOCK_BEGIN do { +# define LZO_BLOCK_END } while __lzo_cte(0) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else +# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) +# define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) -# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) @@ -1611,18 +1397,18 @@ extern "C" { # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) -# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} +# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) -# if (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -# define LZO_UNUSED_LABEL(l) if (0) goto l +# if (LZO_CC_CLANG >= 0x020800ul) +# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) +# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l # else -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) @@ -1634,39 +1420,488 @@ extern "C" { # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif -#if !defined(LZO_UNCONST_CAST) -# if 0 && defined(__cplusplus) -# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) -# else -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +#if !defined(__lzo_inline) +#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) +#elif defined(__cplusplus) +# define __lzo_inline inline +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) +# define __lzo_inline inline +#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) +# define __lzo_inline __inline +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_inline __inline__ +#elif (LZO_CC_DMC) +# define __lzo_inline __inline +#elif (LZO_CC_GHS) +# define __lzo_inline __inline__ +#elif (LZO_CC_IBMC >= 600) +# define __lzo_inline __inline__ +#elif (LZO_CC_INTELC) +# define __lzo_inline __inline +#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) +# define __lzo_inline __inline +#elif (LZO_CC_MSC && (_MSC_VER >= 900)) +# define __lzo_inline __inline +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_inline __inline__ +#endif +#endif +#if defined(__lzo_inline) +# ifndef __lzo_HAVE_inline +# define __lzo_HAVE_inline 1 # endif +#else +# define __lzo_inline /*empty*/ +#endif +#if !defined(__lzo_forceinline) +#if (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) +# define __lzo_forceinline __forceinline +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +# define __lzo_forceinline __forceinline +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#endif +#endif +#if defined(__lzo_forceinline) +# ifndef __lzo_HAVE_forceinline +# define __lzo_HAVE_forceinline 1 +# endif +#else +# define __lzo_forceinline __lzo_inline +#endif +#if !defined(__lzo_noinline) +#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) +# define __lzo_noinline __attribute__((__noinline__,__used__)) +#elif (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) +# define __lzo_noinline __declspec(noinline) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_noinline __declspec(noinline) +#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) +# if defined(__cplusplus) +# else +# define __lzo_noinline __declspec(noinline) +# endif +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_noinline __attribute__((__noinline__)) +#endif +#endif +#if defined(__lzo_noinline) +# ifndef __lzo_HAVE_noinline +# define __lzo_HAVE_noinline 1 +# endif +#else +# define __lzo_noinline /*empty*/ +#endif +#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +# error "unexpected configuration - check your compiler defines" +#endif +#if !defined(__lzo_static_inline) +#if (LZO_CC_IBMC) +# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline +#endif +#endif +#if !defined(__lzo_static_inline) +# define __lzo_static_inline static __lzo_inline +#endif +#if !defined(__lzo_static_forceinline) +#if (LZO_CC_IBMC) +# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline +#endif +#endif +#if !defined(__lzo_static_forceinline) +# define __lzo_static_forceinline static __lzo_forceinline +#endif +#if !defined(__lzo_static_noinline) +#if (LZO_CC_IBMC) +# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline +#endif +#endif +#if !defined(__lzo_static_noinline) +# define __lzo_static_noinline static __lzo_noinline +#endif +#if !defined(__lzo_c99_extern_inline) +#if defined(__GNUC_GNU_INLINE__) +# define __lzo_c99_extern_inline __lzo_inline +#elif defined(__GNUC_STDC_INLINE__) +# define __lzo_c99_extern_inline extern __lzo_inline +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) +# define __lzo_c99_extern_inline extern __lzo_inline +#endif +#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) +# define __lzo_c99_extern_inline __lzo_inline +#endif +#endif +#if defined(__lzo_c99_extern_inline) +# ifndef __lzo_HAVE_c99_extern_inline +# define __lzo_HAVE_c99_extern_inline 1 +# endif +#else +# define __lzo_c99_extern_inline /*empty*/ +#endif +#if !defined(__lzo_may_alias) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_CLANG >= 0x020900ul) +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 +# define __lzo_may_alias __attribute__((__may_alias__)) +#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 +# define __lzo_may_alias __attribute__((__may_alias__)) +#endif +#endif +#if defined(__lzo_may_alias) +# ifndef __lzo_HAVE_may_alias +# define __lzo_HAVE_may_alias 1 +# endif +#else +# define __lzo_may_alias /*empty*/ +#endif +#if !defined(__lzo_noreturn) +#if (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) +# define __lzo_noreturn __declspec(noreturn) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_noreturn __attribute__((__noreturn__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +# define __lzo_noreturn __declspec(noreturn) +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_noreturn __attribute__((__noreturn__)) +#endif +#endif +#if defined(__lzo_noreturn) +# ifndef __lzo_HAVE_noreturn +# define __lzo_HAVE_noreturn 1 +# endif +#else +# define __lzo_noreturn /*empty*/ +#endif +#if !defined(__lzo_nothrow) +#if (LZO_CC_GNUC >= 0x030300ul) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) +# define __lzo_nothrow __declspec(nothrow) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) +# define __lzo_nothrow __declspec(nothrow) +#endif +#endif +#if defined(__lzo_nothrow) +# ifndef __lzo_HAVE_nothrow +# define __lzo_HAVE_nothrow 1 +# endif +#else +# define __lzo_nothrow /*empty*/ +#endif +#if !defined(__lzo_restrict) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_IBMC >= 1210) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) +# define __lzo_restrict __restrict +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_restrict __restrict__ +#endif +#endif +#if defined(__lzo_restrict) +# ifndef __lzo_HAVE_restrict +# define __lzo_HAVE_restrict 1 +# endif +#else +# define __lzo_restrict /*empty*/ +#endif +#if !defined(__lzo_alignof) +#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_GHS) && !defined(__cplusplus) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_IBMC >= 600) +# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) +#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +# define __lzo_alignof(e) __alignof__(e) +#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_alignof(e) __alignof(e) +#elif (LZO_CC_SUNPROC >= 0x5100) +# define __lzo_alignof(e) __alignof__(e) +#endif +#endif +#if defined(__lzo_alignof) +# ifndef __lzo_HAVE_alignof +# define __lzo_HAVE_alignof 1 +# endif +#endif +#if !defined(__lzo_struct_packed) +#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) +#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) +#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) +# define __lzo_struct_packed(s) struct s { +# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_struct_packed(s) struct s { +# define __lzo_struct_packed_end() } __attribute__((__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_IBMC >= 700) +# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { +# define __lzo_struct_packed_end() } __attribute__((__packed__)); +# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { +# define __lzo_struct_packed_end() } __pragma(pack(pop)); +#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) +# define __lzo_struct_packed(s) _Packed struct s { +# define __lzo_struct_packed_end() }; +#endif +#endif +#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) +# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) +#endif +#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) +# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() +#endif +#if !defined(__lzo_byte_struct) +#if defined(__lzo_struct_packed) +# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() +# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() +#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); +# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); +#endif +#endif +#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) +# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) +#endif +#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) +#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) +#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_CILLY || LZO_CC_PCC) +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_struct_align16(s) struct __declspec(align(16)) s { +# define __lzo_struct_align16_end() }; +# define __lzo_struct_align32(s) struct __declspec(align(32)) s { +# define __lzo_struct_align32_end() }; +# define __lzo_struct_align64(s) struct __declspec(align(64)) s { +# define __lzo_struct_align64_end() }; +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_struct_align16(s) struct s { +# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); +# define __lzo_struct_align32(s) struct s { +# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); +# define __lzo_struct_align64(s) struct s { +# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); +#endif +#endif +#if !defined(__lzo_union_um) +#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) +#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) +#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) +#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) +#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) +# define __lzo_union_am(s) union s { +# define __lzo_union_am_end() } __lzo_may_alias; +# define __lzo_union_um(s) union s { +# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_IBMC >= 700) +# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { +# define __lzo_union_am_end() } __lzo_may_alias; +# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { +# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); +#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) +# define __lzo_union_um(s) __pragma(pack(push,1)) union s { +# define __lzo_union_um_end() } __pragma(pack(pop)); +#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) +# define __lzo_union_um(s) _Packed union s { +# define __lzo_union_um_end() }; +#endif +#endif +#if !defined(__lzo_union_am) +# define __lzo_union_am(s) union s { +# define __lzo_union_am_end() }; +#endif +#if !defined(__lzo_constructor) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_constructor __attribute__((__constructor__,__used__)) +#elif (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_constructor __attribute__((__constructor__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_constructor __attribute__((__constructor__,__used__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_constructor __attribute__((__constructor__)) +#endif +#endif +#if defined(__lzo_constructor) +# ifndef __lzo_HAVE_constructor +# define __lzo_HAVE_constructor 1 +# endif +#endif +#if !defined(__lzo_destructor) +#if (LZO_CC_GNUC >= 0x030400ul) +# define __lzo_destructor __attribute__((__destructor__,__used__)) +#elif (LZO_CC_GNUC >= 0x020700ul) +# define __lzo_destructor __attribute__((__destructor__)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) +# define __lzo_destructor __attribute__((__destructor__,__used__)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_destructor __attribute__((__destructor__)) +#endif +#endif +#if defined(__lzo_destructor) +# ifndef __lzo_HAVE_destructor +# define __lzo_HAVE_destructor 1 +# endif +#endif +#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +# error "unexpected configuration - check your compiler defines" +#endif +#if !defined(__lzo_likely) && !defined(__lzo_unlikely) +#if (LZO_CC_GNUC >= 0x030200ul) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_IBMC >= 1010) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#endif +#endif +#if defined(__lzo_likely) +# ifndef __lzo_HAVE_likely +# define __lzo_HAVE_likely 1 +# endif +#else +# define __lzo_likely(e) (e) +#endif +#if defined(__lzo_unlikely) +# ifndef __lzo_HAVE_unlikely +# define __lzo_HAVE_unlikely 1 +# endif +#else +# define __lzo_unlikely(e) (e) +#endif +#if !defined(__lzo_static_unused_void_func) +# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) +# else +# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) +# endif +#endif +#if !defined(__lzo_loop_forever) +# if (LZO_CC_IBMC) +# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END +# else +# define __lzo_loop_forever() do { ; } while __lzo_cte(1) +# endif +#endif +#if !defined(__lzo_unreachable) +#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) +# define __lzo_unreachable() __builtin_unreachable(); +#elif (LZO_CC_GNUC >= 0x040500ul) +# define __lzo_unreachable() __builtin_unreachable(); +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 +# define __lzo_unreachable() __builtin_unreachable(); +#endif +#endif +#if defined(__lzo_unreachable) +# ifndef __lzo_HAVE_unreachable +# define __lzo_HAVE_unreachable 1 +# endif +#else +# if 0 +# define __lzo_unreachable() ((void)0); +# else +# define __lzo_unreachable() __lzo_loop_forever(); +# endif +#endif +#ifndef __LZO_CTA_NAME +#if (LZO_CFG_USE_COUNTER) +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) +#else +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) +#endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END +# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END # else -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} +# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} +# elif (LZO_CC_GNUC >= 0x040700ul) +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} # endif #endif +LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) +#if defined(__cplusplus) +extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) @@ -1730,6 +1965,7 @@ extern "C" { # define __lzo_cdecl_va __lzo_cdecl #endif #if !(LZO_CFG_NO_WINDOWS_H) +#if !defined(LZO_HAVE_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) @@ -1739,61 +1975,615 @@ extern "C" { # endif #endif #endif +#endif +#ifndef LZO_SIZEOF_SHORT +#if defined(SIZEOF_SHORT) +# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) +#elif defined(__SIZEOF_SHORT__) +# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) +#endif +#endif +#ifndef LZO_SIZEOF_INT +#if defined(SIZEOF_INT) +# define LZO_SIZEOF_INT (SIZEOF_INT) +#elif defined(__SIZEOF_INT__) +# define LZO_SIZEOF_INT (__SIZEOF_INT__) +#endif +#endif +#ifndef LZO_SIZEOF_LONG +#if defined(SIZEOF_LONG) +# define LZO_SIZEOF_LONG (SIZEOF_LONG) +#elif defined(__SIZEOF_LONG__) +# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) +#endif +#endif +#ifndef LZO_SIZEOF_LONG_LONG +#if defined(SIZEOF_LONG_LONG) +# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) +#elif defined(__SIZEOF_LONG_LONG__) +# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) +#endif +#endif +#ifndef LZO_SIZEOF___INT16 +#if defined(SIZEOF___INT16) +# define LZO_SIZEOF___INT16 (SIZEOF___INT16) +#endif +#endif +#ifndef LZO_SIZEOF___INT32 +#if defined(SIZEOF___INT32) +# define LZO_SIZEOF___INT32 (SIZEOF___INT32) +#endif +#endif +#ifndef LZO_SIZEOF___INT64 +#if defined(SIZEOF___INT64) +# define LZO_SIZEOF___INT64 (SIZEOF___INT64) +#endif +#endif +#ifndef LZO_SIZEOF_VOID_P +#if defined(SIZEOF_VOID_P) +# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) +#elif defined(__SIZEOF_POINTER__) +# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) +#endif +#endif +#ifndef LZO_SIZEOF_SIZE_T +#if defined(SIZEOF_SIZE_T) +# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) +#elif defined(__SIZEOF_SIZE_T__) +# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) +#endif +#endif +#ifndef LZO_SIZEOF_PTRDIFF_T +#if defined(SIZEOF_PTRDIFF_T) +# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) +#elif defined(__SIZEOF_PTRDIFF_T__) +# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) +#endif +#endif +#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +#if !defined(LZO_SIZEOF_SHORT) +# if (LZO_ARCH_CRAY_PVP) +# define LZO_SIZEOF_SHORT 8 +# elif (USHRT_MAX == LZO_0xffffL) +# define LZO_SIZEOF_SHORT 2 +# elif (__LZO_LSR(USHRT_MAX,7) == 1) +# define LZO_SIZEOF_SHORT 1 +# elif (__LZO_LSR(USHRT_MAX,15) == 1) +# define LZO_SIZEOF_SHORT 2 +# elif (__LZO_LSR(USHRT_MAX,31) == 1) +# define LZO_SIZEOF_SHORT 4 +# elif (__LZO_LSR(USHRT_MAX,63) == 1) +# define LZO_SIZEOF_SHORT 8 +# elif (__LZO_LSR(USHRT_MAX,127) == 1) +# define LZO_SIZEOF_SHORT 16 +# else +# error "LZO_SIZEOF_SHORT" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) +#if !defined(LZO_SIZEOF_INT) +# if (LZO_ARCH_CRAY_PVP) +# define LZO_SIZEOF_INT 8 +# elif (UINT_MAX == LZO_0xffffL) +# define LZO_SIZEOF_INT 2 +# elif (UINT_MAX == LZO_0xffffffffL) +# define LZO_SIZEOF_INT 4 +# elif (__LZO_LSR(UINT_MAX,7) == 1) +# define LZO_SIZEOF_INT 1 +# elif (__LZO_LSR(UINT_MAX,15) == 1) +# define LZO_SIZEOF_INT 2 +# elif (__LZO_LSR(UINT_MAX,31) == 1) +# define LZO_SIZEOF_INT 4 +# elif (__LZO_LSR(UINT_MAX,63) == 1) +# define LZO_SIZEOF_INT 8 +# elif (__LZO_LSR(UINT_MAX,127) == 1) +# define LZO_SIZEOF_INT 16 +# else +# error "LZO_SIZEOF_INT" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) +#if !defined(LZO_SIZEOF_LONG) +# if (ULONG_MAX == LZO_0xffffffffL) +# define LZO_SIZEOF_LONG 4 +# elif (__LZO_LSR(ULONG_MAX,7) == 1) +# define LZO_SIZEOF_LONG 1 +# elif (__LZO_LSR(ULONG_MAX,15) == 1) +# define LZO_SIZEOF_LONG 2 +# elif (__LZO_LSR(ULONG_MAX,31) == 1) +# define LZO_SIZEOF_LONG 4 +# elif (__LZO_LSR(ULONG_MAX,39) == 1) +# define LZO_SIZEOF_LONG 5 +# elif (__LZO_LSR(ULONG_MAX,63) == 1) +# define LZO_SIZEOF_LONG 8 +# elif (__LZO_LSR(ULONG_MAX,127) == 1) +# define LZO_SIZEOF_LONG 16 +# else +# error "LZO_SIZEOF_LONG" +# endif +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) +#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +# if (LZO_CC_GNUC >= 0x030300ul) +# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) +# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +# define LZO_SIZEOF_LONG_LONG 4 +# endif +# endif +# endif +#endif +#endif +#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +#if (LZO_ARCH_I086 && LZO_CC_DMC) +#elif (LZO_CC_CILLY) && defined(__GNUC__) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_SIZEOF_LONG_LONG 8 +#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_OS_WIN64 || defined(_WIN64)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +# define LZO_SIZEOF___INT64 8 +#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) +# define LZO_SIZEOF___INT64 8 +#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define LZO_SIZEOF_LONG_LONG 8 +#endif +#endif +#endif +#if defined(__cplusplus) && (LZO_CC_GNUC) +# if (LZO_CC_GNUC < 0x020800ul) +# undef LZO_SIZEOF_LONG_LONG +# endif +#endif +#if (LZO_CFG_NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(__NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(_NO_LONGLONG) +# undef LZO_SIZEOF_LONG_LONG +#endif +#if !defined(LZO_WORDSIZE) #if (LZO_ARCH_ALPHA) -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 +# define LZO_WORDSIZE 8 #elif (LZO_ARCH_AMD64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# define LZO_OPT_UNALIGNED64 1 -#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -#elif (LZO_ARCH_ARM) -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_CRIS) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_I386) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# define LZO_WORDSIZE 8 +#elif (LZO_ARCH_AVR) +# define LZO_WORDSIZE 1 +#elif (LZO_ARCH_H8300) +# if defined(__NORMAL_MODE__) +# define LZO_WORDSIZE 4 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define LZO_WORDSIZE 4 +# else +# define LZO_WORDSIZE 2 +# endif +#elif (LZO_ARCH_I086) +# define LZO_WORDSIZE 2 #elif (LZO_ARCH_IA64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_WORDSIZE 8 +#elif (LZO_ARCH_M16C) +# define LZO_WORDSIZE 2 +#elif (LZO_ARCH_SPU) +# define LZO_WORDSIZE 4 +#elif (LZO_ARCH_Z80) +# define LZO_WORDSIZE 1 +#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define LZO_WORDSIZE 8 +#elif (LZO_OS_OS400 || defined(__OS400__)) +# define LZO_WORDSIZE 8 +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define LZO_WORDSIZE 8 +#endif +#endif +#if !defined(LZO_SIZEOF_VOID_P) +#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) +# define LZO_SIZEOF_VOID_P 4 +#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) +# define LZO_SIZEOF_VOID_P 8 +#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) +# define LZO_SIZEOF_VOID_P 8 +#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) +# define LZO_SIZEOF_VOID_P 8 +#elif (LZO_ARCH_AVR) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_ARCH_H8300) +# if defined(__NORMAL_MODE__) +# define LZO_SIZEOF_VOID_P 2 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define LZO_SIZEOF_VOID_P 4 +# else +# define LZO_SIZEOF_VOID_P 2 +# endif +# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +# endif +#elif (LZO_ARCH_I086) +# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +# define LZO_SIZEOF_VOID_P 2 +# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +# define LZO_SIZEOF_VOID_P 4 +# else +# error "invalid LZO_ARCH_I086 memory model" +# endif +#elif (LZO_ARCH_M16C) +# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +# define LZO_SIZEOF_VOID_P 4 +# else +# define LZO_SIZEOF_VOID_P 2 +# endif +#elif (LZO_ARCH_SPU) +# define LZO_SIZEOF_VOID_P 4 +#elif (LZO_ARCH_Z80) +# define LZO_SIZEOF_VOID_P 2 +#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define LZO_SIZEOF_VOID_P 4 +#elif (LZO_OS_OS400 || defined(__OS400__)) +# if defined(__LLP64_IFC__) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +# else +# define LZO_SIZEOF_VOID_P 16 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +# endif +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +#endif +#endif +#if !defined(LZO_SIZEOF_VOID_P) +# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) +#if !defined(LZO_SIZEOF_SIZE_T) +#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +# define LZO_SIZEOF_SIZE_T 2 +#endif +#endif +#if !defined(LZO_SIZEOF_SIZE_T) +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +#endif +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) +#endif +#if !defined(LZO_SIZEOF_PTRDIFF_T) +#if (LZO_ARCH_I086) +# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +# define LZO_SIZEOF_PTRDIFF_T 4 +# else +# define LZO_SIZEOF_PTRDIFF_T 2 +# endif +# else +# error "invalid LZO_ARCH_I086 memory model" +# endif +#endif +#endif +#if !defined(LZO_SIZEOF_PTRDIFF_T) +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +#endif +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) +#endif +#if !defined(LZO_WORDSIZE) +# define LZO_WORDSIZE LZO_SIZEOF_VOID_P +#endif +#if (LZO_ABI_NEUTRAL_ENDIAN) +# undef LZO_ABI_BIG_ENDIAN +# undef LZO_ABI_LITTLE_ENDIAN +#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +# define LZO_ABI_BIG_ENDIAN 1 +#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +# if (__LITTLE_ENDIAN__ == 1) +# define LZO_ABI_LITTLE_ENDIAN 1 +# else +# define LZO_ABI_BIG_ENDIAN 1 +# endif +#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) +# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" +# elif defined(__BIG_ENDIAN) +# define LZO_ABI_BIG_ENDIAN 1 +# else +# define LZO_ABI_LITTLE_ENDIAN 1 +# endif +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +# define LZO_ABI_LITTLE_ENDIAN 1 +#endif +#endif +#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" +#endif +#if (LZO_ABI_BIG_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "be" +#elif (LZO_ABI_LITTLE_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "le" +#elif (LZO_ABI_NEUTRAL_ENDIAN) +# define LZO_INFO_ABI_ENDIAN "neutral" +#endif +#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +# define LZO_ABI_I8LP16 1 +# define LZO_INFO_ABI_PM "i8lp16" +#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +# define LZO_ABI_ILP16 1 +# define LZO_INFO_ABI_PM "ilp16" +#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_LP32 1 +# define LZO_INFO_ABI_PM "lp32" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_ILP32 1 +# define LZO_INFO_ABI_PM "ilp32" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +# define LZO_ABI_LLP64 1 +# define LZO_INFO_ABI_PM "llp64" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +# define LZO_ABI_LP64 1 +# define LZO_INFO_ABI_PM "lp64" +#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +# define LZO_ABI_ILP64 1 +# define LZO_INFO_ABI_PM "ilp64" +#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_IP32L64 1 +# define LZO_INFO_ABI_PM "ip32l64" +#endif +#if 0 +#elif !defined(__LZO_LIBC_OVERRIDE) +#if (LZO_LIBC_NAKED) +# define LZO_INFO_LIBC "naked" +#elif (LZO_LIBC_FREESTANDING) +# define LZO_INFO_LIBC "freestanding" +#elif (LZO_LIBC_MOSTLY_FREESTANDING) +# define LZO_INFO_LIBC "mfreestanding" +#elif (LZO_LIBC_ISOC90) +# define LZO_INFO_LIBC "isoc90" +#elif (LZO_LIBC_ISOC99) +# define LZO_INFO_LIBC "isoc99" +#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) +# define LZO_LIBC_ISOC90 1 +# define LZO_INFO_LIBC "isoc90" +#elif defined(__dietlibc__) +# define LZO_LIBC_DIETLIBC 1 +# define LZO_INFO_LIBC "dietlibc" +#elif defined(_NEWLIB_VERSION) +# define LZO_LIBC_NEWLIB 1 +# define LZO_INFO_LIBC "newlib" +#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +# if defined(__UCLIBC_SUBLEVEL__) +# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) +# else +# define LZO_LIBC_UCLIBC 0x00090bL +# endif +# define LZO_INFO_LIBC "uc" "libc" +#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) +# define LZO_INFO_LIBC "glibc" +#elif (LZO_CC_MWERKS) && defined(__MSL__) +# define LZO_LIBC_MSL __MSL__ +# define LZO_INFO_LIBC "msl" +#elif 1 && defined(__IAR_SYSTEMS_ICC__) +# define LZO_LIBC_ISOC90 1 +# define LZO_INFO_LIBC "isoc90" +#else +# define LZO_LIBC_DEFAULT 1 +# define LZO_INFO_LIBC "default" +#endif +#endif +#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +# define LZO_ASM_SYNTAX_MSC 1 +#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) +#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +# define LZO_ASM_SYNTAX_GNUC 1 +#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +# define LZO_ASM_SYNTAX_GNUC 1 +#elif (LZO_CC_GNUC) +# define LZO_ASM_SYNTAX_GNUC 1 +#endif +#if (LZO_ASM_SYNTAX_GNUC) +#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) +# define __LZO_ASM_CLOBBER "ax" +# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) +# define __LZO_ASM_CLOBBER "memory" +# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#else +# define __LZO_ASM_CLOBBER "cc", "memory" +# define __LZO_ASM_CLOBBER_LIST_CC : "cc" +# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" +# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ +#endif +#endif +#if (LZO_ARCH_ALPHA) +# define LZO_OPT_AVOID_UINT_INDEX 1 +#elif (LZO_ARCH_AMD64) +# define LZO_OPT_AVOID_INT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +#elif (LZO_ARCH_ARM) +# if defined(__ARM_FEATURE_UNALIGNED) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# endif +#elif (LZO_ARCH_ARM64) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +#elif (LZO_ARCH_CRIS) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +#elif (LZO_ARCH_I386) +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +#elif (LZO_ARCH_IA64) +# define LZO_OPT_AVOID_INT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 +# define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif # endif #elif (LZO_ARCH_MIPS) -# define LZO_OPT_AVOID_UINT_INDEX 1 +# define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) -# define LZO_OPT_PREFER_PREINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_PREINC 1 +# define LZO_OPT_PREFER_PREDEC 1 # if (LZO_ABI_BIG_ENDIAN) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# if (LZO_WORDSIZE == 8) +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif +# endif # endif #elif (LZO_ARCH_S390) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# if (LZO_SIZEOF_SIZE_T == 8) -# define LZO_OPT_UNALIGNED64 1 +# ifndef LZO_OPT_UNALIGNED16 +# define LZO_OPT_UNALIGNED16 1 +# endif +# ifndef LZO_OPT_UNALIGNED32 +# define LZO_OPT_UNALIGNED32 1 +# endif +# if (LZO_WORDSIZE == 8) +# ifndef LZO_OPT_UNALIGNED64 +# define LZO_OPT_UNALIGNED64 1 +# endif # endif #elif (LZO_ARCH_SH) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 +# define LZO_OPT_PREFER_POSTINC 1 +# define LZO_OPT_PREFER_PREDEC 1 #endif #ifndef LZO_CFG_NO_INLINE_ASM -#if (LZO_CC_LLVM) +#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) +# define LZO_CFG_NO_INLINE_ASM 1 +#elif (LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif +#if (LZO_CFG_NO_INLINE_ASM) +# undef LZO_ASM_SYNTAX_MSC +# undef LZO_ASM_SYNTAX_GNUC +# undef __LZO_ASM_CLOBBER +# undef __LZO_ASM_CLOBBER_LIST_CC +# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY +# undef __LZO_ASM_CLOBBER_LIST_EMPTY +#endif #ifndef LZO_CFG_NO_UNALIGNED #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 @@ -1804,25 +2594,6 @@ extern "C" { # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif -#if (LZO_CFG_NO_INLINE_ASM) -#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -# define LZO_ASM_SYNTAX_MSC 1 -#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#endif -#if (LZO_ASM_SYNTAX_GNUC) -#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -# define __LZO_ASM_CLOBBER "ax" -#elif (LZO_CC_INTELC) -# define __LZO_ASM_CLOBBER "memory" -#else -# define __LZO_ASM_CLOBBER "cc", "memory" -#endif -#endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" @@ -1866,6 +2637,381 @@ extern "C" { #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER +#if !(LZO_CFG_SKIP_LZO_TYPES) +#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) +# error "missing defines for sizes" +#endif +#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) +# error "missing defines for sizes" +#endif +#if !defined(lzo_llong_t) +#if (LZO_SIZEOF_LONG_LONG+0 > 0) +__lzo_gnuc_extension__ typedef long long lzo_llong_t__; +__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; +# define lzo_llong_t lzo_llong_t__ +# define lzo_ullong_t lzo_ullong_t__ +#endif +#endif +#if !defined(lzo_int16e_t) +#if (LZO_SIZEOF_LONG == 2) +# define lzo_int16e_t long +# define lzo_uint16e_t unsigned long +#elif (LZO_SIZEOF_INT == 2) +# define lzo_int16e_t int +# define lzo_uint16e_t unsigned int +#elif (LZO_SIZEOF_SHORT == 2) +# define lzo_int16e_t short int +# define lzo_uint16e_t unsigned short int +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) + typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); + typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); +# define lzo_int16e_t lzo_int16e_hi_t__ +# define lzo_uint16e_t lzo_uint16e_hi_t__ +#elif (LZO_SIZEOF___INT16 == 2) +# define lzo_int16e_t __int16 +# define lzo_uint16e_t unsigned __int16 +#else +#endif +#endif +#if defined(lzo_int16e_t) +# define LZO_SIZEOF_LZO_INT16E_T 2 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) +#endif +#if !defined(lzo_int32e_t) +#if (LZO_SIZEOF_LONG == 4) +# define lzo_int32e_t long int +# define lzo_uint32e_t unsigned long int +#elif (LZO_SIZEOF_INT == 4) +# define lzo_int32e_t int +# define lzo_uint32e_t unsigned int +#elif (LZO_SIZEOF_SHORT == 4) +# define lzo_int32e_t short int +# define lzo_uint32e_t unsigned short int +#elif (LZO_SIZEOF_LONG_LONG == 4) +# define lzo_int32e_t lzo_llong_t +# define lzo_uint32e_t lzo_ullong_t +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) + typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); + typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); +# define lzo_int32e_t lzo_int32e_si_t__ +# define lzo_uint32e_t lzo_uint32e_si_t__ +#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) + typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); + typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); +# define lzo_int32e_t lzo_int32e_si_t__ +# define lzo_uint32e_t lzo_uint32e_si_t__ +# define LZO_INT32_C(c) (c##LL) +# define LZO_UINT32_C(c) (c##ULL) +#elif (LZO_SIZEOF___INT32 == 4) +# define lzo_int32e_t __int32 +# define lzo_uint32e_t unsigned __int32 +#else +#endif +#endif +#if defined(lzo_int32e_t) +# define LZO_SIZEOF_LZO_INT32E_T 4 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) +#endif +#if !defined(lzo_int64e_t) +#if (LZO_SIZEOF___INT64 == 8) +# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) +# define LZO_CFG_TYPE_PREFER___INT64 1 +# endif +#endif +#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_int64e_t int +# define lzo_uint64e_t unsigned int +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG == 8) +# define lzo_int64e_t long int +# define lzo_uint64e_t unsigned long int +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG +#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) +# define lzo_int64e_t lzo_llong_t +# define lzo_uint64e_t lzo_ullong_t +# if (LZO_CC_BORLANDC) +# define LZO_INT64_C(c) ((c) + 0ll) +# define LZO_UINT64_C(c) ((c) + 0ull) +# elif 0 +# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) +# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) +# else +# define LZO_INT64_C(c) (c##LL) +# define LZO_UINT64_C(c) (c##ULL) +# endif +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG +#elif (LZO_SIZEOF___INT64 == 8) +# define lzo_int64e_t __int64 +# define lzo_uint64e_t unsigned __int64 +# if (LZO_CC_BORLANDC) +# define LZO_INT64_C(c) ((c) + 0i64) +# define LZO_UINT64_C(c) ((c) + 0ui64) +# else +# define LZO_INT64_C(c) (c##i64) +# define LZO_UINT64_C(c) (c##ui64) +# endif +# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 +#else +#endif +#endif +#if defined(lzo_int64e_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) +#endif +#if !defined(lzo_int32l_t) +#if defined(lzo_int32e_t) +# define lzo_int32l_t lzo_int32e_t +# define lzo_uint32l_t lzo_uint32e_t +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T +#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_int32l_t int +# define lzo_uint32l_t unsigned int +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG >= 4) +# define lzo_int32l_t long int +# define lzo_uint32l_t unsigned long int +# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG +#else +# error "lzo_int32l_t" +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) +#endif +#if !defined(lzo_int64l_t) +#if defined(lzo_int64e_t) +# define lzo_int64l_t lzo_int64e_t +# define lzo_uint64l_t lzo_uint64e_t +# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T +#else +#endif +#endif +#if defined(lzo_int64l_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) +#endif +#if !defined(lzo_int32f_t) +#if (LZO_SIZEOF_SIZE_T >= 8) +# define lzo_int32f_t lzo_int64l_t +# define lzo_uint32f_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T +#else +# define lzo_int32f_t lzo_int32l_t +# define lzo_uint32f_t lzo_uint32l_t +# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) +#endif +#if !defined(lzo_int64f_t) +#if defined(lzo_int64l_t) +# define lzo_int64f_t lzo_int64l_t +# define lzo_uint64f_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T +#else +#endif +#endif +#if defined(lzo_int64f_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) +#endif +#if !defined(lzo_intptr_t) +#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) +# define __LZO_INTPTR_T_IS_POINTER 1 + typedef char* lzo_intptr_t; + typedef char* lzo_uintptr_t; +# define lzo_intptr_t lzo_intptr_t +# define lzo_uintptr_t lzo_uintptr_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P +#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) + typedef __w64 int lzo_intptr_t; + typedef __w64 unsigned int lzo_uintptr_t; +# define lzo_intptr_t lzo_intptr_t +# define lzo_uintptr_t lzo_uintptr_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) +# define lzo_intptr_t short +# define lzo_uintptr_t unsigned short +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT +#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) +# define lzo_intptr_t int +# define lzo_uintptr_t unsigned int +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT +#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) +# define lzo_intptr_t long +# define lzo_uintptr_t unsigned long +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG +#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) +# define lzo_intptr_t lzo_int64l_t +# define lzo_uintptr_t lzo_uint64l_t +# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T +#else +# error "lzo_intptr_t" +#endif +#endif +#if 1 + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) +#endif +#if !defined(lzo_word_t) +#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) +#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) +# define lzo_word_t lzo_uintptr_t +# define lzo_sword_t lzo_intptr_t +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T +#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) +# define lzo_word_t unsigned long +# define lzo_sword_t long +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG +#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) +# define lzo_word_t unsigned int +# define lzo_sword_t int +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT +#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) +# define lzo_word_t unsigned short +# define lzo_sword_t short +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT +#elif (LZO_WORDSIZE == 1) +# define lzo_word_t unsigned char +# define lzo_sword_t signed char +# define LZO_SIZEOF_LZO_WORD_T 1 +#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) +# define lzo_word_t lzo_uint64l_t +# define lzo_sword_t lzo_int64l_t +# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T +#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) +#if 0 + typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); + typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); +# define lzo_word_t lzo_word_t +# define lzo_sword_t lzo_sword_t +# define LZO_SIZEOF_LZO_WORD_T 16 +#endif +#else +# error "lzo_word_t" +#endif +#endif +#endif +#if 1 && defined(lzo_word_t) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) + LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) +#endif +#if 1 +#define lzo_int8_t signed char +#define lzo_uint8_t unsigned char +#define LZO_SIZEOF_LZO_INT8_T 1 +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) +#endif +#if defined(lzo_int16e_t) +#define lzo_int16_t lzo_int16e_t +#define lzo_uint16_t lzo_uint16e_t +#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) +#endif +#if defined(lzo_int32e_t) +#define lzo_int32_t lzo_int32e_t +#define lzo_uint32_t lzo_uint32e_t +#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) +#endif +#if defined(lzo_int64e_t) +#define lzo_int64_t lzo_int64e_t +#define lzo_uint64_t lzo_uint64e_t +#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) +#endif +#if 1 +#define lzo_int_least32_t lzo_int32l_t +#define lzo_uint_least32_t lzo_uint32l_t +#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) +#endif +#if defined(lzo_int64l_t) +#define lzo_int_least64_t lzo_int64l_t +#define lzo_uint_least64_t lzo_uint64l_t +#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) +#endif +#if 1 +#define lzo_int_fast32_t lzo_int32f_t +#define lzo_uint_fast32_t lzo_uint32f_t +#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) +#endif +#if defined(lzo_int64f_t) +#define lzo_int_fast64_t lzo_int64f_t +#define lzo_uint_fast64_t lzo_uint64f_t +#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) +#endif +#if !defined(LZO_INT16_C) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) +# define LZO_INT16_C(c) ((c) + 0) +# define LZO_UINT16_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) +# define LZO_INT16_C(c) ((c) + 0L) +# define LZO_UINT16_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 2) +# define LZO_INT16_C(c) (c) +# define LZO_UINT16_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 2) +# define LZO_INT16_C(c) (c##L) +# define LZO_UINT16_C(c) (c##UL) +# else +# error "LZO_INT16_C" +# endif +#endif +#if !defined(LZO_INT32_C) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) +# define LZO_INT32_C(c) ((c) + 0) +# define LZO_UINT32_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) +# define LZO_INT32_C(c) ((c) + 0L) +# define LZO_UINT32_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 4) +# define LZO_INT32_C(c) (c) +# define LZO_UINT32_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 4) +# define LZO_INT32_C(c) (c##L) +# define LZO_UINT32_C(c) (c##UL) +# elif (LZO_SIZEOF_LONG_LONG >= 4) +# define LZO_INT32_C(c) (c##LL) +# define LZO_UINT32_C(c) (c##ULL) +# else +# error "LZO_INT32_C" +# endif +#endif +#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) +# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) +# define LZO_INT64_C(c) ((c) + 0) +# define LZO_UINT64_C(c) ((c) + 0U) +# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) +# define LZO_INT64_C(c) ((c) + 0L) +# define LZO_UINT64_C(c) ((c) + 0UL) +# elif (LZO_SIZEOF_INT >= 8) +# define LZO_INT64_C(c) (c) +# define LZO_UINT64_C(c) (c##U) +# elif (LZO_SIZEOF_LONG >= 8) +# define LZO_INT64_C(c) (c##L) +# define LZO_UINT64_C(c) (c##UL) +# else +# error "LZO_INT64_C" +# endif +#endif +#endif #endif @@ -1874,7 +3020,7 @@ extern "C" { #undef LZO_HAVE_CONFIG_H #include "minilzo.h" -#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) +#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) # error "version mismatch in miniLZO source files" #endif @@ -1886,23 +3032,9 @@ extern "C" { #define __LZO_CONF_H 1 #if !defined(__LZO_IN_MINILZO) -#if (LZO_CFG_FREESTANDING) +#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) # define LZO_LIBC_FREESTANDING 1 # define LZO_OS_FREESTANDING 1 -# define ACC_LIBC_FREESTANDING 1 -# define ACC_OS_FREESTANDING 1 -#endif -#if (LZO_CFG_NO_UNALIGNED) -# define ACC_CFG_NO_UNALIGNED 1 -#endif -#if (LZO_ARCH_GENERIC) -# define ACC_ARCH_GENERIC 1 -#endif -#if (LZO_ABI_NEUTRAL_ENDIAN) -# define ACC_ABI_NEUTRAL_ENDIAN 1 -#endif -#if (LZO_HAVE_CONFIG_H) -# define ACC_CONFIG_NO_HEADER 1 #endif #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) # include LZO_CFG_EXTRA_CONFIG_HEADER @@ -1911,22 +3043,27 @@ extern "C" { # error "include this file first" #endif #include "lzo/lzoconf.h" +#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) +# include LZO_CFG_EXTRA_CONFIG_HEADER2 +#endif #endif -#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) +#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) # error "version mismatch" #endif -#if (LZO_CC_BORLANDC && LZO_ARCH_I086) -# pragma option -h +#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) +# pragma warning(disable: 4702) #endif - #if (LZO_CC_MSC && (_MSC_VER >= 1000)) # pragma warning(disable: 4127 4701) +# pragma warning(disable: 4514 4710 4711) #endif #if (LZO_CC_MSC && (_MSC_VER >= 1300)) # pragma warning(disable: 4820) -# pragma warning(disable: 4514 4710 4711) +#endif +#if (LZO_CC_MSC && (_MSC_VER >= 1800)) +# pragma warning(disable: 4746) #endif #if (LZO_CC_SUNPROC) @@ -1937,49 +3074,16 @@ extern "C" { #endif #endif -#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) -# error "this should not happen - check defines for __huge" -#endif - -#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) -#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# define ACC_WANT_ACC_INCD_H 1 -# define ACC_WANT_ACC_INCE_H 1 -# define ACC_WANT_ACC_INCI_H 1 +#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) #elif 1 # include #else -# define ACC_WANT_ACC_INCD_H 1 +# define LZO_WANT_ACC_INCD_H 1 #endif - -#if (LZO_ARCH_I086) -# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT -# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) -# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) -# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +#if defined(LZO_HAVE_CONFIG_H) +# define LZO_CFG_NO_CONFIG_HEADER 1 #endif -#if !defined(lzo_uintptr_t) -# if defined(__LZO_MMODEL_HUGE) -# define lzo_uintptr_t unsigned long -# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) -# define __LZO_UINTPTR_T_IS_POINTER 1 - typedef char* lzo_uintptr_t; -# define lzo_uintptr_t lzo_uintptr_t -# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) -# define lzo_uintptr_t size_t -# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) -# define lzo_uintptr_t unsigned long -# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) -# define lzo_uintptr_t unsigned int -# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) -# define lzo_uintptr_t unsigned long long -# else -# define lzo_uintptr_t size_t -# endif -#endif -LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #if 1 && !defined(LZO_CFG_FREESTANDING) #if 1 && !defined(HAVE_STRING_H) #define HAVE_STRING_H 1 @@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) #include #endif +#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) +#endif +#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) +#endif +#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) +#endif +#if defined(lzo_int64_t) || defined(lzo_uint64_t) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) +#endif + #if (LZO_CFG_FREESTANDING) # undef HAVE_MEMCMP # undef HAVE_MEMCPY @@ -2012,28 +3133,28 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) #if !(HAVE_MEMCMP) # undef memcmp # define memcmp(a,b,c) lzo_memcmp(a,b,c) -#elif !(__LZO_MMODEL_HUGE) +#else # undef lzo_memcmp # define lzo_memcmp(a,b,c) memcmp(a,b,c) #endif #if !(HAVE_MEMCPY) # undef memcpy # define memcpy(a,b,c) lzo_memcpy(a,b,c) -#elif !(__LZO_MMODEL_HUGE) +#else # undef lzo_memcpy # define lzo_memcpy(a,b,c) memcpy(a,b,c) #endif #if !(HAVE_MEMMOVE) # undef memmove # define memmove(a,b,c) lzo_memmove(a,b,c) -#elif !(__LZO_MMODEL_HUGE) +#else # undef lzo_memmove # define lzo_memmove(a,b,c) memmove(a,b,c) #endif #if !(HAVE_MEMSET) # undef memset # define memset(a,b,c) lzo_memset(a,b,c) -#elif !(__LZO_MMODEL_HUGE) +#else # undef lzo_memset # define lzo_memset(a,b,c) memset(a,b,c) #endif @@ -2058,27 +3179,29 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) #endif -#if !defined(__lzo_inline) -# define __lzo_inline /*empty*/ -#endif -#if !defined(__lzo_forceinline) -# define __lzo_forceinline /*empty*/ -#endif -#if !defined(__lzo_noinline) -# define __lzo_noinline /*empty*/ -#endif - #if (LZO_CFG_PGO) -# undef __acc_likely -# undef __acc_unlikely # undef __lzo_likely # undef __lzo_unlikely -# define __acc_likely(e) (e) -# define __acc_unlikely(e) (e) # define __lzo_likely(e) (e) # define __lzo_unlikely(e) (e) #endif +#undef _ +#undef __ +#undef ___ +#undef ____ +#undef _p0 +#undef _p1 +#undef _p2 +#undef _p3 +#undef _p4 +#undef _s0 +#undef _s1 +#undef _s2 +#undef _s3 +#undef _s4 +#undef _ww + #if 1 # define LZO_BYTE(x) ((unsigned char) (x)) #else @@ -2097,84 +3220,548 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) #define LZO_SIZE(bits) (1u << (bits)) #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) -#define LZO_LSIZE(bits) (1ul << (bits)) -#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) - #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) #if !defined(DMUL) #if 0 -# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) +# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) #else # define DMUL(a,b) ((lzo_xint) ((a) * (b))) #endif #endif -#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) -# if (LZO_SIZEOF_SHORT == 2) -# define LZO_UNALIGNED_OK_2 1 -# endif -# if (LZO_SIZEOF_INT == 4) -# define LZO_UNALIGNED_OK_4 1 -# endif +#ifndef __LZO_FUNC_H +#define __LZO_FUNC_H 1 + +#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) +#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) +#define LZO_BITOPS_USE_ASM_BITSCAN 1 +#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) +#define LZO_BITOPS_USE_GNUC_BITSCAN 1 +#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) +#define LZO_BITOPS_USE_MSC_BITSCAN 1 +#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) +#include +#endif +#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) +#pragma intrinsic(_BitScanReverse) +#pragma intrinsic(_BitScanForward) +#endif +#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) +#pragma intrinsic(_BitScanReverse64) +#pragma intrinsic(_BitScanForward64) #endif -#if 1 && (LZO_ARCH_AMD64) -# if defined(LZO_UINT64_MAX) -# define LZO_UNALIGNED_OK_8 1 -# endif #endif -#if (LZO_CFG_NO_UNALIGNED) -# undef LZO_UNALIGNED_OK_2 -# undef LZO_UNALIGNED_OK_4 -# undef LZO_UNALIGNED_OK_8 #endif -#undef UA_GET16 -#undef UA_SET16 -#undef UA_COPY16 -#undef UA_GET32 -#undef UA_SET32 -#undef UA_COPY32 -#undef UA_GET64 -#undef UA_SET64 -#undef UA_COPY64 -#if defined(LZO_UNALIGNED_OK_2) - LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) -# if 1 && defined(ACC_UA_COPY16) -# define UA_GET16 ACC_UA_GET16 -# define UA_SET16 ACC_UA_SET16 -# define UA_COPY16 ACC_UA_COPY16 -# else -# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) -# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) -# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) -# endif +__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) +{ +#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) + unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; +#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) +#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) + lzo_uint32_t r; + __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); + return (unsigned) r ^ 31; +#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) + unsigned r; r = (unsigned) __builtin_clz(v); return r; +#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) +#else + LZO_UNUSED(v); return 0; #endif -#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) - LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) -# if 1 && defined(ACC_UA_COPY32) -# define UA_GET32 ACC_UA_GET32 -# define UA_SET32 ACC_UA_SET32 -# define UA_COPY32 ACC_UA_COPY32 -# else -# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) -# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) -# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) -# endif +} + +#if defined(lzo_uint64_t) +__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) +{ +#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) + unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; +#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) +#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) + lzo_uint64_t r; + __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); + return (unsigned) r ^ 63; +#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) + unsigned r; r = (unsigned) __builtin_clzl(v); return r; +#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) + unsigned r; r = (unsigned) __builtin_clzll(v); return r; +#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) +#else + LZO_UNUSED(v); return 0; #endif -#if defined(LZO_UNALIGNED_OK_8) - LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) -# if 1 && defined(ACC_UA_COPY64) -# define UA_GET64 ACC_UA_GET64 -# define UA_SET64 ACC_UA_SET64 -# define UA_COPY64 ACC_UA_COPY64 -# else -# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) -# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) -# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) -# endif +} +#endif + +__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) +{ +#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) + unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; +#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) +#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) + lzo_uint32_t r; + __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); + return (unsigned) r; +#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) + unsigned r; r = (unsigned) __builtin_ctz(v); return r; +#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) +#else + LZO_UNUSED(v); return 0; +#endif +} + +#if defined(lzo_uint64_t) +__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) +{ +#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) + unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; +#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) +#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) + lzo_uint64_t r; + __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); + return (unsigned) r; +#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) + unsigned r; r = (unsigned) __builtin_ctzl(v); return r; +#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) +#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) + unsigned r; r = (unsigned) __builtin_ctzll(v); return r; +#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) +#else + LZO_UNUSED(v); return 0; +#endif +} +#endif + +#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +static void __attribute__((__unused__)) +#else +__lzo_static_forceinline void +#endif +lzo_bitops_unused_funcs(void) +{ + LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); + LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); +#if defined(lzo_uint64_t) + LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); + LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); +#endif + LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); +} + +#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) +#ifndef __lzo_memops_tcheck +#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) +#endif +#endif +#ifndef lzo_memops_TU0p +#define lzo_memops_TU0p void __LZO_MMODEL * +#endif +#ifndef lzo_memops_TU1p +#define lzo_memops_TU1p unsigned char __LZO_MMODEL * +#endif +#ifndef lzo_memops_TU2p +#if (LZO_OPT_UNALIGNED16) +typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; +#define lzo_memops_TU2p volatile lzo_memops_TU2 * +#elif defined(__lzo_byte_struct) +__lzo_byte_struct(lzo_memops_TU2_struct,2) +typedef struct lzo_memops_TU2_struct lzo_memops_TU2; +#else +struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; +typedef struct lzo_memops_TU2_struct lzo_memops_TU2; +#endif +#ifndef lzo_memops_TU2p +#define lzo_memops_TU2p lzo_memops_TU2 * +#endif +#endif +#ifndef lzo_memops_TU4p +#if (LZO_OPT_UNALIGNED32) +typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; +#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * +#elif defined(__lzo_byte_struct) +__lzo_byte_struct(lzo_memops_TU4_struct,4) +typedef struct lzo_memops_TU4_struct lzo_memops_TU4; +#else +struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; +typedef struct lzo_memops_TU4_struct lzo_memops_TU4; +#endif +#ifndef lzo_memops_TU4p +#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * +#endif +#endif +#ifndef lzo_memops_TU8p +#if (LZO_OPT_UNALIGNED64) +typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; +#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * +#elif defined(__lzo_byte_struct) +__lzo_byte_struct(lzo_memops_TU8_struct,8) +typedef struct lzo_memops_TU8_struct lzo_memops_TU8; +#else +struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; +typedef struct lzo_memops_TU8_struct lzo_memops_TU8; +#endif +#ifndef lzo_memops_TU8p +#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * +#endif +#endif +#ifndef lzo_memops_set_TU1p +#define lzo_memops_set_TU1p volatile lzo_memops_TU1p +#endif +#ifndef lzo_memops_move_TU1p +#define lzo_memops_move_TU1p lzo_memops_TU1p +#endif +#define LZO_MEMOPS_SET1(dd,cc) \ + LZO_BLOCK_BEGIN \ + lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ + d__1[0] = LZO_BYTE(cc); \ + LZO_BLOCK_END +#define LZO_MEMOPS_SET2(dd,cc) \ + LZO_BLOCK_BEGIN \ + lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ + d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ + LZO_BLOCK_END +#define LZO_MEMOPS_SET3(dd,cc) \ + LZO_BLOCK_BEGIN \ + lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ + d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ + LZO_BLOCK_END +#define LZO_MEMOPS_SET4(dd,cc) \ + LZO_BLOCK_BEGIN \ + lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ + d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ + LZO_BLOCK_END +#define LZO_MEMOPS_MOVE1(dd,ss) \ + LZO_BLOCK_BEGIN \ + lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ + d__1[0] = s__1[0]; \ + LZO_BLOCK_END +#define LZO_MEMOPS_MOVE2(dd,ss) \ + LZO_BLOCK_BEGIN \ + lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ + d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ + LZO_BLOCK_END +#define LZO_MEMOPS_MOVE3(dd,ss) \ + LZO_BLOCK_BEGIN \ + lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ + d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ + LZO_BLOCK_END +#define LZO_MEMOPS_MOVE4(dd,ss) \ + LZO_BLOCK_BEGIN \ + lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ + d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ + LZO_BLOCK_END +#define LZO_MEMOPS_MOVE8(dd,ss) \ + LZO_BLOCK_BEGIN \ + lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ + d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ + d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ + LZO_BLOCK_END +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) +#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) +#if (LZO_OPT_UNALIGNED16) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) +#define LZO_MEMOPS_COPY2(dd,ss) \ + * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) +#elif defined(__lzo_memops_tcheck) +#define LZO_MEMOPS_COPY2(dd,ss) \ + LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ + * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ + } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END +#else +#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) +#endif +#if (LZO_OPT_UNALIGNED32) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) +#define LZO_MEMOPS_COPY4(dd,ss) \ + * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) +#elif defined(__lzo_memops_tcheck) +#define LZO_MEMOPS_COPY4(dd,ss) \ + LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ + * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ + } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END +#else +#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) +#endif +#if (LZO_WORDSIZE != 8) +#define LZO_MEMOPS_COPY8(dd,ss) \ + LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END +#else +#if (LZO_OPT_UNALIGNED64) +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) +#define LZO_MEMOPS_COPY8(dd,ss) \ + * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) +#elif (LZO_OPT_UNALIGNED32) +#define LZO_MEMOPS_COPY8(dd,ss) \ + LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END +#elif defined(__lzo_memops_tcheck) +#define LZO_MEMOPS_COPY8(dd,ss) \ + LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ + * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ + } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END +#else +#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) +#endif +#endif +#define LZO_MEMOPS_COPYN(dd,ss,nn) \ + LZO_BLOCK_BEGIN \ + lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ + const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ + lzo_uint n__n = (nn); \ + while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ + if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ + if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ + LZO_BLOCK_END + +__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) +{ + lzo_uint16_t v; +#if (LZO_ABI_LITTLE_ENDIAN) + LZO_MEMOPS_COPY2(&v, ss); +#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) + const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; + unsigned long vv; + __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); + v = (lzo_uint16_t) vv; +#else + const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; + v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); +#endif + return v; +} +#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) +#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) +#else +#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) +#endif + +__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) +{ + lzo_uint32_t v; +#if (LZO_ABI_LITTLE_ENDIAN) + LZO_MEMOPS_COPY4(&v, ss); +#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) + const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; + unsigned long vv; + __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); + v = (lzo_uint32_t) vv; +#else + const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; + v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); +#endif + return v; +} +#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) +#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) +#else +#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) +#endif + +#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) +#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) +#endif + +__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) +{ + lzo_uint16_t v; + LZO_MEMOPS_COPY2(&v, ss); + return v; +} +#if (LZO_OPT_UNALIGNED16) +#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) +#else +#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) +#endif + +__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) +{ + lzo_uint32_t v; + LZO_MEMOPS_COPY4(&v, ss); + return v; +} +#if (LZO_OPT_UNALIGNED32) +#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) +#else +#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) +#endif + +#if (LZO_OPT_UNALIGNED64) +#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) +#endif + +__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) +{ +#if (LZO_ABI_LITTLE_ENDIAN) + LZO_MEMOPS_COPY2(dd, &vv); +#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) + lzo_memops_TU2p d = (lzo_memops_TU2p) dd; + unsigned long v = vv; + __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); +#else + lzo_memops_TU1p d = (lzo_memops_TU1p) dd; + d[0] = LZO_BYTE((vv ) & 0xff); + d[1] = LZO_BYTE((vv >> 8) & 0xff); +#endif +} +#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) +#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) +#else +#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) +#endif + +__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) +{ +#if (LZO_ABI_LITTLE_ENDIAN) + LZO_MEMOPS_COPY4(dd, &vv); +#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) + lzo_memops_TU4p d = (lzo_memops_TU4p) dd; + unsigned long v = vv; + __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); +#else + lzo_memops_TU1p d = (lzo_memops_TU1p) dd; + d[0] = LZO_BYTE((vv ) & 0xff); + d[1] = LZO_BYTE((vv >> 8) & 0xff); + d[2] = LZO_BYTE((vv >> 16) & 0xff); + d[3] = LZO_BYTE((vv >> 24) & 0xff); +#endif +} +#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) +#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) +#else +#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) +#endif + +__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) +{ + LZO_MEMOPS_COPY2(dd, &vv); +} +#if (LZO_OPT_UNALIGNED16) +#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) +#else +#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) +#endif + +__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) +{ + LZO_MEMOPS_COPY4(dd, &vv); +} +#if (LZO_OPT_UNALIGNED32) +#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) +#else +#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) +#endif + +#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +static void __attribute__((__unused__)) +#else +__lzo_static_forceinline void +#endif +lzo_memops_unused_funcs(void) +{ + LZO_UNUSED_FUNC(lzo_memops_get_le16); + LZO_UNUSED_FUNC(lzo_memops_get_le32); + LZO_UNUSED_FUNC(lzo_memops_get_ne16); + LZO_UNUSED_FUNC(lzo_memops_get_ne32); + LZO_UNUSED_FUNC(lzo_memops_put_le16); + LZO_UNUSED_FUNC(lzo_memops_put_le32); + LZO_UNUSED_FUNC(lzo_memops_put_ne16); + LZO_UNUSED_FUNC(lzo_memops_put_ne32); + LZO_UNUSED_FUNC(lzo_memops_unused_funcs); +} + +#endif + +#ifndef UA_SET1 +#define UA_SET1 LZO_MEMOPS_SET1 +#endif +#ifndef UA_SET2 +#define UA_SET2 LZO_MEMOPS_SET2 +#endif +#ifndef UA_SET3 +#define UA_SET3 LZO_MEMOPS_SET3 +#endif +#ifndef UA_SET4 +#define UA_SET4 LZO_MEMOPS_SET4 +#endif +#ifndef UA_MOVE1 +#define UA_MOVE1 LZO_MEMOPS_MOVE1 +#endif +#ifndef UA_MOVE2 +#define UA_MOVE2 LZO_MEMOPS_MOVE2 +#endif +#ifndef UA_MOVE3 +#define UA_MOVE3 LZO_MEMOPS_MOVE3 +#endif +#ifndef UA_MOVE4 +#define UA_MOVE4 LZO_MEMOPS_MOVE4 +#endif +#ifndef UA_MOVE8 +#define UA_MOVE8 LZO_MEMOPS_MOVE8 +#endif +#ifndef UA_COPY1 +#define UA_COPY1 LZO_MEMOPS_COPY1 +#endif +#ifndef UA_COPY2 +#define UA_COPY2 LZO_MEMOPS_COPY2 +#endif +#ifndef UA_COPY3 +#define UA_COPY3 LZO_MEMOPS_COPY3 +#endif +#ifndef UA_COPY4 +#define UA_COPY4 LZO_MEMOPS_COPY4 +#endif +#ifndef UA_COPY8 +#define UA_COPY8 LZO_MEMOPS_COPY8 +#endif +#ifndef UA_COPYN +#define UA_COPYN LZO_MEMOPS_COPYN +#endif +#ifndef UA_COPYN_X +#define UA_COPYN_X LZO_MEMOPS_COPYN +#endif +#ifndef UA_GET_LE16 +#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 +#endif +#ifndef UA_GET_LE32 +#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 +#endif +#ifdef LZO_MEMOPS_GET_LE64 +#ifndef UA_GET_LE64 +#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 +#endif +#endif +#ifndef UA_GET_NE16 +#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 +#endif +#ifndef UA_GET_NE32 +#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 +#endif +#ifdef LZO_MEMOPS_GET_NE64 +#ifndef UA_GET_NE64 +#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 +#endif +#endif +#ifndef UA_PUT_LE16 +#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 +#endif +#ifndef UA_PUT_LE32 +#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 +#endif +#ifndef UA_PUT_NE16 +#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 +#endif +#ifndef UA_PUT_NE32 +#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 #endif #define MEMCPY8_DS(dest,src,len) \ @@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); extern "C" { #endif -#if !defined(lzo_uintptr_t) -# if (__LZO_MMODEL_HUGE) -# define lzo_uintptr_t unsigned long -# else -# define lzo_uintptr_t acc_uintptr_t -# ifdef __ACC_INTPTR_T_IS_POINTER -# define __LZO_UINTPTR_T_IS_POINTER 1 -# endif -# endif -#endif - #if (LZO_ARCH_I086) -#define PTR(a) ((lzo_bytep) (a)) -#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) -#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) +#error "LZO_ARCH_I086 is unsupported" #elif (LZO_MM_PVP) -#define PTR(a) ((lzo_bytep) (a)) -#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) -#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) +#error "LZO_MM_PVP is unsupported" #else #define PTR(a) ((lzo_uintptr_t) (a)) #define PTR_LINEAR(a) PTR(a) @@ -2243,24 +3815,28 @@ typedef union unsigned long a_ulong; lzo_int a_lzo_int; lzo_uint a_lzo_uint; - lzo_int32 a_lzo_int32; - lzo_uint32 a_lzo_uint32; -#if defined(LZO_UINT64_MAX) - lzo_int64 a_lzo_int64; - lzo_uint64 a_lzo_uint64; + lzo_xint a_lzo_xint; + lzo_int16_t a_lzo_int16_t; + lzo_uint16_t a_lzo_uint16_t; + lzo_int32_t a_lzo_int32_t; + lzo_uint32_t a_lzo_uint32_t; +#if defined(lzo_uint64_t) + lzo_int64_t a_lzo_int64_t; + lzo_uint64_t a_lzo_uint64_t; #endif + size_t a_size_t; ptrdiff_t a_ptrdiff_t; lzo_uintptr_t a_lzo_uintptr_t; - lzo_voidp a_lzo_voidp; void * a_void_p; - lzo_bytep a_lzo_bytep; - lzo_bytepp a_lzo_bytepp; - lzo_uintp a_lzo_uintp; - lzo_uint * a_lzo_uint_p; - lzo_uint32p a_lzo_uint32p; - lzo_uint32 * a_lzo_uint32_p; - unsigned char * a_uchar_p; char * a_char_p; + unsigned char * a_uchar_p; + const void * a_c_void_p; + const char * a_c_char_p; + const unsigned char * a_c_uchar_p; + lzo_voidp a_lzo_voidp; + lzo_bytep a_lzo_bytep; + const lzo_voidp a_c_lzo_voidp; + const lzo_bytep a_c_lzo_bytep; } lzo_full_align_t; @@ -2276,18 +3852,14 @@ lzo_full_align_t; #ifndef LZO_DICT_USE_PTR #define LZO_DICT_USE_PTR 1 -#if 0 && (LZO_ARCH_I086) -# undef LZO_DICT_USE_PTR -# define LZO_DICT_USE_PTR 0 -#endif #endif #if (LZO_DICT_USE_PTR) # define lzo_dict_t const lzo_bytep -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * +# define lzo_dict_p lzo_dict_t * #else # define lzo_dict_t lzo_uint -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * +# define lzo_dict_p lzo_dict_t * #endif #endif @@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) lzo_uintptr_t p; #if (LZO_ARCH_I086) - p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); +#error "LZO_ARCH_I086 is unsupported" #elif (LZO_MM_PVP) - p = (lzo_uintptr_t) (ptr); - p = (p << 3) | (p >> 61); +#error "LZO_MM_PVP is unsupported" #else p = (lzo_uintptr_t) PTR_LINEAR(ptr); #endif @@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) LZO_PUBLIC(unsigned) __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) { -#if defined(__LZO_UINTPTR_T_IS_POINTER) - size_t n = (size_t) ptr; - n = (((n + size - 1) / size) * size) - n; +#if (__LZO_UINTPTR_T_IS_POINTER) +#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" #else lzo_uintptr_t p, n; p = __lzo_ptr_linear(ptr); @@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = #else "\r\n\n" "LZO data compression library.\n" - "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" + "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" "\n" "http://www.oberhumer.com $\n\n" "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" @@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = LZO_PUBLIC(const lzo_bytep) lzo_copyright(void) { -#if (LZO_OS_DOS16 && LZO_CC_TURBOC) - return (lzo_voidp) __lzo_copyright; -#else return (const lzo_bytep) __lzo_copyright; -#endif } LZO_PUBLIC(unsigned) @@ -2393,16 +3959,16 @@ _lzo_version_date(void) #define LZO_NMAX 5552 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 -#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); -#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); -#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); -#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); +#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) +#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) +#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) +#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) -LZO_PUBLIC(lzo_uint32) -lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) +LZO_PUBLIC(lzo_uint32_t) +lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) { - lzo_uint32 s1 = adler & 0xffff; - lzo_uint32 s2 = (adler >> 16) & 0xffff; + lzo_uint32_t s1 = adler & 0xffff; + lzo_uint32_t s2 = (adler >> 16) & 0xffff; unsigned k; if (buf == NULL) @@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) - const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; - const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; + const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); + const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); if __lzo_likely(len > 0) do { int d = *p1 - *p2; @@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) - lzo_hbyte_p p1 = (lzo_hbyte_p) dest; - const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; + lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); + const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); if (!(len > 0) || p1 == p2) return dest; do @@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) - lzo_hbyte_p p1 = (lzo_hbyte_p) dest; - const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; + lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); + const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); if (!(len > 0) || p1 == p2) return dest; if (p1 < p2) @@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr return memmove(dest, src, len); #endif } -LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) +LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) - lzo_hbyte_p p = (lzo_hbyte_p) s; + lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); + unsigned char c = LZO_ITRUNC(unsigned char, cc); if __lzo_likely(len > 0) do - *p++ = (unsigned char) c; + *p++ = c; while __lzo_likely(--len > 0); return s; #else - return memset(s, c, len); + return memset(s, cc, len); #endif } #undef LZOLIB_PUBLIC @@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) #if !defined(__LZO_IN_MINILZO) -#define ACC_WANT_ACC_CHK_CH 1 -#undef ACCCHK_ASSERT +#define LZO_WANT_ACC_CHK_CH 1 +#undef LZOCHK_ASSERT - ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) - ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) - - ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) - ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) - ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) - ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) -#if defined(LZO_UINT64_MAX) - ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) - ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) - ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) + LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) + LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) + LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) +#if !(__LZO_UINTPTR_T_IS_POINTER) + LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) #endif - -#if !defined(__LZO_UINTPTR_T_IS_POINTER) - ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) -#endif - ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - - ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) - ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) - ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) - ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) + LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) #endif -#undef ACCCHK_ASSERT +#undef LZOCHK_ASSERT -#if 0 -#define WANT_lzo_bitops_clz32 1 -#define WANT_lzo_bitops_clz64 1 -#endif -#define WANT_lzo_bitops_ctz32 1 -#define WANT_lzo_bitops_ctz64 1 - -#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) -#include -#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 -#pragma intrinsic(_BitScanReverse) -static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) -{ - unsigned long r; - (void) _BitScanReverse(&r, v); - return (unsigned) r; -} -#define lzo_bitops_clz32 lzo_bitops_clz32 -#endif -#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 -#pragma intrinsic(_BitScanReverse64) -static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) -{ - unsigned long r; - (void) _BitScanReverse64(&r, v); - return (unsigned) r; -} -#define lzo_bitops_clz64 lzo_bitops_clz64 -#endif -#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) -#pragma intrinsic(_BitScanForward) -static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) -{ - unsigned long r; - (void) _BitScanForward(&r, v); - return (unsigned) r; -} -#define lzo_bitops_ctz32 lzo_bitops_ctz32 -#endif -#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) -#pragma intrinsic(_BitScanForward64) -static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) -{ - unsigned long r; - (void) _BitScanForward64(&r, v); - return (unsigned) r; -} -#define lzo_bitops_ctz64 lzo_bitops_ctz64 -#endif - -#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) -#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) -#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) -#endif -#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) -#endif -#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) -#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) -#endif -#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) -#endif -#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) -#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) -#endif -#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) -#endif +union lzo_config_check_union { + lzo_uint a[2]; + unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; +#if defined(lzo_uint64_t) + lzo_uint64_t c[2]; #endif +}; #if 0 #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) @@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) LZO_PUBLIC(int) _lzo_config_check(void) { - lzo_bool r = 1; - union { - lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; -#if defined(LZO_UNALIGNED_OK_8) - lzo_uint64 c[2]; +#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) +# if 0 + volatile +# endif #endif - unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; - } u; + union lzo_config_check_union u; lzo_voidp p; + unsigned r = 1; u.a[0] = u.a[1] = 0; p = u2p(&u, 0); r &= ((* (lzo_bytep) p) == 0); -#if !defined(LZO_CFG_NO_CONFIG_CHECK) -#if defined(LZO_ABI_BIG_ENDIAN) +#if !(LZO_CFG_NO_CONFIG_CHECK) +#if (LZO_ABI_BIG_ENDIAN) u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; p = u2p(&u, 0); r &= ((* (lzo_uintp) p) == 128); #endif -#if defined(LZO_ABI_LITTLE_ENDIAN) +#if (LZO_ABI_LITTLE_ENDIAN) u.a[0] = u.a[1] = 0; u.b[0] = 128; p = u2p(&u, 0); r &= ((* (lzo_uintp) p) == 128); #endif -#if defined(LZO_UNALIGNED_OK_2) u.a[0] = u.a[1] = 0; - u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; + u.b[0] = 1; u.b[3] = 2; p = u2p(&u, 1); - r &= ((* (lzo_ushortp) p) == 0); + r &= UA_GET_NE16(p) == 0; + r &= UA_GET_LE16(p) == 0; + u.b[1] = 128; + r &= UA_GET_LE16(p) == 128; + u.b[2] = 129; + r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); +#if (LZO_ABI_BIG_ENDIAN) + r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); +#endif +#if (LZO_ABI_LITTLE_ENDIAN) + r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); #endif -#if defined(LZO_UNALIGNED_OK_4) u.a[0] = u.a[1] = 0; - u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; + u.b[0] = 3; u.b[5] = 4; p = u2p(&u, 1); - r &= ((* (lzo_uint32p) p) == 0); + r &= UA_GET_NE32(p) == 0; + r &= UA_GET_LE32(p) == 0; + u.b[1] = 128; + r &= UA_GET_LE32(p) == 128; + u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; + r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); +#if (LZO_ABI_BIG_ENDIAN) + r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); #endif -#if defined(LZO_UNALIGNED_OK_8) +#if (LZO_ABI_LITTLE_ENDIAN) + r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); +#endif +#if defined(UA_GET_NE64) u.c[0] = u.c[1] = 0; - u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; + u.b[0] = 5; u.b[9] = 6; p = u2p(&u, 1); - r &= ((* (lzo_uint64p) p) == 0); -#endif -#if defined(lzo_bitops_clz32) - { unsigned i; lzo_uint32 v = 1; - for (i = 0; i < 31; i++, v <<= 1) - r &= lzo_bitops_clz32(v) == 31 - i; - } -#endif -#if defined(lzo_bitops_clz64) - { unsigned i; lzo_uint64 v = 1; - for (i = 0; i < 63; i++, v <<= 1) - r &= lzo_bitops_clz64(v) == 63 - i; - } -#endif -#if defined(lzo_bitops_ctz32) - { unsigned i; lzo_uint32 v = 1; - for (i = 0; i < 31; i++, v <<= 1) - r &= lzo_bitops_ctz32(v) == i; - } -#endif -#if defined(lzo_bitops_ctz64) - { unsigned i; lzo_uint64 v = 1; - for (i = 0; i < 63; i++, v <<= 1) - r &= lzo_bitops_ctz64(v) == i; - } + u.c[0] = u.c[1] = 0; + r &= UA_GET_NE64(p) == 0; +#if defined(UA_GET_LE64) + r &= UA_GET_LE64(p) == 0; + u.b[1] = 128; + r &= UA_GET_LE64(p) == 128; #endif #endif +#if defined(lzo_bitops_ctlz32) + { unsigned i = 0; lzo_uint32_t v; + for (v = 1; v != 0 && r == 1; v <<= 1, i++) { + r &= lzo_bitops_ctlz32(v) == 31 - i; + r &= lzo_bitops_ctlz32_func(v) == 31 - i; + }} +#endif +#if defined(lzo_bitops_ctlz64) + { unsigned i = 0; lzo_uint64_t v; + for (v = 1; v != 0 && r == 1; v <<= 1, i++) { + r &= lzo_bitops_ctlz64(v) == 63 - i; + r &= lzo_bitops_ctlz64_func(v) == 63 - i; + }} +#endif +#if defined(lzo_bitops_cttz32) + { unsigned i = 0; lzo_uint32_t v; + for (v = 1; v != 0 && r == 1; v <<= 1, i++) { + r &= lzo_bitops_cttz32(v) == i; + r &= lzo_bitops_cttz32_func(v) == i; + }} +#endif +#if defined(lzo_bitops_cttz64) + { unsigned i = 0; lzo_uint64_t v; + for (v = 1; v != 0 && r == 1; v <<= 1, i++) { + r &= lzo_bitops_cttz64(v) == i; + r &= lzo_bitops_cttz64_func(v) == i; + }} +#endif +#endif + LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); return r == 1 ? LZO_E_OK : LZO_E_ERROR; } @@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, #if defined(__LZO_IN_MINILZO) #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) #else -#define ACC_WANT_ACC_CHK_CH 1 -#undef ACCCHK_ASSERT -#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) +#define LZO_WANT_ACC_CHK_CH 1 +#undef LZOCHK_ASSERT +#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) #endif -#undef ACCCHK_ASSERT +#undef LZOCHK_ASSERT if (v == 0) return LZO_E_ERROR; @@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, r = (s1 == -1 || s1 == (int) sizeof(short)) && (s2 == -1 || s2 == (int) sizeof(int)) && (s3 == -1 || s3 == (int) sizeof(long)) && - (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && + (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && (s7 == -1 || s7 == (int) sizeof(char *)) && @@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) -#if 1 && defined(UA_GET32) +#if 1 && defined(UA_GET_LE32) #undef LZO_DICT_USE_PTR #define LZO_DICT_USE_PTR 0 #undef lzo_dict_t -#define lzo_dict_t unsigned short +#define lzo_dict_t lzo_uint16_t #endif #define LZO_NEED_DICT_H 1 @@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) #endif #if 1 && defined(DO_COMPRESS) && !defined(do_compress) -# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) -#endif - -#if defined(UA_GET64) -# define WANT_lzo_bitops_ctz64 1 -#elif defined(UA_GET32) -# define WANT_lzo_bitops_ctz32 1 -#endif - -#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) -#include -#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 -#pragma intrinsic(_BitScanReverse) -static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) -{ - unsigned long r; - (void) _BitScanReverse(&r, v); - return (unsigned) r; -} -#define lzo_bitops_clz32 lzo_bitops_clz32 -#endif -#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 -#pragma intrinsic(_BitScanReverse64) -static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) -{ - unsigned long r; - (void) _BitScanReverse64(&r, v); - return (unsigned) r; -} -#define lzo_bitops_clz64 lzo_bitops_clz64 -#endif -#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) -#pragma intrinsic(_BitScanForward) -static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) -{ - unsigned long r; - (void) _BitScanForward(&r, v); - return (unsigned) r; -} -#define lzo_bitops_ctz32 lzo_bitops_ctz32 -#endif -#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) -#pragma intrinsic(_BitScanForward64) -static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) -{ - unsigned long r; - (void) _BitScanForward64(&r, v); - return (unsigned) r; -} -#define lzo_bitops_ctz64 lzo_bitops_ctz64 -#endif - -#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) -#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) -#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) -#endif -#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) -#endif -#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) -#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) -#endif -#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) -#endif -#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) -#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) -#endif -#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) -#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) -#endif +# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) #endif static __lzo_noinline lzo_uint @@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_uint ti, lzo_voidp wrkmem) { - register const lzo_bytep ip; + const lzo_bytep ip; lzo_bytep op; const lzo_bytep const in_end = in + in_len; const lzo_bytep const ip_end = in + in_len - 20; @@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, op = out; ip = in; - ii = ip - ti; + ii = ip; ip += ti < 4 ? 4 - ti : 0; for (;;) @@ -3205,8 +4653,8 @@ next: goto literal; try_match: -#if defined(UA_GET32) - if (UA_GET32(m_pos) != UA_GET32(ip)) +#if (LZO_OPT_UNALIGNED32) + if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) #else if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) #endif @@ -3221,49 +4669,43 @@ literal: lzo_uint m_off; lzo_uint m_len; { - lzo_uint32 dv; + lzo_uint32_t dv; lzo_uint dindex; literal: ip += 1 + ((ip - ii) >> 5); next: if __lzo_unlikely(ip >= ip_end) break; - dv = UA_GET32(ip); + dv = UA_GET_LE32(ip); dindex = DINDEX(dv,ip); GINDEX(m_off,m_pos,in+dict,dindex,in); UPDATE_I(dict,0,dindex,ip,in); - if __lzo_unlikely(dv != UA_GET32(m_pos)) + if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) goto literal; } #endif + ii -= ti; ti = 0; { - register lzo_uint t = pd(ip,ii); + lzo_uint t = pd(ip,ii); if (t != 0) { if (t <= 3) { - op[-2] |= LZO_BYTE(t); -#if defined(UA_COPY32) - UA_COPY32(op, ii); + op[-2] = LZO_BYTE(op[-2] | t); +#if (LZO_OPT_UNALIGNED32) + UA_COPY4(op, ii); op += t; #else { do *op++ = *ii++; while (--t > 0); } #endif } -#if defined(UA_COPY32) || defined(UA_COPY64) +#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) else if (t <= 16) { *op++ = LZO_BYTE(t - 3); -#if defined(UA_COPY64) - UA_COPY64(op, ii); - UA_COPY64(op+8, ii+8); -#else - UA_COPY32(op, ii); - UA_COPY32(op+4, ii+4); - UA_COPY32(op+8, ii+8); - UA_COPY32(op+12, ii+12); -#endif + UA_COPY8(op, ii); + UA_COPY8(op+8, ii+8); op += t; } #endif @@ -3273,31 +4715,21 @@ next: *op++ = LZO_BYTE(t - 3); else { - register lzo_uint tt = t - 18; + lzo_uint tt = t - 18; *op++ = 0; while __lzo_unlikely(tt > 255) { tt -= 255; -#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) - * (volatile unsigned char *) op++ = 0; -#else - *op++ = 0; -#endif + UA_SET1(op, 0); + op++; } assert(tt > 0); *op++ = LZO_BYTE(tt); } -#if defined(UA_COPY32) || defined(UA_COPY64) +#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) do { -#if defined(UA_COPY64) - UA_COPY64(op, ii); - UA_COPY64(op+8, ii+8); -#else - UA_COPY32(op, ii); - UA_COPY32(op+4, ii+4); - UA_COPY32(op+8, ii+8); - UA_COPY32(op+12, ii+12); -#endif + UA_COPY8(op, ii); + UA_COPY8(op+8, ii+8); op += 16; ii += 16; t -= 16; } while (t >= 16); if (t > 0) #endif @@ -3307,19 +4739,26 @@ next: } m_len = 4; { -#if defined(UA_GET64) - lzo_uint64 v; - v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); +#if (LZO_OPT_UNALIGNED64) + lzo_uint64_t v; + v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); if __lzo_unlikely(v == 0) { do { m_len += 8; - v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); + v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (v == 0); } -#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) - m_len += lzo_bitops_ctz64(v) / CHAR_BIT; +#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) + m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; +#elif (LZO_ABI_BIG_ENDIAN) + if ((v >> (64 - CHAR_BIT)) == 0) do { + v <<= CHAR_BIT; + m_len += 1; + } while ((v >> (64 - CHAR_BIT)) == 0); +#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) + m_len += lzo_bitops_cttz64(v) / CHAR_BIT; #elif (LZO_ABI_LITTLE_ENDIAN) if ((v & UCHAR_MAX) == 0) do { v >>= CHAR_BIT; @@ -3330,19 +4769,30 @@ next: m_len += 1; } while (ip[m_len] == m_pos[m_len]); #endif -#elif defined(UA_GET32) - lzo_uint32 v; - v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); +#elif (LZO_OPT_UNALIGNED32) + lzo_uint32_t v; + v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); if __lzo_unlikely(v == 0) { do { m_len += 4; - v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); + v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); + if (v != 0) + break; + m_len += 4; + v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (v == 0); } -#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) - m_len += lzo_bitops_ctz32(v) / CHAR_BIT; +#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) + m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; +#elif (LZO_ABI_BIG_ENDIAN) + if ((v >> (32 - CHAR_BIT)) == 0) do { + v <<= CHAR_BIT; + m_len += 1; + } while ((v >> (32 - CHAR_BIT)) == 0); +#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) + m_len += lzo_bitops_cttz32(v) / CHAR_BIT; #elif (LZO_ABI_LITTLE_ENDIAN) if ((v & UCHAR_MAX) == 0) do { v >>= CHAR_BIT; @@ -3357,6 +4807,27 @@ next: if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { do { m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; + if (ip[m_len] != m_pos[m_len]) + break; + m_len += 1; if __lzo_unlikely(ip + m_len >= ip_end) goto m_len_done; } while (ip[m_len] == m_pos[m_len]); @@ -3390,11 +4861,8 @@ m_len_done: while __lzo_unlikely(m_len > 255) { m_len -= 255; -#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) - * (volatile unsigned char *) op++ = 0; -#else - *op++ = 0; -#endif + UA_SET1(op, 0); + op++; } *op++ = LZO_BYTE(m_len); } @@ -3413,11 +4881,8 @@ m_len_done: while __lzo_unlikely(m_len > 255) { m_len -= 255; -#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) - * (volatile unsigned char *) op++ = 0; -#else - *op++ = 0; -#endif + UA_SET1(op, 0); + op++; } *op++ = LZO_BYTE(m_len); } @@ -3428,7 +4893,7 @@ m_len_done: } *out_len = pd(op, out); - return pd(in_end,ii); + return pd(in_end,ii-ti); } LZO_PUBLIC(int) @@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, if (op == out && t <= 238) *op++ = LZO_BYTE(17 + t); else if (t <= 3) - op[-2] |= LZO_BYTE(t); + op[-2] = LZO_BYTE(op[-2] | t); else if (t <= 18) *op++ = LZO_BYTE(t - 3); else @@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, while (tt > 255) { tt -= 255; -#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) - - * (volatile unsigned char *) op++ = 0; -#else - *op++ = 0; -#endif + UA_SET1(op, 0); + op++; } assert(tt > 0); *op++ = LZO_BYTE(tt); } - do *op++ = *ii++; while (--t > 0); + UA_COPYN(op, ii, t); + op += t; } *op++ = M4_MARKER | 1; @@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, #undef TEST_IP #undef TEST_OP +#undef TEST_IP_AND_TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP +#undef TEST_IV +#undef TEST_OV #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP @@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun +# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun # endif #endif @@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun +# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) -# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun -# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun +# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun +# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) @@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, # define TEST_OP 1 #endif +#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) +# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) +#elif defined(HAVE_TEST_IP) +# define TEST_IP_AND_TEST_OP TEST_IP +#elif defined(HAVE_TEST_OP) +# define TEST_IP_AND_TEST_OP TEST_OP +#else +# define TEST_IP_AND_TEST_OP 1 +#endif + #if defined(NEED_IP) # define HAVE_NEED_IP 1 #else # define NEED_IP(x) ((void) 0) +# define TEST_IV(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP 1 #else # define NEED_OP(x) ((void) 0) +# define TEST_OV(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) @@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_voidp wrkmem ) #endif { - register lzo_bytep op; - register const lzo_bytep ip; - register lzo_uint t; + lzo_bytep op; + const lzo_bytep ip; + lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else - register const lzo_bytep m_pos; + const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; @@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, op = out; ip = in; + NEED_IP(1); if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; - assert(t > 0); NEED_OP(t); NEED_IP(t+1); + assert(t > 0); NEED_OP(t); NEED_IP(t+3); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } - while (TEST_IP && TEST_OP) + for (;;) { + NEED_IP(3); t = *ip++; if (t >= 16) goto match; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_IV(t); NEED_IP(1); } t += 15 + *ip++; } - assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); -#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); +#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) t += 3; if (t >= 8) do { - UA_COPY64(op,ip); + UA_COPY8(op,ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } if (t > 0) @@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } } -#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) +#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) if (PTR_ALIGNED2_4(op,ip)) { #endif - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); @@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, else do *op++ = *ip++; while (--t > 0); } -#if !defined(LZO_UNALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) } else #endif #endif -#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) +#if !(LZO_OPT_UNALIGNED32) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); @@ -3753,7 +5234,7 @@ first_literal_run: #endif goto match_done; - do { + for (;;) { match: if (t >= 64) { @@ -3813,14 +5294,15 @@ match: t &= 31; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_OV(t); NEED_IP(1); } t += 31 + *ip++; + NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) @@ -3836,9 +5318,9 @@ match: m_pos = op - off; last_m_off = off; } -#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; - m_pos -= UA_GET16(ip) >> 2; + m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); @@ -3857,14 +5339,15 @@ match: t &= 7; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_OV(t); NEED_IP(1); } t += 7 + *ip++; + NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) @@ -3882,8 +5365,8 @@ match: #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); -#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) - m_pos -= UA_GET16(ip) >> 2; +#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif @@ -3931,18 +5414,18 @@ match: #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); -#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) +#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) if (op - m_pos >= 8) { t += (3 - 1); if (t >= 8) do { - UA_COPY64(op,m_pos); + UA_COPY8(op,m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) @@ -3952,8 +5435,8 @@ match: } } else -#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) +#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); @@ -3961,10 +5444,10 @@ match: if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); @@ -3989,7 +5472,7 @@ match_done: break; match_next: - assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); + assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); #if 0 do *op++ = *ip++; while (--t > 0); #else @@ -3997,16 +5480,10 @@ match_next: if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; - } while (TEST_IP && TEST_OP); + } } -#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) - *out_len = pd(op, out); - return LZO_E_EOF_NOT_FOUND; -#endif - eof_found: - assert(t == 1); *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); @@ -4052,10 +5529,13 @@ lookbehind_overrun: #undef TEST_IP #undef TEST_OP +#undef TEST_IP_AND_TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP +#undef TEST_IV +#undef TEST_OV #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP @@ -4070,6 +5550,7 @@ lookbehind_overrun: # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun +# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun # endif #endif @@ -4081,12 +5562,13 @@ lookbehind_overrun: # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun +# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) -# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun -# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun +# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun +# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) @@ -4107,15 +5589,27 @@ lookbehind_overrun: # define TEST_OP 1 #endif +#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) +# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) +#elif defined(HAVE_TEST_IP) +# define TEST_IP_AND_TEST_OP TEST_IP +#elif defined(HAVE_TEST_OP) +# define TEST_IP_AND_TEST_OP TEST_OP +#else +# define TEST_IP_AND_TEST_OP 1 +#endif + #if defined(NEED_IP) # define HAVE_NEED_IP 1 #else # define NEED_IP(x) ((void) 0) +# define TEST_IV(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP 1 #else # define NEED_OP(x) ((void) 0) +# define TEST_OV(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) @@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_voidp wrkmem ) #endif { - register lzo_bytep op; - register const lzo_bytep ip; - register lzo_uint t; + lzo_bytep op; + const lzo_bytep ip; + lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else - register const lzo_bytep m_pos; + const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; @@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, op = out; ip = in; + NEED_IP(1); if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; - assert(t > 0); NEED_OP(t); NEED_IP(t+1); + assert(t > 0); NEED_OP(t); NEED_IP(t+3); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } - while (TEST_IP && TEST_OP) + for (;;) { + NEED_IP(3); t = *ip++; if (t >= 16) goto match; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_IV(t); NEED_IP(1); } t += 15 + *ip++; } - assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); -#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); +#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) t += 3; if (t >= 8) do { - UA_COPY64(op,ip); + UA_COPY8(op,ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } if (t > 0) @@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } } -#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) +#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) if (PTR_ALIGNED2_4(op,ip)) { #endif - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { - UA_COPY32(op,ip); + UA_COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); @@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, else do *op++ = *ip++; while (--t > 0); } -#if !defined(LZO_UNALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) } else #endif #endif -#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) +#if !(LZO_OPT_UNALIGNED32) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); @@ -4279,7 +5775,7 @@ first_literal_run: #endif goto match_done; - do { + for (;;) { match: if (t >= 64) { @@ -4339,14 +5835,15 @@ match: t &= 31; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_OV(t); NEED_IP(1); } t += 31 + *ip++; + NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) @@ -4362,9 +5859,9 @@ match: m_pos = op - off; last_m_off = off; } -#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; - m_pos -= UA_GET16(ip) >> 2; + m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); @@ -4383,14 +5880,15 @@ match: t &= 7; if (t == 0) { - NEED_IP(1); while (*ip == 0) { t += 255; ip++; + TEST_OV(t); NEED_IP(1); } t += 7 + *ip++; + NEED_IP(2); } #if defined(COPY_DICT) #if defined(LZO1Z) @@ -4408,8 +5906,8 @@ match: #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); -#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) - m_pos -= UA_GET16(ip) >> 2; +#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos -= UA_GET_LE16(ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif @@ -4457,18 +5955,18 @@ match: #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); -#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) +#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) if (op - m_pos >= 8) { t += (3 - 1); if (t >= 8) do { - UA_COPY64(op,m_pos); + UA_COPY8(op,m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) @@ -4478,8 +5976,8 @@ match: } } else -#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) +#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) +#if !(LZO_OPT_UNALIGNED32) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); @@ -4487,10 +5985,10 @@ match: if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { - UA_COPY32(op,m_pos); + UA_COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); @@ -4515,7 +6013,7 @@ match_done: break; match_next: - assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); + assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); #if 0 do *op++ = *ip++; while (--t > 0); #else @@ -4523,16 +6021,10 @@ match_next: if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; - } while (TEST_IP && TEST_OP); + } } -#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) - *out_len = pd(op, out); - return LZO_E_EOF_NOT_FOUND; -#endif - eof_found: - assert(t == 1); *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); @@ -4559,4 +6051,3 @@ lookbehind_overrun: #endif /***** End of minilzo.c *****/ - diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h index 74fefa9fe..793745467 100644 --- a/grub-core/lib/minilzo/minilzo.h +++ b/grub-core/lib/minilzo/minilzo.h @@ -2,22 +2,7 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -50,7 +35,7 @@ #ifndef __MINILZO_H #define __MINILZO_H 1 -#define MINILZO_VERSION 0x2050 +#define MINILZO_VERSION 0x2080 #ifdef __LZOCONF_H # error "you cannot use both LZO and miniLZO" @@ -78,7 +63,7 @@ extern "C" { */ #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) +#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) #define LZO1X_MEM_DECOMPRESS (0) From aa096037ae013c553acf52f9e3aa3a49c91f3c57 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 14 Feb 2020 12:44:14 +0100 Subject: [PATCH 1041/1167] normal: Move common datetime functions out of the normal module The common datetime helper functions are currently included in the normal module, but this makes any other module that calls these functions to have a dependency with the normal module only for this reason. Since the normal module does a lot of stuff, it calls functions from other modules. But since other modules may depend on it for calling the datetime helpers, this could lead to circular dependencies between modules. As an example, when platform == xen the grub_get_datetime() function from the datetime module calls to the grub_unixtime2datetime() helper function from the normal module. Which leads to the following module dependency: datetime -> normal and send_dhcp_packet() from the net module calls the grub_get_datetime() function, which leads to the following module dependency: net -> datetime -> normal but that means that the normal module is not allowed to depend on net or any other module that depends on it due the transitive dependency caused by datetime. A recent patch attempted to add support to fetch the config file over the network, which leads to the following circular dependency: normal -> net -> datetime -> normal So having the datetime helpers in the normal module makes it quite fragile and easy to add circular dependencies like these, that break the build due the genmoddep.awk script catching the issues. Fix this by taking the datetime helper functions out of the normal module and instead add them to the datetime module itself. Besides fixing these issues, it makes more sense to have these helper functions there anyways. Reported-by: Daniel Kiper Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- Makefile.util.def | 2 +- grub-core/Makefile.core.def | 2 +- grub-core/{normal => lib}/datetime.c | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename grub-core/{normal => lib}/datetime.c (100%) diff --git a/Makefile.util.def b/Makefile.util.def index 94336392b..174877c41 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -141,7 +141,7 @@ library = { common = grub-core/lib/crc.c; common = grub-core/lib/adler32.c; common = grub-core/lib/crc64.c; - common = grub-core/normal/datetime.c; + common = grub-core/lib/datetime.c; common = grub-core/normal/misc.c; common = grub-core/partmap/acorn.c; common = grub-core/partmap/amiga.c; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a0507a1fa..91297e4eb 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1687,6 +1687,7 @@ module = { module = { name = datetime; + common = lib/datetime.c; cmos = lib/cmos_datetime.c; efi = lib/efi/datetime.c; uboot = lib/dummy/datetime.c; @@ -1926,7 +1927,6 @@ module = { common = normal/autofs.c; common = normal/color.c; common = normal/completion.c; - common = normal/datetime.c; common = normal/menu.c; common = normal/menu_entry.c; common = normal/menu_text.c; diff --git a/grub-core/normal/datetime.c b/grub-core/lib/datetime.c similarity index 100% rename from grub-core/normal/datetime.c rename to grub-core/lib/datetime.c From 8c2c35dcc027a77aee48de89093d8770de0a8cf8 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Wed, 22 Jan 2020 12:01:52 +0100 Subject: [PATCH 1042/1167] kern: Add %X option to printf functions The printf(3) function has support for the %X format specifier, to output an unsigned hexadecimal integer in uppercase. This can be achived in GRUB using the %x format specifier in grub_printf() and calling grub_toupper(), but it is more convenient if there is support for %X in grub_printf(). Signed-off-by: Paulo Flabiano Smorigo Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- grub-core/kern/misc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 3b633d51f..76e7fb228 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) static inline char * grub_lltoa (char *str, int c, unsigned long long n) { - unsigned base = (c == 'x') ? 16 : 10; + unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10; char *p; if ((long long) n < 0 && c == 'd') @@ -603,7 +603,7 @@ grub_lltoa (char *str, int c, unsigned long long n) do { unsigned d = (unsigned) (n & 0xf); - *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; + *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0'; } while (n >>= 4); else @@ -676,6 +676,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, { case 'p': case 'x': + case 'X': case 'u': case 'd': case 'c': @@ -762,6 +763,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, switch (c) { case 'x': + case 'X': case 'u': args->ptr[curn].type = UNSIGNED_INT + longfmt; break; @@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, c = 'x'; /* Fall through. */ case 'x': + case 'X': case 'u': case 'd': { From e92111985773a79563ea2adf5022859611cf9dba Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 22 Jan 2020 12:01:53 +0100 Subject: [PATCH 1043/1167] net/dhcp: Consistently use decimal numbers for DHCP/BOOTP options enum The DHCP Options and BOOTP Vendor Extensions enum values are a mixture of decimal and hexadecimal numbers. Change this to consistently use decimal numbers for all since that is how these values are defined by RFC 2132. Suggested-by: Daniel Kiper Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- include/grub/net.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/grub/net.h b/include/grub/net.h index 4a9069a14..b5fedb28b 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -454,14 +454,14 @@ struct grub_net_bootp_packet enum { - GRUB_NET_BOOTP_PAD = 0x00, - GRUB_NET_BOOTP_NETMASK = 0x01, - GRUB_NET_BOOTP_ROUTER = 0x03, - GRUB_NET_BOOTP_DNS = 0x06, - GRUB_NET_BOOTP_HOSTNAME = 0x0c, - GRUB_NET_BOOTP_DOMAIN = 0x0f, - GRUB_NET_BOOTP_ROOT_PATH = 0x11, - GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, + GRUB_NET_BOOTP_PAD = 0, + GRUB_NET_BOOTP_NETMASK = 1, + GRUB_NET_BOOTP_ROUTER = 3, + GRUB_NET_BOOTP_DNS = 6, + GRUB_NET_BOOTP_HOSTNAME = 12, + GRUB_NET_BOOTP_DOMAIN = 15, + GRUB_NET_BOOTP_ROOT_PATH = 17, + GRUB_NET_BOOTP_EXTENSIONS_PATH = 18, GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, GRUB_NET_DHCP_OVERLOAD = 52, GRUB_NET_DHCP_MESSAGE_TYPE = 53, @@ -469,7 +469,7 @@ enum GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55, GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, GRUB_NET_DHCP_BOOTFILE_NAME = 67, - GRUB_NET_BOOTP_END = 0xff + GRUB_NET_BOOTP_END = 255 }; struct grub_net_network_level_interface * From febc761e678079345122f85b9a686d0e32a3b37f Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Wed, 22 Jan 2020 12:01:54 +0100 Subject: [PATCH 1044/1167] net/dhcp: Set net__client{id, uuid} variables from DHCP options This patch sets a net__clientid and net__clientuuid GRUB environment variables, using the DHCP client ID and UUID options if these are found. In the same way than net__